Minor Update

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@96319 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2014-05-30 11:05:09 +00:00
parent 6f0fab052d
commit ffd5c3b778
5 changed files with 530 additions and 8 deletions

View File

@ -3962,3 +3962,35 @@ Compiling...
Compilation completed in 0.00 seconds Compilation completed in 0.00 seconds
Removing invalidated units Removing invalidated units
Finding entry point classes Finding entry point classes
Public resources found in...
Translatable source found in...
Found 0 cached/archived units. Used 0 / 2719 units from cache.
Compiling...
60% complete (ETR: 3 seconds)
60% complete (ETR: 3 seconds)
60% complete (ETR: 3 seconds)
60% complete (ETR: 3 seconds)
60% complete (ETR: 3 seconds)
60% complete (ETR: 3 seconds)
60% complete (ETR: 3 seconds)
70% complete (ETR: 2 seconds)
80% complete (ETR: 2 seconds)
90% complete (ETR: 1 seconds)
100% complete (ETR: 0 seconds)
Compilation completed in 10.77 seconds
Removing invalidated units
Finding entry point classes
Public resources found in...
Translatable source found in...
Found 2719 cached/archived units. Used 2719 / 2719 units from cache.
Compiling...
Compilation completed in 0.00 seconds
Removing invalidated units
Finding entry point classes
Public resources found in...
Translatable source found in...
Found 2719 cached/archived units. Used 2719 / 2719 units from cache.
Compiling...
Compilation completed in 0.00 seconds
Removing invalidated units
Finding entry point classes

View File

@ -0,0 +1,71 @@
package org.gcube.portlets.user.td.columnwidget.client.create;
import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import com.allen_sauer.gwt.log.client.Log;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
/**
* Edit Row
*
* @author "Giancarlo Panichi"
*
*/
public class AddColumnDialog extends Window {
protected String WIDTH = "650px";
protected String HEIGHT = "530px";
protected EventBus eventBus;
protected AddColumnPanel addColumnPanel;
protected TRId trId;
public AddColumnDialog(TRId trId, EventBus eventBus) {
super();
Log.debug("AddColumnDialog");
this.eventBus = eventBus;
this.trId=trId;
initWindow();
addColumnPanel = new AddColumnPanel(this, trId,eventBus);
add(addColumnPanel);
}
protected void initWindow() {
setWidth(WIDTH);
setHeight(HEIGHT);
setBodyBorder(false);
setResizable(false);
setClosable(true);
setModal(true);
forceLayoutOnResize = true;
getHeader().setIcon(ResourceBundle.INSTANCE.columnValue());
setHeadingText("Add Column");
}
/**
* {@inheritDoc}
*/
@Override
protected void initTools() {
super.initTools();
closeBtn.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
close();
}
});
}
public void close() {
hide();
}
}

View File

@ -0,0 +1,420 @@
package org.gcube.portlets.user.td.columnwidget.client.create;
import java.util.ArrayList;
import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnTypeCodeProperties;
import org.gcube.portlets.user.td.columnwidget.client.properties.LocaleTypeProperties;
import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle;
import org.gcube.portlets.user.td.columnwidget.client.store.ColumnTypeCodeElement;
import org.gcube.portlets.user.td.columnwidget.client.store.ColumnTypeCodeStore;
import org.gcube.portlets.user.td.columnwidget.client.store.LocaleTypeElement;
import org.gcube.portlets.user.td.columnwidget.client.utils.UtilsGXT3;
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
import org.gcube.portlets.user.td.gwtservice.shared.tr.DefNewColumn;
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.TableType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
import com.allen_sauer.gwt.log.client.Log;
import com.google.gwt.core.client.GWT;
import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.logical.shared.SelectionEvent;
import com.google.gwt.event.logical.shared.SelectionHandler;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.shared.LabelProvider;
import com.sencha.gxt.data.shared.ListStore;
import com.sencha.gxt.widget.core.client.FramedPanel;
import com.sencha.gxt.widget.core.client.button.TextButton;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign;
import com.sencha.gxt.widget.core.client.container.SimpleContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
import com.sencha.gxt.widget.core.client.form.ComboBox;
import com.sencha.gxt.widget.core.client.form.FieldLabel;
import com.sencha.gxt.widget.core.client.form.TextField;
import com.sencha.gxt.widget.core.client.info.Info;
/**
*
* @author "Giancarlo Panichi"
*
*/
public class AddColumnPanel extends FramedPanel {
protected static final String WIDTH = "640px";
protected static final String HEIGHT = "520px";
protected static final String FIELDWIDTH = "436px";
protected static final String FIELDSHEIGHT = "130px";
protected EventBus eventBus;
protected AddColumnDialog parent;
protected TRId trId;
protected TableType tableType;
protected ComboBox<ColumnTypeCodeElement> comboColumnTypeCode = null;
protected FieldLabel comboColumnTypeCodeLabel;
protected ComboBox<LocaleTypeElement> comboLocaleType = null;
protected FieldLabel comboLocaleTypeLabel;
protected ListStore<LocaleTypeElement> storeComboLocaleType;
private TextButton btnSave;
private TextButton btnClose;
private SimpleContainer form;
private VerticalLayoutContainer formLayout;
private TextField label;
private TextField defaultValue;
/**
*
* @param parent
* @param eventBus
*/
public AddColumnPanel(AddColumnDialog parent, TRId trId, EventBus eventBus) {
super();
Log.debug("CreateDefColumnPanel[parent: "+parent+", trId: "+trId);
this.parent = parent;
this.eventBus = eventBus;
this.trId=trId;
retriveTableType();
}
private void retriveTableType() {
String tableT=trId.getTableType();
if(tableT.compareTo(TableType.CODELIST.toString())==0){
tableType=TableType.CODELIST;
} else {
if(tableT.compareTo(TableType.GENERIC.toString())==0){
tableType=TableType.GENERIC;
} else {
if(tableT.compareTo(TableType.DATASET.toString())==0){
tableType=TableType.DATASET;
} else {
UtilsGXT3.alert("Attention", "This tabular resource has type unknown");
close();
return;
}
}
}
init();
create();
}
protected void init() {
setWidth(WIDTH);
setHeight(HEIGHT);
setHeaderVisible(false);
setBodyBorder(false);
}
protected void create() {
// Label
label = new TextField();
FieldLabel nameLabel = new FieldLabel(label, "Column Label");
// Default Value
defaultValue = new TextField();
FieldLabel defaultValueLabel = new FieldLabel(defaultValue,
"Default Value");
// comboColumnTypeCode
ColumnTypeCodeProperties propsColumnTypeCode = GWT
.create(ColumnTypeCodeProperties.class);
ListStore<ColumnTypeCodeElement> storeComboTypeCode = new ListStore<ColumnTypeCodeElement>(
propsColumnTypeCode.id());
switch (tableType) {
case CODELIST:
storeComboTypeCode.addAll(ColumnTypeCodeStore
.getColumnTypeCodesForCodelist());
break;
case DATASET:
storeComboTypeCode.addAll(ColumnTypeCodeStore
.getColumnTypeCodesForDataset());
break;
case GENERIC:
storeComboTypeCode.addAll(ColumnTypeCodeStore
.getColumnTypeCodesForGeneric());
break;
default:
break;
}
comboColumnTypeCode = new ComboBox<ColumnTypeCodeElement>(
storeComboTypeCode, propsColumnTypeCode.label());
Log.trace("ComboColumnTypeCode created");
addHandlersForComboColumnTypeCode(propsColumnTypeCode.label());
comboColumnTypeCode.setEmptyText("Select a column type...");
comboColumnTypeCode.setWidth(191);
comboColumnTypeCode.setTypeAhead(true);
comboColumnTypeCode.setTriggerAction(TriggerAction.ALL);
comboColumnTypeCodeLabel = new FieldLabel(comboColumnTypeCode,
"Column Type");
// comboLocaleType
LocaleTypeProperties propsLocaleType = GWT
.create(LocaleTypeProperties.class);
storeComboLocaleType = new ListStore<LocaleTypeElement>(
propsLocaleType.id());
comboLocaleType = new ComboBox<LocaleTypeElement>(storeComboLocaleType,
propsLocaleType.label()) {
protected void onAfterFirstAttach() {
super.onAfterFirstAttach();
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
public void execute() {
retriveLocales();
}
});
}
};
Log.trace("ComboLocaleType created");
addHandlersForComboLocaleType(propsLocaleType.label());
comboLocaleType.setEmptyText("Select a locale type...");
comboLocaleType.setWidth(191);
comboLocaleType.setTypeAhead(true);
comboLocaleType.setTriggerAction(TriggerAction.ALL);
comboLocaleTypeLabel = new FieldLabel(comboLocaleType, "Locale");
//
form = new SimpleContainer();
form.setWidth(FIELDWIDTH);
form.setHeight(FIELDSHEIGHT);
formLayout = new VerticalLayoutContainer();
formLayout.setScrollMode(ScrollMode.AUTO);
formLayout
.add(nameLabel, new VerticalLayoutData(1, -1, new Margins(0)));
formLayout.add(comboColumnTypeCodeLabel, new VerticalLayoutData(1, -1,
new Margins(0)));
formLayout.add(comboLocaleTypeLabel, new VerticalLayoutData(1, -1,
new Margins(0)));
formLayout.add(defaultValueLabel, new VerticalLayoutData(1, -1,
new Margins(0)));
form.add(formLayout);
btnSave = new TextButton("Save");
btnSave.setIcon(ResourceBundle.INSTANCE.save());
btnSave.setIconAlign(IconAlign.RIGHT);
btnSave.setTitle("Save");
btnSave.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
Log.debug("Pressed Save");
btnSave.disable();
save();
}
});
btnClose = new TextButton("Close");
btnClose.setIcon(ResourceBundle.INSTANCE.close());
btnClose.setIconAlign(IconAlign.RIGHT);
btnClose.setTitle("Close");
btnClose.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
Log.debug("Pressed Close");
close();
}
});
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
flowButton.setPack(BoxLayoutPack.CENTER);
flowButton.add(btnSave, new BoxLayoutData(new Margins(2, 4, 2, 4)));
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
VerticalLayoutContainer vPanel = new VerticalLayoutContainer();
vPanel.add(form, new VerticalLayoutData(1, -1));
vPanel.add(flowButton, new VerticalLayoutData(1, -1, new Margins(1)));
add(vPanel);
comboLocaleTypeLabel.setVisible(false);
}
protected void save() {
ColumnTypeCode currentType = null;
String localeName = null;
String lab = label.getCurrentValue();
ColumnTypeCodeElement typeElement = comboColumnTypeCode
.getCurrentValue();
LocaleTypeElement localeElement = comboLocaleType.getCurrentValue();
String valueDefault = defaultValue.getCurrentValue();
Log.debug("CheckValue: label: " + lab + ", type: " + typeElement
+ ", locale: " + localeElement + ", default: " + valueDefault);
if (lab == null || lab.isEmpty()) {
UtilsGXT3.alert("Attention", "Add a label");
return;
}
if (typeElement == null) {
UtilsGXT3.alert("Attention", "No type selected");
return;
} else {
if (typeElement.getCode() == null) {
UtilsGXT3.alert("Attention", "No type selected");
return;
} else {
currentType = typeElement.getCode();
}
}
if (currentType != null && currentType == ColumnTypeCode.CODENAME) {
if (localeElement == null) {
UtilsGXT3.alert("Attention", "No locale selected");
return;
} else {
if (localeElement.getLocaleName() == null
|| localeElement.getLocaleName().isEmpty()) {
UtilsGXT3.alert("Attention", "No locale selected");
return;
} else {
localeName = localeElement.getLocaleName();
}
}
}
/*
DefNewColumn defNewColumn = new DefNewColumn(id, lab, currentType,
localeName, valueDefault);
Log.debug("DefNewColumn:" + defNewColumn);
*/
}
public void close() {
if (parent != null) {
parent.close();
}
}
protected void addHandlersForComboColumnTypeCode(
final LabelProvider<ColumnTypeCodeElement> labelProvider) {
comboColumnTypeCode
.addSelectionHandler(new SelectionHandler<ColumnTypeCodeElement>() {
public void onSelection(
SelectionEvent<ColumnTypeCodeElement> event) {
Info.display(
"Column Type Selected",
"You selected "
+ (event.getSelectedItem() == null ? "nothing"
: labelProvider.getLabel(event
.getSelectedItem())
+ "!"));
Log.debug("ComboColumnTypeCode selected: "
+ event.getSelectedItem());
ColumnTypeCodeElement columnType = event
.getSelectedItem();
updateColumnType(columnType.getCode());
}
});
}
protected void addHandlersForComboLocaleType(
final LabelProvider<LocaleTypeElement> labelProvider) {
comboLocaleType
.addSelectionHandler(new SelectionHandler<LocaleTypeElement>() {
public void onSelection(
SelectionEvent<LocaleTypeElement> event) {
Info.display(
"Locale Type Selected",
"You selected "
+ (event.getSelectedItem() == null ? "nothing"
: labelProvider.getLabel(event
.getSelectedItem())
+ "!"));
Log.debug("ComboLocaleType selected: "
+ event.getSelectedItem());
LocaleTypeElement localeType = event.getSelectedItem();
updateLocaleType(localeType);
}
});
}
protected void updateColumnType(ColumnTypeCode type) {
Log.debug("Update ColumnTypeCode " + type.toString());
switch (type) {
case CODENAME:
comboLocaleTypeLabel.setVisible(true);
forceLayout();
break;
default:
comboLocaleTypeLabel.setVisible(false);
forceLayout();
break;
}
}
protected void updateLocaleType(LocaleTypeElement type) {
}
protected void retriveLocales() {
TDGWTServiceAsync.INSTANCE
.getLocales(new AsyncCallback<ArrayList<String>>() {
@Override
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
eventBus.fireEvent(new SessionExpiredEvent(
SessionExpiredType.EXPIREDONSERVER));
} else {
Log.debug(caught.getLocalizedMessage());
UtilsGXT3.alert("Error retrieving locales",
caught.getLocalizedMessage());
}
}
@Override
public void onSuccess(ArrayList<String> result) {
storeComboLocaleType.clear();
ArrayList<LocaleTypeElement> locales = new ArrayList<LocaleTypeElement>();
LocaleTypeElement locale;
for (String local : result) {
locale = new LocaleTypeElement(local);
locales.add(locale);
}
storeComboLocaleType.addAll(locales);
storeComboLocaleType.commitChanges();
}
});
}
}

