Updated Change Column Label
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-column-widget@99387 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
821b7ff71c
commit
3f55852b8c
|
@ -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
|
||||
|
|
|
@ -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" <a
|
||||
|
@ -60,129 +45,38 @@ import com.sencha.gxt.widget.core.client.info.Info;
|
|||
*/
|
||||
public class LabelColumnPanel extends FramedPanel implements
|
||||
MonitorDialogListener {
|
||||
protected String WIDTH = "640px";
|
||||
protected String HEIGHT = "520px";
|
||||
protected static final String WIDTH = "640px";
|
||||
protected static final String HEIGHT = "520px";
|
||||
protected static final int LABELWIDTH = 140;
|
||||
|
||||
protected EventBus eventBus;
|
||||
protected ChangeColumnTypeDialog parent;
|
||||
protected TextField label = null;
|
||||
protected TRId trId;
|
||||
protected String columnName;
|
||||
protected ColumnData column;
|
||||
protected ComboBox<ColumnData> comboColumn = null;
|
||||
protected ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader;
|
||||
|
||||
protected ArrayList<ColumnData> 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<ColumnData> storeCombo = new ListStore<ColumnData>(
|
||||
propsColumnData.id());
|
||||
|
||||
Log.trace("StoreCombo created");
|
||||
|
||||
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
|
||||
|
||||
public void load(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
||||
loadData(loadConfig, callback);
|
||||
}
|
||||
};
|
||||
|
||||
loader = new ListLoader<ListLoadConfig, ListLoadResult<ColumnData>>(
|
||||
proxy) {
|
||||
@Override
|
||||
protected ListLoadConfig newLoadConfig() {
|
||||
return (ListLoadConfig) new ListLoadConfigBean();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ColumnData, ListLoadResult<ColumnData>>(
|
||||
storeCombo));
|
||||
Log.trace("LoaderCombo created");
|
||||
|
||||
comboColumn = new ComboBox<ColumnData>(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<ColumnData> labelProvider) {
|
||||
comboColumn.addSelectionHandler(new SelectionHandler<ColumnData>() {
|
||||
public void onSelection(SelectionEvent<ColumnData> 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<ListLoadResult<ColumnData>> callback) {
|
||||
protected void retrieveColumns() {
|
||||
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
||||
|
@ -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<ColumnData> result) {
|
||||
|
@ -213,59 +107,153 @@ public class LabelColumnPanel extends FramedPanel implements
|
|||
if (removables.size() > 0) {
|
||||
result.removeAll(removables);
|
||||
}
|
||||
setComboStatus(result);
|
||||
callback.onSuccess(new ListLoadResultBean<ColumnData>(
|
||||
result));
|
||||
columns = result;
|
||||
startCreate();
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void setComboStatus(ArrayList<ColumnData> 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<FieldLabel> fields = generateFields();
|
||||
for (FieldLabel fl : fields) {
|
||||
columnsLayoutContainer.add(fl, layoutData);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
protected ArrayList<FieldLabel> generateFields() {
|
||||
ArrayList<FieldLabel> fields = new ArrayList<FieldLabel>();
|
||||
|
||||
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<ColumnData, String> maps = new HashMap<ColumnData, String>();
|
||||
|
||||
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);
|
||||
|
|
Loading…
Reference in New Issue