Minor Updated
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-table-widget@92788 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
797124698b
commit
5b33878ffb
|
@ -0,0 +1,25 @@
|
||||||
|
package org.gcube.portlets.user.td.tablewidget.client.properties;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||||
|
|
||||||
|
import com.google.gwt.editor.client.Editor.Path;
|
||||||
|
import com.sencha.gxt.core.client.ValueProvider;
|
||||||
|
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||||
|
import com.sencha.gxt.data.shared.PropertyAccess;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi"
|
||||||
|
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public interface ColumnDataProperties extends
|
||||||
|
PropertyAccess<ColumnData> {
|
||||||
|
|
||||||
|
@Path("id")
|
||||||
|
ModelKeyProvider<ColumnData> id();
|
||||||
|
|
||||||
|
ValueProvider<ColumnData,String> label();
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,177 @@
|
||||||
|
package org.gcube.portlets.user.td.tablewidget.client.rows;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData;
|
||||||
|
import org.gcube.portlets.user.td.gwtservice.shared.tr.rows.DeleteRowsSession;
|
||||||
|
import org.gcube.portlets.user.td.tablewidget.client.progress.DeleteRowsProgressDialog;
|
||||||
|
import org.gcube.portlets.user.td.tablewidget.client.properties.ColumnDataProperties;
|
||||||
|
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.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
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;
|
||||||
|
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding;
|
||||||
|
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||||
|
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
||||||
|
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.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;
|
||||||
|
|
||||||
|
public class DeleteDuplicateRowsPanel extends FramedPanel {
|
||||||
|
protected String WIDTH = "640px";
|
||||||
|
protected String HEIGHT = "520px";
|
||||||
|
|
||||||
|
protected TRId trId;
|
||||||
|
protected EventBus eventBus;
|
||||||
|
protected ArrayList<String> rows;
|
||||||
|
protected DeleteRowsSession deleteRowsSession;
|
||||||
|
protected DeleteRowsProgressDialog deleteRowsProgressDialog;
|
||||||
|
|
||||||
|
protected ListLoader<ListLoadConfig, ListLoadResult<ColumnData>> loader;
|
||||||
|
protected FieldLabel columnsSelectLabel;
|
||||||
|
protected TextButton deleteButton;
|
||||||
|
|
||||||
|
public DeleteDuplicateRowsPanel(TRId trId, EventBus eventBus) {
|
||||||
|
setWidth(WIDTH);
|
||||||
|
setHeight(HEIGHT);
|
||||||
|
setHeaderVisible(false);
|
||||||
|
setBodyBorder(false);
|
||||||
|
this.trId = trId;
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
Log.debug("Create DeleteDuplicatePanel(): [" + trId.toString() + "]");
|
||||||
|
|
||||||
|
ColumnDataProperties props = GWT.create(ColumnDataProperties.class);
|
||||||
|
ListStore<ColumnData> store = new ListStore<ColumnData>(props.id());
|
||||||
|
|
||||||
|
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>>(
|
||||||
|
store));
|
||||||
|
|
||||||
|
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() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
onDeleteDuplicate();
|
||||||
|
|
||||||
|
}
|
||||||
|
};
|
||||||
|
deleteButton.addSelectHandler(changeHandler);
|
||||||
|
FieldLabel columnsLabel = new FieldLabel(null,"Columns");
|
||||||
|
columnsSelectLabel = new FieldLabel(columnsField);
|
||||||
|
|
||||||
|
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(deleteButton, new VerticalLayoutData(-1, -1, new Margins(10, 0,
|
||||||
|
10, 0)));
|
||||||
|
|
||||||
|
add(v, new VerticalLayoutData(-1, -1, new Margins(0)));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void loadData(ListLoadConfig loadConfig,
|
||||||
|
final AsyncCallback<ListLoadResult<ColumnData>> callback) {
|
||||||
|
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||||
|
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||||
|
|
||||||
|
public void onFailure(Throwable caught) {
|
||||||
|
Log.error("load columns failure:"
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
|
alert("Error retrieving columns",
|
||||||
|
"Error retrieving columns");
|
||||||
|
callback.onFailure(caught);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSuccess(ArrayList<ColumnData> result) {
|
||||||
|
Log.trace("loaded " + result.size() + " ColumnData");
|
||||||
|
callback.onSuccess(new ListLoadResultBean<ColumnData>(
|
||||||
|
result));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
|
||||||
|
private void alert(String title, String message) {
|
||||||
|
final AlertMessageBox d = new AlertMessageBox(title, message);
|
||||||
|
d.addHideHandler(new HideHandler() {
|
||||||
|
|
||||||
|
public void onHide(HideEvent event) {
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
d.show();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue