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 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<ListLoadConfig, ListLoadResult<ColumnData>> loader;
|
||||
protected Grid<ColumnData> grid;
|
||||
protected CheckBoxSelectionModel<ColumnData> 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<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());
|
||||
|
||||
RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<ColumnData>>() {
|
||||
|
@ -71,27 +88,38 @@ public class DuplicateRowsDeletePanel extends FramedPanel {
|
|||
loadData(loadConfig, callback);
|
||||
}
|
||||
};
|
||||
|
||||
loader = new ListLoader<ListLoadConfig, ListLoadResult<ColumnData>>(
|
||||
proxy) {
|
||||
@Override
|
||||
protected ListLoadConfig newLoadConfig() {
|
||||
return (ListLoadConfig) new ListLoadConfigBean();
|
||||
}
|
||||
proxy);
|
||||
|
||||
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>>(
|
||||
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<ColumnData> toStore = new ListStore<ColumnData>(props.id());
|
||||
|
||||
final DualListField<ColumnData, String> columnsField = new DualListField<ColumnData, String>(
|
||||
store, toStore, props.label(), new TextCell());
|
||||
columnsField.addValidator(new EmptyValidator<List<ColumnData>>());
|
||||
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<ListLoadResult<ColumnData>> callback) {
|
||||
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||
|
@ -139,26 +171,22 @@ public class DuplicateRowsDeletePanel extends FramedPanel {
|
|||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void onDeleteDuplicate() {
|
||||
/*TDGWTServiceAsync.INSTANCE.startDeleteRows(deleteRowsSession,
|
||||
new AsyncCallback<Void>() {
|
||||
|
||||
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<Void>() {
|
||||
*
|
||||
* 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); }
|
||||
*
|
||||
* });
|
||||
*/
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue