Updated Rule

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@114089 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-04-15 16:59:49 +00:00
parent 03bab57cb4
commit afe3741a9e
6 changed files with 170 additions and 69 deletions

View File

@ -41,7 +41,7 @@ public class RuleToolBar {
private TextButton ruleOpenButton;
private TextButton ruleDeleteButton;
private TextButton ruleApplyButton;
private TextButton ruleShareButton;
//private TextButton ruleShareButton;
public RuleToolBar(EventBus eventBus) {
@ -68,8 +68,8 @@ public class RuleToolBar {
//templateGroup.disable();
toolBar.add(rulesGroup);
FlexTable templateLayout = new FlexTable();
rulesGroup.add(templateLayout);
FlexTable ruleLayout = new FlexTable();
rulesGroup.add(ruleLayout);
ruleNewButton = new TextButton(msgs.ruleNewButton(),
TabularDataResources.INSTANCE.ruleAdd32());
@ -86,8 +86,8 @@ public class RuleToolBar {
}
});
templateLayout.setWidget(0, 0, ruleNewButton);
templateLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
ruleLayout.setWidget(0, 0, ruleNewButton);
ruleLayout.getFlexCellFormatter().setRowSpan(0, 0, 2);
ruleOpenButton = new TextButton(msgs.ruleOpenButton(),
TabularDataResources.INSTANCE.ruleEdit32());
@ -104,8 +104,8 @@ public class RuleToolBar {
}
});
templateLayout.setWidget(0, 1, ruleOpenButton);
templateLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
ruleLayout.setWidget(0, 1, ruleOpenButton);
ruleLayout.getFlexCellFormatter().setRowSpan(0, 1, 2);
ruleDeleteButton = new TextButton(msgs.ruleDeleteButton(),
@ -123,8 +123,8 @@ public class RuleToolBar {
}
});
templateLayout.setWidget(0, 2, ruleDeleteButton);
templateLayout.getFlexCellFormatter().setRowSpan(0, 2, 2);
ruleLayout.setWidget(0, 2, ruleDeleteButton);
ruleLayout.getFlexCellFormatter().setRowSpan(0, 2, 2);
ruleApplyButton = new TextButton(msgs.ruleApplyButton(),
@ -141,10 +141,10 @@ public class RuleToolBar {
}
});
templateLayout.setWidget(0, 3, ruleApplyButton);
templateLayout.getFlexCellFormatter().setRowSpan(0, 3, 2);
ruleLayout.setWidget(0, 3, ruleApplyButton);
ruleLayout.getFlexCellFormatter().setRowSpan(0, 3, 2);
/*
ruleShareButton = new TextButton(msgs.ruleShareButton(),
TabularDataResources.INSTANCE.ruleShare32());
ruleShareButton.enable();
@ -159,10 +159,11 @@ public class RuleToolBar {
}
});
templateLayout.setWidget(0, 4, ruleShareButton);
templateLayout.getFlexCellFormatter().setRowSpan(0, 4, 2);
cleanCells(templateLayout.getElement());
ruleLayout.setWidget(0, 4, ruleShareButton);
ruleLayout.getFlexCellFormatter().setRowSpan(0, 4, 2);
*/
cleanCells(ruleLayout.getElement());
eventBus.addHandler(UIStateEvent.TYPE,
new UIStateEvent.UIStateHandler() {
@ -195,7 +196,7 @@ public class RuleToolBar {
ruleNewButton.enable();
ruleDeleteButton.enable();
ruleApplyButton.disable();
ruleShareButton.enable();
//ruleShareButton.enable();
break;
case TR_CLOSE:
case TR_READONLY:
@ -203,7 +204,7 @@ public class RuleToolBar {
ruleNewButton.enable();
ruleDeleteButton.enable();
ruleApplyButton.disable();
ruleShareButton.enable();
//ruleShareButton.enable();
break;
case TR_OPEN:
case TABLEUPDATE:
@ -212,14 +213,14 @@ public class RuleToolBar {
ruleNewButton.enable();
ruleDeleteButton.enable();
ruleApplyButton.enable();
ruleShareButton.enable();
//ruleShareButton.enable();
break;
case WIZARD_OPEN:
ruleOpenButton.disable();
ruleNewButton.disable();
ruleDeleteButton.disable();
ruleApplyButton.disable();
ruleShareButton.disable();
//ruleShareButton.disable();
break;
default:
break;

View File

@ -58,18 +58,19 @@ public class TabularDataRibbon {
con.add(modifyToolBar.getToolBar(), vldata);
ribbon.add(con, msgs.modify());
ruleToolBar = new RuleToolBar(eventBus);
con = new VerticalLayoutContainer();
con.add(ruleToolBar.getToolBar(), vldata);
ribbon.add(con, msgs.rule());
templateToolBar = new TemplateToolBar(eventBus);
con = new VerticalLayoutContainer();
con.add(templateToolBar.getToolBar(), vldata);
ribbon.add(con, msgs.template());
analyseToolBar = new AnalyseToolBar(eventBus);
con = new VerticalLayoutContainer();
con.add(analyseToolBar.getToolBar(), vldata);

View File

@ -15,16 +15,20 @@ 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.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
import com.sencha.gxt.core.client.IdentityValueProvider;
import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.core.client.XTemplates;
import com.sencha.gxt.core.client.resources.ThemeStyles;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.client.loader.RpcProxy;
@ -58,6 +62,12 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
public class RuleDeletePanel extends FramedPanel {
private static final String WIDTH = "630px";
private static final String HEIGHT = "520px";
private interface RuleDeleteTemplates extends XTemplates {
@XTemplate("<span title=\"{value}\">{value}</span>")
SafeHtml format(String value);
}
private EventBus eventBus;
private RuleDeleteDialog parent;
private TemplateDeleteSession templateDeleteSession;
@ -104,15 +114,57 @@ public class RuleDeletePanel extends FramedPanel {
ColumnConfig<RuleDescriptionData, String> nameCol = new ColumnConfig<RuleDescriptionData, String>(
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> descriptionCol = new ColumnConfig<RuleDescriptionData, String>(
props.description(), 120, "Description");
descriptionCol.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> ownerCol = new ColumnConfig<RuleDescriptionData, String>(
props.owner(), 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));
}
});
ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>(
props.readableExpression(), 230, "Expression");
props.readableExpression(), 160, "Expression");
readableExpressionCol.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, ?>>();
l.add(nameCol);
l.add(descriptionCol);
l.add(ownerCol);
l.add(readableExpressionCol);
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(

View File

@ -1,8 +1,10 @@
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.shared.rule.RuleDescriptionData;
import com.allen_sauer.gwt.log.client.Log;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.widget.core.client.Window;
import com.sencha.gxt.widget.core.client.event.SelectEvent;
@ -17,10 +19,11 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
public class RuleOpenDialog extends Window {
private static final String WIDTH = "720px";
private static final String HEIGHT = "530px";
private EventBus eventBus;
public RuleOpenDialog(EventBus eventBus) {
initWindow();
this.eventBus=eventBus;
RuleOpenPanel templateOpenPanel = new RuleOpenPanel(this,
eventBus);
add(templateOpenPanel);
@ -59,10 +62,17 @@ public class RuleOpenDialog extends Window {
hide();
}
public void ruleOpen(RuleDescriptionData ruleDescriptionData) {
close();
public void ruleEdit(RuleDescriptionData ruleDescriptionData) {
openRuleDialog(ruleDescriptionData);
}
private void openRuleDialog(RuleDescriptionData ruleDescriptionData) {
Log.debug("Request Open New Rule Dialog");
RuleDialog cfDialog = new RuleDialog(ruleDescriptionData,eventBus);
cfDialog.show();
}
}

View File

@ -14,16 +14,20 @@ 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.safehtml.shared.SafeHtml;
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.web.bindery.event.shared.EventBus;
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
import com.sencha.gxt.core.client.IdentityValueProvider;
import com.sencha.gxt.core.client.Style.SelectionMode;
import com.sencha.gxt.core.client.XTemplates;
import com.sencha.gxt.core.client.resources.ThemeStyles;
import com.sencha.gxt.core.client.util.Margins;
import com.sencha.gxt.data.client.loader.RpcProxy;
@ -63,12 +67,17 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
public class RuleOpenPanel extends FramedPanel {
private static final String WIDTH = "630px";
private static final String HEIGHT = "520px";
private interface RuleOpenTemplates extends XTemplates {
@XTemplate("<span title=\"{value}\">{value}</span>")
SafeHtml format(String value);
}
private EventBus eventBus;
private RuleOpenDialog parent;
private TextButton btnOpen;
private TextButton btnClose;
private ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>> loader;
private Grid<RuleDescriptionData> grid;
@ -103,25 +112,68 @@ public class RuleOpenPanel extends FramedPanel {
CheckBoxSelectionModel<RuleDescriptionData> sm = new CheckBoxSelectionModel<RuleDescriptionData>(
identity);
RuleDescriptionDataProperties props = GWT.create(RuleDescriptionDataProperties.class);
RuleDescriptionDataProperties props = GWT
.create(RuleDescriptionDataProperties.class);
ColumnConfig<RuleDescriptionData, String> nameCol = new ColumnConfig<RuleDescriptionData, String>(
props.name(), 120, "Name");
nameCol.setCell(new AbstractCell<String>() {
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
RuleOpenTemplates ruleOpenTemplates = GWT
.create(RuleOpenTemplates.class);
sb.append(ruleOpenTemplates.format(value));
}
});
ColumnConfig<RuleDescriptionData, String> descriptionCol = new ColumnConfig<RuleDescriptionData, String>(
props.description(), 120, "Description");
descriptionCol.setCell(new AbstractCell<String>() {
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
RuleOpenTemplates ruleOpenTemplates = GWT
.create(RuleOpenTemplates.class);
sb.append(ruleOpenTemplates.format(value));
}
});
ColumnConfig<RuleDescriptionData, String> ownerCol = new ColumnConfig<RuleDescriptionData, String>(
props.owner(), 70, "Owner");
ownerCol.setCell(new AbstractCell<String>() {
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
RuleOpenTemplates ruleOpenTemplates = GWT
.create(RuleOpenTemplates.class);
sb.append(ruleOpenTemplates.format(value));
}
});
ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>(
props.readableExpression(), 230, "Expression");
props.readableExpression(), 160, "Expression");
readableExpressionCol.setCell(new AbstractCell<String>() {
@Override
public void render(Context context, String value, SafeHtmlBuilder sb) {
RuleOpenTemplates ruleOpenTemplates = GWT
.create(RuleOpenTemplates.class);
sb.append(ruleOpenTemplates.format(value));
}
});
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
l.add(nameCol);
l.add(descriptionCol);
l.add(ownerCol);
l.add(readableExpressionCol);
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(l);
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(
l);
store = new ExtendedListStore<RuleDescriptionData>(props.id());
@ -149,7 +201,8 @@ public class RuleOpenPanel extends FramedPanel {
RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>>() {
public void load(ListLoadConfig loadConfig,
public void load(
ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
loadData(loadConfig, callback);
}
@ -201,15 +254,15 @@ public class RuleOpenPanel extends FramedPanel {
toolBar.addStyleName(ThemeStyles.get().style().borderTop());
toolBar.getElement().getStyle().setProperty("borderBottom", "none");
btnOpen = new TextButton("Open");
btnOpen = new TextButton("Edit");
btnOpen.setIcon(TabularDataResources.INSTANCE.ruleEdit());
btnOpen.setIconAlign(IconAlign.RIGHT);
btnOpen.setToolTip("Open");
btnOpen.setToolTip("Edit");
btnOpen.addSelectHandler(new SelectHandler() {
public void onSelect(SelectEvent event) {
Log.debug("Pressed Open");
open();
edit();
}
});
@ -226,8 +279,6 @@ public class RuleOpenPanel extends FramedPanel {
}
});
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
flowButton.setPack(BoxLayoutPack.CENTER);
@ -235,7 +286,6 @@ public class RuleOpenPanel extends FramedPanel {
BoxLayoutData boxLayoutData = new BoxLayoutData(new Margins(2, 4, 2, 4));
flowButton.add(btnOpen, boxLayoutData);
flowButton.add(btnClose, boxLayoutData);
VerticalLayoutContainer v = new VerticalLayoutContainer();
v.add(toolBarHead, new VerticalLayoutData(1, -1, new Margins(0)));
@ -249,8 +299,8 @@ public class RuleOpenPanel extends FramedPanel {
protected void loadData(ListLoadConfig loadConfig,
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
ExpressionServiceAsync.INSTANCE.getRules(RuleScopeType.COLUMN,
ExpressionServiceAsync.INSTANCE.getRules(RuleScopeType.COLUMN,
new AsyncCallback<ArrayList<RuleDescriptionData>>() {
@Override
@ -265,7 +315,7 @@ public class RuleOpenPanel extends FramedPanel {
"Error retrieving rules");
}
callback.onFailure(caught);
}
@Override
@ -273,38 +323,29 @@ public class RuleOpenPanel extends FramedPanel {
Log.trace("loaded " + result.size() + " Rules");
callback.onSuccess(new ListLoadResultBean<RuleDescriptionData>(
result));
}
});
}
protected ArrayList<RuleDescriptionData> getSelectedItem() {
ArrayList<RuleDescriptionData> templates = new ArrayList<RuleDescriptionData>();
for (RuleDescriptionData template : grid.getSelectionModel()
.getSelectedItems()) {
templates.add(template);
}
return templates;
protected RuleDescriptionData getSelectedItem() {
RuleDescriptionData template = grid.getSelectionModel().getSelectedItem();
return template;
}
protected void open() {
protected void edit() {
ArrayList<RuleDescriptionData> templates = getSelectedItem();
if (templates == null || templates.size() == 0) {
UtilsGXT3.info("Attention", "Select the template");
RuleDescriptionData rule = getSelectedItem();
if (rule == null ) {
UtilsGXT3.info("Attention", "Select the rule");
} else {
RuleDescriptionData template = templates.get(0);
Log.debug("templateOpenSession: " + template);
parent.ruleOpen(template);
parent.ruleEdit(rule);
}
}
protected void close() {
parent.close();
}

View File

@ -61,12 +61,12 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
public class TemplateOpenPanel extends FramedPanel {
private static final String WIDTH = "630px";
private static final String HEIGHT = "520px";
private EventBus eventBus;
private TemplateOpenDialog parent;
private TextButton btnOpen;
private TextButton btnClose;
private ListLoader<ListLoadConfig, ListLoadResult<TemplateData>> loader;
private Grid<TemplateData> grid;
@ -105,6 +105,7 @@ public class TemplateOpenPanel extends FramedPanel {
ColumnConfig<TemplateData, String> nameCol = new ColumnConfig<TemplateData, String>(
props.name(), 120, "Name");
ColumnConfig<TemplateData, String> categoryCol = new ColumnConfig<TemplateData, String>(
props.category(), 60, "Category");
@ -121,7 +122,7 @@ public class TemplateOpenPanel extends FramedPanel {
l.add(nameCol);
l.add(categoryCol);
l.add(ownerCol);
l.add(agencyCol);
l.add(agencyCol);
l.add(descriptionCol);
ColumnModel<TemplateData> cm = new ColumnModel<TemplateData>(l);
@ -229,8 +230,6 @@ public class TemplateOpenPanel extends FramedPanel {
}
});
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
flowButton.setPack(BoxLayoutPack.CENTER);
@ -238,7 +237,6 @@ public class TemplateOpenPanel extends FramedPanel {
BoxLayoutData boxLayoutData = new BoxLayoutData(new Margins(2, 4, 2, 4));
flowButton.add(btnOpen, boxLayoutData);
flowButton.add(btnClose, boxLayoutData);
VerticalLayoutContainer v = new VerticalLayoutContainer();
v.add(toolBarHead, new VerticalLayoutData(1, -1, new Margins(0)));
@ -303,8 +301,6 @@ public class TemplateOpenPanel extends FramedPanel {
}
protected void close() {
parent.close();
}