From cf12254a96f0b038f195c70d7c66187d98317427 Mon Sep 17 00:00:00 2001 From: Giancarlo Panichi Date: Tue, 14 Apr 2015 12:46:34 +0000 Subject: [PATCH] Updated Rule git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@114022 82a268e6-3cf1-43bd-a215-b396298e98cf --- .../user/td/client/rule/RuleApplyDialog.java | 2 +- .../user/td/client/rule/RuleApplyPanel.java | 110 ++++++++--------- .../td/client/rule/RuleDataProperties.java | 32 ----- .../user/td/client/rule/RuleDeleteDialog.java | 4 +- .../user/td/client/rule/RuleDeletePanel.java | 113 ++++++++--------- .../user/td/client/rule/RuleOpenDialog.java | 19 +-- .../user/td/client/rule/RuleOpenPanel.java | 116 ++++++++---------- .../user/td/client/rule/RuleShareDialog.java | 4 +- .../user/td/client/rule/RuleSharePanel.java | 114 ++++++++--------- 9 files changed, 219 insertions(+), 295 deletions(-) delete mode 100644 src/main/java/org/gcube/portlets/user/td/client/rule/RuleDataProperties.java diff --git a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleApplyDialog.java b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleApplyDialog.java index d7e62f2..cda731c 100644 --- a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleApplyDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleApplyDialog.java @@ -54,7 +54,7 @@ public class RuleApplyDialog extends Window implements setClosable(true); setModal(true); forceLayoutOnResize = true; - getHeader().setIcon(TabularDataResources.INSTANCE.templateApply()); + getHeader().setIcon(TabularDataResources.INSTANCE.ruleApply()); } diff --git a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleApplyPanel.java b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleApplyPanel.java index 4e2da2e..30cf7ab 100644 --- a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleApplyPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleApplyPanel.java @@ -4,10 +4,12 @@ import java.util.ArrayList; import java.util.List; import org.gcube.portlets.user.td.client.resource.TabularDataResources; -import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync; +import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData; +import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties; +import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession; -import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData; import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; @@ -71,12 +73,11 @@ public class RuleApplyPanel extends FramedPanel { private TextButton btnApply; private TextButton btnClose; - private ListLoader> loader; - private Grid grid; - private ExtendedListStore store; + private ListLoader> loader; + private Grid grid; + private ExtendedListStore store; - public RuleApplyPanel(RuleApplyDialog parent, TRId trId, - EventBus eventBus) { + public RuleApplyPanel(RuleApplyDialog parent, TRId trId, EventBus eventBus) { this.parent = parent; this.trId = trId; Log.debug("TemplateApplyPanel"); @@ -102,36 +103,31 @@ public class RuleApplyPanel extends FramedPanel { btnReload.setToolTip("Reload"); toolBarHead.add(btnReload); - IdentityValueProvider identity = new IdentityValueProvider(); - CheckBoxSelectionModel sm = new CheckBoxSelectionModel( + IdentityValueProvider identity = new IdentityValueProvider(); + CheckBoxSelectionModel sm = new CheckBoxSelectionModel( identity); - RuleDataProperties props = GWT.create(RuleDataProperties.class); + RuleDescriptionDataProperties props = GWT + .create(RuleDescriptionDataProperties.class); - ColumnConfig nameCol = new ColumnConfig( + ColumnConfig nameCol = new ColumnConfig( props.name(), 120, "Name"); - ColumnConfig categoryCol = new ColumnConfig( - props.category(), 60, "Category"); - ColumnConfig ownerCol = new ColumnConfig( - props.ownerLogin(), 70, "Owner"); - - ColumnConfig agencyCol = new ColumnConfig( - props.agency(), 100, "Agency"); - - ColumnConfig descriptionCol = new ColumnConfig( + ColumnConfig descriptionCol = new ColumnConfig( props.description(), 120, "Description"); - List> l = new ArrayList>(); + ColumnConfig readableExpressionCol = new ColumnConfig( + props.readableExpression(), 230, "Expression"); + + List> l = new ArrayList>(); l.add(nameCol); - l.add(categoryCol); - l.add(ownerCol); - l.add(agencyCol); l.add(descriptionCol); + l.add(readableExpressionCol); + + ColumnModel cm = new ColumnModel( + l); - ColumnModel cm = new ColumnModel(l); - - store = new ExtendedListStore(props.id()); + store = new ExtendedListStore(props.id()); searchField.addKeyUpHandler(new KeyUpHandler() { @@ -141,11 +137,11 @@ public class RuleApplyPanel extends FramedPanel { } }); - store.addFilter(new StoreFilter() { + store.addFilter(new StoreFilter() { @Override - public boolean select(Store store, - TemplateData parent, TemplateData item) { + public boolean select(Store store, + RuleDescriptionData parent, RuleDescriptionData item) { String searchTerm = searchField.getCurrentValue(); if (searchTerm == null) return true; @@ -155,18 +151,19 @@ public class RuleApplyPanel extends FramedPanel { store.setEnableFilters(true); - RpcProxy> proxy = new RpcProxy>() { + RpcProxy> proxy = new RpcProxy>() { - public void load(ListLoadConfig loadConfig, - final AsyncCallback> callback) { + public void load( + ListLoadConfig loadConfig, + final AsyncCallback> callback) { loadData(loadConfig, callback); } }; - loader = new ListLoader>( + loader = new ListLoader>( proxy); loader.setRemoteSort(false); - loader.addLoadHandler(new LoadResultListStoreBinding>( + loader.addLoadHandler(new LoadResultListStoreBinding>( store) { }); @@ -178,7 +175,7 @@ public class RuleApplyPanel extends FramedPanel { btnReload.addSelectHandler(sh); - grid = new Grid(store, cm) { + grid = new Grid(store, cm) { @Override protected void onAfterFirstAttach() { super.onAfterFirstAttach(); @@ -210,7 +207,7 @@ public class RuleApplyPanel extends FramedPanel { toolBar.getElement().getStyle().setProperty("borderBottom", "none"); btnApply = new TextButton("Apply"); - btnApply.setIcon(TabularDataResources.INSTANCE.templateApply()); + btnApply.setIcon(TabularDataResources.INSTANCE.ruleApply()); btnApply.setIconAlign(IconAlign.RIGHT); btnApply.setToolTip("Apply Template"); btnApply.addSelectHandler(new SelectHandler() { @@ -252,47 +249,48 @@ public class RuleApplyPanel extends FramedPanel { } protected void loadData(ListLoadConfig loadConfig, - final AsyncCallback> callback) { + final AsyncCallback> callback) { - TDGWTServiceAsync.INSTANCE - .getTemplates(new AsyncCallback>() { + ExpressionServiceAsync.INSTANCE.getRules(RuleScopeType.COLUMN, + new AsyncCallback>() { + @Override public void onFailure(Throwable caught) { if (caught instanceof TDGWTSessionExpiredException) { eventBus.fireEvent(new SessionExpiredEvent( SessionExpiredType.EXPIREDONSERVER)); } else { - Log.error("Load templates failure:" + Log.error("Load rules failure:" + caught.getLocalizedMessage()); - UtilsGXT3.alert("Error retrieving templates", - "Error retrieving templates"); + UtilsGXT3.alert("Error retrieving rules", + "Error retrieving rules"); } callback.onFailure(caught); + } - public void onSuccess(ArrayList result) { - Log.trace("loaded " + result.size() + " Occurences"); - callback.onSuccess(new ListLoadResultBean( + @Override + public void onSuccess(ArrayList result) { + Log.trace("loaded " + result.size() + " Rules"); + callback.onSuccess(new ListLoadResultBean( result)); } - }); } - - protected TemplateData getSelectedItem() { + protected RuleDescriptionData getSelectedItem() { return grid.getSelectionModel().getSelectedItem(); } protected void apply() { templateApplySession = new TemplateApplySession(); - TemplateData template = getSelectedItem(); + RuleDescriptionData template = getSelectedItem(); if (template == null) { UtilsGXT3.info("Attention", "Select the template to apply"); } else { - templateApplySession.setTemplateData(getSelectedItem()); + //templateApplySession.setRuleDescriptionData(getSelectedItem()); templateApplySession.setTrId(trId); Log.debug("applyTemplateSession: " + templateApplySession); parent.applyTemplate(templateApplySession); @@ -319,19 +317,11 @@ public class RuleApplyPanel extends FramedPanel { grid.getLoader().load(); } - protected boolean select(TemplateData item, String searchTerm) { + protected boolean select(RuleDescriptionData item, String searchTerm) { if (item.getName() != null && item.getName().toLowerCase() .contains(searchTerm.toLowerCase())) return true; - if (item.getCategory() != null - && item.getCategory().toLowerCase() - .contains(searchTerm.toLowerCase())) - return true; - if (item.getAgency() != null - && item.getAgency().toLowerCase() - .contains(searchTerm.toLowerCase())) - return true; if (item.getDescription() != null && item.getDescription().toLowerCase() .contains(searchTerm.toLowerCase())) diff --git a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleDataProperties.java b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleDataProperties.java deleted file mode 100644 index 99c5b63..0000000 --- a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleDataProperties.java +++ /dev/null @@ -1,32 +0,0 @@ -package org.gcube.portlets.user.td.client.rule; - - - -import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData; - -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 - * email: g.panichi@isti.cnr.it - * - */ -public interface RuleDataProperties extends PropertyAccess { - - @Path("id") - ModelKeyProvider id(); - - ValueProvider name(); - ValueProvider category(); - ValueProvider ownerLogin(); - ValueProvider agency(); - ValueProvider description(); - - - -} - diff --git a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleDeleteDialog.java b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleDeleteDialog.java index ab79660..91dfc8b 100644 --- a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleDeleteDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleDeleteDialog.java @@ -41,11 +41,11 @@ public class RuleDeleteDialog extends Window { setHeight(HEIGHT); setBodyBorder(false); setResizable(false); - setHeadingText("Delete Template"); + setHeadingText("Delete Rule"); setClosable(true); setModal(true); forceLayoutOnResize = true; - getHeader().setIcon(TabularDataResources.INSTANCE.templateDelete()); + getHeader().setIcon(TabularDataResources.INSTANCE.ruleDelete()); } diff --git a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleDeletePanel.java b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleDeletePanel.java index 9795c9a..051cf0f 100644 --- a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleDeletePanel.java +++ b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleDeletePanel.java @@ -4,9 +4,11 @@ import java.util.ArrayList; import java.util.List; import org.gcube.portlets.user.td.client.resource.TabularDataResources; -import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync; +import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData; +import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties; +import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; -import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData; import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession; import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; @@ -63,13 +65,13 @@ public class RuleDeletePanel extends FramedPanel { private TextButton btnDelete; private TextButton btnClose; - private ListLoader> loader; - private Grid grid; - private ExtendedListStore store; + private ListLoader> loader; + private Grid grid; + private ExtendedListStore store; public RuleDeletePanel(RuleDeleteDialog parent, EventBus eventBus) { this.parent = parent; - Log.debug("TemplateDeletePanel"); + Log.debug("RuleDeletePanel"); setWidth(WIDTH); setHeight(HEIGHT); setHeaderVisible(false); @@ -92,36 +94,31 @@ public class RuleDeletePanel extends FramedPanel { btnReload.setToolTip("Reload"); toolBarHead.add(btnReload); - IdentityValueProvider identity = new IdentityValueProvider(); - CheckBoxSelectionModel sm = new CheckBoxSelectionModel( + IdentityValueProvider identity = new IdentityValueProvider(); + CheckBoxSelectionModel sm = new CheckBoxSelectionModel( identity); - RuleDataProperties props = GWT.create(RuleDataProperties.class); + RuleDescriptionDataProperties props = GWT + .create(RuleDescriptionDataProperties.class); - ColumnConfig nameCol = new ColumnConfig( + ColumnConfig nameCol = new ColumnConfig( props.name(), 120, "Name"); - ColumnConfig categoryCol = new ColumnConfig( - props.category(), 60, "Category"); - ColumnConfig ownerCol = new ColumnConfig( - props.ownerLogin(), 70, "Owner"); - - ColumnConfig agencyCol = new ColumnConfig( - props.agency(), 100, "Agency"); - - ColumnConfig descriptionCol = new ColumnConfig( + ColumnConfig descriptionCol = new ColumnConfig( props.description(), 120, "Description"); - List> l = new ArrayList>(); + ColumnConfig readableExpressionCol = new ColumnConfig( + props.readableExpression(), 230, "Expression"); + + List> l = new ArrayList>(); l.add(nameCol); - l.add(categoryCol); - l.add(ownerCol); - l.add(agencyCol); l.add(descriptionCol); + l.add(readableExpressionCol); - ColumnModel cm = new ColumnModel(l); + ColumnModel cm = new ColumnModel( + l); - store = new ExtendedListStore(props.id()); + store = new ExtendedListStore(props.id()); searchField.addKeyUpHandler(new KeyUpHandler() { @@ -131,11 +128,11 @@ public class RuleDeletePanel extends FramedPanel { } }); - store.addFilter(new StoreFilter() { + store.addFilter(new StoreFilter() { @Override - public boolean select(Store store, - TemplateData parent, TemplateData item) { + public boolean select(Store store, + RuleDescriptionData parent, RuleDescriptionData item) { String searchTerm = searchField.getCurrentValue(); if (searchTerm == null) return true; @@ -145,18 +142,19 @@ public class RuleDeletePanel extends FramedPanel { store.setEnableFilters(true); - RpcProxy> proxy = new RpcProxy>() { + RpcProxy> proxy = new RpcProxy>() { - public void load(ListLoadConfig loadConfig, - final AsyncCallback> callback) { + public void load( + ListLoadConfig loadConfig, + final AsyncCallback> callback) { loadData(loadConfig, callback); } }; - loader = new ListLoader>( + loader = new ListLoader>( proxy); loader.setRemoteSort(false); - loader.addLoadHandler(new LoadResultListStoreBinding>( + loader.addLoadHandler(new LoadResultListStoreBinding>( store) { }); @@ -168,7 +166,7 @@ public class RuleDeletePanel extends FramedPanel { btnReload.addSelectHandler(sh); - grid = new Grid(store, cm) { + grid = new Grid(store, cm) { @Override protected void onAfterFirstAttach() { super.onAfterFirstAttach(); @@ -200,7 +198,7 @@ public class RuleDeletePanel extends FramedPanel { toolBar.getElement().getStyle().setProperty("borderBottom", "none"); btnDelete = new TextButton("Delete"); - btnDelete.setIcon(TabularDataResources.INSTANCE.templateDelete()); + btnDelete.setIcon(TabularDataResources.INSTANCE.ruleDelete()); btnDelete.setIconAlign(IconAlign.RIGHT); btnDelete.setToolTip("Delete Template"); btnDelete.addSelectHandler(new SelectHandler() { @@ -243,33 +241,34 @@ public class RuleDeletePanel extends FramedPanel { } protected void loadData(ListLoadConfig loadConfig, - final AsyncCallback> callback) { + final AsyncCallback> callback) { - TDGWTServiceAsync.INSTANCE - .getTemplates(new AsyncCallback>() { + ExpressionServiceAsync.INSTANCE.getRules(RuleScopeType.COLUMN, + new AsyncCallback>() { + @Override public void onFailure(Throwable caught) { if (caught instanceof TDGWTSessionExpiredException) { eventBus.fireEvent(new SessionExpiredEvent( SessionExpiredType.EXPIREDONSERVER)); } else { - Log.error("Load templates failure:" + Log.error("Load rules failure:" + caught.getLocalizedMessage()); - UtilsGXT3.alert("Error retrieving templates", - "Error retrieving templates"); + UtilsGXT3.alert("Error retrieving rules", + "Error retrieving rules"); } callback.onFailure(caught); + } - public void onSuccess(ArrayList result) { - Log.trace("loaded " + result.size() + " Occurences"); - callback.onSuccess(new ListLoadResultBean( + @Override + public void onSuccess(ArrayList result) { + Log.trace("loaded " + result.size() + " Rules"); + callback.onSuccess(new ListLoadResultBean( result)); } - }); - } /* @@ -281,7 +280,7 @@ public class RuleDeletePanel extends FramedPanel { * deleteTemplateItem.addSelectionHandler(new SelectionHandler() { * * @Override public void onSelection(SelectionEvent event) { - * Log.debug("Delete Template"); TemplateData templateDesc = + * Log.debug("Delete Template"); RuleDescriptionData templateDesc = * getSelectedItem(); * * } }); @@ -289,9 +288,9 @@ public class RuleDeletePanel extends FramedPanel { * grid.setContextMenu(contextMenu); } */ - protected ArrayList getSelectedItem() { - ArrayList templates = new ArrayList(); - for (TemplateData template : grid.getSelectionModel() + protected ArrayList getSelectedItem() { + ArrayList templates = new ArrayList(); + for (RuleDescriptionData template : grid.getSelectionModel() .getSelectedItems()) { templates.add(template); } @@ -300,11 +299,11 @@ public class RuleDeletePanel extends FramedPanel { protected void delete() { templateDeleteSession = new TemplateDeleteSession(); - ArrayList templates = getSelectedItem(); + ArrayList templates = getSelectedItem(); if (templates == null || templates.size() == 0) { UtilsGXT3.info("Attention", "Select the template to be deleted"); } else { - templateDeleteSession.setTemplates(getSelectedItem()); + // templateDeleteSession.setTemplates(getSelectedItem()); Log.debug("templateDeleteSession: " + templateDeleteSession); parent.templatesDelete(templateDeleteSession); @@ -332,19 +331,11 @@ public class RuleDeletePanel extends FramedPanel { grid.getLoader().load(); } - protected boolean select(TemplateData item, String searchTerm) { + protected boolean select(RuleDescriptionData item, String searchTerm) { if (item.getName() != null && item.getName().toLowerCase() .contains(searchTerm.toLowerCase())) return true; - if (item.getCategory() != null - && item.getCategory().toLowerCase() - .contains(searchTerm.toLowerCase())) - return true; - if (item.getAgency() != null - && item.getAgency().toLowerCase() - .contains(searchTerm.toLowerCase())) - return true; if (item.getDescription() != null && item.getDescription().toLowerCase() .contains(searchTerm.toLowerCase())) diff --git a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleOpenDialog.java b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleOpenDialog.java index a8e09ef..b3d12d5 100644 --- a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleOpenDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleOpenDialog.java @@ -1,9 +1,7 @@ package org.gcube.portlets.user.td.client.rule; import org.gcube.portlets.user.td.client.resource.TabularDataResources; -import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData; -import org.gcube.portlets.user.tdtemplate.client.TdTemplateController; -import org.gcube.portlets.user.tdtemplate.client.TdTemplateControllerUpdater; +import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData; import com.google.web.bindery.event.shared.EventBus; import com.sencha.gxt.widget.core.client.Window; @@ -19,10 +17,8 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; public class RuleOpenDialog extends Window { private static final String WIDTH = "720px"; private static final String HEIGHT = "530px"; - private EventBus eventBus; - + public RuleOpenDialog(EventBus eventBus) { - this.eventBus = eventBus; initWindow(); RuleOpenPanel templateOpenPanel = new RuleOpenPanel(this, @@ -35,11 +31,11 @@ public class RuleOpenDialog extends Window { setHeight(HEIGHT); setBodyBorder(false); setResizable(false); - setHeadingText("Open Template"); + setHeadingText("Open Rule"); setClosable(true); setModal(true); forceLayoutOnResize = true; - getHeader().setIcon(TabularDataResources.INSTANCE.templateEdit()); + getHeader().setIcon(TabularDataResources.INSTANCE.ruleEdit()); } @@ -63,11 +59,8 @@ public class RuleOpenDialog extends Window { hide(); } - public void templateOpen(TemplateData template) { - TdTemplateControllerUpdater controller = new TdTemplateControllerUpdater( - template.getId()); - TdTemplateController.bindCommonBus(eventBus); - controller.getWindowTemplatePanel().show(); + public void ruleOpen(RuleDescriptionData ruleDescriptionData) { + close(); } diff --git a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleOpenPanel.java b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleOpenPanel.java index 80e4785..136d2e6 100644 --- a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleOpenPanel.java +++ b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleOpenPanel.java @@ -4,9 +4,11 @@ import java.util.ArrayList; import java.util.List; import org.gcube.portlets.user.td.client.resource.TabularDataResources; -import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync; +import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData; +import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties; +import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; -import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData; import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; @@ -68,13 +70,13 @@ public class RuleOpenPanel extends FramedPanel { private TextButton btnClose; - private ListLoader> loader; - private Grid grid; - private ExtendedListStore store; + private ListLoader> loader; + private Grid grid; + private ExtendedListStore store; public RuleOpenPanel(RuleOpenDialog parent, EventBus eventBus) { this.parent = parent; - Log.debug("TemplateEditPanel"); + Log.debug("RuleOpenPanel"); setWidth(WIDTH); setHeight(HEIGHT); setHeaderVisible(false); @@ -97,36 +99,31 @@ public class RuleOpenPanel extends FramedPanel { btnReload.setToolTip("Reload"); toolBarHead.add(btnReload); - IdentityValueProvider identity = new IdentityValueProvider(); - CheckBoxSelectionModel sm = new CheckBoxSelectionModel( + IdentityValueProvider identity = new IdentityValueProvider(); + CheckBoxSelectionModel sm = new CheckBoxSelectionModel( identity); - RuleDataProperties props = GWT.create(RuleDataProperties.class); + RuleDescriptionDataProperties props = GWT.create(RuleDescriptionDataProperties.class); - ColumnConfig nameCol = new ColumnConfig( + ColumnConfig nameCol = new ColumnConfig( props.name(), 120, "Name"); - ColumnConfig categoryCol = new ColumnConfig( - props.category(), 60, "Category"); - - ColumnConfig ownerCol = new ColumnConfig( - props.ownerLogin(), 70, "Owner"); - - ColumnConfig agencyCol = new ColumnConfig( - props.agency(), 100, "Agency"); - - ColumnConfig descriptionCol = new ColumnConfig( + + ColumnConfig descriptionCol = new ColumnConfig( props.description(), 120, "Description"); - List> l = new ArrayList>(); + + ColumnConfig readableExpressionCol = new ColumnConfig( + props.readableExpression(), 230, "Expression"); + + + List> l = new ArrayList>(); l.add(nameCol); - l.add(categoryCol); - l.add(ownerCol); - l.add(agencyCol); l.add(descriptionCol); + l.add(readableExpressionCol); - ColumnModel cm = new ColumnModel(l); + ColumnModel cm = new ColumnModel(l); - store = new ExtendedListStore(props.id()); + store = new ExtendedListStore(props.id()); searchField.addKeyUpHandler(new KeyUpHandler() { @@ -136,11 +133,11 @@ public class RuleOpenPanel extends FramedPanel { } }); - store.addFilter(new StoreFilter() { + store.addFilter(new StoreFilter() { @Override - public boolean select(Store store, - TemplateData parent, TemplateData item) { + public boolean select(Store store, + RuleDescriptionData parent, RuleDescriptionData item) { String searchTerm = searchField.getCurrentValue(); if (searchTerm == null) return true; @@ -150,18 +147,18 @@ public class RuleOpenPanel extends FramedPanel { store.setEnableFilters(true); - RpcProxy> proxy = new RpcProxy>() { + RpcProxy> proxy = new RpcProxy>() { public void load(ListLoadConfig loadConfig, - final AsyncCallback> callback) { + final AsyncCallback> callback) { loadData(loadConfig, callback); } }; - loader = new ListLoader>( + loader = new ListLoader>( proxy); loader.setRemoteSort(false); - loader.addLoadHandler(new LoadResultListStoreBinding>( + loader.addLoadHandler(new LoadResultListStoreBinding>( store) { }); @@ -173,7 +170,7 @@ public class RuleOpenPanel extends FramedPanel { btnReload.addSelectHandler(sh); - grid = new Grid(store, cm) { + grid = new Grid(store, cm) { @Override protected void onAfterFirstAttach() { super.onAfterFirstAttach(); @@ -205,7 +202,7 @@ public class RuleOpenPanel extends FramedPanel { toolBar.getElement().getStyle().setProperty("borderBottom", "none"); btnOpen = new TextButton("Open"); - btnOpen.setIcon(TabularDataResources.INSTANCE.templateEdit()); + btnOpen.setIcon(TabularDataResources.INSTANCE.ruleEdit()); btnOpen.setIconAlign(IconAlign.RIGHT); btnOpen.setToolTip("Open"); btnOpen.addSelectHandler(new SelectHandler() { @@ -251,38 +248,41 @@ public class RuleOpenPanel extends FramedPanel { } protected void loadData(ListLoadConfig loadConfig, - final AsyncCallback> callback) { - - TDGWTServiceAsync.INSTANCE - .getTemplates(new AsyncCallback>() { + final AsyncCallback> callback) { + + ExpressionServiceAsync.INSTANCE.getRules(RuleScopeType.COLUMN, + new AsyncCallback>() { + @Override public void onFailure(Throwable caught) { if (caught instanceof TDGWTSessionExpiredException) { eventBus.fireEvent(new SessionExpiredEvent( SessionExpiredType.EXPIREDONSERVER)); } else { - Log.error("Load templates failure:" + Log.error("Load rules failure:" + caught.getLocalizedMessage()); - UtilsGXT3.alert("Error retrieving templates", - "Error retrieving templates"); + UtilsGXT3.alert("Error retrieving rules", + "Error retrieving rules"); } callback.onFailure(caught); + } - public void onSuccess(ArrayList result) { - Log.trace("loaded " + result.size() + " Occurences"); - callback.onSuccess(new ListLoadResultBean( + @Override + public void onSuccess(ArrayList result) { + Log.trace("loaded " + result.size() + " Rules"); + callback.onSuccess(new ListLoadResultBean( result)); - + } - }); + } - protected ArrayList getSelectedItem() { - ArrayList templates = new ArrayList(); - for (TemplateData template : grid.getSelectionModel() + protected ArrayList getSelectedItem() { + ArrayList templates = new ArrayList(); + for (RuleDescriptionData template : grid.getSelectionModel() .getSelectedItems()) { templates.add(template); } @@ -291,13 +291,13 @@ public class RuleOpenPanel extends FramedPanel { protected void open() { - ArrayList templates = getSelectedItem(); + ArrayList templates = getSelectedItem(); if (templates == null || templates.size() == 0) { UtilsGXT3.info("Attention", "Select the template"); } else { - TemplateData template = templates.get(0); + RuleDescriptionData template = templates.get(0); Log.debug("templateOpenSession: " + template); - parent.templateOpen(template); + parent.ruleOpen(template); } @@ -325,19 +325,11 @@ public class RuleOpenPanel extends FramedPanel { grid.getLoader().load(); } - protected boolean select(TemplateData item, String searchTerm) { + protected boolean select(RuleDescriptionData item, String searchTerm) { if (item.getName() != null && item.getName().toLowerCase() .contains(searchTerm.toLowerCase())) return true; - if (item.getCategory() != null - && item.getCategory().toLowerCase() - .contains(searchTerm.toLowerCase())) - return true; - if (item.getAgency() != null - && item.getAgency().toLowerCase() - .contains(searchTerm.toLowerCase())) - return true; if (item.getDescription() != null && item.getDescription().toLowerCase() .contains(searchTerm.toLowerCase())) diff --git a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleShareDialog.java b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleShareDialog.java index 1e8712f..214b433 100644 --- a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleShareDialog.java +++ b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleShareDialog.java @@ -36,11 +36,11 @@ public class RuleShareDialog extends Window { setHeight(HEIGHT); setBodyBorder(false); setResizable(false); - setHeadingText("Share Template"); + setHeadingText("Share Rule"); setClosable(true); setModal(true); forceLayoutOnResize = true; - getHeader().setIcon(TabularDataResources.INSTANCE.templateShare()); + getHeader().setIcon(TabularDataResources.INSTANCE.ruleShare()); } diff --git a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleSharePanel.java b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleSharePanel.java index cae797e..29e4fbd 100644 --- a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleSharePanel.java +++ b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleSharePanel.java @@ -4,9 +4,11 @@ import java.util.ArrayList; import java.util.List; import org.gcube.portlets.user.td.client.resource.TabularDataResources; -import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync; +import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync; +import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData; +import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties; +import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType; import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; -import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateData; import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3; import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent; import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; @@ -20,7 +22,7 @@ import com.google.gwt.event.dom.client.KeyUpHandler; 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.IdentityValueProvider; import com.sencha.gxt.core.client.Style.SelectionMode; import com.sencha.gxt.core.client.resources.ThemeStyles; import com.sencha.gxt.core.client.util.Margins; @@ -67,13 +69,13 @@ public class RuleSharePanel extends FramedPanel { private TextButton btnClose; private TextButton btnShare; - private ListLoader> loader; - private Grid grid; - private ExtendedListStore store; + private ListLoader> loader; + private Grid grid; + private ExtendedListStore store; public RuleSharePanel(RuleShareDialog parent, EventBus eventBus) { this.parent = parent; - Log.debug("TemplateSharePanel"); + Log.debug("RuleSharePanel"); setWidth(WIDTH); setHeight(HEIGHT); setHeaderVisible(false); @@ -96,36 +98,30 @@ public class RuleSharePanel extends FramedPanel { btnReload.setToolTip("Reload"); toolBarHead.add(btnReload); - IdentityValueProvider identity = new IdentityValueProvider(); - CheckBoxSelectionModel sm = new CheckBoxSelectionModel( + IdentityValueProvider identity = new IdentityValueProvider(); + CheckBoxSelectionModel sm = new CheckBoxSelectionModel( identity); - RuleDataProperties props = GWT.create(RuleDataProperties.class); + RuleDescriptionDataProperties props = GWT.create(RuleDescriptionDataProperties.class); - ColumnConfig nameCol = new ColumnConfig( + ColumnConfig nameCol = new ColumnConfig( props.name(), 120, "Name"); - ColumnConfig categoryCol = new ColumnConfig( - props.category(), 60, "Category"); - ColumnConfig ownerCol = new ColumnConfig( - props.ownerLogin(), 70, "Owner"); - - ColumnConfig agencyCol = new ColumnConfig( - props.agency(), 100, "Agency"); - - ColumnConfig descriptionCol = new ColumnConfig( + ColumnConfig descriptionCol = new ColumnConfig( props.description(), 120, "Description"); - List> l = new ArrayList>(); + ColumnConfig readableExpressionCol = new ColumnConfig( + props.readableExpression(), 230, "Expression"); + + + List> l = new ArrayList>(); l.add(nameCol); - l.add(categoryCol); - l.add(ownerCol); - l.add(agencyCol); l.add(descriptionCol); + l.add(readableExpressionCol); + + ColumnModel cm = new ColumnModel(l); - ColumnModel cm = new ColumnModel(l); - - store = new ExtendedListStore(props.id()); + store = new ExtendedListStore(props.id()); searchField.addKeyUpHandler(new KeyUpHandler() { @@ -135,11 +131,11 @@ public class RuleSharePanel extends FramedPanel { } }); - store.addFilter(new StoreFilter() { + store.addFilter(new StoreFilter() { @Override - public boolean select(Store store, - TemplateData parent, TemplateData item) { + public boolean select(Store store, + RuleDescriptionData parent, RuleDescriptionData item) { String searchTerm = searchField.getCurrentValue(); if (searchTerm == null) return true; @@ -149,18 +145,18 @@ public class RuleSharePanel extends FramedPanel { store.setEnableFilters(true); - RpcProxy> proxy = new RpcProxy>() { + RpcProxy> proxy = new RpcProxy>() { public void load(ListLoadConfig loadConfig, - final AsyncCallback> callback) { + final AsyncCallback> callback) { loadData(loadConfig, callback); } }; - loader = new ListLoader>( + loader = new ListLoader>( proxy); loader.setRemoteSort(false); - loader.addLoadHandler(new LoadResultListStoreBinding>( + loader.addLoadHandler(new LoadResultListStoreBinding>( store) { }); @@ -172,7 +168,7 @@ public class RuleSharePanel extends FramedPanel { btnReload.addSelectHandler(sh); - grid = new Grid(store, cm) { + grid = new Grid(store, cm) { @Override protected void onAfterFirstAttach() { super.onAfterFirstAttach(); @@ -218,7 +214,7 @@ public class RuleSharePanel extends FramedPanel { }); btnShare = new TextButton("Share"); - btnShare.setIcon(TabularDataResources.INSTANCE.share()); + btnShare.setIcon(TabularDataResources.INSTANCE.ruleShare()); btnShare.setIconAlign(IconAlign.RIGHT); btnShare.setToolTip("Share"); btnShare.addSelectHandler(new SelectHandler() { @@ -248,40 +244,42 @@ public class RuleSharePanel extends FramedPanel { } protected void loadData(ListLoadConfig loadConfig, - final AsyncCallback> callback) { + final AsyncCallback> callback) { - TDGWTServiceAsync.INSTANCE - .getTemplates(new AsyncCallback>() { + ExpressionServiceAsync.INSTANCE.getRules(RuleScopeType.COLUMN, + new AsyncCallback>() { + @Override public void onFailure(Throwable caught) { if (caught instanceof TDGWTSessionExpiredException) { eventBus.fireEvent(new SessionExpiredEvent( SessionExpiredType.EXPIREDONSERVER)); } else { - Log.error("Load templates failure:" + Log.error("Load rules failure:" + caught.getLocalizedMessage()); - UtilsGXT3.alert("Error retrieving templates", - "Error retrieving templates"); + UtilsGXT3.alert("Error retrieving rules", + "Error retrieving rules"); } callback.onFailure(caught); + } - public void onSuccess(ArrayList result) { - Log.trace("loaded " + result.size() + " Occurences"); - callback.onSuccess(new ListLoadResultBean( + @Override + public void onSuccess(ArrayList result) { + Log.trace("loaded " + result.size() + " Rules"); + callback.onSuccess(new ListLoadResultBean( result)); - + } - }); } - protected ArrayList getSelectedItem() { - ArrayList templates = new ArrayList(); - for (TemplateData template : grid.getSelectionModel() + protected ArrayList getSelectedItem() { + ArrayList templates = new ArrayList(); + for (RuleDescriptionData template : grid.getSelectionModel() .getSelectedItems()) { templates.add(template); } @@ -291,13 +289,13 @@ public class RuleSharePanel extends FramedPanel { protected void share() { - ArrayList templates = getSelectedItem(); + ArrayList templates = getSelectedItem(); if (templates == null || templates.size() == 0) { UtilsGXT3.info("Attention", "Select the template"); } else { - TemplateData template = templates.get(0); + RuleDescriptionData template = templates.get(0); Log.debug("templateShare: " + template); - parent.templateShare(template); + //parent.templateShare(template); } @@ -323,19 +321,11 @@ public class RuleSharePanel extends FramedPanel { grid.getLoader().load(); } - protected boolean select(TemplateData item, String searchTerm) { + protected boolean select(RuleDescriptionData item, String searchTerm) { if (item.getName() != null && item.getName().toLowerCase() .contains(searchTerm.toLowerCase())) return true; - if (item.getCategory() != null - && item.getCategory().toLowerCase() - .contains(searchTerm.toLowerCase())) - return true; - if (item.getAgency() != null - && item.getAgency().toLowerCase() - .contains(searchTerm.toLowerCase())) - return true; if (item.getDescription() != null && item.getDescription().toLowerCase() .contains(searchTerm.toLowerCase()))