Minor Updated
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-table-widget@92800 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
2790930ea0
commit
c09a54c8bc
|
@ -11,15 +11,17 @@ import org.gcube.portlets.user.td.tablewidget.client.properties.ColumnDataProper
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.cell.client.TextCell;
|
|
||||||
import com.google.gwt.core.client.GWT;
|
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.user.client.rpc.AsyncCallback;
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
import com.google.web.bindery.event.shared.EventBus;
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
import com.sencha.gxt.core.client.IdentityValueProvider;
|
||||||
|
import com.sencha.gxt.core.client.Style.SelectionMode;
|
||||||
import com.sencha.gxt.core.client.util.Margins;
|
import com.sencha.gxt.core.client.util.Margins;
|
||||||
import com.sencha.gxt.data.client.loader.RpcProxy;
|
import com.sencha.gxt.data.client.loader.RpcProxy;
|
||||||
import com.sencha.gxt.data.shared.ListStore;
|
import com.sencha.gxt.data.shared.ListStore;
|
||||||
import com.sencha.gxt.data.shared.loader.ListLoadConfig;
|
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.ListLoadResult;
|
||||||
import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
|
import com.sencha.gxt.data.shared.loader.ListLoadResultBean;
|
||||||
import com.sencha.gxt.data.shared.loader.ListLoader;
|
import com.sencha.gxt.data.shared.loader.ListLoader;
|
||||||
|
@ -30,13 +32,14 @@ import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||||
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer;
|
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.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
||||||
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
|
||||||
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
||||||
|
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.event.SelectEvent.SelectHandler;
|
||||||
import com.sencha.gxt.widget.core.client.form.DualListField;
|
|
||||||
import com.sencha.gxt.widget.core.client.form.DualListField.Mode;
|
|
||||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
||||||
import com.sencha.gxt.widget.core.client.form.validator.EmptyValidator;
|
import com.sencha.gxt.widget.core.client.grid.CheckBoxSelectionModel;
|
||||||
|
import com.sencha.gxt.widget.core.client.grid.ColumnConfig;
|
||||||
|
import com.sencha.gxt.widget.core.client.grid.ColumnModel;
|
||||||
|
import com.sencha.gxt.widget.core.client.grid.Grid;
|
||||||
|
|
||||||
public class DuplicateRowsDeletePanel extends FramedPanel {
|
public class DuplicateRowsDeletePanel extends FramedPanel {
|
||||||
protected String WIDTH = "640px";
|
protected String WIDTH = "640px";
|
||||||
|
@ -49,6 +52,8 @@ public class DuplicateRowsDeletePanel extends FramedPanel {
|
||||||
protected DeleteRowsProgressDialog deleteRowsProgressDialog;
|
protected DeleteRowsProgressDialog deleteRowsProgressDialog;
|
||||||
|
|
||||||
protected ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader;
|
protected ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader;
|
||||||
|
protected Grid<ColumnData> grid;
|
||||||
|
protected CheckBoxSelectionModel<ColumnData> sm;
|
||||||
protected FieldLabel columnsSelectLabel;
|
protected FieldLabel columnsSelectLabel;
|
||||||
protected TextButton deleteButton;
|
protected TextButton deleteButton;
|
||||||
|
|
||||||
|
@ -62,6 +67,18 @@ public class DuplicateRowsDeletePanel extends FramedPanel {
|
||||||
Log.debug("Create DeleteDuplicatePanel(): [" + trId.toString() + "]");
|
Log.debug("Create DeleteDuplicatePanel(): [" + trId.toString() + "]");
|
||||||
|
|
||||||
ColumnDataProperties props = GWT.create(ColumnDataProperties.class);
|
ColumnDataProperties props = GWT.create(ColumnDataProperties.class);
|
||||||
|
|
||||||
|
ColumnConfig<ColumnData, String> labelCol = new ColumnConfig<ColumnData, String>(
|
||||||
|
props.label());
|
||||||
|
|
||||||
|
IdentityValueProvider<ColumnData> identity = new IdentityValueProvider<ColumnData>();
|
||||||
|
sm = new CheckBoxSelectionModel<ColumnData>(identity);
|
||||||
|
|
||||||
|
List<ColumnConfig<ColumnData, ?>> l = new ArrayList<ColumnConfig<ColumnData, ?>>();
|
||||||
|
l.add(sm.getColumn());
|
||||||
|
l.add(labelCol);
|
||||||
|
ColumnModel<ColumnData> cm = new ColumnModel<ColumnData>(l);
|
||||||
|
|
||||||
ListStore<ColumnData> store = new ListStore<ColumnData>(props.id());
|
ListStore<ColumnData> store = new ListStore<ColumnData>(props.id());
|
||||||
|
|
||||||
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
|
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
|
||||||
|
@ -71,26 +88,37 @@ public class DuplicateRowsDeletePanel extends FramedPanel {
|
||||||
loadData(loadConfig, callback);
|
loadData(loadConfig, callback);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
loader = new ListLoader<ListLoadConfig, ListLoadResult<ColumnData>>(
|
loader = new ListLoader<ListLoadConfig, ListLoadResult<ColumnData>>(
|
||||||
proxy) {
|
proxy);
|
||||||
@Override
|
|
||||||
protected ListLoadConfig newLoadConfig() {
|
|
||||||
return (ListLoadConfig) new ListLoadConfigBean();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
loader.setRemoteSort(false);
|
||||||
|
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ColumnData, ListLoadResult<ColumnData>>(
|
||||||
|
store) {
|
||||||
|
});
|
||||||
|
|
||||||
|
grid = new Grid<ColumnData>(store, cm) {
|
||||||
|
@Override
|
||||||
|
protected void onAfterFirstAttach() {
|
||||||
|
super.onAfterFirstAttach();
|
||||||
|
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||||
|
|
||||||
|
public void execute() {
|
||||||
|
loader.load();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, ColumnData, ListLoadResult<ColumnData>>(
|
sm.setSelectionMode(SelectionMode.MULTI);
|
||||||
store));
|
grid.setLoader(loader);
|
||||||
|
grid.setSelectionModel(sm);
|
||||||
ListStore<ColumnData> toStore = new ListStore<ColumnData>(props.id());
|
grid.getView().setAutoExpandColumn(labelCol);
|
||||||
|
grid.getView().setStripeRows(true);
|
||||||
final DualListField<ColumnData, String> columnsField = new DualListField<ColumnData, String>(
|
grid.getView().setColumnLines(true);
|
||||||
store, toStore, props.label(), new TextCell());
|
grid.getView().setAutoFill(true);
|
||||||
columnsField.addValidator(new EmptyValidator<List<ColumnData>>());
|
grid.setBorders(false);
|
||||||
columnsField.setEnableDnd(true);
|
grid.setLoadMask(true);
|
||||||
columnsField.setMode(Mode.INSERT);
|
grid.setColumnReordering(true);
|
||||||
|
|
||||||
// Delete Button
|
// Delete Button
|
||||||
deleteButton = new TextButton("Delete");
|
deleteButton = new TextButton("Delete");
|
||||||
|
@ -102,12 +130,11 @@ public class DuplicateRowsDeletePanel extends FramedPanel {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
deleteButton.addSelectHandler(changeHandler);
|
deleteButton.addSelectHandler(changeHandler);
|
||||||
FieldLabel columnsLabel = new FieldLabel(null,"Columns");
|
|
||||||
columnsSelectLabel = new FieldLabel(columnsField);
|
//FieldLabel columnsLabel = new FieldLabel(null, "Columns");
|
||||||
|
|
||||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||||
v.add(columnsLabel, new VerticalLayoutData(1, -1, new Margins(1)));
|
v.add(grid, new VerticalLayoutData(1, -1, new Margins(1)));
|
||||||
v.add(columnsSelectLabel, new VerticalLayoutData(1, -1, new Margins(1)));
|
|
||||||
v.add(deleteButton, new VerticalLayoutData(-1, -1, new Margins(10, 0,
|
v.add(deleteButton, new VerticalLayoutData(-1, -1, new Margins(10, 0,
|
||||||
10, 0)));
|
10, 0)));
|
||||||
|
|
||||||
|
@ -115,6 +142,11 @@ public class DuplicateRowsDeletePanel extends FramedPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void update(TRId trId) {
|
||||||
|
this.trId = trId;
|
||||||
|
loader.load();
|
||||||
|
}
|
||||||
|
|
||||||
protected void loadData(ListLoadConfig loadConfig,
|
protected void loadData(ListLoadConfig loadConfig,
|
||||||
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
||||||
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||||
|
@ -139,26 +171,22 @@ public class DuplicateRowsDeletePanel extends FramedPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected void onDeleteDuplicate() {
|
protected void onDeleteDuplicate() {
|
||||||
/*TDGWTServiceAsync.INSTANCE.startDeleteRows(deleteRowsSession,
|
/*
|
||||||
new AsyncCallback<Void>() {
|
* TDGWTServiceAsync.INSTANCE.startDeleteRows(deleteRowsSession, new
|
||||||
|
* AsyncCallback<Void>() {
|
||||||
public void onFailure(Throwable caught) {
|
*
|
||||||
Log.debug("Delete Rows Error: "
|
* public void onFailure(Throwable caught) {
|
||||||
+ caught.getLocalizedMessage());
|
* Log.debug("Delete Rows Error: " + caught.getLocalizedMessage());
|
||||||
alert("Error Deleting Rows",
|
* alert("Error Deleting Rows",
|
||||||
"Error in invocation Delete Rows operation!");
|
* "Error in invocation Delete Rows operation!");
|
||||||
|
*
|
||||||
}
|
* }
|
||||||
|
*
|
||||||
public void onSuccess(Void result) {
|
* public void onSuccess(Void result) { deleteRowsProgressDialog = new
|
||||||
deleteRowsProgressDialog = new DeleteRowsProgressDialog(
|
* DeleteRowsProgressDialog( deleteRowsSession, eventBus); }
|
||||||
deleteRowsSession, eventBus);
|
*
|
||||||
}
|
* });
|
||||||
|
|
||||||
});
|
|
||||||
*/
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue