From fe8d7b3768e254fefaa7b2209a6de35bf8fd09f5 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Thu, 3 Jul 2014 10:27:49 +0000 Subject: [PATCH] git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-table-widget@98347 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../normalization/NormalizationDialog.java | 71 ---- .../normalization/NormalizationPanel.java | 315 ------------------ 2 files changed, 386 deletions(-) delete mode 100644 src/main/java/org/gcube/portlets/user/td/tablewidget/client/normalization/NormalizationDialog.java delete mode 100644 src/main/java/org/gcube/portlets/user/td/tablewidget/client/normalization/NormalizationPanel.java diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/normalization/NormalizationDialog.java b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/normalization/NormalizationDialog.java deleted file mode 100644 index cb61446..0000000 --- a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/normalization/NormalizationDialog.java +++ /dev/null @@ -1,71 +0,0 @@ -package org.gcube.portlets.user.td.tablewidget.client.normalization; - -import org.gcube.portlets.user.td.columnwidget.client.resources.ResourceBundle; -import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; - -import com.allen_sauer.gwt.log.client.Log; -import com.google.web.bindery.event.shared.EventBus; -import com.sencha.gxt.widget.core.client.Window; -import com.sencha.gxt.widget.core.client.event.SelectEvent; -import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; - -/** - * - * @author "Giancarlo Panichi" - * email: g.panichi@isti.cnr.it - * - */ -public class NormalizationDialog extends Window { - protected String WIDTH = "650px"; - protected String HEIGHT = "530px"; - protected EventBus eventBus; - protected NormalizationPanel normalizationPanel; - protected TRId trId; - - public NormalizationDialog(TRId trId, EventBus eventBus) { - super(); - Log.debug("AddColumnDialog"); - this.eventBus = eventBus; - this.trId=trId; - initWindow(); - normalizationPanel = new NormalizationPanel(this, trId,eventBus); - add(normalizationPanel); - } - - protected void initWindow() { - setWidth(WIDTH); - setHeight(HEIGHT); - setBodyBorder(false); - setResizable(false); - - setClosable(true); - setModal(true); - forceLayoutOnResize = true; - getHeader().setIcon(ResourceBundle.INSTANCE.columnValue()); - setHeadingText("Normalization"); - } - - /** - * {@inheritDoc} - */ - @Override - protected void initTools() { - super.initTools(); - - closeBtn.addSelectHandler(new SelectHandler() { - - public void onSelect(SelectEvent event) { - close(); - } - }); - - } - - public void close() { - hide(); - - } - - - -} diff --git a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/normalization/NormalizationPanel.java b/src/main/java/org/gcube/portlets/user/td/tablewidget/client/normalization/NormalizationPanel.java deleted file mode 100644 index dbe1ccc..0000000 --- a/src/main/java/org/gcube/portlets/user/td/tablewidget/client/normalization/NormalizationPanel.java +++ /dev/null @@ -1,315 +0,0 @@ -package org.gcube.portlets.user.td.tablewidget.client.normalization; - -import java.util.ArrayList; -import java.util.List; - -import org.gcube.portlets.user.td.columnwidget.client.progress.ProgressDialogListener; - -import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; -import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; -import org.gcube.portlets.user.td.gwtservice.shared.tr.ColumnData; -import org.gcube.portlets.user.td.gwtservice.shared.tr.normalization.NormalizationSession; -import org.gcube.portlets.user.td.tablewidget.client.progress.DuplicatesRowsProgressDialog; -import org.gcube.portlets.user.td.tablewidget.client.progress.NormalizationProgressDialog; -import org.gcube.portlets.user.td.tablewidget.client.properties.ColumnDataProperties; -import org.gcube.portlets.user.td.tablewidget.client.resources.ResourceBundle; -import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3; -import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent; -import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; -import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType; -import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy; -import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; -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.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.core.client.IdentityValueProvider; -import com.sencha.gxt.core.client.Style.SelectionMode; -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.ListStore; -import com.sencha.gxt.data.shared.loader.ListLoadConfig; -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.BoxLayoutContainer.BoxLayoutData; -import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer; -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.FieldLabel; -import com.sencha.gxt.widget.core.client.form.TextField; -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 NormalizationPanel extends FramedPanel implements ProgressDialogListener { - protected String WIDTH = "640px"; - protected String HEIGHT = "520px"; - - protected TRId trId; - protected EventBus eventBus; - protected ArrayList rows; - - protected NormalizationSession normalizationSession; - protected DuplicatesRowsProgressDialog duplicatesRowsProgressDialog; - - protected ListLoader> loader; - protected Grid grid; - protected CheckBoxSelectionModel sm; - protected FieldLabel columnsSelectLabel; - protected TextButton normalizeButton; - protected TextField normalizedColumnName; - protected TextField valueColumnName; - protected NormalizationDialog parent; - - - public NormalizationPanel(NormalizationDialog parent,TRId trId, EventBus eventBus) { - this.parent=parent; - this.trId = trId; - this.eventBus = eventBus; - create(); - } - - public NormalizationPanel(TRId trId, EventBus eventBus) { - this.trId = trId; - this.eventBus = eventBus; - this.parent=null; - create(); - } - - protected void create(){ - - setWidth(WIDTH); - setHeight(HEIGHT); - setHeaderVisible(false); - setBodyBorder(false); - Log.debug("Create NormalizationPanel(): [" + 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>() { - - public void load(ListLoadConfig loadConfig, - final AsyncCallback> callback) { - loadData(loadConfig, callback); - } - }; - loader = new ListLoader>( - 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(); - } - }); - } - }; - - sm.setSelectionMode(SelectionMode.MULTI); - grid.setLoader(loader); - grid.setSelectionModel(sm); - // grid.getView().setAutoExpandColumn(labelCol); - grid.setHeight(360); - grid.getView().setStripeRows(true); - grid.getView().setColumnLines(true); - grid.getView().setAutoFill(true); - grid.setBorders(false); - grid.setLoadMask(true); - grid.setColumnReordering(true); - grid.setColumnResize(false); - - //Normalize Button - normalizeButton = new TextButton("Normalize"); - normalizeButton.setIcon(ResourceBundle.INSTANCE.tableNormalize()); - normalizeButton.setIconAlign(IconAlign.RIGHT); - normalizeButton.setTitle("Normalize"); - - SelectHandler deleteHandler = new SelectHandler() { - - public void onSelect(SelectEvent event) { - onNormalize(); - - } - }; - normalizeButton.addSelectHandler(deleteHandler); - - normalizedColumnName = new TextField(); - FieldLabel normalizedColumnNameLabel=new FieldLabel(normalizedColumnName, "Normalized column"); - normalizedColumnNameLabel.setLabelWidth(120); - - valueColumnName = new TextField(); - FieldLabel valueColumnNameLabel=new FieldLabel(valueColumnName, "Value column"); - valueColumnNameLabel.setLabelWidth(120); - - FieldLabel columnsLabel = new FieldLabel(null,"Columns to Normalize"); - columnsLabel.setLabelWidth(180); - - columnsLabel.getElement().applyStyles("font-weight:bold"); - HBoxLayoutContainer hBox = new HBoxLayoutContainer(); - hBox.add(normalizeButton, new BoxLayoutData(new Margins(2, 5, 2, 5))); - - VerticalLayoutContainer v = new VerticalLayoutContainer(); - v.setScrollMode(ScrollMode.AUTO); - v.add(normalizedColumnNameLabel,new VerticalLayoutData(1, -1)); - v.add(valueColumnNameLabel, - new VerticalLayoutData(1, -1)); - v.add(columnsLabel, new VerticalLayoutData(-1, -1, new Margins(2, 1, 5, - 1))); - v.add(grid, new VerticalLayoutData(1, -1, new Margins(0))); - v.add(hBox, new VerticalLayoutData(-1, -1, new Margins(10, 0, 10, 0))); - add(v, new VerticalLayoutData(-1, -1, new Margins(0))); - - } - - protected ArrayList getSelectedItems() { - return new ArrayList(grid.getSelectionModel() - .getSelectedItems()); - - } - - public void update(TRId trId) { - this.trId = trId; - loader.load(); - } - - protected void loadData(ListLoadConfig loadConfig, - final AsyncCallback> callback) { - TDGWTServiceAsync.INSTANCE.getColumns(trId, - new AsyncCallback>() { - - public void onFailure(Throwable caught) { - if (caught instanceof TDGWTSessionExpiredException) { - eventBus.fireEvent(new SessionExpiredEvent( - SessionExpiredType.EXPIREDONSERVER)); - } else { - Log.error("load columns failure:" - + caught.getLocalizedMessage()); - UtilsGXT3.alert("Error retrieving columns", - "Error retrieving columns"); - } - callback.onFailure(caught); - } - - public void onSuccess(ArrayList result) { - Log.trace("loaded " + result.size() + " ColumnData"); - callback.onSuccess(new ListLoadResultBean( - result)); - - } - - }); - - } - - protected void onNormalize() { - ArrayList col = getSelectedItems(); - if (col == null || col.size() < 1) { - UtilsGXT3.alert("Attention", "Attention no column selected!"); - return; - } - - String name=normalizedColumnName.getCurrentValue(); - String value=valueColumnName.getCurrentValue(); - - normalizationSession = new NormalizationSession(trId, col, - name,value); - - TDGWTServiceAsync.INSTANCE.startNormalization(normalizationSession, - new AsyncCallback() { - - public void onFailure(Throwable caught) { - if (caught instanceof TDGWTSessionExpiredException) { - eventBus.fireEvent(new SessionExpiredEvent( - SessionExpiredType.EXPIREDONSERVER)); - } else { - Log.debug("Normalization Error: " - + caught.getLocalizedMessage()); - UtilsGXT3 - .alert("Error on Normalization",caught.getLocalizedMessage()); - } - } - - public void onSuccess(Void result) { - callNormalizationProgressDialog(); - } - - }); - - } - - public void close() { - if (parent != null) { - parent.close(); - } - } - - protected void callNormalizationProgressDialog(){ - NormalizationProgressDialog normalizeProgressDialog = new NormalizationProgressDialog(eventBus); - normalizeProgressDialog.addProgressDialogListener(this); - normalizeProgressDialog.show(); - } - - - @Override - public void operationComplete(TRId trId) { - ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED; - ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent( - ChangeTableRequestType.NORMALIZE, trId, why); - eventBus.fireEvent(changeTableRequestEvent); - close(); - - } - - @Override - public void operationFailed(Throwable caught, String reason) { - UtilsGXT3.alert("Error in Normalize", reason); - close(); - } - - @Override - public void operationStopped(TRId trId, String reason, String details) { - ChangeTableWhy why = ChangeTableWhy.TABLECURATION; - ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent( - ChangeTableRequestType.NORMALIZE, trId, why); - eventBus.fireEvent(changeTableRequestEvent); - close(); - } - - - -}