diff --git a/.gwt/.gwt-log b/.gwt/.gwt-log index 4c7092f..165707d 100644 --- a/.gwt/.gwt-log +++ b/.gwt/.gwt-log @@ -5786,3 +5786,67 @@ Compiling... Compilation completed in 0.00 seconds Removing invalidated units Finding entry point classes +Public resources found in... +Translatable source found in... +Found 0 cached/archived units. Used 0 / 2719 units from cache. +Compiling... + 30% complete (ETR: 11 seconds) + 30% complete (ETR: 11 seconds) + 30% complete (ETR: 11 seconds) + 30% complete (ETR: 11 seconds) + 40% complete (ETR: 8 seconds) + 50% complete (ETR: 7 seconds) + 60% complete (ETR: 5 seconds) + 70% complete (ETR: 3 seconds) + 80% complete (ETR: 2 seconds) + 90% complete (ETR: 1 seconds) + 100% complete (ETR: 0 seconds) + Compilation completed in 23.33 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 +Public resources found in... +Translatable source found in... +Found 0 cached/archived units. Used 0 / 2719 units from cache. +Compiling... + 20% complete (ETR: 12 seconds) + 20% complete (ETR: 12 seconds) + 20% complete (ETR: 12 seconds) + 30% complete (ETR: 12 seconds) + 40% complete (ETR: 8 seconds) + 50% complete (ETR: 7 seconds) + 60% complete (ETR: 5 seconds) + 70% complete (ETR: 3 seconds) + 80% complete (ETR: 2 seconds) + 90% complete (ETR: 1 seconds) + 100% complete (ETR: 0 seconds) + Compilation completed in 19.31 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 diff --git a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/LabelColumnPanel.java b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/LabelColumnPanel.java index d26cb48..8c8661b 100644 --- a/src/main/java/org/gcube/portlets/user/td/columnwidget/client/LabelColumnPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/columnwidget/client/LabelColumnPanel.java @@ -1,8 +1,8 @@ package org.gcube.portlets.user.td.columnwidget.client; import java.util.ArrayList; +import java.util.HashMap; -import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnDataPropertiesCombo; import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle; import org.gcube.portlets.user.td.columnwidget.client.utils.UtilsGXT3; import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; @@ -19,39 +19,24 @@ import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredTy import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; 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.client.loader.RpcProxy; -import com.sencha.gxt.data.shared.LabelProvider; -import com.sencha.gxt.data.shared.ListStore; -import com.sencha.gxt.data.shared.loader.ListLoadConfig; -import com.sencha.gxt.data.shared.loader.ListLoadConfigBean; -import com.sencha.gxt.data.shared.loader.ListLoadResult; -import com.sencha.gxt.data.shared.loader.ListLoadResultBean; -import com.sencha.gxt.data.shared.loader.ListLoader; -import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding; 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.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; /** * - * ChangeColumnTypePanel is the panel for change column type + * LabelColumnPanel is the panel for change columns labels * * * @author "Giancarlo Panichi" comboColumn = null; - protected ListLoader> loader; + + protected ArrayList columns; + protected SimpleContainer columnsContainer; + protected VerticalLayoutContainer columnsLayoutContainer; protected TextButton change; protected LabelColumnSession labelColumnSession; + private boolean updateStatus; public LabelColumnPanel(TRId trId, String columnName, EventBus eventBus) { - setWidth(WIDTH); - setHeight(HEIGHT); - setHeaderVisible(false); - setBodyBorder(false); this.trId = trId; this.columnName = columnName; this.eventBus = eventBus; - Log.debug("LabelColumnPanel(): [" + trId.toString() + " columnName: " - + columnName + "]"); - - // Column Data - ColumnDataPropertiesCombo propsColumnData = GWT - .create(ColumnDataPropertiesCombo.class); - ListStore storeCombo = new ListStore( - propsColumnData.id()); - - Log.trace("StoreCombo created"); - - RpcProxy> proxy = new RpcProxy>() { - - public void load(ListLoadConfig loadConfig, - final AsyncCallback> callback) { - loadData(loadConfig, callback); - } - }; - - loader = new ListLoader>( - proxy) { - @Override - protected ListLoadConfig newLoadConfig() { - return (ListLoadConfig) new ListLoadConfigBean(); - } - - }; - - loader.addLoadHandler(new LoadResultListStoreBinding>( - storeCombo)); - Log.trace("LoaderCombo created"); - - comboColumn = new ComboBox(storeCombo, - propsColumnData.label()) { - - protected void onAfterFirstAttach() { - super.onAfterFirstAttach(); - Scheduler.get().scheduleDeferred(new ScheduledCommand() { - public void execute() { - loader.load(); - } - }); - } - }; - Log.trace("Combo ColumnData created"); - - addHandlersForComboColumn(propsColumnData.label()); - - comboColumn.setLoader(loader); - comboColumn.setEmptyText("Select a column..."); - comboColumn.setWidth(150); - comboColumn.setTypeAhead(false); - comboColumn.setEditable(false); - comboColumn.setTriggerAction(TriggerAction.ALL); - - label = new TextField(); - label.setAllowBlank(false); - - change = new TextButton("Change"); - change.setIcon(ResourceBundle.INSTANCE.columnLabel()); - change.setIconAlign(IconAlign.RIGHT); - change.setTitle("Change Column Label"); - - change.addSelectHandler(new SelectHandler() { - - public void onSelect(SelectEvent event) { - onLabelColumn(); - - } - }); - - VerticalLayoutContainer v = new VerticalLayoutContainer(); - v.add(new FieldLabel(comboColumn, "Column"), new VerticalLayoutData(1, - -1)); - v.add(new FieldLabel(label, "Label"), new VerticalLayoutData(1, -1)); - v.add(change, new VerticalLayoutData(-1, -1, new Margins(10, 0, 10, 0))); - add(v, new VerticalLayoutData(-1, -1, new Margins())); + updateStatus = false; + Log.debug("LabelColumnPanel(): [" + trId + " columnName: " + columnName + + "]"); + init(); + retrieveColumns(); } - protected void addHandlersForComboColumn( - final LabelProvider labelProvider) { - comboColumn.addSelectionHandler(new SelectionHandler() { - public void onSelection(SelectionEvent event) { - Info.display( - "Column Selected", - "You selected " - + (event.getSelectedItem() == null ? "nothing" - : labelProvider.getLabel(event - .getSelectedItem()) + "!")); - Log.debug("ComboColumn selected: " + event.getSelectedItem()); - ColumnData columnData = event.getSelectedItem(); - updateComboStatus(columnData); - } - - }); - } - - protected void loadData(ListLoadConfig loadConfig, - final AsyncCallback> callback) { + protected void retrieveColumns() { TDGWTServiceAsync.INSTANCE.getColumns(trId, new AsyncCallback>() { @@ -197,7 +91,7 @@ public class LabelColumnPanel extends FramedPanel implements "Error retrieving columns of tabular resource:" + trId.getId()); } - callback.onFailure(caught); + } public void onSuccess(ArrayList result) { @@ -213,59 +107,153 @@ public class LabelColumnPanel extends FramedPanel implements if (removables.size() > 0) { result.removeAll(removables); } - setComboStatus(result); - callback.onSuccess(new ListLoadResultBean( - result)); + columns = result; + startCreate(); } }); - } - protected void setComboStatus(ArrayList result) { - Log.debug("ColumnName:" + columnName); - if (columnName != null) { - for (ColumnData cd : result) { - Log.debug("ColumnData name:" + cd.getName()); - if (cd.getName().compareTo(columnName) == 0) { - updateComboStatus(cd); - } - } + protected void startCreate() { + if (updateStatus) { + updatePanel(); + } else { + create(); } } - protected void updateComboStatus(ColumnData cd) { - Log.debug("ColumnData: " + cd.toString()); - labelColumnSession = new LabelColumnSession(); - labelColumnSession.setColumnData(cd); - labelColumnSession.setLabel(cd.getLabel()); - comboColumn.setValue(cd); - label.setValue(cd.getLabel()); + protected void create() { + Log.debug("Create LabelColunmPanel"); + SimpleContainer columnsContainer = new SimpleContainer(); + //columnsContainer.setHeight(getOffsetHeight(true)-50); + + columnsLayoutContainer = new VerticalLayoutContainer(); + columnsLayoutContainer.setScrollMode(ScrollMode.AUTO); + columnsContainer.add(columnsLayoutContainer); + + addFields(); + columnsContainer.forceLayout(); + + change = new TextButton("Change"); + change.setIcon(ResourceBundle.INSTANCE.columnLabel()); + change.setIconAlign(IconAlign.RIGHT); + change.setTitle("Change Column Label"); + + change.addSelectHandler(new SelectHandler() { + + public void onSelect(SelectEvent event) { + changeLabelColumns(); + + } + }); + + VerticalLayoutContainer v = new VerticalLayoutContainer(); + + v.add(columnsContainer, new VerticalLayoutData(1, -1, new Margins(1))); + v.add(change, new VerticalLayoutData(-1, -1, new Margins(10, 0, 10, 0))); + add(v, new VerticalLayoutData(-1, -1, new Margins())); + + forceLayout(); + + } + + protected void addFields() { + VerticalLayoutData layoutData = new VerticalLayoutData(1, -1, + new Margins(1)); + + ArrayList fields = generateFields(); + for (FieldLabel fl : fields) { + columnsLayoutContainer.add(fl, layoutData); + + } + } + + protected ArrayList generateFields() { + ArrayList fields = new ArrayList(); + + for (ColumnData col : columns) { + if (col != null) { + FieldLabel textLabel; + if (col.getLabel() != null && !col.getLabel().isEmpty()) { + TextField text = new TextField(); + text.setValue(col.getLabel()); + textLabel = new FieldLabel(text, col.getLabel()); + textLabel.setLabelWidth(LABELWIDTH); + textLabel.setId(col.getColumnId()); + } else { + TextField text = new TextField(); + text.setValue(col.getLabel()); + textLabel = new FieldLabel(text, "nolabel"); + textLabel.setLabelWidth(LABELWIDTH); + textLabel.setId(col.getColumnId()); + } + fields.add(textLabel); + } + + } + Log.debug("Fields: "+fields.size()); + return fields; + } + + protected void init() { + setWidth(WIDTH); + setHeight(HEIGHT); + setHeaderVisible(false); + setBodyBorder(false); } public void update(TRId trId, String columnName) { this.trId = trId; this.columnName = columnName; - loader.load(); + + updateStatus = true; + retrieveColumns(); } - protected void onLabelColumn() { + protected void updatePanel() { + columnsLayoutContainer.clear(); + addFields(); + + forceLayout(); + } - ColumnData columnData = comboColumn.getCurrentValue(); - if (columnData != null) { - String lab = label.getCurrentValue(); - if (lab != null && !lab.isEmpty()) { - labelColumnSession = new LabelColumnSession(); - labelColumnSession.setColumnData(columnData); - labelColumnSession.setLabel(lab); - callLabelColumn(); - } else { - UtilsGXT3.alert("Attention", "Insert a valid label!"); + protected void changeLabelColumns() { + int i = 0; + int lenght = columnsLayoutContainer.getWidgetCount(); + HashMap maps = new HashMap(); + + for (; i < lenght; i++) { + FieldLabel fieldLabel = (FieldLabel) columnsLayoutContainer + .getWidget(i); + String columnId = fieldLabel.getId(); + ColumnData colCurrent = null; + for (ColumnData col : columns) { + if (col.getColumnId().compareTo(columnId) == 0) { + colCurrent = col; + break; + } } - } else { - UtilsGXT3.alert("Attention", "Select a column!"); + if (colCurrent == null) { + continue; + } + + TextField text = (TextField) fieldLabel.getWidget(); + String val = text.getCurrentValue(); + if (val == null || val.isEmpty()) { + continue; + } + maps.put(colCurrent, val); + } + + if (maps.size() > 0) { + labelColumnSession = new LabelColumnSession(trId,maps); + callLabelColumn(); + } else { + UtilsGXT3.alert("Attention", "Insert valid labels!"); + } + } private void callLabelColumn() { @@ -286,7 +274,7 @@ public class LabelColumnPanel extends FramedPanel implements } public void onSuccess(String taskId) { - openMonitorDialog(taskId) ; + openMonitorDialog(taskId); } }); @@ -299,7 +287,7 @@ public class LabelColumnPanel extends FramedPanel implements } } - /// + // / protected void openMonitorDialog(String taskId) { MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus); monitorDialog.addProgressDialogListener(this);