Added the sharing of rules

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@114329 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-04-22 12:20:10 +00:00
parent 1d1d9ead45
commit c7bd80cf99
9 changed files with 271 additions and 109 deletions

View File

@ -37,13 +37,14 @@ public class RuleToolBar {
private ToolBar toolBar; private ToolBar toolBar;
// Rules // Rules
private TextButton ruleNewButton;
private TextButton ruleOpenButton; private TextButton ruleOpenButton;
private TextButton ruleDeleteButton; private TextButton ruleDeleteButton;
private TextButton ruleApplyButton; private TextButton ruleOnTabularResourceButton;
private TextButton ruleTabularResourceButton; private TextButton ruleShareButton;
// private TextButton ruleShareButton; // On Column
private TextButton ruleOnColumnNewButton;
private TextButton ruleOnColumnApplyButton;
public RuleToolBar(EventBus eventBus) { public RuleToolBar(EventBus eventBus) {
this.eventBus = eventBus; this.eventBus = eventBus;
@ -106,40 +107,42 @@ public class RuleToolBar {
ruleLayout.setWidget(0, 1, ruleDeleteButton); ruleLayout.setWidget(0, 1, ruleDeleteButton);
ruleLayout.getFlexCellFormatter().setRowSpan(0, 1, 2); ruleLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
ruleTabularResourceButton = new TextButton(msgs.ruleTabularResourceButton(), ruleOnTabularResourceButton = new TextButton(
msgs.ruleTabularResourceButton(),
TabularDataResources.INSTANCE.ruleTabularResource32()); TabularDataResources.INSTANCE.ruleTabularResource32());
ruleTabularResourceButton.disable(); ruleOnTabularResourceButton.disable();
ruleTabularResourceButton.setScale(ButtonScale.LARGE); ruleOnTabularResourceButton.setScale(ButtonScale.LARGE);
ruleTabularResourceButton.setIconAlign(IconAlign.TOP); ruleOnTabularResourceButton.setIconAlign(IconAlign.TOP);
ruleTabularResourceButton.setToolTip(msgs.ruleTabularResourceButtonToolTip()); ruleOnTabularResourceButton.setToolTip(msgs
ruleTabularResourceButton.setArrowAlign(ButtonArrowAlign.BOTTOM); .ruleTabularResourceButtonToolTip());
ruleTabularResourceButton.addSelectHandler(new SelectHandler() { ruleOnTabularResourceButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
ruleOnTabularResourceButton.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) { 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); ruleLayout.getFlexCellFormatter().setRowSpan(0, 2, 2);
/* ruleShareButton = new TextButton(msgs.ruleShareButton(),
* ruleShareButton = new TextButton(msgs.ruleShareButton(), TabularDataResources.INSTANCE.ruleShare32());
* TabularDataResources.INSTANCE.ruleShare32()); ruleShareButton.enable();
* ruleShareButton.enable(); ruleShareButton.setScale(ButtonScale.LARGE);
* ruleShareButton.setScale(ButtonScale.LARGE); ruleShareButton.setIconAlign(IconAlign.TOP);
* ruleShareButton.setIconAlign(IconAlign.TOP); ruleShareButton.setToolTip(msgs.ruleShareButtonToolTip());
* ruleShareButton.setToolTip(msgs.ruleShareButtonToolTip()); ruleShareButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
* ruleShareButton.setArrowAlign(ButtonArrowAlign.BOTTOM); ruleShareButton.addSelectHandler(new SelectHandler() {
* ruleShareButton.addSelectHandler(new SelectHandler() {
* public void onSelect(SelectEvent event) {
* public void onSelect(SelectEvent event) { eventBus.fireEvent(new eventBus.fireEvent(new RibbonEvent(RibbonType.RULE_SHARE));
* RibbonEvent(RibbonType.RULE_SHARE)); } }); }
* });
* ruleLayout.setWidget(0, 3, ruleShareButton);
* ruleLayout.getFlexCellFormatter().setRowSpan(0, 3, 2); ruleLayout.setWidget(0, 3, ruleShareButton);
*/ ruleLayout.getFlexCellFormatter().setRowSpan(0, 3, 2);
cleanCells(ruleLayout.getElement()); cleanCells(ruleLayout.getElement());
@ -153,41 +156,41 @@ public class RuleToolBar {
FlexTable ruleOnColumnLayout = new FlexTable(); FlexTable ruleOnColumnLayout = new FlexTable();
ruleOnColumnGroup.add(ruleOnColumnLayout); ruleOnColumnGroup.add(ruleOnColumnLayout);
ruleNewButton = new TextButton(msgs.ruleNewButton(), ruleOnColumnNewButton = new TextButton(msgs.ruleNewButton(),
TabularDataResources.INSTANCE.ruleColumnAdd32()); TabularDataResources.INSTANCE.ruleColumnAdd32());
ruleNewButton.enable(); ruleOnColumnNewButton.enable();
ruleNewButton.setToolTip(msgs.ruleNewButtonToolTip()); ruleOnColumnNewButton.setToolTip(msgs.ruleNewButtonToolTip());
ruleNewButton.setScale(ButtonScale.LARGE); ruleOnColumnNewButton.setScale(ButtonScale.LARGE);
ruleNewButton.setIconAlign(IconAlign.TOP); ruleOnColumnNewButton.setIconAlign(IconAlign.TOP);
ruleNewButton.setArrowAlign(ButtonArrowAlign.BOTTOM); ruleOnColumnNewButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
ruleNewButton.addSelectHandler(new SelectHandler() { ruleOnColumnNewButton.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) { public void onSelect(SelectEvent event) {
eventBus.fireEvent(new RibbonEvent(RibbonType.RULE_NEW)); eventBus.fireEvent(new RibbonEvent(RibbonType.RULE_NEW));
} }
}); });
ruleOnColumnLayout.setWidget(0, 0, ruleNewButton); ruleOnColumnLayout.setWidget(0, 0, ruleOnColumnNewButton);
ruleOnColumnLayout.getFlexCellFormatter().setRowSpan(0, 0, 2); ruleOnColumnLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
ruleApplyButton = new TextButton(msgs.ruleApplyButton(), ruleOnColumnApplyButton = new TextButton(msgs.ruleApplyButton(),
TabularDataResources.INSTANCE.ruleColumnApply32()); TabularDataResources.INSTANCE.ruleColumnApply32());
ruleApplyButton.disable(); ruleOnColumnApplyButton.disable();
ruleApplyButton.setScale(ButtonScale.LARGE); ruleOnColumnApplyButton.setScale(ButtonScale.LARGE);
ruleApplyButton.setIconAlign(IconAlign.TOP); ruleOnColumnApplyButton.setIconAlign(IconAlign.TOP);
ruleApplyButton.setToolTip(msgs.ruleApplyButtonToolTip()); ruleOnColumnApplyButton.setToolTip(msgs.ruleApplyButtonToolTip());
ruleApplyButton.setArrowAlign(ButtonArrowAlign.BOTTOM); ruleOnColumnApplyButton.setArrowAlign(ButtonArrowAlign.BOTTOM);
ruleApplyButton.addSelectHandler(new SelectHandler() { ruleOnColumnApplyButton.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) { public void onSelect(SelectEvent event) {
eventBus.fireEvent(new RibbonEvent(RibbonType.RULE_APPLY)); eventBus.fireEvent(new RibbonEvent(RibbonType.RULE_APPLY));
} }
}); });
ruleOnColumnLayout.setWidget(0, 1, ruleApplyButton); ruleOnColumnLayout.setWidget(0, 1, ruleOnColumnApplyButton);
ruleOnColumnLayout.getFlexCellFormatter().setRowSpan(0, 1, 2); ruleOnColumnLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
cleanCells(ruleLayout.getElement()); cleanCells(ruleLayout.getElement());
eventBus.addHandler(UIStateEvent.TYPE, eventBus.addHandler(UIStateEvent.TYPE,
@ -218,38 +221,40 @@ public class RuleToolBar {
switch (uiStateType) { switch (uiStateType) {
case START: case START:
ruleOpenButton.enable(); ruleOpenButton.enable();
ruleNewButton.enable();
ruleDeleteButton.enable(); ruleDeleteButton.enable();
ruleApplyButton.disable(); ruleOnTabularResourceButton.disable();
ruleTabularResourceButton.disable(); ruleShareButton.enable();
// ruleShareButton.enable(); ruleOnColumnNewButton.enable();
ruleOnColumnApplyButton.disable();
break; break;
case TR_CLOSE: case TR_CLOSE:
case TR_READONLY: case TR_READONLY:
ruleOpenButton.enable(); ruleOpenButton.enable();
ruleNewButton.enable();
ruleDeleteButton.enable(); ruleDeleteButton.enable();
ruleApplyButton.disable(); ruleOnTabularResourceButton.disable();
ruleTabularResourceButton.disable(); ruleShareButton.enable();
// ruleShareButton.enable(); ruleOnColumnNewButton.enable();
ruleOnColumnApplyButton.disable();
break; break;
case TR_OPEN: case TR_OPEN:
case TABLEUPDATE: case TABLEUPDATE:
case TABLECURATION: case TABLECURATION:
ruleOpenButton.enable(); ruleOpenButton.enable();
ruleNewButton.enable();
ruleDeleteButton.enable(); ruleDeleteButton.enable();
ruleApplyButton.enable(); ruleOnTabularResourceButton.enable();
ruleTabularResourceButton.enable(); ruleShareButton.enable();
// ruleShareButton.enable(); ruleOnColumnNewButton.enable();
ruleOnColumnApplyButton.enable();
break; break;
case WIZARD_OPEN: case WIZARD_OPEN:
ruleOpenButton.disable(); ruleOpenButton.disable();
ruleNewButton.disable();
ruleDeleteButton.disable(); ruleDeleteButton.disable();
ruleApplyButton.disable(); ruleOnTabularResourceButton.disable();
ruleTabularResourceButton.disable(); ruleShareButton.disable();
// ruleShareButton.disable(); ruleOnColumnNewButton.disable();
ruleOnColumnApplyButton.disable();
break; break;
default: default:
break; break;

View File

@ -23,7 +23,6 @@ public class TabularDataRibbon {
private TabPanel ribbon; private TabPanel ribbon;
//private PlainTabPanel ribbon;
private FileToolBar fileToolBar; private FileToolBar fileToolBar;
private CurationToolBar curationToolBar; private CurationToolBar curationToolBar;

View File

@ -242,7 +242,7 @@ public class RuleAppliedPanel extends FramedPanel {
}); });
ColumnConfig<RuleDescriptionData, String> ownerCol = new ColumnConfig<RuleDescriptionData, String>( ColumnConfig<RuleDescriptionData, String> ownerCol = new ColumnConfig<RuleDescriptionData, String>(
propsRules.owner(), 70, "Owner"); propsRules.ownerLogin(), 70, "Owner");
ownerCol.setCell(new AbstractCell<String>() { ownerCol.setCell(new AbstractCell<String>() {
@Override @Override
@ -253,9 +253,11 @@ public class RuleAppliedPanel extends FramedPanel {
} }
}); });
/*
ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>( ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>(
propsRules.readableExpression(), 160, "Expression"); propsRules.readableExpression(), 160, "Expression");
readableExpressionCol.setCell(new AbstractCell<String>() { readableExpressionCol.setCell(new AbstractCell<String>() {
@Override @Override
@ -264,13 +266,13 @@ public class RuleAppliedPanel extends FramedPanel {
.create(RuleApplyTemplates.class); .create(RuleApplyTemplates.class);
sb.append(ruleApplyTemplates.format(value)); sb.append(ruleApplyTemplates.format(value));
} }
}); });*/
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>(); List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
l.add(nameCol); l.add(nameCol);
l.add(descriptionCol); l.add(descriptionCol);
l.add(ownerCol); l.add(ownerCol);
l.add(readableExpressionCol); //l.add(readableExpressionCol);
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>( ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(
l); l);
@ -390,7 +392,7 @@ public class RuleAppliedPanel extends FramedPanel {
TextField ruleOwner = new TextField(); TextField ruleOwner = new TextField();
ruleOwner.setToolTip("Rule Owner"); ruleOwner.setToolTip("Rule Owner");
ruleOwner.setValue(rule.getOwner()); ruleOwner.setValue(rule.getOwnerLogin());
ruleOwner.setReadOnly(true); ruleOwner.setReadOnly(true);
FieldLabel ruleOwnerLabel = new FieldLabel(ruleOwner, "Owner"); FieldLabel ruleOwnerLabel = new FieldLabel(ruleOwner, "Owner");
configurationFieldSetLayout.add(ruleOwnerLabel, new VerticalLayoutData( configurationFieldSetLayout.add(ruleOwnerLabel, new VerticalLayoutData(

View File

@ -229,7 +229,7 @@ public class RuleApplyPanel extends FramedPanel {
}); });
ColumnConfig<RuleDescriptionData, String> ownerCol = new ColumnConfig<RuleDescriptionData, String>( ColumnConfig<RuleDescriptionData, String> ownerCol = new ColumnConfig<RuleDescriptionData, String>(
propsRules.owner(), 70, "Owner"); propsRules.ownerLogin(), 70, "Owner");
ownerCol.setCell(new AbstractCell<String>() { ownerCol.setCell(new AbstractCell<String>() {
@Override @Override
@ -240,6 +240,7 @@ public class RuleApplyPanel extends FramedPanel {
} }
}); });
/*
ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>( ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>(
propsRules.readableExpression(), 160, "Expression"); propsRules.readableExpression(), 160, "Expression");
@ -251,13 +252,13 @@ public class RuleApplyPanel extends FramedPanel {
.create(RuleApplyTemplates.class); .create(RuleApplyTemplates.class);
sb.append(ruleApplyTemplates.format(value)); sb.append(ruleApplyTemplates.format(value));
} }
}); });*/
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>(); List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
l.add(nameCol); l.add(nameCol);
l.add(descriptionCol); l.add(descriptionCol);
l.add(ownerCol); l.add(ownerCol);
l.add(readableExpressionCol); //l.add(readableExpressionCol);
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>( ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(
l); l);
@ -401,6 +402,8 @@ public class RuleApplyPanel extends FramedPanel {
protected void updateRulesInGrids(ColumnData columnData) { protected void updateRulesInGrids(ColumnData columnData) {
column = columnData; column = columnData;
applicableRulesStore.clear();
appliesRulesStore.clear();
HashMap<String, ArrayList<RuleDescriptionData>> columnRuleMapping = appliedRuleResponseData HashMap<String, ArrayList<RuleDescriptionData>> columnRuleMapping = appliedRuleResponseData
.getColumnRuleMapping(); .getColumnRuleMapping();
@ -410,7 +413,6 @@ public class RuleApplyPanel extends FramedPanel {
if (applied != null) { if (applied != null) {
appliedRules = applied; appliedRules = applied;
appliesRulesStore.clear();
appliesRulesStore.addAll(new ArrayList<RuleDescriptionData>( appliesRulesStore.addAll(new ArrayList<RuleDescriptionData>(
applied)); applied));
@ -457,9 +459,6 @@ public class RuleApplyPanel extends FramedPanel {
} }
applicableRules = result; applicableRules = result;
applicableRulesStore.clear();
applicableRulesStore applicableRulesStore
.addAll(new ArrayList<RuleDescriptionData>( .addAll(new ArrayList<RuleDescriptionData>(
applicableRules)); applicableRules));
@ -596,7 +595,7 @@ public class RuleApplyPanel extends FramedPanel {
TextField ruleOwner = new TextField(); TextField ruleOwner = new TextField();
ruleOwner.setToolTip("Rule Owner"); ruleOwner.setToolTip("Rule Owner");
ruleOwner.setValue(rule.getOwner()); ruleOwner.setValue(rule.getOwnerLogin());
ruleOwner.setReadOnly(true); ruleOwner.setReadOnly(true);
FieldLabel ruleOwnerLabel = new FieldLabel(ruleOwner, "Owner"); FieldLabel ruleOwnerLabel = new FieldLabel(ruleOwner, "Owner");
configurationFieldSetLayout.add(ruleOwnerLabel, new VerticalLayoutData( configurationFieldSetLayout.add(ruleOwnerLabel, new VerticalLayoutData(

View File

@ -159,7 +159,7 @@ public class RuleDeletePanel extends FramedPanel {
}); });
ColumnConfig<RuleDescriptionData, String> ownerCol = new ColumnConfig<RuleDescriptionData, String>( ColumnConfig<RuleDescriptionData, String> ownerCol = new ColumnConfig<RuleDescriptionData, String>(
props.owner(), 70, "Owner"); props.ownerLogin(), 70, "Owner");
ownerCol.setCell(new AbstractCell<String>() { ownerCol.setCell(new AbstractCell<String>() {
@Override @Override
@ -170,6 +170,7 @@ public class RuleDeletePanel extends FramedPanel {
} }
}); });
/*
ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>( ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>(
props.readableExpression(), 160, "Expression"); props.readableExpression(), 160, "Expression");
@ -181,14 +182,14 @@ public class RuleDeletePanel extends FramedPanel {
.create(RuleDeleteTemplates.class); .create(RuleDeleteTemplates.class);
sb.append(ruleDeleteTemplates.format(value)); sb.append(ruleDeleteTemplates.format(value));
} }
}); });*/
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>(); List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
l.add(nameCol); l.add(nameCol);
l.add(scopeCol); l.add(scopeCol);
l.add(descriptionCol); l.add(descriptionCol);
l.add(ownerCol); l.add(ownerCol);
l.add(readableExpressionCol); //l.add(readableExpressionCol);
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>( ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(
l); l);
@ -445,7 +446,7 @@ public class RuleDeletePanel extends FramedPanel {
TextField ruleOwner = new TextField(); TextField ruleOwner = new TextField();
ruleOwner.setToolTip("Rule Owner"); ruleOwner.setToolTip("Rule Owner");
ruleOwner.setValue(rule.getOwner()); ruleOwner.setValue(rule.getOwnerLogin());
ruleOwner.setReadOnly(true); ruleOwner.setReadOnly(true);
FieldLabel ruleOwnerLabel = new FieldLabel(ruleOwner, "Owner"); FieldLabel ruleOwnerLabel = new FieldLabel(ruleOwner, "Owner");
configurationFieldSetLayout.add(ruleOwnerLabel, new VerticalLayoutData( configurationFieldSetLayout.add(ruleOwnerLabel, new VerticalLayoutData(

View File

@ -165,7 +165,7 @@ public class RuleOpenPanel extends FramedPanel {
}); });
ColumnConfig<RuleDescriptionData, String> ownerCol = new ColumnConfig<RuleDescriptionData, String>( ColumnConfig<RuleDescriptionData, String> ownerCol = new ColumnConfig<RuleDescriptionData, String>(
props.owner(), 70, "Owner"); props.ownerLogin(), 70, "Owner");
ownerCol.setCell(new AbstractCell<String>() { ownerCol.setCell(new AbstractCell<String>() {
@Override @Override
@ -175,7 +175,8 @@ public class RuleOpenPanel extends FramedPanel {
sb.append(ruleOpenTemplates.format(value)); sb.append(ruleOpenTemplates.format(value));
} }
}); });
/*
ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>( ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>(
props.readableExpression(), 160, "Expression"); props.readableExpression(), 160, "Expression");
@ -187,14 +188,14 @@ public class RuleOpenPanel extends FramedPanel {
.create(RuleOpenTemplates.class); .create(RuleOpenTemplates.class);
sb.append(ruleOpenTemplates.format(value)); sb.append(ruleOpenTemplates.format(value));
} }
}); });*/
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>(); List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
l.add(nameCol); l.add(nameCol);
l.add(scopeCol); l.add(scopeCol);
l.add(descriptionCol); l.add(descriptionCol);
l.add(ownerCol); l.add(ownerCol);
l.add(readableExpressionCol); //l.add(readableExpressionCol);
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>( ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(
l); l);
@ -453,7 +454,7 @@ public class RuleOpenPanel extends FramedPanel {
TextField ruleOwner = new TextField(); TextField ruleOwner = new TextField();
ruleOwner.setToolTip("Rule Owner"); ruleOwner.setToolTip("Rule Owner");
ruleOwner.setValue(rule.getOwner()); ruleOwner.setValue(rule.getOwnerLogin());
ruleOwner.setReadOnly(true); ruleOwner.setReadOnly(true);
FieldLabel ruleOwnerLabel = new FieldLabel(ruleOwner, "Owner"); FieldLabel ruleOwnerLabel = new FieldLabel(ruleOwner, "Owner");
configurationFieldSetLayout.add(ruleOwnerLabel, new VerticalLayoutData( configurationFieldSetLayout.add(ruleOwnerLabel, new VerticalLayoutData(

View File

@ -1,8 +1,8 @@
package org.gcube.portlets.user.td.client.rule; package org.gcube.portlets.user.td.client.rule;
import org.gcube.portlets.user.td.client.resource.TabularDataResources; 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.gwtservice.shared.rule.RuleDescriptionData;
import org.gcube.portlets.user.td.sharewidget.client.TemplateShare; import org.gcube.portlets.user.td.sharewidget.client.RuleShare;
import com.allen_sauer.gwt.log.client.Log; import com.allen_sauer.gwt.log.client.Log;
import com.google.web.bindery.event.shared.EventBus; 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"); Log.debug("Share Window");
@SuppressWarnings("unused") @SuppressWarnings("unused")
TemplateShare templateShare = new TemplateShare(templateData, eventBus); RuleShare ruleShare = new RuleShare(ruleDescriptionData, eventBus);
close(); close();
} }

View File

@ -4,6 +4,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.gcube.portlets.user.td.client.resource.TabularDataResources; 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.client.rpc.ExpressionServiceAsync;
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties; import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties;
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException; 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 org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
import com.allen_sauer.gwt.log.client.Log; 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.GWT;
import com.google.gwt.core.client.Scheduler; import com.google.gwt.core.client.Scheduler;
import com.google.gwt.core.client.Scheduler.ScheduledCommand; import com.google.gwt.core.client.Scheduler.ScheduledCommand;
import com.google.gwt.event.dom.client.KeyUpEvent; import com.google.gwt.event.dom.client.KeyUpEvent;
import com.google.gwt.event.dom.client.KeyUpHandler; 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.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus; import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign; 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.ListLoadResultBean;
import com.sencha.gxt.data.shared.loader.ListLoader; import com.sencha.gxt.data.shared.loader.ListLoader;
import com.sencha.gxt.data.shared.loader.LoadResultListStoreBinding; 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.FramedPanel;
import com.sencha.gxt.widget.core.client.button.TextButton; 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.BoxLayoutData;
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack; 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;
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign; 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;
import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.VerticalLayoutData; 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;
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler; 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.form.TextField;
import com.sencha.gxt.widget.core.client.grid.CheckBoxSelectionModel; 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.ColumnConfig;
import com.sencha.gxt.widget.core.client.grid.ColumnModel; 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.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.LabelToolItem;
import com.sencha.gxt.widget.core.client.toolbar.ToolBar; import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
@ -102,22 +116,66 @@ public class RuleSharePanel extends FramedPanel {
CheckBoxSelectionModel<RuleDescriptionData> sm = new CheckBoxSelectionModel<RuleDescriptionData>( CheckBoxSelectionModel<RuleDescriptionData> sm = new CheckBoxSelectionModel<RuleDescriptionData>(
identity); identity);
RuleDescriptionDataProperties props = GWT.create(RuleDescriptionDataProperties.class); RuleDescriptionDataProperties props = GWT
.create(RuleDescriptionDataProperties.class);
ColumnConfig<RuleDescriptionData, String> nameCol = new ColumnConfig<RuleDescriptionData, String>( ColumnConfig<RuleDescriptionData, String> nameCol = new ColumnConfig<RuleDescriptionData, String>(
props.name(), 120, "Name"); props.name(), 120, "Name");
nameCol.setCell(new AbstractCell<String>() {
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
RuleDeleteTemplates ruleDeleteTemplates = GWT
.create(RuleDeleteTemplates.class);
sb.append(ruleDeleteTemplates.format(value));
}
});
ColumnConfig<RuleDescriptionData, String> scopeCol = new ColumnConfig<RuleDescriptionData, String>(
props.scopeLabel(), 40, "Scope");
nameCol.setCell(new AbstractCell<String>() {
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
RuleDeleteTemplates ruleDeleteTemplates = GWT
.create(RuleDeleteTemplates.class);
sb.append(ruleDeleteTemplates.format(value));
}
});
ColumnConfig<RuleDescriptionData, String> descriptionCol = new ColumnConfig<RuleDescriptionData, String>( ColumnConfig<RuleDescriptionData, String> descriptionCol = new ColumnConfig<RuleDescriptionData, String>(
props.description(), 120, "Description"); props.description(), 120, "Description");
descriptionCol.setCell(new AbstractCell<String>() {
ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>( @Override
props.readableExpression(), 230, "Expression"); public void render(Context context, String value, SafeHtmlBuilder sb) {
RuleDeleteTemplates ruleDeleteTemplates = GWT
.create(RuleDeleteTemplates.class);
sb.append(ruleDeleteTemplates.format(value));
}
});
ColumnConfig<RuleDescriptionData, String> ownerCol = new ColumnConfig<RuleDescriptionData, String>(
props.ownerLogin(), 70, "Owner");
ownerCol.setCell(new AbstractCell<String>() {
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
RuleDeleteTemplates ruleDeleteTemplates = GWT
.create(RuleDeleteTemplates.class);
sb.append(ruleDeleteTemplates.format(value));
}
});
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>(); List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
l.add(nameCol); l.add(nameCol);
l.add(scopeCol);
l.add(descriptionCol); l.add(descriptionCol);
l.add(readableExpressionCol); l.add(ownerCol);
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(l); ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(l);
@ -193,7 +251,10 @@ public class RuleSharePanel extends FramedPanel {
grid.setColumnReordering(true); grid.setColumnReordering(true);
grid.setColumnResize(true); grid.setColumnResize(true);
grid.getView().setAutoExpandColumn(descriptionCol); grid.getView().setAutoExpandColumn(descriptionCol);
createContextMenu();
ToolBar toolBar = new ToolBar(); ToolBar toolBar = new ToolBar();
toolBar.add(grid); toolBar.add(grid);
toolBar.addStyleName(ThemeStyles.get().style().borderTop()); toolBar.addStyleName(ThemeStyles.get().style().borderTop());
@ -278,24 +339,24 @@ public class RuleSharePanel extends FramedPanel {
protected ArrayList<RuleDescriptionData> getSelectedItem() { protected ArrayList<RuleDescriptionData> getSelectedItem() {
ArrayList<RuleDescriptionData> templates = new ArrayList<RuleDescriptionData>(); ArrayList<RuleDescriptionData> rules = new ArrayList<RuleDescriptionData>();
for (RuleDescriptionData template : grid.getSelectionModel() for (RuleDescriptionData rule : grid.getSelectionModel()
.getSelectedItems()) { .getSelectedItems()) {
templates.add(template); rules.add(rule);
} }
return templates; return rules;
} }
protected void share() { protected void share() {
ArrayList<RuleDescriptionData> templates = getSelectedItem(); ArrayList<RuleDescriptionData> rules = getSelectedItem();
if (templates == null || templates.size() == 0) { if (rules == null || rules.size() == 0) {
UtilsGXT3.info("Attention", "Select the template"); UtilsGXT3.info("Attention", "Select the rule");
} else { } else {
RuleDescriptionData template = templates.get(0); RuleDescriptionData rule = rules.get(0);
Log.debug("templateShare: " + template); Log.debug("templateShare: " + rule);
//parent.templateShare(template); parent.ruleShare(rule);
} }
@ -332,5 +393,99 @@ public class RuleSharePanel extends FramedPanel {
return true; return true;
return false; 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<Item>() {
@Override
public void onSelection(SelectionEvent<Item> event) {
RuleDescriptionData selected = grid.getSelectionModel()
.getSelectedItem();
Log.debug(selected.toString());
requestInfo(selected);
}
});
contextMenu.add(infoItem);
grid.setContextMenu(contextMenu);
}
} }

View File

@ -106,11 +106,11 @@
<set-property name="log_SystemLogger" value="ENABLED" /> --> <set-property name="log_SystemLogger" value="ENABLED" /> -->
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED" /> --> <!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="ENABLED" /> -->
<set-property name="log_ConsoleLogger" value="DISABLED" /> <set-property name="log_ConsoleLogger" value="DISABLED" />
<set-property name="log_DivLogger" value="DISABLED" /> <set-property name="log_DivLogger" value="DISABLED" />
<set-property name="log_GWTLogger" value="DISABLED" /> <set-property name="log_GWTLogger" value="DISABLED" />
<set-property name="log_SystemLogger" value="DISABLED" /> <set-property name="log_SystemLogger" value="DISABLED" />
<!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="DISABLED" /> --> <!-- Not in GWT 2.6 <set-property name="log_FirebugLogger" value="DISABLED" /> -->
<!-- Specify the paths for translatable code --> <!-- Specify the paths for translatable code -->