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 9ca52e8..8017a32 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
@@ -6,7 +6,7 @@ import java.util.List;
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
import org.gcube.portlets.user.td.columnwidget.client.properties.ColumnDataPropertiesCombo;
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
-import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataPropertiesCombo;
+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;
@@ -20,23 +20,22 @@ 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.TextCell;
+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.cell.core.client.form.ComboBoxCell.TriggerAction;
+import com.sencha.gxt.core.client.XTemplates;
import com.sencha.gxt.core.client.util.Margins;
-import com.sencha.gxt.data.client.loader.RpcProxy;
import com.sencha.gxt.data.shared.LabelProvider;
import com.sencha.gxt.data.shared.ListStore;
-import com.sencha.gxt.data.shared.loader.ListLoadConfig;
-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.dnd.core.client.GridDragSource;
+import com.sencha.gxt.dnd.core.client.GridDropTarget;
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;
@@ -48,11 +47,13 @@ import com.sencha.gxt.widget.core.client.container.VerticalLayoutContainer.Verti
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.ComboBox;
-import com.sencha.gxt.widget.core.client.form.DualListField;
-import com.sencha.gxt.widget.core.client.form.FieldSet;
-import com.sencha.gxt.widget.core.client.form.DualListField.Mode;
import com.sencha.gxt.widget.core.client.form.FieldLabel;
-import com.sencha.gxt.widget.core.client.form.validator.EmptyValidator;
+import com.sencha.gxt.widget.core.client.form.FieldSet;
+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.info.Info;
/**
@@ -62,26 +63,43 @@ import com.sencha.gxt.widget.core.client.info.Info;
*
*/
public class RuleApplyPanel extends FramedPanel {
+ private static final String RULES_GRID_HEIGHT = "184px";
+ private static final String SET_RULES = "SetRules";
+
+ interface RuleApplyTemplates extends XTemplates {
+ @XTemplate("{value}")
+ SafeHtml format(String value);
+ }
+
private static final String WIDTH = "630px";
private static final String HEIGHT = "520px";
+
private EventBus eventBus;
private RuleApplyDialog parent;
private TRId trId;
private ArrayList columns;
private ColumnData column;
-
+ private ArrayList applicableRules;
+ private ArrayList appliesRules;
+
+
private TextButton btnApply;
private TextButton btnClose;
-
private ComboBox comboColumns;
- private ListLoader> availableRulesLoader;
- private ListLoader> appliesRulesLoader;
- private DualListField rulesDualList;
+ private ListStore applicableRulesStore;
+ private Grid gridApplicableRules;
+ private ListStore appliesRulesStore;
+ private Grid gridAppliesRules;
+
+
- public RuleApplyPanel(RuleApplyDialog parent, TRId trId, EventBus eventBus) {
+ public RuleApplyPanel(RuleApplyDialog parent, TRId trId, EventBus eventBus) {
this.parent = parent;
this.trId = trId;
+ applicableRules=new ArrayList();
+ appliesRules=new ArrayList();
+
Log.debug("TemplateApplyPanel");
setWidth(WIDTH);
setHeight(HEIGHT);
@@ -140,15 +158,14 @@ public class RuleApplyPanel extends FramedPanel {
protected void create() {
Log.debug("Create RuleApplyPanel(): " + trId);
-
+
FieldSet configurationFieldSet = new FieldSet();
configurationFieldSet.setHeadingText("Configuration");
configurationFieldSet.setCollapsible(false);
-
- VerticalLayoutContainer configurationFieldSetLayout=new VerticalLayoutContainer();
+ VerticalLayoutContainer configurationFieldSetLayout = new VerticalLayoutContainer();
configurationFieldSet.add(configurationFieldSetLayout);
-
+
// Column Data
ColumnDataPropertiesCombo propsColumnData = GWT
.create(ColumnDataPropertiesCombo.class);
@@ -170,64 +187,152 @@ public class RuleApplyPanel extends FramedPanel {
comboColumns.setTriggerAction(TriggerAction.ALL);
FieldLabel comboColumnsLabel = new FieldLabel(comboColumns, "Column");
- configurationFieldSetLayout.add(comboColumnsLabel, new VerticalLayoutData(1, -1,
- new Margins(0)));
-
+ configurationFieldSetLayout.add(comboColumnsLabel,
+ new VerticalLayoutData(1, -1, new Margins(0)));
+
// Rules
- RuleDescriptionDataPropertiesCombo propsRules = GWT
- .create(RuleDescriptionDataPropertiesCombo.class);
+ // IdentityValueProvider identity = new
+ // IdentityValueProvider();
+ // CheckBoxSelectionModel sm = new
+ // CheckBoxSelectionModel(
+ // identity);
- ListStore availableRulesStore = new ListStore(
- propsRules.id());
-
- RpcProxy> availableRulesProxy = new RpcProxy>() {
+ RuleDescriptionDataProperties propsRules = GWT
+ .create(RuleDescriptionDataProperties.class);
- public void load(
- ListLoadConfig loadConfig,
- final AsyncCallback> callback) {
- loadAvaibleRules(loadConfig, callback);
+ 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));
}
- };
- availableRulesLoader = new ListLoader>(
- availableRulesProxy);
-
- availableRulesLoader.setRemoteSort(false);
- availableRulesLoader.addLoadHandler(new LoadResultListStoreBinding>(
- availableRulesStore) {
});
-
- ListStore appliesRulesStore = new ListStore(
- propsRules.id());
-
- RpcProxy> appliesRulesProxy = new RpcProxy>() {
+ ColumnConfig descriptionCol = new ColumnConfig(
+ propsRules.description(), 120, "Description");
+ descriptionCol.setCell(new AbstractCell() {
- public void load(
- ListLoadConfig loadConfig,
- final AsyncCallback> callback) {
- loadAppliesRules(loadConfig, callback);
+ @Override
+ public void render(Context context, String value, SafeHtmlBuilder sb) {
+ RuleApplyTemplates ruleApplyTemplates = GWT
+ .create(RuleApplyTemplates.class);
+ sb.append(ruleApplyTemplates.format(value));
}
- };
- appliesRulesLoader = new ListLoader>(
- appliesRulesProxy);
-
- appliesRulesLoader.setRemoteSort(false);
- appliesRulesLoader.addLoadHandler(new LoadResultListStoreBinding>(
- appliesRulesStore) {
});
+
+ 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());
- rulesDualList = new DualListField(
- availableRulesStore, appliesRulesStore, propsRules.nameProv(), new TextCell());
- rulesDualList.addValidator(new EmptyValidator>());
- rulesDualList.setEnableDnd(true);
- rulesDualList.setMode(Mode.INSERT);
+ // Applicable Rules
+ applicableRulesStore = new ListStore(
+ propsRules.id());
+
+ gridApplicableRules = new Grid(
+ applicableRulesStore, cm);
+ gridApplicableRules.setHeight(RULES_GRID_HEIGHT);
+ gridApplicableRules.getView().setStripeRows(true);
+ gridApplicableRules.getView().setColumnLines(true);
+ gridApplicableRules.getView().setAutoFill(true);
+ gridApplicableRules.setBorders(false);
+ gridApplicableRules.setLoadMask(true);
+ gridApplicableRules.setColumnReordering(true);
+ gridApplicableRules.setColumnResize(true);
+ gridApplicableRules.getView().setAutoExpandColumn(descriptionCol);
- FieldLabel ruleDualListLabel = new FieldLabel(rulesDualList, "Rules");
- configurationFieldSetLayout.add(ruleDualListLabel, new VerticalLayoutData(1, -1,
- new Margins(0)));
+ GridFilters filtersApplicableRules = new GridFilters();
+ filtersApplicableRules.initPlugin(gridApplicableRules);
+ filtersApplicableRules.setLocal(true);
+ filtersApplicableRules.addFilter(nameFilter);
+ filtersApplicableRules.addFilter(descriptionFilter);
+
+
+ // Applies Rules
+ appliesRulesStore = new ListStore(
+ propsRules.id());
+
+ gridAppliesRules = new Grid(
+ appliesRulesStore, cm);
+ gridAppliesRules.setHeight(RULES_GRID_HEIGHT);
+ gridAppliesRules.getView().setStripeRows(true);
+ gridAppliesRules.getView().setColumnLines(true);
+ gridAppliesRules.getView().setAutoFill(true);
+ gridAppliesRules.setBorders(false);
+ gridAppliesRules.setLoadMask(true);
+ gridAppliesRules.setColumnReordering(true);
+ gridAppliesRules.setColumnResize(true);
+ gridAppliesRules.getView().setAutoExpandColumn(descriptionCol);
+
+ GridFilters filtersAppliesRules = new GridFilters();
+ filtersAppliesRules.initPlugin(gridAppliesRules);
+ filtersAppliesRules.setLocal(true);
+ filtersAppliesRules.addFilter(nameFilter);
+ filtersAppliesRules.addFilter(descriptionFilter);
+
+ //
+
+
+ new GridDragSource(gridApplicableRules).setGroup(SET_RULES);
+ new GridDragSource(gridAppliesRules).setGroup(SET_RULES);
+
+ new GridDropTarget(gridApplicableRules).setGroup(SET_RULES);
+ new GridDropTarget(gridAppliesRules).setGroup(SET_RULES);
+
+
+
+
+ //
+ FieldLabel rulesApplicableLabel = new FieldLabel(gridApplicableRules, "Applicable Rules");
+
+ configurationFieldSetLayout.add(rulesApplicableLabel,
+ new VerticalLayoutData(1, -1, new Margins(0)));
+
+
+ FieldLabel rulesAppliesLabel = new FieldLabel(gridAppliesRules, "Applies Rules");
+
+ configurationFieldSetLayout.add(rulesAppliesLabel,
+ new VerticalLayoutData(1, -1, new Margins(0)));
+
// Button
btnApply = new TextButton("Apply");
@@ -263,14 +368,16 @@ public class RuleApplyPanel extends FramedPanel {
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
VerticalLayoutContainer v = new VerticalLayoutContainer();
- v.add(configurationFieldSet, new VerticalLayoutData(-1, -1, new Margins(0)));
+ v.add(configurationFieldSet, new VerticalLayoutData(-1, -1,
+ new Margins(0)));
v.add(flowButton,
new VerticalLayoutData(1, 36, new Margins(5, 2, 5, 2)));
add(v);
}
- private void addHandlersForComboColumn(final LabelProvider labelProvider) {
+ private void addHandlersForComboColumn(
+ final LabelProvider labelProvider) {
comboColumns.addSelectionHandler(new SelectionHandler() {
public void onSelection(SelectionEvent event) {
Info.display(
@@ -281,21 +388,50 @@ public class RuleApplyPanel extends FramedPanel {
.getSelectedItem()) + "!"));
Log.debug("ComboColumn selected: " + event.getSelectedItem());
ColumnData columnData = event.getSelectedItem();
- updateRulesInDualList(columnData);
+ updateRulesInGrids(columnData);
}
});
}
- protected void updateRulesInDualList(ColumnData columnData) {
- column=columnData;
- availableRulesLoader.load();
+ protected void updateRulesInGrids(ColumnData columnData) {
+ column = columnData;
+ getApplicableBaseColumnRules();
+
}
- protected void loadAvaibleRules(ListLoadConfig loadConfig,
- final AsyncCallback> callback) {
+ protected void getApplicableBaseColumnRules(){
+ ExpressionServiceAsync.INSTANCE.getApplicableBaseColumnRules(column,
+ new AsyncCallback>() {
+
+ @Override
+ public void onFailure(Throwable caught) {
+ if (caught instanceof TDGWTSessionExpiredException) {
+ eventBus.fireEvent(new SessionExpiredEvent(
+ SessionExpiredType.EXPIREDONSERVER));
+ } else {
+ Log.error("Error retrieving applicable rules:"
+ + caught.getLocalizedMessage());
+ UtilsGXT3.alert("Error retrieving rules",
+ "Error retrieving applicable rules");
+ }
+
+ }
+
+ @Override
+ public void onSuccess(ArrayList result) {
+ Log.trace("loaded " + result.size() + " Rules");
+ applicableRules=result;
+ getAppliesBaseColumnRules();
+
+ }
+ });
+
+ }
+
+ protected void getAppliesBaseColumnRules(){
ExpressionServiceAsync.INSTANCE.getApplicableBaseColumnRules(column,
new AsyncCallback>() {
@@ -311,71 +447,42 @@ public class RuleApplyPanel extends FramedPanel {
UtilsGXT3.alert("Error retrieving rules",
"Error retrieving applicable rules");
}
- callback.onFailure(caught);
+
}
@Override
public void onSuccess(ArrayList result) {
Log.trace("loaded " + result.size() + " Rules");
- callback.onSuccess(new ListLoadResultBean(
- result));
+ appliesRules=result;
+ applicableRulesStore.clear();
+ applicableRulesStore.addAll(applicableRules);
+ appliesRulesStore.clear();
+ appliesRulesStore.addAll(appliesRules);
+ forceLayout();
}
});
}
-
- protected void loadAppliesRules(ListLoadConfig loadConfig,
- final AsyncCallback> callback) {
-
- ExpressionServiceAsync.INSTANCE.getApplicableBaseColumnRules(column,
- new AsyncCallback>() {
-
- @Override
- public void onFailure(Throwable caught) {
- if (caught instanceof TDGWTSessionExpiredException) {
- eventBus.fireEvent(new SessionExpiredEvent(
- SessionExpiredType.EXPIREDONSERVER));
- } else {
- Log.error("Error retrieving applicable rules:"
- + caught.getLocalizedMessage());
- UtilsGXT3.alert("Error retrieving rules",
- "Error retrieving applicable rules");
- }
- callback.onFailure(caught);
-
- }
-
- @Override
- public void onSuccess(ArrayList result) {
- Log.trace("loaded " + result.size() + " Rules");
- callback.onSuccess(new ListLoadResultBean(
- result));
-
- }
- });
-
- }
-
-
protected ArrayList getSelectedItems() {
- List selectedItems=rulesDualList.getValue();
- ArrayList rulesSelected=new ArrayList(selectedItems);
+ List selectedItems = appliesRulesStore.getAll();
+ ArrayList rulesSelected = new ArrayList(
+ selectedItems);
return rulesSelected;
}
protected void apply() {
ArrayList selectedRules = getSelectedItems();
- ColumnData column=comboColumns.getCurrentValue();
- if(column!=null){
- RulesOnColumnApplySession rulesOnColumnApplySession=new RulesOnColumnApplySession(trId, column, selectedRules);
+ ColumnData column = comboColumns.getCurrentValue();
+ if (column != null) {
+ RulesOnColumnApplySession rulesOnColumnApplySession = new RulesOnColumnApplySession(
+ trId, column, selectedRules);
parent.applyRules(rulesOnColumnApplySession);
} else {
Log.error("No column selected");
- UtilsGXT3.alert("Attention",
- "Select a column");
+ UtilsGXT3.alert("Attention", "Select a column");
}
}
@@ -383,6 +490,4 @@ public class RuleApplyPanel extends FramedPanel {
parent.close();
}
-
-
}
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 f480caa..29aa9a2 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
@@ -20,6 +20,8 @@ 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.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -40,21 +42,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.FramedPanel;
+import com.sencha.gxt.widget.core.client.Dialog.PredefinedButton;
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.MarginData;
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign;
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;
@@ -242,7 +253,9 @@ public class RuleDeletePanel 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());
@@ -322,23 +335,6 @@ public class RuleDeletePanel extends FramedPanel {
});
}
- /*
- * protected void setMenu() { Menu contextMenu = new Menu();
- *
- * MenuItem deleteTemplateItem = new MenuItem("Delete");
- * deleteTemplateItem.setId("DeleteTemplate");
- * deleteTemplateItem.setIcon(ResourceBundle.INSTANCE.removeTemplate());
- * deleteTemplateItem.addSelectionHandler(new SelectionHandler- () {
- *
- * @Override public void onSelection(SelectionEvent
- event) {
- * Log.debug("Delete Template"); RuleDescriptionData templateDesc =
- * getSelectedItem();
- *
- * } });
- *
- * grid.setContextMenu(contextMenu); }
- */
-
protected ArrayList getSelectedItem() {
ArrayList rules = new ArrayList();
for (RuleDescriptionData rule : grid.getSelectionModel()
@@ -392,4 +388,84 @@ public class RuleDeletePanel extends FramedPanel {
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)));
+
+
+ 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() {
+ 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/java/org/gcube/portlets/user/td/client/rule/RuleOpenDialog.java b/src/main/java/org/gcube/portlets/user/td/client/rule/RuleOpenDialog.java
index 5d8a6e5..ac1f9d0 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
@@ -2,6 +2,8 @@ package org.gcube.portlets.user.td.client.rule;
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
import org.gcube.portlets.user.td.expressionwidget.client.RuleDialog;
+import org.gcube.portlets.user.td.expressionwidget.client.notification.RuleDialogNotification;
+import org.gcube.portlets.user.td.expressionwidget.client.notification.RuleDialogNotification.RuleDialogNotificationListener;
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
import com.allen_sauer.gwt.log.client.Log;
@@ -16,17 +18,18 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it
*
*/
-public class RuleOpenDialog extends Window {
+public class RuleOpenDialog extends Window implements RuleDialogNotificationListener {
private static final String WIDTH = "720px";
private static final String HEIGHT = "530px";
private EventBus eventBus;
+ private RuleOpenPanel rulesOpenPanel;
public RuleOpenDialog(EventBus eventBus) {
initWindow();
this.eventBus=eventBus;
- RuleOpenPanel templateOpenPanel = new RuleOpenPanel(this,
+ rulesOpenPanel= new RuleOpenPanel(this,
eventBus);
- add(templateOpenPanel);
+ add(rulesOpenPanel);
}
protected void initWindow() {
@@ -67,12 +70,33 @@ public class RuleOpenDialog extends Window {
}
- private void openRuleDialog(RuleDescriptionData ruleDescriptionData) {
+ protected void openRuleDialog(RuleDescriptionData ruleDescriptionData) {
Log.debug("Request Open New Rule Dialog");
RuleDialog cfDialog = new RuleDialog(ruleDescriptionData,eventBus);
+ cfDialog.addRuleDialogNotificationListener(this);
cfDialog.show();
}
+
+ @Override
+ public void onNotification(RuleDialogNotification ruleDialogNotification) {
+ rulesOpenPanel.gridReload();
+
+ }
+
+ @Override
+ public void aborted() {
+
+ }
+
+ @Override
+ public void failed(Throwable throwable) {
+ Log.debug("Error in edit rule: "+throwable.getLocalizedMessage());
+
+ }
+
+
+
}
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 ca94c52..2969307 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
@@ -20,6 +20,8 @@ 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.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.rpc.AsyncCallback;
@@ -40,21 +42,31 @@ 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.ContentPanel;
+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;
@@ -139,7 +151,7 @@ public class RuleOpenPanel extends FramedPanel {
sb.append(ruleOpenTemplates.format(value));
}
});
-
+
ColumnConfig ownerCol = new ColumnConfig(
props.owner(), 70, "Owner");
ownerCol.setCell(new AbstractCell() {
@@ -151,7 +163,6 @@ public class RuleOpenPanel extends FramedPanel {
sb.append(ruleOpenTemplates.format(value));
}
});
-
ColumnConfig readableExpressionCol = new ColumnConfig(
props.readableExpression(), 160, "Expression");
@@ -249,6 +260,8 @@ public class RuleOpenPanel extends FramedPanel {
grid.setColumnResize(true);
grid.getView().setAutoExpandColumn(descriptionCol);
+ createContextMenu();
+
ToolBar toolBar = new ToolBar();
toolBar.add(grid);
toolBar.addStyleName(ThemeStyles.get().style().borderTop());
@@ -320,7 +333,11 @@ public class RuleOpenPanel extends FramedPanel {
@Override
public void onSuccess(ArrayList result) {
- Log.trace("loaded " + result.size() + " Rules");
+ if (result != null) {
+ Log.trace("loaded " + result.size() + " Rules");
+ } else {
+ Log.trace("get Rules return: null");
+ }
callback.onSuccess(new ListLoadResultBean(
result));
@@ -330,14 +347,15 @@ public class RuleOpenPanel extends FramedPanel {
}
protected RuleDescriptionData getSelectedItem() {
- RuleDescriptionData template = grid.getSelectionModel().getSelectedItem();
+ RuleDescriptionData template = grid.getSelectionModel()
+ .getSelectedItem();
return template;
}
protected void edit() {
RuleDescriptionData rule = getSelectedItem();
- if (rule == null ) {
+ if (rule == null) {
UtilsGXT3.info("Attention", "Select the rule");
} else {
parent.ruleEdit(rule);
@@ -378,4 +396,82 @@ public class RuleOpenPanel extends FramedPanel {
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)));
+
+
+ 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() {
+ 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 b6e2e51..47558ce 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 @@
-->
-
+
-
+