From c09a54c8bcdc80489661c872c7465a782818ac1d Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Fri, 7 Mar 2014 09:41:21 +0000 Subject: [PATCH] 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 --- .../client/rows/DuplicateRowsDeletePanel.java | 120 +++++++++++------- 1 file changed, 74 insertions(+), 46 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/rows/DuplicateRowsDeletePanel.java b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/rows/DuplicateRowsDeletePanel.java index a5c0af1..b24cef8 100644 --- a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/rows/DuplicateRowsDeletePanel.java +++ b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/rows/DuplicateRowsDeletePanel.java @@ -11,15 +11,17 @@ import org.gcube.portlets.user.td.tablewidget.client.properties.ColumnDataProper import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; 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.Scheduler; +import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.user.client.rpc.AsyncCallback; 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.data.client.loader.RpcProxy; 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; @@ -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.VerticalLayoutData; 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.SelectEvent; 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.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 { protected String WIDTH = "640px"; @@ -49,6 +52,8 @@ public class DuplicateRowsDeletePanel extends FramedPanel { protected DeleteRowsProgressDialog deleteRowsProgressDialog; protected ListLoader> loader; + protected Grid grid; + protected CheckBoxSelectionModel sm; protected FieldLabel columnsSelectLabel; protected TextButton deleteButton; @@ -62,6 +67,18 @@ public class DuplicateRowsDeletePanel extends FramedPanel { Log.debug("Create DeleteDuplicatePanel(): [" + trId.toString() + "]"); ColumnDataProperties props = GWT.create(ColumnDataProperties.class); + + ColumnConfig labelCol = new ColumnConfig( + props.label()); + + IdentityValueProvider identity = new IdentityValueProvider(); + sm = new CheckBoxSelectionModel(identity); + + List> l = new ArrayList>(); + l.add(sm.getColumn()); + l.add(labelCol); + ColumnModel cm = new ColumnModel(l); + ListStore store = new ListStore(props.id()); RpcProxy> proxy = new RpcProxy>() { @@ -71,27 +88,38 @@ public class DuplicateRowsDeletePanel extends FramedPanel { loadData(loadConfig, callback); } }; - loader = new ListLoader>( - proxy) { - @Override - protected ListLoadConfig newLoadConfig() { - return (ListLoadConfig) new ListLoadConfigBean(); - } + proxy); + loader.setRemoteSort(false); + loader.addLoadHandler(new LoadResultListStoreBinding>( + store) { + }); + + grid = new Grid(store, cm) { + @Override + protected void onAfterFirstAttach() { + super.onAfterFirstAttach(); + Scheduler.get().scheduleDeferred(new ScheduledCommand() { + + public void execute() { + loader.load(); + } + }); + } }; - loader.addLoadHandler(new LoadResultListStoreBinding>( - store)); + sm.setSelectionMode(SelectionMode.MULTI); + grid.setLoader(loader); + grid.setSelectionModel(sm); + grid.getView().setAutoExpandColumn(labelCol); + grid.getView().setStripeRows(true); + grid.getView().setColumnLines(true); + grid.getView().setAutoFill(true); + grid.setBorders(false); + grid.setLoadMask(true); + grid.setColumnReordering(true); - ListStore toStore = new ListStore(props.id()); - - final DualListField columnsField = new DualListField( - store, toStore, props.label(), new TextCell()); - columnsField.addValidator(new EmptyValidator>()); - columnsField.setEnableDnd(true); - columnsField.setMode(Mode.INSERT); - // Delete Button deleteButton = new TextButton("Delete"); SelectHandler changeHandler = new SelectHandler() { @@ -102,12 +130,11 @@ public class DuplicateRowsDeletePanel extends FramedPanel { } }; deleteButton.addSelectHandler(changeHandler); - FieldLabel columnsLabel = new FieldLabel(null,"Columns"); - columnsSelectLabel = new FieldLabel(columnsField); - + + //FieldLabel columnsLabel = new FieldLabel(null, "Columns"); + VerticalLayoutContainer v = new VerticalLayoutContainer(); - v.add(columnsLabel, new VerticalLayoutData(1, -1, new Margins(1))); - v.add(columnsSelectLabel, new VerticalLayoutData(1, -1, new Margins(1))); + v.add(grid, new VerticalLayoutData(1, -1, new Margins(1))); v.add(deleteButton, new VerticalLayoutData(-1, -1, new Margins(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, final AsyncCallback> callback) { TDGWTServiceAsync.INSTANCE.getColumns(trId, @@ -139,26 +171,22 @@ public class DuplicateRowsDeletePanel extends FramedPanel { } - - protected void onDeleteDuplicate() { - /*TDGWTServiceAsync.INSTANCE.startDeleteRows(deleteRowsSession, - new AsyncCallback() { - - public void onFailure(Throwable caught) { - Log.debug("Delete Rows Error: " - + caught.getLocalizedMessage()); - alert("Error Deleting Rows", - "Error in invocation Delete Rows operation!"); - - } - - public void onSuccess(Void result) { - deleteRowsProgressDialog = new DeleteRowsProgressDialog( - deleteRowsSession, eventBus); - } - - }); + /* + * TDGWTServiceAsync.INSTANCE.startDeleteRows(deleteRowsSession, new + * AsyncCallback() { + * + * public void onFailure(Throwable caught) { + * Log.debug("Delete Rows Error: " + caught.getLocalizedMessage()); + * alert("Error Deleting Rows", + * "Error in invocation Delete Rows operation!"); + * + * } + * + * public void onSuccess(Void result) { deleteRowsProgressDialog = new + * DeleteRowsProgressDialog( deleteRowsSession, eventBus); } + * + * }); */ }