From 1754f1867004a894503889b4f3ad92bd5bfbcf1b Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 18 Feb 2014 14:07:10 +0000 Subject: [PATCH] Minor Updated git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@91844 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../client/ColumnExpressionPanel.java | 2 +- .../client/FilterColumnDialog.java | 60 ++++++++++++++++++- .../progress/ColumnFilterProgressDialog.java | 8 ++- .../shared/session/ColumnFilterSession.java | 10 ++++ 4 files changed, 74 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnExpressionPanel.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnExpressionPanel.java index fc350ff..b1ef143 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnExpressionPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/ColumnExpressionPanel.java @@ -206,7 +206,7 @@ public class ColumnExpressionPanel extends FramedPanel { parentRuleDialog.hide(); eventBus.fireEvent(expressionEvent); } else { - parentFilterDialog.setExpression(exp); + parentFilterDialog.applyFilter(exp); } } diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/FilterColumnDialog.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/FilterColumnDialog.java index 5724675..0744a7d 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/FilterColumnDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/FilterColumnDialog.java @@ -1,6 +1,9 @@ package org.gcube.portlets.user.td.expressionwidget.client; +import org.gcube.portlets.user.td.expressionwidget.client.progress.ColumnFilterProgressDialog; import org.gcube.portlets.user.td.expressionwidget.client.resource.ExpressionResources; +import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync; +import org.gcube.portlets.user.td.expressionwidget.shared.session.ColumnFilterSession; 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.widgetcommonevent.shared.TRId; @@ -13,6 +16,9 @@ import com.google.gwt.user.client.rpc.AsyncCallback; import com.google.gwt.user.client.ui.HTML; import com.google.web.bindery.event.shared.EventBus; import com.sencha.gxt.widget.core.client.Window; +import com.sencha.gxt.widget.core.client.box.AlertMessageBox; +import com.sencha.gxt.widget.core.client.event.HideEvent; +import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler; public class FilterColumnDialog extends Window { protected String WIDTH = "650px"; @@ -23,6 +29,8 @@ public class FilterColumnDialog extends Window { protected TRId trId; protected String columnName = null; protected EventBus eventBus; + private ColumnFilterSession columnFilterSession; + private ColumnFilterProgressDialog dialog; public FilterColumnDialog(String columnId, ColumnTypeCode columnTypeCode, ColumnDataType dataTypeName, @@ -72,6 +80,8 @@ public class FilterColumnDialog extends Window { || column.getTypeCode().compareTo( ColumnTypeCode.MEASURE.toString()) == 0) { columnExpressionPanel = new ColumnExpressionPanel(this, column); + columnExpressionPanel.getBtnSave().setVisible(false); + columnExpressionPanel.getBtnSearch().setVisible(false); add(columnExpressionPanel); } else { HTML errorMessage = new HTML( @@ -87,10 +97,14 @@ public class FilterColumnDialog extends Window { protected void setExpression(C_Expression exp) { Log.debug("New Expression set:" + exp.toString()); this.exp = exp; - - } + protected void applyFilter(C_Expression exp){ + this.exp=exp; + callApplyFilter(); + } + + protected void close(){ } @@ -104,7 +118,13 @@ public class FilterColumnDialog extends Window { public void onFailure(Throwable caught) { Log.error("Error retrieving column: " + caught.getMessage()); - + AlertMessageBox d = new AlertMessageBox("Error retrieving column", caught.getMessage()); + d.addHideHandler(new HideHandler() { + public void onHide(HideEvent event) { + hide(); + } + }); + d.show(); } public void onSuccess(ColumnData result) { @@ -119,6 +139,40 @@ public class FilterColumnDialog extends Window { + + protected void callApplyFilter() { + columnFilterSession= new ColumnFilterSession(column,exp); + ExpressionServiceAsync.INSTANCE.submitColumnFilter(columnFilterSession, new AsyncCallback() { + + @Override + public void onSuccess(Void result) { + Log.debug("Submitted column filter"); + callColumnFilterProgressDialog(); + } + + @Override + public void onFailure(Throwable caught) { + Log.error("Error submitting the column filter: " + + caught.getMessage()); + AlertMessageBox d = new AlertMessageBox("Error submitting the column filter", caught.getMessage()); + d.addHideHandler(new HideHandler() { + public void onHide(HideEvent event) { + hide(); + } + }); + d.show(); + + } + }); + + + } + + protected void callColumnFilterProgressDialog(){ + dialog=new ColumnFilterProgressDialog(this,eventBus); + dialog.show(); + } + } diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/progress/ColumnFilterProgressDialog.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/progress/ColumnFilterProgressDialog.java index 004eb93..80b92c9 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/progress/ColumnFilterProgressDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/client/progress/ColumnFilterProgressDialog.java @@ -1,5 +1,6 @@ package org.gcube.portlets.user.td.expressionwidget.client.progress; +import org.gcube.portlets.user.td.expressionwidget.client.FilterColumnDialog; import org.gcube.portlets.user.td.widgetcommonevent.client.event.ChangeTableRequestEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType; import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId; @@ -36,8 +37,10 @@ public class ColumnFilterProgressDialog extends Window implements ColumnFilterPr protected ColumnFilterProgressUpdater progressUpdater; protected TextButton ok; protected TRId trId; + protected FilterColumnDialog dialog; - public ColumnFilterProgressDialog(EventBus eventBus) { + public ColumnFilterProgressDialog(FilterColumnDialog dialog,EventBus eventBus) { + this.dialog=dialog; this.eventBus=eventBus; setWidth(WIDTH); setHeight(HEIGHT); @@ -79,7 +82,7 @@ public class ColumnFilterProgressDialog extends Window implements ColumnFilterPr progressUpdater.addListener(this); progressUpdater.scheduleRepeating(STATUS_POLLING_DELAY); - show(); + ok.setVisible(false); } @@ -118,6 +121,7 @@ public class ColumnFilterProgressDialog extends Window implements ColumnFilterPr new ChangeTableRequestEvent(ChangeTableRequestType.COLUMNFILTER, trId); eventBus.fireEvent(changeTableRequestEvent); } + dialog.hide(); hide(); } } diff --git a/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/session/ColumnFilterSession.java b/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/session/ColumnFilterSession.java index 529b5d6..b8aa578 100644 --- a/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/session/ColumnFilterSession.java +++ b/src/main/java/org/gcube/portlets/user/td/expressionwidget/shared/session/ColumnFilterSession.java @@ -11,6 +11,16 @@ public class ColumnFilterSession implements Serializable{ protected ColumnData column; protected C_Expression cexpression; + public ColumnFilterSession(){ + + } + + public ColumnFilterSession(ColumnData column, C_Expression cexpression){ + this.column=column; + this.cexpression=cexpression; + } + + public ColumnData getColumn() { return column; }