View File

@ -22,14 +22,14 @@ public class CreateDefColumnDialog extends Window {
protected CreateDefColumnPanel createDefColumnPanel; protected CreateDefColumnPanel createDefColumnPanel;
protected TableType tableType; protected TableType tableType;
public CreateDefColumnDialog(String id, TableType tableType, public CreateDefColumnDialog(TableType tableType,
EventBus eventBus) { EventBus eventBus) {
super(); super();
Log.debug("CreateDefColumnDialog [id: "+id+", tableType: "+tableType+"]"); Log.debug("CreateDefColumnDialog [tableType: "+tableType+"]");
this.eventBus = eventBus; this.eventBus = eventBus;
this.tableType = tableType; this.tableType = tableType;
initWindow(); initWindow();
createDefColumnPanel = new CreateDefColumnPanel(this, id, tableType, createDefColumnPanel = new CreateDefColumnPanel(this, tableType,
eventBus); eventBus);
add(createDefColumnPanel); add(createDefColumnPanel);
} }

View File

@ -63,7 +63,7 @@ public class CreateDefColumnPanel extends FramedPanel {
protected EventBus eventBus; protected EventBus eventBus;
protected CreateDefColumnDialog parent; protected CreateDefColumnDialog parent;
protected TableType tableType; protected TableType tableType;
protected String id;
protected ComboBox<ColumnTypeCodeElement> comboColumnTypeCode = null; protected ComboBox<ColumnTypeCodeElement> comboColumnTypeCode = null;
protected FieldLabel comboColumnTypeCodeLabel; protected FieldLabel comboColumnTypeCodeLabel;
@ -84,14 +84,13 @@ public class CreateDefColumnPanel extends FramedPanel {
* @param parent * @param parent
* @param eventBus * @param eventBus
*/ */
public CreateDefColumnPanel(CreateDefColumnDialog parent, String id, public CreateDefColumnPanel(CreateDefColumnDialog parent,
TableType tableType, EventBus eventBus) { TableType tableType, EventBus eventBus) {
super(); super();
Log.debug("CreateDefColumnPanel[parent: "+parent+", id: "+id+", tableType: "+tableType); Log.debug("CreateDefColumnPanel[parent: "+parent+", tableType: "+tableType);
this.parent = parent; this.parent = parent;
this.eventBus = eventBus; this.eventBus = eventBus;
this.tableType = tableType; this.tableType = tableType;
this.id = id;
initListeners(); initListeners();
init(); init();
create(); create();
@ -289,7 +288,7 @@ public class CreateDefColumnPanel extends FramedPanel {
} }
} }
DefNewColumn defNewColumn = new DefNewColumn(id, lab, currentType, DefNewColumn defNewColumn = new DefNewColumn(lab, currentType,
localeName, valueDefault); localeName, valueDefault);
Log.debug("DefNewColumn:" + defNewColumn); Log.debug("DefNewColumn:" + defNewColumn);
fireCompleted(defNewColumn); fireCompleted(defNewColumn);