diff --git a/src/main/java/org/gcube/portlets/user/td/client/TabularDataController.java b/src/main/java/org/gcube/portlets/user/td/client/TabularDataController.java
index 2eb899e..49178d1 100644
--- a/src/main/java/org/gcube/portlets/user/td/client/TabularDataController.java
+++ b/src/main/java/org/gcube/portlets/user/td/client/TabularDataController.java
@@ -8,6 +8,7 @@ import java.util.HashMap;
import org.gcube.portlets.user.td.chartswidget.client.ChartsWidgetTD;
import org.gcube.portlets.user.td.client.logs.TDMLogs;
import org.gcube.portlets.user.td.client.rstudio.RStudio;
+import org.gcube.portlets.user.td.client.rule.RuleAppliedDialog;
import org.gcube.portlets.user.td.client.rule.RuleApplyDialog;
import org.gcube.portlets.user.td.client.rule.RuleDeleteDialog;
import org.gcube.portlets.user.td.client.rule.RuleOpenDialog;
@@ -1758,7 +1759,7 @@ public class TabularDataController {
private void openRulesAppliedOnTabularResource() {
Log.debug("Request Open Rules Applied on TabularResource Dialog");
if (trId != null) {
- RuleApplyDialog raDialog = new RuleApplyDialog(
+ RuleAppliedDialog raDialog = new RuleAppliedDialog(
trId, eventBus);
raDialog.show();
} else {
diff --git a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleAppliedDialog.java b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleAppliedDialog.java
new file mode 100644
index 0000000..797a78e
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleAppliedDialog.java
@@ -0,0 +1,63 @@
+package org.gcube.portlets.user.td.client.rule;
+
+import org.gcube.portlets.user.td.client.resource.TabularDataResources;
+import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
+
+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" g.panichi@isti.cnr.it
+ *
+ */
+public class RuleAppliedDialog extends Window {
+ private static final String WIDTH = "720px";
+ private static final String HEIGHT = "428px";
+ public RuleAppliedDialog(TRId trId, EventBus eventBus) {
+ initWindow();
+
+ RuleAppliedPanel ruleApplyPanel = new RuleAppliedPanel(this,
+ trId, eventBus);
+ add(ruleApplyPanel);
+ }
+
+ protected void initWindow() {
+ setWidth(WIDTH);
+ setHeight(HEIGHT);
+ setBodyBorder(false);
+ setResizable(false);
+ setHeadingText("Rules Applied On TabularResource");
+ setClosable(true);
+ setModal(true);
+ forceLayoutOnResize = true;
+ getHeader().setIcon(TabularDataResources.INSTANCE.ruleTabularResource());
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected void initTools() {
+ super.initTools();
+
+ closeBtn.addSelectHandler(new SelectHandler() {
+
+ public void onSelect(SelectEvent event) {
+ close();
+ }
+ });
+
+ }
+
+ protected void close() {
+ hide();
+ }
+
+
+
+}
diff --git a/src/main/java/org/gcube/portlets/user/td/client/rule/RuleAppliedPanel.java b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleAppliedPanel.java
new file mode 100644
index 0000000..473fbf7
--- /dev/null
+++ b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleAppliedPanel.java
@@ -0,0 +1,441 @@
+package org.gcube.portlets.user.td.client.rule;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+
+import org.gcube.portlets.user.td.client.resource.TabularDataResources;
+import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
+import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties;
+import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
+import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
+import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
+import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
+import org.gcube.portlets.user.td.gwtservice.shared.rule.AppliedRulesResponseData;
+import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
+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;
+import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
+import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
+
+import com.allen_sauer.gwt.log.client.Log;
+import com.google.gwt.cell.client.AbstractCell;
+import com.google.gwt.core.client.GWT;
+import com.google.gwt.event.logical.shared.SelectionEvent;
+import com.google.gwt.event.logical.shared.SelectionHandler;
+import com.google.gwt.safehtml.shared.SafeHtml;
+import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
+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.XTemplates;
+import com.sencha.gxt.core.client.dom.ScrollSupport.ScrollMode;
+import com.sencha.gxt.core.client.util.Margins;
+import com.sencha.gxt.data.shared.ListStore;
+import com.sencha.gxt.widget.core.client.Dialog;
+import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton;
+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.BoxLayoutContainer.BoxLayoutPack;
+import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
+import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign;
+import com.sencha.gxt.widget.core.client.container.MarginData;
+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.FieldSet;
+import com.sencha.gxt.widget.core.client.form.TextArea;
+import com.sencha.gxt.widget.core.client.form.TextField;
+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;
+import com.sencha.gxt.widget.core.client.grid.filters.GridFilters;
+import com.sencha.gxt.widget.core.client.grid.filters.StringFilter;
+import com.sencha.gxt.widget.core.client.menu.Item;
+import com.sencha.gxt.widget.core.client.menu.Menu;
+import com.sencha.gxt.widget.core.client.menu.MenuItem;
+
+/**
+ *
+ * @author giancarlo email: g.panichi@isti.cnr.it
+ *
+ */
+public class RuleAppliedPanel extends FramedPanel {
+ private static final int RULE_ON_COLUMN_FIELDSET_HEIGHT = 348;
+ private static final String RULES_GRID_HEIGHT = "102px";
+ private static final String WIDTH = "630px";
+ private static final String HEIGHT = "418px";
+
+ interface RuleApplyTemplates extends XTemplates {
+ @XTemplate("{value}")
+ SafeHtml format(String value);
+ }
+
+ private EventBus eventBus;
+ private RuleAppliedDialog parent;
+ private TRId trId;
+ private ArrayList columns;
+
+ private AppliedRulesResponseData appliedRuleResponseData;
+
+ private TextButton btnClose;
+
+ public RuleAppliedPanel(RuleAppliedDialog parent, TRId trId,
+ EventBus eventBus) {
+ this.parent = parent;
+ this.trId = trId;
+
+ Log.debug("RuleAppliedPanel");
+ setWidth(WIDTH);
+ setHeight(HEIGHT);
+ setHeaderVisible(false);
+ setBodyBorder(false);
+ this.eventBus = eventBus;
+ retrieveColumns();
+
+ }
+
+ protected void retrieveColumns() {
+ TDGWTServiceAsync.INSTANCE.getColumns(trId,
+ new AsyncCallback>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ if (caught instanceof TDGWTSessionExpiredException) {
+ eventBus.fireEvent(new SessionExpiredEvent(
+ SessionExpiredType.EXPIREDONSERVER));
+ } else {
+ if (caught instanceof TDGWTIsLockedException) {
+ Log.error(caught.getLocalizedMessage());
+ UtilsGXT3.alert("Error Locked",
+ caught.getLocalizedMessage());
+ } else {
+ if (caught instanceof TDGWTIsFinalException) {
+ Log.error(caught.getLocalizedMessage());
+ UtilsGXT3.alert("Error Final",
+ caught.getLocalizedMessage());
+ } else {
+ Log.debug("Error retrieving columns: "
+ + caught.getLocalizedMessage());
+ UtilsGXT3
+ .alert("Error retrieving columns",
+ "Error retrieving column on server!");
+ }
+ }
+ }
+
+ }
+
+ @Override
+ public void onSuccess(ArrayList result) {
+ Log.debug("Retrieved Columns");
+ if (result == null) {
+ UtilsGXT3.alert("Error",
+ "The requested columns is null");
+ }
+ columns = result;
+
+ getAppliedBaseColumnRules();
+
+ }
+ });
+ }
+
+ protected void create() {
+
+ Log.debug("Create RuleAppliedPanel(): " + trId);
+
+ // SimpleContainer rulesOnColumnContainer=new SimpleContainer();
+ FieldSet columnRulesFieldSet = new FieldSet();
+ columnRulesFieldSet.setHeadingText("Rules On Column");
+ columnRulesFieldSet.setCollapsible(false);
+
+ VerticalLayoutContainer columnRulesFieldSetLayout = new VerticalLayoutContainer();
+ columnRulesFieldSetLayout.setScrollMode(ScrollMode.AUTO);
+ columnRulesFieldSetLayout.setAdjustForScroll(true);
+
+ columnRulesFieldSet.add(columnRulesFieldSetLayout);
+
+ HashMap> columnRuleMapping = appliedRuleResponseData
+ .getColumnRuleMapping();
+ if (columnRuleMapping != null && columnRuleMapping.size() > 0) {
+
+ for (ColumnData column : columns) {
+ ArrayList columnAppliedRules = columnRuleMapping
+ .get(column.getColumnId());
+ if (columnAppliedRules != null && columnAppliedRules.size() > 0) {
+ FieldLabel columnLabel = createColumnRules(column,
+ columnAppliedRules);
+ columnRulesFieldSetLayout.add(columnLabel,
+ new VerticalLayoutData(1, -1, new Margins(0)));
+ }
+ }
+ } else {
+ FieldLabel noRulesLabel = new FieldLabel(null, "No rules applied!");
+ noRulesLabel.setLabelSeparator("");
+ columnRulesFieldSetLayout.add(noRulesLabel, new VerticalLayoutData(
+ 1, -1, new Margins(0)));
+
+ }
+
+ btnClose = new TextButton("Close");
+ btnClose.setIcon(TabularDataResources.INSTANCE.close());
+ btnClose.setIconAlign(IconAlign.RIGHT);
+ btnClose.setToolTip("Close");
+ btnClose.addSelectHandler(new SelectHandler() {
+
+ public void onSelect(SelectEvent event) {
+ Log.debug("Pressed Close");
+ close();
+ }
+ });
+
+ HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
+ flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
+ flowButton.setPack(BoxLayoutPack.CENTER);
+ flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
+
+ VerticalLayoutContainer v = new VerticalLayoutContainer();
+ v.add(columnRulesFieldSet, new VerticalLayoutData(-1,
+ RULE_ON_COLUMN_FIELDSET_HEIGHT, new Margins(0)));
+ v.add(flowButton,
+ new VerticalLayoutData(1, 36, new Margins(5, 2, 5, 2)));
+ add(v);
+
+ }
+
+ private FieldLabel createColumnRules(ColumnData column,
+ ArrayList columnAppliedRules) {
+ // Rules
+
+ RuleDescriptionDataProperties propsRules = GWT
+ .create(RuleDescriptionDataProperties.class);
+
+ ColumnConfig nameCol = new ColumnConfig(
+ propsRules.name(), 120, "Name");
+
+ nameCol.setCell(new AbstractCell() {
+
+ @Override
+ public void render(Context context, String value, SafeHtmlBuilder sb) {
+ RuleApplyTemplates ruleApplyTemplates = GWT
+ .create(RuleApplyTemplates.class);
+ sb.append(ruleApplyTemplates.format(value));
+ }
+ });
+
+ ColumnConfig descriptionCol = new ColumnConfig(
+ propsRules.description(), 120, "Description");
+ descriptionCol.setCell(new AbstractCell() {
+
+ @Override
+ public void render(Context context, String value, SafeHtmlBuilder sb) {
+ RuleApplyTemplates ruleApplyTemplates = GWT
+ .create(RuleApplyTemplates.class);
+ sb.append(ruleApplyTemplates.format(value));
+ }
+ });
+
+ ColumnConfig ownerCol = new ColumnConfig(
+ propsRules.owner(), 70, "Owner");
+ ownerCol.setCell(new AbstractCell() {
+
+ @Override
+ public void render(Context context, String value, SafeHtmlBuilder sb) {
+ RuleApplyTemplates ruleApplyTemplates = GWT
+ .create(RuleApplyTemplates.class);
+ sb.append(ruleApplyTemplates.format(value));
+ }
+ });
+
+ ColumnConfig readableExpressionCol = new ColumnConfig(
+ propsRules.readableExpression(), 160, "Expression");
+
+ readableExpressionCol.setCell(new AbstractCell() {
+
+ @Override
+ public void render(Context context, String value, SafeHtmlBuilder sb) {
+ RuleApplyTemplates ruleApplyTemplates = GWT
+ .create(RuleApplyTemplates.class);
+ sb.append(ruleApplyTemplates.format(value));
+ }
+ });
+
+ List> l = new ArrayList>();
+ l.add(nameCol);
+ l.add(descriptionCol);
+ l.add(ownerCol);
+ l.add(readableExpressionCol);
+
+ ColumnModel cm = new ColumnModel(
+ l);
+
+ StringFilter nameFilter = new StringFilter(
+ propsRules.name());
+ StringFilter descriptionFilter = new StringFilter(
+ propsRules.description());
+
+ // Applies Rules
+ ListStore appliedRulesStore = new ListStore(
+ propsRules.id());
+
+ if (columnAppliedRules != null && columnAppliedRules.size() > 0) {
+ appliedRulesStore.addAll(columnAppliedRules);
+ }
+
+ final Grid gridAppliedRules = new Grid(
+ appliedRulesStore, cm);
+ gridAppliedRules.setHeight(RULES_GRID_HEIGHT);
+ gridAppliedRules.getView().setStripeRows(true);
+ gridAppliedRules.getView().setColumnLines(true);
+ gridAppliedRules.getView().setAutoFill(true);
+ gridAppliedRules.setBorders(false);
+ gridAppliedRules.setLoadMask(true);
+ gridAppliedRules.setColumnReordering(true);
+ gridAppliedRules.setColumnResize(true);
+ gridAppliedRules.getView().setAutoExpandColumn(descriptionCol);
+
+ GridFilters filtersAppliesRules = new GridFilters();
+ filtersAppliesRules.initPlugin(gridAppliedRules);
+ filtersAppliesRules.setLocal(true);
+ filtersAppliesRules.addFilter(nameFilter);
+ filtersAppliesRules.addFilter(descriptionFilter);
+
+ createContextMenu(gridAppliedRules);
+
+ FieldLabel rulesAppliedLabel = new FieldLabel(gridAppliedRules,
+ column.getLabel());
+
+ return rulesAppliedLabel;
+ }
+
+ protected void getAppliedBaseColumnRules() {
+
+ ExpressionServiceAsync.INSTANCE.getAppliedRulesByTabularResourceId(
+ trId, new AsyncCallback() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ if (caught instanceof TDGWTSessionExpiredException) {
+ eventBus.fireEvent(new SessionExpiredEvent(
+ SessionExpiredType.EXPIREDONSERVER));
+ } else {
+ Log.error(caught.getLocalizedMessage());
+ UtilsGXT3.alert("Error retrieving applied rules",
+ caught.getLocalizedMessage());
+ }
+
+ }
+
+ @Override
+ public void onSuccess(AppliedRulesResponseData result) {
+ Log.trace("AppliedRuleResponseData: " + result);
+ appliedRuleResponseData = result;
+ create();
+ }
+ });
+
+ }
+
+ protected void close() {
+ parent.close();
+ }
+
+ protected void requestInfo(RuleDescriptionData rule) {
+
+ final Dialog infoRuleDialog = new Dialog();
+ infoRuleDialog.setHeadingText("Info Rule");
+ infoRuleDialog.getHeader().setIcon(
+ TabularDataResources.INSTANCE.information());
+ infoRuleDialog.setPredefinedButtons(PredefinedButton.OK);
+
+ FieldSet configurationFieldSet = new FieldSet();
+ configurationFieldSet.setHeadingText("Configuration");
+ configurationFieldSet.setCollapsible(false);
+ configurationFieldSet.setBorders(true);
+
+ VerticalLayoutContainer configurationFieldSetLayout = new VerticalLayoutContainer();
+ configurationFieldSet.add(configurationFieldSetLayout,
+ new MarginData(0));
+
+ TextField ruleName = new TextField();
+ ruleName.setToolTip("Rule Name");
+ ruleName.setValue(rule.getName());
+ ruleName.setReadOnly(true);
+ FieldLabel ruleNameLabel = new FieldLabel(ruleName, "Name");
+ configurationFieldSetLayout.add(ruleNameLabel, new VerticalLayoutData(
+ 1, -1, new Margins(0)));
+
+ TextField ruleScope = new TextField();
+ ruleScope.setToolTip("Rule Scope");
+ ruleScope.setValue(rule.getScopeLabel());
+ ruleScope.setReadOnly(true);
+ FieldLabel ruleScopeLabel = new FieldLabel(ruleScope, "Scope");
+ configurationFieldSetLayout.add(ruleScopeLabel, new VerticalLayoutData(
+ 1, -1, new Margins(0)));
+
+ TextArea ruleDescription = new TextArea();
+ ruleDescription.setToolTip("Rule Description");
+ ruleDescription.setValue(rule.getDescription());
+ ruleDescription.setReadOnly(true);
+ FieldLabel ruleDescriptionLabel = new FieldLabel(ruleDescription,
+ "Description");
+ configurationFieldSetLayout.add(ruleDescriptionLabel,
+ new VerticalLayoutData(1, -1, new Margins(0)));
+
+ TextField ruleOwner = new TextField();
+ ruleOwner.setToolTip("Rule Owner");
+ ruleOwner.setValue(rule.getOwner());
+ ruleOwner.setReadOnly(true);
+ FieldLabel ruleOwnerLabel = new FieldLabel(ruleOwner, "Owner");
+ configurationFieldSetLayout.add(ruleOwnerLabel, new VerticalLayoutData(
+ 1, -1, new Margins(0)));
+
+ TextArea ruleExpression = new TextArea();
+ ruleExpression.setToolTip("Rule Expression");
+ ruleExpression.setValue(rule.getReadableExpression());
+ ruleExpression.setReadOnly(true);
+ ruleExpression.setHeight("82px");
+ FieldLabel ruleExpressionLabel = new FieldLabel(ruleExpression,
+ "Expression");
+ configurationFieldSetLayout.add(ruleExpressionLabel,
+ new VerticalLayoutData(1, -1, new Margins(0)));
+
+ infoRuleDialog.add(configurationFieldSet, new MarginData(0));
+ infoRuleDialog.setHideOnButtonClick(true);
+ infoRuleDialog.setButtonAlign(BoxLayoutPack.CENTER);
+ infoRuleDialog.setWidth(500);
+
+ infoRuleDialog.show();
+
+ }
+
+ protected void createContextMenu(final Grid grid) {
+ Menu contextMenu = new Menu();
+
+ MenuItem infoItem = new MenuItem();
+ infoItem.setText("Info");
+ infoItem.setIcon(TabularDataResources.INSTANCE.information());
+ infoItem.addSelectionHandler(new SelectionHandler- () {
+
+ @Override
+ public void onSelection(SelectionEvent
- event) {
+ RuleDescriptionData selected = grid.getSelectionModel()
+ .getSelectedItem();
+ Log.debug(selected.toString());
+ requestInfo(selected);
+ }
+ });
+
+ contextMenu.add(infoItem);
+
+ grid.setContextMenu(contextMenu);
+
+ }
+
+}
diff --git a/src/main/resources/org/gcube/portlets/user/td/tabulardataportlet.gwt.xml b/src/main/resources/org/gcube/portlets/user/td/tabulardataportlet.gwt.xml
index 47558ce..cd14e26 100644
--- a/src/main/resources/org/gcube/portlets/user/td/tabulardataportlet.gwt.xml
+++ b/src/main/resources/org/gcube/portlets/user/td/tabulardataportlet.gwt.xml
@@ -99,18 +99,18 @@
-->
-
+
-
+