diff --git a/src/main/java/org/gcube/portlets/user/td/client/ribbon/RuleToolBar.java b/src/main/java/org/gcube/portlets/user/td/client/ribbon/RuleToolBar.java index 1c8d9ff..95cc108 100644 --- a/src/main/java/org/gcube/portlets/user/td/client/ribbon/RuleToolBar.java +++ b/src/main/java/org/gcube/portlets/user/td/client/ribbon/RuleToolBar.java @@ -37,13 +37,14 @@ public class RuleToolBar { private ToolBar toolBar; // Rules - private TextButton ruleNewButton; private TextButton ruleOpenButton; private TextButton ruleDeleteButton; - private TextButton ruleApplyButton; - private TextButton ruleTabularResourceButton; + private TextButton ruleOnTabularResourceButton; + private TextButton ruleShareButton; - // private TextButton ruleShareButton; + // On Column + private TextButton ruleOnColumnNewButton; + private TextButton ruleOnColumnApplyButton; public RuleToolBar(EventBus eventBus) { this.eventBus = eventBus; @@ -106,40 +107,42 @@ public class RuleToolBar { ruleLayout.setWidget(0, 1, ruleDeleteButton); ruleLayout.getFlexCellFormatter().setRowSpan(0, 1, 2); - ruleTabularResourceButton = new TextButton(msgs.ruleTabularResourceButton(), + ruleOnTabularResourceButton = new TextButton( + msgs.ruleTabularResourceButton(), TabularDataResources.INSTANCE.ruleTabularResource32()); - ruleTabularResourceButton.disable(); - ruleTabularResourceButton.setScale(ButtonScale.LARGE); - ruleTabularResourceButton.setIconAlign(IconAlign.TOP); - ruleTabularResourceButton.setToolTip(msgs.ruleTabularResourceButtonToolTip()); - ruleTabularResourceButton.setArrowAlign(ButtonArrowAlign.BOTTOM); - ruleTabularResourceButton.addSelectHandler(new SelectHandler() { + ruleOnTabularResourceButton.disable(); + ruleOnTabularResourceButton.setScale(ButtonScale.LARGE); + ruleOnTabularResourceButton.setIconAlign(IconAlign.TOP); + ruleOnTabularResourceButton.setToolTip(msgs + .ruleTabularResourceButtonToolTip()); + ruleOnTabularResourceButton.setArrowAlign(ButtonArrowAlign.BOTTOM); + ruleOnTabularResourceButton.addSelectHandler(new SelectHandler() { public void onSelect(SelectEvent event) { - eventBus.fireEvent(new RibbonEvent(RibbonType.RULES_APPLIED_ON_TABULAR_RESOURCE)); + eventBus.fireEvent(new RibbonEvent( + RibbonType.RULES_APPLIED_ON_TABULAR_RESOURCE)); } }); - ruleLayout.setWidget(0, 2, ruleTabularResourceButton); + ruleLayout.setWidget(0, 2, ruleOnTabularResourceButton); ruleLayout.getFlexCellFormatter().setRowSpan(0, 2, 2); - - /* - * ruleShareButton = new TextButton(msgs.ruleShareButton(), - * TabularDataResources.INSTANCE.ruleShare32()); - * ruleShareButton.enable(); - * ruleShareButton.setScale(ButtonScale.LARGE); - * ruleShareButton.setIconAlign(IconAlign.TOP); - * ruleShareButton.setToolTip(msgs.ruleShareButtonToolTip()); - * ruleShareButton.setArrowAlign(ButtonArrowAlign.BOTTOM); - * ruleShareButton.addSelectHandler(new SelectHandler() { - * - * public void onSelect(SelectEvent event) { eventBus.fireEvent(new - * RibbonEvent(RibbonType.RULE_SHARE)); } }); - * - * ruleLayout.setWidget(0, 3, ruleShareButton); - * ruleLayout.getFlexCellFormatter().setRowSpan(0, 3, 2); - */ + ruleShareButton = new TextButton(msgs.ruleShareButton(), + TabularDataResources.INSTANCE.ruleShare32()); + ruleShareButton.enable(); + ruleShareButton.setScale(ButtonScale.LARGE); + ruleShareButton.setIconAlign(IconAlign.TOP); + ruleShareButton.setToolTip(msgs.ruleShareButtonToolTip()); + ruleShareButton.setArrowAlign(ButtonArrowAlign.BOTTOM); + ruleShareButton.addSelectHandler(new SelectHandler() { + + public void onSelect(SelectEvent event) { + eventBus.fireEvent(new RibbonEvent(RibbonType.RULE_SHARE)); + } + }); + + ruleLayout.setWidget(0, 3, ruleShareButton); + ruleLayout.getFlexCellFormatter().setRowSpan(0, 3, 2); cleanCells(ruleLayout.getElement()); @@ -153,41 +156,41 @@ public class RuleToolBar { FlexTable ruleOnColumnLayout = new FlexTable(); ruleOnColumnGroup.add(ruleOnColumnLayout); - - ruleNewButton = new TextButton(msgs.ruleNewButton(), + + ruleOnColumnNewButton = new TextButton(msgs.ruleNewButton(), TabularDataResources.INSTANCE.ruleColumnAdd32()); - ruleNewButton.enable(); - ruleNewButton.setToolTip(msgs.ruleNewButtonToolTip()); - ruleNewButton.setScale(ButtonScale.LARGE); - ruleNewButton.setIconAlign(IconAlign.TOP); - ruleNewButton.setArrowAlign(ButtonArrowAlign.BOTTOM); - ruleNewButton.addSelectHandler(new SelectHandler() { + ruleOnColumnNewButton.enable(); + ruleOnColumnNewButton.setToolTip(msgs.ruleNewButtonToolTip()); + ruleOnColumnNewButton.setScale(ButtonScale.LARGE); + ruleOnColumnNewButton.setIconAlign(IconAlign.TOP); + ruleOnColumnNewButton.setArrowAlign(ButtonArrowAlign.BOTTOM); + ruleOnColumnNewButton.addSelectHandler(new SelectHandler() { public void onSelect(SelectEvent event) { eventBus.fireEvent(new RibbonEvent(RibbonType.RULE_NEW)); } }); - - ruleOnColumnLayout.setWidget(0, 0, ruleNewButton); + + ruleOnColumnLayout.setWidget(0, 0, ruleOnColumnNewButton); ruleOnColumnLayout.getFlexCellFormatter().setRowSpan(0, 0, 2); - - ruleApplyButton = new TextButton(msgs.ruleApplyButton(), + + ruleOnColumnApplyButton = new TextButton(msgs.ruleApplyButton(), TabularDataResources.INSTANCE.ruleColumnApply32()); - ruleApplyButton.disable(); - ruleApplyButton.setScale(ButtonScale.LARGE); - ruleApplyButton.setIconAlign(IconAlign.TOP); - ruleApplyButton.setToolTip(msgs.ruleApplyButtonToolTip()); - ruleApplyButton.setArrowAlign(ButtonArrowAlign.BOTTOM); - ruleApplyButton.addSelectHandler(new SelectHandler() { + ruleOnColumnApplyButton.disable(); + ruleOnColumnApplyButton.setScale(ButtonScale.LARGE); + ruleOnColumnApplyButton.setIconAlign(IconAlign.TOP); + ruleOnColumnApplyButton.setToolTip(msgs.ruleApplyButtonToolTip()); + ruleOnColumnApplyButton.setArrowAlign(ButtonArrowAlign.BOTTOM); + ruleOnColumnApplyButton.addSelectHandler(new SelectHandler() { public void onSelect(SelectEvent event) { eventBus.fireEvent(new RibbonEvent(RibbonType.RULE_APPLY)); } }); - ruleOnColumnLayout.setWidget(0, 1, ruleApplyButton); + ruleOnColumnLayout.setWidget(0, 1, ruleOnColumnApplyButton); ruleOnColumnLayout.getFlexCellFormatter().setRowSpan(0, 1, 2); - + cleanCells(ruleLayout.getElement()); eventBus.addHandler(UIStateEvent.TYPE, @@ -218,38 +221,40 @@ public class RuleToolBar { switch (uiStateType) { case START: ruleOpenButton.enable(); - ruleNewButton.enable(); ruleDeleteButton.enable(); - ruleApplyButton.disable(); - ruleTabularResourceButton.disable(); - // ruleShareButton.enable(); + ruleOnTabularResourceButton.disable(); + ruleShareButton.enable(); + ruleOnColumnNewButton.enable(); + ruleOnColumnApplyButton.disable(); break; case TR_CLOSE: case TR_READONLY: ruleOpenButton.enable(); - ruleNewButton.enable(); ruleDeleteButton.enable(); - ruleApplyButton.disable(); - ruleTabularResourceButton.disable(); - // ruleShareButton.enable(); + ruleOnTabularResourceButton.disable(); + ruleShareButton.enable(); + ruleOnColumnNewButton.enable(); + ruleOnColumnApplyButton.disable(); + break; case TR_OPEN: case TABLEUPDATE: case TABLECURATION: ruleOpenButton.enable(); - ruleNewButton.enable(); ruleDeleteButton.enable(); - ruleApplyButton.enable(); - ruleTabularResourceButton.enable(); - // ruleShareButton.enable(); + ruleOnTabularResourceButton.enable(); + ruleShareButton.enable(); + ruleOnColumnNewButton.enable(); + ruleOnColumnApplyButton.enable(); + break; case WIZARD_OPEN: ruleOpenButton.disable(); - ruleNewButton.disable(); ruleDeleteButton.disable(); - ruleApplyButton.disable(); - ruleTabularResourceButton.disable(); - // ruleShareButton.disable(); + ruleOnTabularResourceButton.disable(); + ruleShareButton.disable(); + ruleOnColumnNewButton.disable(); + ruleOnColumnApplyButton.disable(); break; default: break; diff --git a/src/main/java/org/gcube/portlets/user/td/client/ribbon/TabularDataRibbon.java b/src/main/java/org/gcube/portlets/user/td/client/ribbon/TabularDataRibbon.java index fa8e860..47d9880 100644 --- a/src/main/java/org/gcube/portlets/user/td/client/ribbon/TabularDataRibbon.java +++ b/src/main/java/org/gcube/portlets/user/td/client/ribbon/TabularDataRibbon.java @@ -23,7 +23,6 @@ public class TabularDataRibbon { private TabPanel ribbon; - //private PlainTabPanel ribbon; private FileToolBar fileToolBar; private CurationToolBar curationToolBar; 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 index 473fbf7..eb02140 100644 --- 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 @@ -242,7 +242,7 @@ public class RuleAppliedPanel extends FramedPanel { }); ColumnConfig ownerCol = new ColumnConfig( - propsRules.owner(), 70, "Owner"); + propsRules.ownerLogin(), 70, "Owner"); ownerCol.setCell(new AbstractCell() { @Override @@ -253,9 +253,11 @@ public class RuleAppliedPanel extends FramedPanel { } }); + /* ColumnConfig readableExpressionCol = new ColumnConfig( propsRules.readableExpression(), 160, "Expression"); + readableExpressionCol.setCell(new AbstractCell() { @Override @@ -264,13 +266,13 @@ public class RuleAppliedPanel extends FramedPanel { .create(RuleApplyTemplates.class); sb.append(ruleApplyTemplates.format(value)); } - }); + });*/ List> l = new ArrayList>(); l.add(nameCol); l.add(descriptionCol); l.add(ownerCol); - l.add(readableExpressionCol); + //l.add(readableExpressionCol); ColumnModel cm = new ColumnModel( l); @@ -390,7 +392,7 @@ public class RuleAppliedPanel extends FramedPanel { TextField ruleOwner = new TextField(); ruleOwner.setToolTip("Rule Owner"); - ruleOwner.setValue(rule.getOwner()); + ruleOwner.setValue(rule.getOwnerLogin()); ruleOwner.setReadOnly(true); FieldLabel ruleOwnerLabel = new FieldLabel(ruleOwner, "Owner"); configurationFieldSetLayout.add(ruleOwnerLabel, new VerticalLayoutData( 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 a6503c1..00db03c 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 @@ -229,7 +229,7 @@ public class RuleApplyPanel extends FramedPanel { }); ColumnConfig ownerCol = new ColumnConfig( - propsRules.owner(), 70, "Owner"); + propsRules.ownerLogin(), 70, "Owner"); ownerCol.setCell(new AbstractCell() { @Override @@ -240,6 +240,7 @@ public class RuleApplyPanel extends FramedPanel { } }); + /* ColumnConfig readableExpressionCol = new ColumnConfig( propsRules.readableExpression(), 160, "Expression"); @@ -251,13 +252,13 @@ public class RuleApplyPanel extends FramedPanel { .create(RuleApplyTemplates.class); sb.append(ruleApplyTemplates.format(value)); } - }); + });*/ List> l = new ArrayList>(); l.add(nameCol); l.add(descriptionCol); l.add(ownerCol); - l.add(readableExpressionCol); + //l.add(readableExpressionCol); ColumnModel cm = new ColumnModel( l); @@ -401,6 +402,8 @@ public class RuleApplyPanel extends FramedPanel { protected void updateRulesInGrids(ColumnData columnData) { column = columnData; + applicableRulesStore.clear(); + appliesRulesStore.clear(); HashMap> columnRuleMapping = appliedRuleResponseData .getColumnRuleMapping(); @@ -410,7 +413,6 @@ public class RuleApplyPanel extends FramedPanel { if (applied != null) { appliedRules = applied; - appliesRulesStore.clear(); appliesRulesStore.addAll(new ArrayList( applied)); @@ -457,9 +459,6 @@ public class RuleApplyPanel extends FramedPanel { } applicableRules = result; - - - applicableRulesStore.clear(); applicableRulesStore .addAll(new ArrayList( applicableRules)); @@ -596,7 +595,7 @@ public class RuleApplyPanel extends FramedPanel { TextField ruleOwner = new TextField(); ruleOwner.setToolTip("Rule Owner"); - ruleOwner.setValue(rule.getOwner()); + ruleOwner.setValue(rule.getOwnerLogin()); ruleOwner.setReadOnly(true); FieldLabel ruleOwnerLabel = new FieldLabel(ruleOwner, "Owner"); configurationFieldSetLayout.add(ruleOwnerLabel, new VerticalLayoutData( 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 3ae6748..62b0dcc 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 @@ -159,7 +159,7 @@ public class RuleDeletePanel extends FramedPanel { }); ColumnConfig ownerCol = new ColumnConfig( - props.owner(), 70, "Owner"); + props.ownerLogin(), 70, "Owner"); ownerCol.setCell(new AbstractCell() { @Override @@ -170,6 +170,7 @@ public class RuleDeletePanel extends FramedPanel { } }); + /* ColumnConfig readableExpressionCol = new ColumnConfig( props.readableExpression(), 160, "Expression"); @@ -181,14 +182,14 @@ public class RuleDeletePanel extends FramedPanel { .create(RuleDeleteTemplates.class); sb.append(ruleDeleteTemplates.format(value)); } - }); + });*/ List> l = new ArrayList>(); l.add(nameCol); l.add(scopeCol); l.add(descriptionCol); l.add(ownerCol); - l.add(readableExpressionCol); + //l.add(readableExpressionCol); ColumnModel cm = new ColumnModel( l); @@ -445,7 +446,7 @@ public class RuleDeletePanel extends FramedPanel { TextField ruleOwner = new TextField(); ruleOwner.setToolTip("Rule Owner"); - ruleOwner.setValue(rule.getOwner()); + ruleOwner.setValue(rule.getOwnerLogin()); ruleOwner.setReadOnly(true); FieldLabel ruleOwnerLabel = new FieldLabel(ruleOwner, "Owner"); configurationFieldSetLayout.add(ruleOwnerLabel, new VerticalLayoutData( 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 6f53336..0ea36f2 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 @@ -165,7 +165,7 @@ public class RuleOpenPanel extends FramedPanel { }); ColumnConfig ownerCol = new ColumnConfig( - props.owner(), 70, "Owner"); + props.ownerLogin(), 70, "Owner"); ownerCol.setCell(new AbstractCell() { @Override @@ -175,7 +175,8 @@ public class RuleOpenPanel extends FramedPanel { sb.append(ruleOpenTemplates.format(value)); } }); - + + /* ColumnConfig readableExpressionCol = new ColumnConfig( props.readableExpression(), 160, "Expression"); @@ -187,14 +188,14 @@ public class RuleOpenPanel extends FramedPanel { .create(RuleOpenTemplates.class); sb.append(ruleOpenTemplates.format(value)); } - }); + });*/ List> l = new ArrayList>(); l.add(nameCol); l.add(scopeCol); l.add(descriptionCol); l.add(ownerCol); - l.add(readableExpressionCol); + //l.add(readableExpressionCol); ColumnModel cm = new ColumnModel( l); @@ -453,7 +454,7 @@ public class RuleOpenPanel extends FramedPanel { TextField ruleOwner = new TextField(); ruleOwner.setToolTip("Rule Owner"); - ruleOwner.setValue(rule.getOwner()); + ruleOwner.setValue(rule.getOwnerLogin()); ruleOwner.setReadOnly(true); FieldLabel ruleOwnerLabel = new FieldLabel(ruleOwner, "Owner"); configurationFieldSetLayout.add(ruleOwnerLabel, new VerticalLayoutData( 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 214b433..c6ca539 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 @@ -1,8 +1,8 @@ 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.td.sharewidget.client.TemplateShare; +import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData; +import org.gcube.portlets.user.td.sharewidget.client.RuleShare; import com.allen_sauer.gwt.log.client.Log; import com.google.web.bindery.event.shared.EventBus; @@ -65,10 +65,10 @@ public class RuleShareDialog extends Window { } - public void templateShare(TemplateData templateData) { + public void ruleShare(RuleDescriptionData ruleDescriptionData) { Log.debug("Share Window"); @SuppressWarnings("unused") - TemplateShare templateShare = new TemplateShare(templateData, eventBus); + RuleShare ruleShare = new RuleShare(ruleDescriptionData, eventBus); close(); } 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 746ece9..0e20327 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,6 +4,7 @@ import java.util.ArrayList; import java.util.List; import org.gcube.portlets.user.td.client.resource.TabularDataResources; +import org.gcube.portlets.user.td.client.rule.RuleDeletePanel.RuleDeleteTemplates; 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.shared.exception.TDGWTSessionExpiredException; @@ -14,11 +15,15 @@ import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredE import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType; 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.core.client.Scheduler; import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpHandler; +import com.google.gwt.event.logical.shared.SelectionEvent; +import com.google.gwt.event.logical.shared.SelectionHandler; +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; @@ -36,21 +41,30 @@ 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.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.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; +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; import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem; import com.sencha.gxt.widget.core.client.toolbar.ToolBar; @@ -102,22 +116,66 @@ public class RuleSharePanel extends FramedPanel { CheckBoxSelectionModel sm = new CheckBoxSelectionModel( identity); - RuleDescriptionDataProperties props = GWT.create(RuleDescriptionDataProperties.class); + RuleDescriptionDataProperties props = GWT + .create(RuleDescriptionDataProperties.class); ColumnConfig nameCol = new ColumnConfig( props.name(), 120, "Name"); + nameCol.setCell(new AbstractCell() { + + @Override + public void render(Context context, String value, SafeHtmlBuilder sb) { + RuleDeleteTemplates ruleDeleteTemplates = GWT + .create(RuleDeleteTemplates.class); + sb.append(ruleDeleteTemplates.format(value)); + } + }); + + ColumnConfig scopeCol = new ColumnConfig( + props.scopeLabel(), 40, "Scope"); + + nameCol.setCell(new AbstractCell() { + + @Override + public void render(Context context, String value, SafeHtmlBuilder sb) { + RuleDeleteTemplates ruleDeleteTemplates = GWT + .create(RuleDeleteTemplates.class); + sb.append(ruleDeleteTemplates.format(value)); + } + }); + ColumnConfig descriptionCol = new ColumnConfig( props.description(), 120, "Description"); + descriptionCol.setCell(new AbstractCell() { - ColumnConfig readableExpressionCol = new ColumnConfig( - props.readableExpression(), 230, "Expression"); + @Override + public void render(Context context, String value, SafeHtmlBuilder sb) { + RuleDeleteTemplates ruleDeleteTemplates = GWT + .create(RuleDeleteTemplates.class); + sb.append(ruleDeleteTemplates.format(value)); + } + }); + + ColumnConfig ownerCol = new ColumnConfig( + props.ownerLogin(), 70, "Owner"); + ownerCol.setCell(new AbstractCell() { + + @Override + public void render(Context context, String value, SafeHtmlBuilder sb) { + RuleDeleteTemplates ruleDeleteTemplates = GWT + .create(RuleDeleteTemplates.class); + sb.append(ruleDeleteTemplates.format(value)); + } + }); List> l = new ArrayList>(); l.add(nameCol); + l.add(scopeCol); l.add(descriptionCol); - l.add(readableExpressionCol); + l.add(ownerCol); + ColumnModel cm = new ColumnModel(l); @@ -193,7 +251,10 @@ public class RuleSharePanel extends FramedPanel { grid.setColumnReordering(true); grid.setColumnResize(true); grid.getView().setAutoExpandColumn(descriptionCol); - + + createContextMenu(); + + ToolBar toolBar = new ToolBar(); toolBar.add(grid); toolBar.addStyleName(ThemeStyles.get().style().borderTop()); @@ -278,24 +339,24 @@ public class RuleSharePanel extends FramedPanel { protected ArrayList getSelectedItem() { - ArrayList templates = new ArrayList(); - for (RuleDescriptionData template : grid.getSelectionModel() + ArrayList rules = new ArrayList(); + for (RuleDescriptionData rule : grid.getSelectionModel() .getSelectedItems()) { - templates.add(template); + rules.add(rule); } - return templates; + return rules; } protected void share() { - ArrayList templates = getSelectedItem(); - if (templates == null || templates.size() == 0) { - UtilsGXT3.info("Attention", "Select the template"); + ArrayList rules = getSelectedItem(); + if (rules == null || rules.size() == 0) { + UtilsGXT3.info("Attention", "Select the rule"); } else { - RuleDescriptionData template = templates.get(0); - Log.debug("templateShare: " + template); - //parent.templateShare(template); + RuleDescriptionData rule = rules.get(0); + Log.debug("templateShare: " + rule); + parent.ruleShare(rule); } @@ -332,5 +393,99 @@ public class RuleSharePanel extends FramedPanel { return true; return false; } + + 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.getOwnerLogin()); + 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() { + 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 cd14e26..f93f627 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 @@ -106,11 +106,11 @@ --> - + - +