81: Allow the creation and use of expressions on multi column in TDM portlet
Task-Url: https://support.d4science.org/issues/81 Updated apply rule on table git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-rule-widget@115074 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
70fd65a970
commit
553d88c52d
|
@ -15,7 +15,7 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
|||
*
|
||||
*/
|
||||
public class RuleActiveDialog extends Window {
|
||||
private static final String WIDTH = "720px";
|
||||
private static final String WIDTH = "770px";
|
||||
private static final String HEIGHT = "428px";
|
||||
public RuleActiveDialog(TRId trId, EventBus eventBus) {
|
||||
initWindow();
|
||||
|
|
|
@ -62,12 +62,13 @@ import com.sencha.gxt.widget.core.client.menu.MenuItem;
|
|||
*
|
||||
*/
|
||||
public class RuleActivePanel extends FramedPanel {
|
||||
private static final String WIDTH = "760px";
|
||||
private static final String HEIGHT = "418px";
|
||||
private static final int RULE_ON_COLUMN_FIELDSET_HEIGHT = 348;
|
||||
private static final String RULES_GRID_HEIGHT = "102px";
|
||||
private static final String WIDTH = "630px";
|
||||
private static final String HEIGHT = "418px";
|
||||
|
||||
interface RuleApplyTemplates extends XTemplates {
|
||||
|
||||
|
||||
interface RuleActiveTemplates extends XTemplates {
|
||||
@XTemplate("<span title=\"{value}\">{value}</span>")
|
||||
SafeHtml format(String value);
|
||||
}
|
||||
|
@ -220,9 +221,9 @@ public class RuleActivePanel extends FramedPanel {
|
|||
|
||||
@Override
|
||||
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
||||
RuleApplyTemplates ruleApplyTemplates = GWT
|
||||
.create(RuleApplyTemplates.class);
|
||||
sb.append(ruleApplyTemplates.format(value));
|
||||
RuleActiveTemplates ruleActiveTemplates = GWT
|
||||
.create(RuleActiveTemplates.class);
|
||||
sb.append(ruleActiveTemplates.format(value));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -232,9 +233,9 @@ public class RuleActivePanel extends FramedPanel {
|
|||
|
||||
@Override
|
||||
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
||||
RuleApplyTemplates ruleApplyTemplates = GWT
|
||||
.create(RuleApplyTemplates.class);
|
||||
sb.append(ruleApplyTemplates.format(value));
|
||||
RuleActiveTemplates ruleActiveTemplates = GWT
|
||||
.create(RuleActiveTemplates.class);
|
||||
sb.append(ruleActiveTemplates.format(value));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -244,33 +245,32 @@ public class RuleActivePanel extends FramedPanel {
|
|||
|
||||
@Override
|
||||
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
||||
RuleApplyTemplates ruleApplyTemplates = GWT
|
||||
.create(RuleApplyTemplates.class);
|
||||
sb.append(ruleApplyTemplates.format(value));
|
||||
RuleActiveTemplates ruleActiveTemplates = GWT
|
||||
.create(RuleActiveTemplates.class);
|
||||
sb.append(ruleActiveTemplates.format(value));
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>(
|
||||
propsRules.readableExpression(), 160, "Expression");
|
||||
ColumnConfig<RuleDescriptionData, String> creationDateCol = new ColumnConfig<RuleDescriptionData, String>(
|
||||
propsRules.creationDate(), 50, "Creation Date");
|
||||
|
||||
|
||||
readableExpressionCol.setCell(new AbstractCell<String>() {
|
||||
creationDateCol.setCell(new AbstractCell<String>() {
|
||||
|
||||
@Override
|
||||
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
||||
RuleApplyTemplates ruleApplyTemplates = GWT
|
||||
.create(RuleApplyTemplates.class);
|
||||
sb.append(ruleApplyTemplates.format(value));
|
||||
RuleActiveTemplates ruleActiveTemplates = GWT
|
||||
.create(RuleActiveTemplates .class);
|
||||
sb.append(ruleActiveTemplates.format(value));
|
||||
}
|
||||
});*/
|
||||
});
|
||||
|
||||
|
||||
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
|
||||
l.add(nameCol);
|
||||
l.add(descriptionCol);
|
||||
l.add(ownerCol);
|
||||
//l.add(readableExpressionCol);
|
||||
|
||||
l.add(creationDateCol);
|
||||
|
||||
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(
|
||||
l);
|
||||
|
||||
|
|
|
@ -33,7 +33,7 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
|||
*/
|
||||
public class RuleApplyDialog extends Window implements
|
||||
MonitorDialogListener {
|
||||
private static final String WIDTH = "720px";
|
||||
private static final String WIDTH = "770px";
|
||||
private static final String HEIGHT = "530px";
|
||||
private EventBus eventBus;
|
||||
|
||||
|
|
|
@ -69,6 +69,8 @@ import com.sencha.gxt.widget.core.client.menu.MenuItem;
|
|||
*
|
||||
*/
|
||||
public class RuleApplyPanel extends FramedPanel {
|
||||
private static final String WIDTH = "760px";
|
||||
private static final String HEIGHT = "520px";
|
||||
private static final String RULE_TIP = "<p>Tip.: Use drag and drop in order to change selected rules.</p>";
|
||||
private static final String RULES_GRID_HEIGHT = "184px";
|
||||
private static final String SET_RULES = "SetRules";
|
||||
|
@ -78,9 +80,6 @@ public class RuleApplyPanel extends FramedPanel {
|
|||
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;
|
||||
|
@ -236,13 +235,27 @@ public class RuleApplyPanel extends FramedPanel {
|
|||
sb.append(ruleApplyTemplates.format(value));
|
||||
}
|
||||
});
|
||||
|
||||
ColumnConfig<RuleDescriptionData, String> creationDateCol = new ColumnConfig<RuleDescriptionData, String>(
|
||||
propsRules.creationDate(), 50, "Creation Date");
|
||||
|
||||
creationDateCol.setCell(new AbstractCell<String>() {
|
||||
|
||||
@Override
|
||||
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
||||
RuleApplyTemplates ruleApplyTemplates = GWT
|
||||
.create(RuleApplyTemplates .class);
|
||||
sb.append(ruleApplyTemplates.format(value));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
|
||||
l.add(nameCol);
|
||||
l.add(descriptionCol);
|
||||
l.add(ownerCol);
|
||||
// l.add(readableExpressionCol);
|
||||
|
||||
l.add(creationDateCol);
|
||||
|
||||
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(
|
||||
l);
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
|||
*
|
||||
*/
|
||||
public class RuleDeleteDialog extends Window {
|
||||
private static final String WIDTH = "720px";
|
||||
private static final String WIDTH = "770px";
|
||||
private static final String HEIGHT = "530px";
|
||||
private EventBus eventBus;
|
||||
private RuleDeletePanel ruleDeletePanel;
|
||||
|
|
|
@ -64,9 +64,10 @@ import com.sencha.gxt.widget.core.client.toolbar.LabelToolItem;
|
|||
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
||||
|
||||
public class RuleDeletePanel extends FramedPanel {
|
||||
private static final String WIDTH = "630px";
|
||||
private static final String WIDTH = "760px";
|
||||
private static final String HEIGHT = "520px";
|
||||
|
||||
private static final String GRID_HEIGHT = "384px";
|
||||
|
||||
interface RuleDeleteTemplates extends XTemplates {
|
||||
@XTemplate("<span title=\"{value}\">{value}</span>")
|
||||
SafeHtml format(String value);
|
||||
|
@ -164,27 +165,27 @@ public class RuleDeletePanel extends FramedPanel {
|
|||
}
|
||||
});
|
||||
|
||||
/*
|
||||
ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>(
|
||||
props.readableExpression(), 160, "Expression");
|
||||
ColumnConfig<RuleDescriptionData, String> creationDateCol = new ColumnConfig<RuleDescriptionData, String>(
|
||||
props.creationDate(), 50, "Creation Date");
|
||||
|
||||
readableExpressionCol.setCell(new AbstractCell<String>() {
|
||||
creationDateCol.setCell(new AbstractCell<String>() {
|
||||
|
||||
@Override
|
||||
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
||||
RuleDeleteTemplates ruleDeleteTemplates = GWT
|
||||
.create(RuleDeleteTemplates.class);
|
||||
RuleDeleteTemplates ruleDeleteTemplates = GWT
|
||||
.create(RuleDeleteTemplates .class);
|
||||
sb.append(ruleDeleteTemplates.format(value));
|
||||
}
|
||||
});*/
|
||||
});
|
||||
|
||||
|
||||
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
|
||||
l.add(nameCol);
|
||||
l.add(scopeCol);
|
||||
l.add(descriptionCol);
|
||||
l.add(ownerCol);
|
||||
//l.add(readableExpressionCol);
|
||||
|
||||
l.add(creationDateCol);
|
||||
|
||||
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(
|
||||
l);
|
||||
|
||||
|
@ -252,7 +253,7 @@ public class RuleDeletePanel extends FramedPanel {
|
|||
sm.setSelectionMode(SelectionMode.MULTI);
|
||||
grid.setLoader(loader);
|
||||
grid.setSelectionModel(sm);
|
||||
grid.setHeight("384px");
|
||||
grid.setHeight(GRID_HEIGHT);
|
||||
grid.getView().setStripeRows(true);
|
||||
grid.getView().setColumnLines(true);
|
||||
grid.getView().setAutoFill(true);
|
||||
|
|
|
@ -14,35 +14,33 @@ 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;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class RuleInfoDialog extends Dialog {
|
||||
public class RuleInfoDialog extends Dialog {
|
||||
RuleDescriptionData ruleDescriptionData;
|
||||
|
||||
public RuleInfoDialog(RuleDescriptionData ruleDescriptionData){
|
||||
this.ruleDescriptionData=ruleDescriptionData;
|
||||
|
||||
public RuleInfoDialog(RuleDescriptionData ruleDescriptionData) {
|
||||
this.ruleDescriptionData = ruleDescriptionData;
|
||||
initWindow();
|
||||
create();
|
||||
}
|
||||
|
||||
protected void initWindow(){
|
||||
|
||||
protected void initWindow() {
|
||||
setModal(true);
|
||||
setHeadingText("Info Rule");
|
||||
getHeader().setIcon(
|
||||
ResourceBundle.INSTANCE.information());
|
||||
getHeader().setIcon(ResourceBundle.INSTANCE.information());
|
||||
setPredefinedButtons(PredefinedButton.OK);
|
||||
setHideOnButtonClick(true);
|
||||
setButtonAlign(BoxLayoutPack.CENTER);
|
||||
setWidth(500);
|
||||
|
||||
}
|
||||
|
||||
protected void create(){
|
||||
|
||||
protected void create() {
|
||||
FieldSet configurationFieldSet = new FieldSet();
|
||||
configurationFieldSet.setHeadingText("Configuration");
|
||||
configurationFieldSet.setCollapsible(false);
|
||||
|
@ -81,6 +79,14 @@ public class RuleInfoDialog extends Dialog {
|
|||
configurationFieldSetLayout.add(ruleOwnerLabel, new VerticalLayoutData(
|
||||
1, -1, new Margins(0)));
|
||||
|
||||
TextField ruleCreationDate = new TextField();
|
||||
ruleCreationDate.setValue(ruleDescriptionData.getOwnerLogin());
|
||||
ruleCreationDate.setReadOnly(true);
|
||||
FieldLabel ruleCreationDateLabel = new FieldLabel(ruleCreationDate,
|
||||
"Creation Date");
|
||||
configurationFieldSetLayout.add(ruleCreationDateLabel,
|
||||
new VerticalLayoutData(1, -1, new Margins(0)));
|
||||
|
||||
TextArea ruleExpression = new TextArea();
|
||||
ruleExpression.setValue(ruleDescriptionData.getReadableExpression());
|
||||
ruleExpression.setReadOnly(true);
|
||||
|
@ -91,8 +97,7 @@ public class RuleInfoDialog extends Dialog {
|
|||
new VerticalLayoutData(1, -1, new Margins(0)));
|
||||
|
||||
add(configurationFieldSet, new MarginData(0));
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
|||
*
|
||||
*/
|
||||
public class RuleOpenDialog extends Window implements RuleEditDialogNotificationListener {
|
||||
private static final String WIDTH = "720px";
|
||||
private static final String WIDTH = "770px";
|
||||
private static final String HEIGHT = "530px";
|
||||
private RuleOpenPanel rulesOpenPanel;
|
||||
private EventBus eventBus;
|
||||
|
|
|
@ -70,9 +70,10 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
|||
*
|
||||
*/
|
||||
public class RuleOpenPanel extends FramedPanel {
|
||||
private static final String WIDTH = "630px";
|
||||
private static final String WIDTH = "760px";
|
||||
private static final String HEIGHT = "520px";
|
||||
|
||||
private static final String GRID_HEIGHT = "384px";
|
||||
|
||||
interface RuleOpenTemplates extends XTemplates {
|
||||
@XTemplate("<span title=\"{value}\">{value}</span>")
|
||||
SafeHtml format(String value);
|
||||
|
@ -170,26 +171,25 @@ public class RuleOpenPanel extends FramedPanel {
|
|||
}
|
||||
});
|
||||
|
||||
/*
|
||||
ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>(
|
||||
props.readableExpression(), 160, "Expression");
|
||||
ColumnConfig<RuleDescriptionData, String> creationDateCol = new ColumnConfig<RuleDescriptionData, String>(
|
||||
props.creationDate(), 50, "Creation Date");
|
||||
|
||||
readableExpressionCol.setCell(new AbstractCell<String>() {
|
||||
creationDateCol.setCell(new AbstractCell<String>() {
|
||||
|
||||
@Override
|
||||
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
||||
RuleOpenTemplates ruleOpenTemplates = GWT
|
||||
.create(RuleOpenTemplates.class);
|
||||
RuleOpenTemplates ruleOpenTemplates = GWT
|
||||
.create(RuleOpenTemplates .class);
|
||||
sb.append(ruleOpenTemplates.format(value));
|
||||
}
|
||||
});*/
|
||||
});
|
||||
|
||||
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
|
||||
l.add(nameCol);
|
||||
l.add(scopeCol);
|
||||
l.add(descriptionCol);
|
||||
l.add(ownerCol);
|
||||
//l.add(readableExpressionCol);
|
||||
l.add(creationDateCol);
|
||||
|
||||
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(
|
||||
l);
|
||||
|
@ -258,7 +258,7 @@ public class RuleOpenPanel extends FramedPanel {
|
|||
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||
grid.setLoader(loader);
|
||||
grid.setSelectionModel(sm);
|
||||
grid.setHeight("384px");
|
||||
grid.setHeight(GRID_HEIGHT);
|
||||
grid.getView().setStripeRows(true);
|
||||
grid.getView().setColumnLines(true);
|
||||
grid.getView().setAutoFill(true);
|
||||
|
|
|
@ -17,7 +17,7 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
|||
*
|
||||
*/
|
||||
public class RuleShareDialog extends Window {
|
||||
private static final String WIDTH = "720px";
|
||||
private static final String WIDTH = "770px";
|
||||
private static final String HEIGHT = "530px";
|
||||
|
||||
private EventBus eventBus;
|
||||
|
|
|
@ -8,7 +8,6 @@ import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDa
|
|||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleScopeType;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.rulewidget.client.RuleDeletePanel.RuleDeleteTemplates;
|
||||
import org.gcube.portlets.user.td.rulewidget.client.resources.ResourceBundle;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
|
@ -23,12 +22,14 @@ 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;
|
||||
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;
|
||||
|
@ -69,8 +70,10 @@ import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
|||
*
|
||||
*/
|
||||
public class RuleSharePanel extends FramedPanel {
|
||||
private static final String WIDTH = "630px";
|
||||
private static final String WIDTH = "760px";
|
||||
private static final String HEIGHT = "520px";
|
||||
private static final String GRID_HEIGHT = "384px";
|
||||
|
||||
private EventBus eventBus;
|
||||
private RuleShareDialog parent;
|
||||
|
||||
|
@ -80,7 +83,12 @@ public class RuleSharePanel extends FramedPanel {
|
|||
private ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>> loader;
|
||||
private Grid<RuleDescriptionData> grid;
|
||||
private ExtendedListStore<RuleDescriptionData> store;
|
||||
|
||||
|
||||
interface RuleShareTemplates extends XTemplates {
|
||||
@XTemplate("<span title=\"{value}\">{value}</span>")
|
||||
SafeHtml format(String value);
|
||||
}
|
||||
|
||||
public RuleSharePanel(RuleShareDialog parent, EventBus eventBus) {
|
||||
this.parent = parent;
|
||||
Log.debug("RuleSharePanel");
|
||||
|
@ -120,9 +128,9 @@ public class RuleSharePanel extends FramedPanel {
|
|||
|
||||
@Override
|
||||
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
||||
RuleDeleteTemplates ruleDeleteTemplates = GWT
|
||||
.create(RuleDeleteTemplates.class);
|
||||
sb.append(ruleDeleteTemplates.format(value));
|
||||
RuleShareTemplates ruleShareTemplates = GWT
|
||||
.create(RuleShareTemplates.class);
|
||||
sb.append(ruleShareTemplates.format(value));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -133,9 +141,9 @@ public class RuleSharePanel extends FramedPanel {
|
|||
|
||||
@Override
|
||||
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
||||
RuleDeleteTemplates ruleDeleteTemplates = GWT
|
||||
.create(RuleDeleteTemplates.class);
|
||||
sb.append(ruleDeleteTemplates.format(value));
|
||||
RuleShareTemplates ruleShareTemplates = GWT
|
||||
.create(RuleShareTemplates.class);
|
||||
sb.append(ruleShareTemplates.format(value));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -145,9 +153,9 @@ public class RuleSharePanel extends FramedPanel {
|
|||
|
||||
@Override
|
||||
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
||||
RuleDeleteTemplates ruleDeleteTemplates = GWT
|
||||
.create(RuleDeleteTemplates.class);
|
||||
sb.append(ruleDeleteTemplates.format(value));
|
||||
RuleShareTemplates ruleShareTemplates = GWT
|
||||
.create(RuleShareTemplates.class);
|
||||
sb.append(ruleShareTemplates.format(value));
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -157,18 +165,32 @@ public class RuleSharePanel extends FramedPanel {
|
|||
|
||||
@Override
|
||||
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
||||
RuleDeleteTemplates ruleDeleteTemplates = GWT
|
||||
.create(RuleDeleteTemplates.class);
|
||||
sb.append(ruleDeleteTemplates.format(value));
|
||||
RuleShareTemplates ruleShareTemplates = GWT
|
||||
.create(RuleShareTemplates.class);
|
||||
sb.append(ruleShareTemplates.format(value));
|
||||
}
|
||||
});
|
||||
|
||||
ColumnConfig<RuleDescriptionData, String> creationDateCol = new ColumnConfig<RuleDescriptionData, String>(
|
||||
props.creationDate(), 50, "Creation Date");
|
||||
|
||||
creationDateCol.setCell(new AbstractCell<String>() {
|
||||
|
||||
@Override
|
||||
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
||||
RuleShareTemplates ruleShareTemplates = GWT
|
||||
.create(RuleShareTemplates .class);
|
||||
sb.append(ruleShareTemplates.format(value));
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
|
||||
l.add(nameCol);
|
||||
l.add(scopeCol);
|
||||
l.add(descriptionCol);
|
||||
l.add(ownerCol);
|
||||
l.add(creationDateCol);
|
||||
|
||||
|
||||
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(l);
|
||||
|
@ -236,7 +258,7 @@ public class RuleSharePanel extends FramedPanel {
|
|||
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||
grid.setLoader(loader);
|
||||
grid.setSelectionModel(sm);
|
||||
grid.setHeight("384px");
|
||||
grid.setHeight(GRID_HEIGHT);
|
||||
grid.getView().setStripeRows(true);
|
||||
grid.getView().setColumnLines(true);
|
||||
grid.getView().setAutoFill(true);
|
||||
|
|
|
@ -0,0 +1,377 @@
|
|||
package org.gcube.portlets.user.td.rulewidget.client.multicolumn;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.properties.ColumnDataPropertiesCombo;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyTableRuleSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleColumnPlaceHolderDescriptor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.type.TDRuleTableType;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.type.TDRuleType;
|
||||
import org.gcube.portlets.user.td.rulewidget.client.multicolumn.data.MapPlaceHolderToColumnRow;
|
||||
import org.gcube.portlets.user.td.rulewidget.client.multicolumn.data.MapPlaceHolderToColumnRowProperties;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
|
||||
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.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlUtils;
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
||||
import com.sencha.gxt.core.client.Style.SelectionMode;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.core.client.util.Padding;
|
||||
import com.sencha.gxt.data.shared.ListStore;
|
||||
import com.sencha.gxt.widget.core.client.box.AlertMessageBox;
|
||||
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.BeforeStartEditEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.BeforeStartEditEvent.BeforeStartEditHandler;
|
||||
import com.sencha.gxt.widget.core.client.event.CancelEditEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.CancelEditEvent.CancelEditHandler;
|
||||
import com.sencha.gxt.widget.core.client.event.CompleteEditEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.CompleteEditEvent.CompleteEditHandler;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
||||
import com.sencha.gxt.widget.core.client.form.ComboBox;
|
||||
import com.sencha.gxt.widget.core.client.form.FormPanel;
|
||||
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.GridSelectionModel;
|
||||
import com.sencha.gxt.widget.core.client.grid.editing.GridRowEditing;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class RuleOnTableApplyMapColumnCard extends WizardCard {
|
||||
|
||||
private RuleOnTableApplyMapColumnCard thisCard;
|
||||
private ApplyTableRuleSession applyTableRuleSession;
|
||||
private Grid<MapPlaceHolderToColumnRow> grid;
|
||||
private ListStore<MapPlaceHolderToColumnRow> store;
|
||||
private ArrayList<MapPlaceHolderToColumnRow> rows;
|
||||
private ArrayList<ColumnData> columns;
|
||||
|
||||
public RuleOnTableApplyMapColumnCard(
|
||||
ApplyTableRuleSession applyTableRuleSession) {
|
||||
super("Map columns", "");
|
||||
this.thisCard = this;
|
||||
this.applyTableRuleSession = applyTableRuleSession;
|
||||
createData();
|
||||
retrieveColumns();
|
||||
|
||||
}
|
||||
|
||||
protected void createData() {
|
||||
RuleDescriptionData ruleDescriptionData = applyTableRuleSession
|
||||
.getRuleDescriptionData();
|
||||
TDRuleType tdRuleType = ruleDescriptionData.getTdRuleType();
|
||||
if (tdRuleType instanceof TDRuleTableType) {
|
||||
TDRuleTableType tdRuleTableType = (TDRuleTableType) tdRuleType;
|
||||
ArrayList<RuleColumnPlaceHolderDescriptor> rulePlaceHolderDescriptorList = tdRuleTableType
|
||||
.getRuleColumnPlaceHolderDescriptors();
|
||||
rows = new ArrayList<MapPlaceHolderToColumnRow>();
|
||||
|
||||
for (int i = 0; i < rulePlaceHolderDescriptorList.size(); i++) {
|
||||
RuleColumnPlaceHolderDescriptor placeHolder = rulePlaceHolderDescriptorList
|
||||
.get(i);
|
||||
rows.add(new MapPlaceHolderToColumnRow(i, placeHolder, null));
|
||||
}
|
||||
} else {
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
|
||||
HideHandler hideHandler = new HideHandler() {
|
||||
|
||||
public void onHide(HideEvent event) {
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(true);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
AlertMessageBox d = new AlertMessageBox("Attention",
|
||||
"This is not a rule on table!");
|
||||
d.addHideHandler(hideHandler);
|
||||
d.setModal(false);
|
||||
d.show();
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void create() {
|
||||
FormPanel panel = new FormPanel();
|
||||
panel.setLabelWidth(90);
|
||||
panel.getElement().setPadding(new Padding(5));
|
||||
setCenterWidget(panel, new MarginData(0));
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
panel.add(v);
|
||||
|
||||
// Grid
|
||||
MapPlaceHolderToColumnRowProperties props = GWT
|
||||
.create(MapPlaceHolderToColumnRowProperties.class);
|
||||
|
||||
ColumnConfig<MapPlaceHolderToColumnRow, String> placeHolderCol = new ColumnConfig<MapPlaceHolderToColumnRow, String>(
|
||||
props.placeHolderLabel(), 220, "Place Holder");
|
||||
ColumnConfig<MapPlaceHolderToColumnRow, ColumnData> columnCol = new ColumnConfig<MapPlaceHolderToColumnRow, ColumnData>(
|
||||
props.column(), 220, "Column");
|
||||
|
||||
columnCol.setCell(new AbstractCell<ColumnData>() {
|
||||
|
||||
@Override
|
||||
public void render(Context context, ColumnData value,
|
||||
SafeHtmlBuilder sb) {
|
||||
if (value == null) {
|
||||
sb.appendHtmlConstant("");
|
||||
} else {
|
||||
sb.appendHtmlConstant("<span title='"
|
||||
+ SafeHtmlUtils.htmlEscape(value.getLabel()) + "'>"
|
||||
+ SafeHtmlUtils.htmlEscape(value.getLabel())
|
||||
+ "</span>");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
ArrayList<ColumnConfig<MapPlaceHolderToColumnRow, ?>> l = new ArrayList<ColumnConfig<MapPlaceHolderToColumnRow, ?>>();
|
||||
l.add(placeHolderCol);
|
||||
l.add(columnCol);
|
||||
|
||||
ColumnModel<MapPlaceHolderToColumnRow> gridColumns = new ColumnModel<MapPlaceHolderToColumnRow>(
|
||||
l);
|
||||
|
||||
store = new ListStore<MapPlaceHolderToColumnRow>(props.id());
|
||||
store.addAll(rows);
|
||||
|
||||
final GridSelectionModel<MapPlaceHolderToColumnRow> sm = new GridSelectionModel<MapPlaceHolderToColumnRow>();
|
||||
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||
|
||||
grid = new Grid<MapPlaceHolderToColumnRow>(store, gridColumns);
|
||||
grid.setSelectionModel(sm);
|
||||
grid.getView().setStripeRows(true);
|
||||
grid.getView().setColumnLines(true);
|
||||
grid.getView().setAutoFill(true);
|
||||
grid.setBorders(false);
|
||||
grid.setLoadMask(true);
|
||||
grid.setColumnReordering(false);
|
||||
grid.getView().setAutoExpandColumn(columnCol);
|
||||
|
||||
// EDITING //
|
||||
ColumnDataPropertiesCombo columnDataPropertiesCombo = GWT
|
||||
.create(ColumnDataPropertiesCombo.class);
|
||||
|
||||
ListStore<ColumnData> storeComboColumnData = new ListStore<ColumnData>(
|
||||
columnDataPropertiesCombo.id());
|
||||
storeComboColumnData.addAll(columns);
|
||||
|
||||
ComboBox<ColumnData> comboColumnData = new ComboBox<ColumnData>(
|
||||
storeComboColumnData, columnDataPropertiesCombo.label());
|
||||
comboColumnData.setClearValueOnParseError(false);
|
||||
comboColumnData.setAllowBlank(false);
|
||||
comboColumnData.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
final GridRowEditing<MapPlaceHolderToColumnRow> editing = new GridRowEditing<MapPlaceHolderToColumnRow>(
|
||||
grid);
|
||||
|
||||
editing.addEditor(columnCol, comboColumnData);
|
||||
|
||||
editing.addBeforeStartEditHandler(new BeforeStartEditHandler<MapPlaceHolderToColumnRow>() {
|
||||
|
||||
@Override
|
||||
public void onBeforeStartEdit(
|
||||
BeforeStartEditEvent<MapPlaceHolderToColumnRow> event) {
|
||||
setEnableNextButton(false);
|
||||
}
|
||||
});
|
||||
|
||||
editing.addCancelEditHandler(new CancelEditHandler<MapPlaceHolderToColumnRow>() {
|
||||
|
||||
@Override
|
||||
public void onCancelEdit(
|
||||
CancelEditEvent<MapPlaceHolderToColumnRow> event) {
|
||||
store.rejectChanges();
|
||||
setEnableNextButton(true);
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
editing.addCompleteEditHandler(new CompleteEditHandler<MapPlaceHolderToColumnRow>() {
|
||||
|
||||
@Override
|
||||
public void onCompleteEdit(
|
||||
CompleteEditEvent<MapPlaceHolderToColumnRow> event) {
|
||||
try {
|
||||
|
||||
store.commitChanges();
|
||||
boolean fillAll = true;
|
||||
for (MapPlaceHolderToColumnRow row : store.getAll()) {
|
||||
if (row.getColumn() == null) {
|
||||
fillAll = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (fillAll) {
|
||||
setEnableNextButton(true);
|
||||
} else {
|
||||
setEnableNextButton(false);
|
||||
}
|
||||
|
||||
} catch (Throwable e) {
|
||||
Log.error("Error in RuleOnTableNewDefinitionCard: "
|
||||
+ e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
//
|
||||
v.add(grid, new VerticalLayoutData(1, 1, new Margins(0)));
|
||||
|
||||
forceLayout();
|
||||
return;
|
||||
}
|
||||
|
||||
protected void retrieveColumns() {
|
||||
TDGWTServiceAsync.INSTANCE.getColumns(applyTableRuleSession.getTrId(),
|
||||
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
getEventBus()
|
||||
.fireEvent(
|
||||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsLockedException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
|
||||
} else {
|
||||
Log.error("Error retrieving column: "
|
||||
+ caught.getMessage());
|
||||
UtilsGXT3.alert("Error retrieving column",
|
||||
caught.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void onSuccess(ArrayList<ColumnData> result) {
|
||||
Log.debug("Retrived column: " + result);
|
||||
columns = result;
|
||||
sanitizesColumns();
|
||||
create();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void sanitizesColumns() {
|
||||
ArrayList<ColumnData> removableColumn = new ArrayList<ColumnData>();
|
||||
for (ColumnData c : columns) {
|
||||
if (c.getTypeCode().compareTo(ColumnTypeCode.DIMENSION.toString()) == 0
|
||||
|| c.getTypeCode().compareTo(
|
||||
ColumnTypeCode.TIMEDIMENSION.toString()) == 0) {
|
||||
removableColumn.add(c);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
columns.removeAll(removableColumn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
Log.debug("RuleOnTableApplyMapColumnCard Setup");
|
||||
Command sayNextCard = new Command() {
|
||||
|
||||
public void execute() {
|
||||
Log.debug("RuleOnTableApplyMapColumnCard Call sayNextCard");
|
||||
checkData();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Command sayPreviousCard = new Command() {
|
||||
public void execute() {
|
||||
try {
|
||||
getWizardWindow().previousCard();
|
||||
getWizardWindow().removeCard(thisCard);
|
||||
Log.info("Remove RuleOnTableApplyMapColumnCard");
|
||||
} catch (Exception e) {
|
||||
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||
|
||||
setEnableBackButton(true);
|
||||
setBackButtonVisible(true);
|
||||
setEnableNextButton(true);
|
||||
}
|
||||
|
||||
protected void checkData() {
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
|
||||
HideHandler hideHandler = new HideHandler() {
|
||||
|
||||
public void onHide(HideEvent event) {
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
getWizardWindow().setEnableBackButton(true);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
if (store == null || store.size() <= 0) {
|
||||
AlertMessageBox d = new AlertMessageBox("Attention",
|
||||
"Add at least one column");
|
||||
d.addHideHandler(hideHandler);
|
||||
d.setModal(false);
|
||||
d.show();
|
||||
return;
|
||||
}
|
||||
|
||||
goNext();
|
||||
}
|
||||
|
||||
protected void goNext() {
|
||||
try {
|
||||
RuleOnTableApplyOperationInProgressCard createRuleOnTableExpressionCard = new RuleOnTableApplyOperationInProgressCard(
|
||||
applyTableRuleSession);
|
||||
getWizardWindow().addCard(createRuleOnTableExpressionCard);
|
||||
getWizardWindow().nextCard();
|
||||
} catch (Exception e) {
|
||||
Log.error("sayNextCard :" + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,280 @@
|
|||
/**
|
||||
*
|
||||
*/
|
||||
package org.gcube.portlets.user.td.rulewidget.client.multicolumn;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsLockedException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyTableRuleSession;
|
||||
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
|
||||
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.OperationResult;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
import com.google.gwt.user.client.ui.FlexTable;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||
import com.sencha.gxt.widget.core.client.container.HtmlLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.MarginData;
|
||||
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer;
|
||||
import com.sencha.gxt.widget.core.client.container.VBoxLayoutContainer.VBoxLayoutAlign;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class RuleOnTableApplyOperationInProgressCard extends WizardCard
|
||||
implements MonitorDialogListener {
|
||||
|
||||
private HtmlLayoutContainer resultField;
|
||||
private ApplyTableRuleSession applyTableRuleSession;
|
||||
|
||||
public RuleOnTableApplyOperationInProgressCard(
|
||||
ApplyTableRuleSession applyTableRuleSession) {
|
||||
super("Apply Rule On Table", "");
|
||||
|
||||
this.applyTableRuleSession = applyTableRuleSession;
|
||||
VBoxLayoutContainer operationInProgressPanel = new VBoxLayoutContainer();
|
||||
operationInProgressPanel.setVBoxLayoutAlign(VBoxLayoutAlign.CENTER);
|
||||
|
||||
final FlexTable description = new FlexTable();
|
||||
// FlexCellFormatter cellFormatter = description.getFlexCellFormatter();
|
||||
description.setCellSpacing(10);
|
||||
description.setCellPadding(4);
|
||||
description.setBorderWidth(0);
|
||||
|
||||
// display:block;vertical-align:text-top;
|
||||
description.setHTML(0, 0,
|
||||
"<span style=\"font-weight:bold;\";>Rule Name: </span>");
|
||||
description.setText(0, 1, applyTableRuleSession
|
||||
.getRuleDescriptionData().getName());
|
||||
description.setHTML(1, 0,
|
||||
"<span style=\"font-weight:bold;\";>Rule Description: </span>");
|
||||
description.setText(1, 1, applyTableRuleSession
|
||||
.getRuleDescriptionData().getDescription());
|
||||
|
||||
FramedPanel summary = new FramedPanel();
|
||||
summary.setHeadingText("Rule On Table");
|
||||
summary.setWidth(400);
|
||||
summary.add(description);
|
||||
operationInProgressPanel.add(summary, new BoxLayoutData(new Margins(20,
|
||||
5, 10, 5)));
|
||||
|
||||
resultField = new HtmlLayoutContainer("<div></div>");
|
||||
|
||||
operationInProgressPanel.add(resultField, new BoxLayoutData(
|
||||
new Margins(10, 5, 10, 5)));
|
||||
|
||||
setCenterWidget(operationInProgressPanel, new MarginData(0));
|
||||
resultField.setVisible(false);
|
||||
|
||||
}
|
||||
|
||||
public void applyTableRule() {
|
||||
ExpressionServiceAsync.INSTANCE.startApplyTableRule(applyTableRuleSession,
|
||||
new AsyncCallback<String>() {
|
||||
|
||||
public void onSuccess(String taskId) {
|
||||
openMonitorDialog(taskId);
|
||||
|
||||
}
|
||||
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
getEventBus()
|
||||
.fireEvent(
|
||||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsLockedException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
showErrorAndHide("Error","Error ",
|
||||
caught.getLocalizedMessage(), caught);
|
||||
} else {
|
||||
showErrorAndHide("Error",
|
||||
"An error occured in apply rule on table: ",
|
||||
caught.getLocalizedMessage(),
|
||||
caught);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
setBackButtonVisible(false);
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setNextButtonToFinish();
|
||||
applyTableRule();
|
||||
}
|
||||
|
||||
//
|
||||
protected void openMonitorDialog(String taskId) {
|
||||
MonitorDialog monitorDialog = new MonitorDialog(taskId, getEventBus());
|
||||
monitorDialog.addProgressDialogListener(this);
|
||||
monitorDialog.setBackgroundBtnEnabled(false);
|
||||
monitorDialog.show();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationComplete(OperationResult operationResult) {
|
||||
final TRId newTrId = operationResult.getTrId();
|
||||
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
||||
safeHtmlBuilder
|
||||
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold; color:#009900;'>Operation Completed</div>");
|
||||
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
||||
resultField.setVisible(true);
|
||||
|
||||
Command sayComplete = new Command() {
|
||||
public void execute() {
|
||||
try {
|
||||
getWizardWindow().close(false);
|
||||
Log.info("fire Complete: " + newTrId);
|
||||
|
||||
getWizardWindow().fireCompleted(newTrId);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.error("fire Complete :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getWizardWindow().setNextButtonCommand(sayComplete);
|
||||
|
||||
setNextButtonVisible(true);
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
|
||||
forceLayout();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationFailed(Throwable caught, String reason, String details) {
|
||||
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
||||
safeHtmlBuilder
|
||||
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color:red;'>Operation Failed</div>");
|
||||
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
||||
resultField.setVisible(true);
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
getEventBus()
|
||||
.fireEvent(
|
||||
new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
showErrorAndHide("Error",
|
||||
reason,details,caught);
|
||||
}
|
||||
|
||||
forceLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationStopped(OperationResult operationResult, String reason, String details) {
|
||||
final TRId newTrId = operationResult.getTrId();
|
||||
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
||||
safeHtmlBuilder
|
||||
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #FF9900;'>Problems in the Operation</div>");
|
||||
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
||||
resultField.setVisible(true);
|
||||
|
||||
Command sayComplete = new Command() {
|
||||
public void execute() {
|
||||
try {
|
||||
getWizardWindow().close(false);
|
||||
Log.info("fire Complete: tabular resource "
|
||||
+ newTrId.getId());
|
||||
Log.info("fire Complete: tableId " + newTrId.getTableId());
|
||||
|
||||
getWizardWindow().fireCompleted(newTrId);
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.error("fire Complete :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getWizardWindow().setNextButtonCommand(sayComplete);
|
||||
|
||||
setNextButtonVisible(true);
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
|
||||
forceLayout();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationAborted() {
|
||||
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
||||
safeHtmlBuilder
|
||||
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #AA00AA;'>Operation Aborted</div>");
|
||||
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
||||
resultField.setVisible(true);
|
||||
|
||||
Command sayComplete = new Command() {
|
||||
public void execute() {
|
||||
try {
|
||||
getWizardWindow().close(false);
|
||||
Log.info("fire Aborted");
|
||||
|
||||
getWizardWindow().fireAborted();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.error("fire Aborted :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getWizardWindow().setNextButtonCommand(sayComplete);
|
||||
|
||||
setNextButtonVisible(true);
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
forceLayout();
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void operationPutInBackground() {
|
||||
SafeHtmlBuilder safeHtmlBuilder = new SafeHtmlBuilder();
|
||||
safeHtmlBuilder
|
||||
.appendHtmlConstant("<div style='text-align:center;font-size:large;font-weight:bold;color: #00AAAA;'>Operation in Background</div>");
|
||||
resultField.setHTML(safeHtmlBuilder.toSafeHtml());
|
||||
resultField.setVisible(true);
|
||||
|
||||
Command sayComplete = new Command() {
|
||||
public void execute() {
|
||||
try {
|
||||
getWizardWindow().close(false);
|
||||
Log.info("fire Operation In Background");
|
||||
|
||||
getWizardWindow().firePutInBackground();
|
||||
|
||||
} catch (Exception e) {
|
||||
Log.error("fire Operation In Background :"
|
||||
+ e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getWizardWindow().setNextButtonCommand(sayComplete);
|
||||
|
||||
setNextButtonVisible(true);
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
forceLayout();
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,485 @@
|
|||
package org.gcube.portlets.user.td.rulewidget.client.multicolumn;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyTableRuleSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleColumnPlaceHolderDescriptor;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleScopeType;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.description.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.type.TDRuleTableType;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.type.TDRuleType;
|
||||
import org.gcube.portlets.user.td.rulewidget.client.RuleInfoDialog;
|
||||
import org.gcube.portlets.user.td.rulewidget.client.resources.ResourceBundle;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardCard;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.util.UtilsGXT3;
|
||||
|
||||
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.SafeHtml;
|
||||
import com.google.gwt.safehtml.shared.SafeHtmlBuilder;
|
||||
import com.google.gwt.user.client.Command;
|
||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||
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.core.client.util.Padding;
|
||||
import com.sencha.gxt.data.client.loader.RpcProxy;
|
||||
import com.sencha.gxt.data.shared.ListStore;
|
||||
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||
import com.sencha.gxt.data.shared.Store;
|
||||
import com.sencha.gxt.data.shared.Store.StoreFilter;
|
||||
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.widget.core.client.box.AlertMessageBox;
|
||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||
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.HideEvent;
|
||||
import com.sencha.gxt.widget.core.client.event.HideEvent.HideHandler;
|
||||
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.FormPanel;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class RuleOnTableApplySelectRuleCard extends WizardCard {
|
||||
|
||||
private static final String GRID_HEIGHT = "334px";
|
||||
|
||||
interface RuleOnTableSelectTemplates extends XTemplates {
|
||||
@XTemplate("<span title=\"{value}\">{value}</span>")
|
||||
SafeHtml format(String value);
|
||||
}
|
||||
|
||||
private RuleOnTableApplySelectRuleCard thisCard;
|
||||
private ApplyTableRuleSession applyTableRuleSession;
|
||||
private Grid<RuleDescriptionData> grid;
|
||||
private ExtendedListStore<RuleDescriptionData> store;
|
||||
private ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>> loader;
|
||||
private RuleDescriptionData ruleDescriptionData;
|
||||
|
||||
public RuleOnTableApplySelectRuleCard(ApplyTableRuleSession applyTableRuleSession) {
|
||||
super("Select Rule",
|
||||
"");
|
||||
this.thisCard = this;
|
||||
this.applyTableRuleSession=applyTableRuleSession;
|
||||
FormPanel panel = createPanel();
|
||||
setCenterWidget(panel, new MarginData(0));
|
||||
|
||||
}
|
||||
|
||||
protected FormPanel createPanel() {
|
||||
FormPanel panel = new FormPanel();
|
||||
panel.setLabelWidth(90);
|
||||
panel.getElement().setPadding(new Padding(5));
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
panel.add(v);
|
||||
|
||||
|
||||
//ToolBarHead
|
||||
ToolBar toolBarHead = new ToolBar();
|
||||
toolBarHead.add(new LabelToolItem("Search: "));
|
||||
final TextField searchField = new TextField();
|
||||
toolBarHead.add(searchField);
|
||||
|
||||
TextButton btnReload = new TextButton();
|
||||
// btnReload.setText("Reload");
|
||||
btnReload.setIcon(ResourceBundle.INSTANCE.refresh());
|
||||
btnReload.setToolTip("Reload");
|
||||
toolBarHead.add(btnReload);
|
||||
|
||||
IdentityValueProvider<RuleDescriptionData> identity = new IdentityValueProvider<RuleDescriptionData>();
|
||||
CheckBoxSelectionModel<RuleDescriptionData> sm = new CheckBoxSelectionModel<RuleDescriptionData>(
|
||||
identity);
|
||||
|
||||
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) {
|
||||
RuleOnTableSelectTemplates ruleOnTableSelectTemplates = GWT
|
||||
.create(RuleOnTableSelectTemplates.class);
|
||||
sb.append(ruleOnTableSelectTemplates.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) {
|
||||
RuleOnTableSelectTemplates ruleOnTableSelectTemplates = GWT
|
||||
.create(RuleOnTableSelectTemplates.class);
|
||||
sb.append(ruleOnTableSelectTemplates.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) {
|
||||
RuleOnTableSelectTemplates ruleOnTableSelectTemplates = GWT
|
||||
.create(RuleOnTableSelectTemplates.class);
|
||||
sb.append(ruleOnTableSelectTemplates.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) {
|
||||
RuleOnTableSelectTemplates ruleDeleteTemplates = GWT
|
||||
.create(RuleOnTableSelectTemplates.class);
|
||||
sb.append(ruleDeleteTemplates.format(value));
|
||||
}
|
||||
});
|
||||
|
||||
ColumnConfig<RuleDescriptionData, String> creationDateCol = new ColumnConfig<RuleDescriptionData, String>(
|
||||
props.creationDate(), 50, "Creation Date");
|
||||
|
||||
creationDateCol.setCell(new AbstractCell<String>() {
|
||||
|
||||
@Override
|
||||
public void render(Context context, String value, SafeHtmlBuilder sb) {
|
||||
RuleOnTableSelectTemplates ruleOnTableSelectTemplates = GWT
|
||||
.create(RuleOnTableSelectTemplates.class);
|
||||
sb.append(ruleOnTableSelectTemplates.format(value));
|
||||
}
|
||||
});
|
||||
|
||||
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
|
||||
l.add(nameCol);
|
||||
l.add(scopeCol);
|
||||
l.add(descriptionCol);
|
||||
l.add(ownerCol);
|
||||
l.add(creationDateCol);
|
||||
|
||||
|
||||
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(
|
||||
l);
|
||||
|
||||
store = new ExtendedListStore<RuleDescriptionData>(props.id());
|
||||
|
||||
searchField.addKeyUpHandler(new KeyUpHandler() {
|
||||
|
||||
public void onKeyUp(KeyUpEvent event) {
|
||||
Log.trace("searchTerm: " + searchField.getCurrentValue());
|
||||
store.applyFilters();
|
||||
}
|
||||
});
|
||||
|
||||
store.addFilter(new StoreFilter<RuleDescriptionData>() {
|
||||
|
||||
@Override
|
||||
public boolean select(Store<RuleDescriptionData> store,
|
||||
RuleDescriptionData parent, RuleDescriptionData item) {
|
||||
String searchTerm = searchField.getCurrentValue();
|
||||
if (searchTerm == null)
|
||||
return true;
|
||||
return thisCard.select(item, searchTerm);
|
||||
}
|
||||
});
|
||||
|
||||
store.setEnableFilters(true);
|
||||
|
||||
RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>>() {
|
||||
|
||||
public void load(
|
||||
ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
|
||||
loadData(loadConfig, callback);
|
||||
}
|
||||
};
|
||||
loader = new ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>>(
|
||||
proxy);
|
||||
|
||||
loader.setRemoteSort(false);
|
||||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, RuleDescriptionData, ListLoadResult<RuleDescriptionData>>(
|
||||
store) {
|
||||
});
|
||||
|
||||
SelectHandler sh = new SelectHandler() {
|
||||
public void onSelect(SelectEvent event) {
|
||||
loader.load();
|
||||
}
|
||||
};
|
||||
|
||||
btnReload.addSelectHandler(sh);
|
||||
|
||||
grid = new Grid<RuleDescriptionData>(store, cm) {
|
||||
@Override
|
||||
protected void onAfterFirstAttach() {
|
||||
super.onAfterFirstAttach();
|
||||
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
|
||||
|
||||
public void execute() {
|
||||
loader.load();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
sm.setSelectionMode(SelectionMode.SINGLE);
|
||||
grid.setLoader(loader);
|
||||
grid.setHeight(GRID_HEIGHT);
|
||||
grid.setSelectionModel(sm);
|
||||
grid.getView().setStripeRows(true);
|
||||
grid.getView().setColumnLines(true);
|
||||
grid.getView().setAutoFill(true);
|
||||
grid.setBorders(false);
|
||||
grid.setLoadMask(true);
|
||||
grid.setColumnReordering(true);
|
||||
grid.setColumnResize(true);
|
||||
grid.getView().setAutoExpandColumn(descriptionCol);
|
||||
|
||||
createContextMenu();
|
||||
|
||||
ToolBar toolBar = new ToolBar();
|
||||
toolBar.add(grid);
|
||||
toolBar.addStyleName(ThemeStyles.get().style().borderTop());
|
||||
toolBar.getElement().getStyle().setProperty("borderBottom", "none");
|
||||
|
||||
v.add(toolBarHead, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||
v.add(grid, new VerticalLayoutData(1, -1, new Margins(0)));
|
||||
v.add(toolBar, new VerticalLayoutData(1, 25, new Margins(0)));
|
||||
return panel;
|
||||
}
|
||||
|
||||
protected void loadData(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
|
||||
|
||||
ExpressionServiceAsync.INSTANCE.getRules(RuleScopeType.TABLE,
|
||||
new AsyncCallback<ArrayList<RuleDescriptionData>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
getEventBus().fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("Load rules failure:"
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error retrieving rules",
|
||||
"Error retrieving rules");
|
||||
}
|
||||
callback.onFailure(caught);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<RuleDescriptionData> result) {
|
||||
Log.trace("loaded " + result.size() + " Rules");
|
||||
callback.onSuccess(new ListLoadResultBean<RuleDescriptionData>(
|
||||
result));
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected RuleDescriptionData getSelectedItem() {
|
||||
RuleDescriptionData rule = grid.getSelectionModel()
|
||||
.getSelectedItem();
|
||||
return rule;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void setup() {
|
||||
Log.debug("RuleOnTableApplySelectRuleCard Setup");
|
||||
Command sayNextCard = new Command() {
|
||||
|
||||
public void execute() {
|
||||
Log.debug("RuleOnTableApplySelectRuleCard Call sayNextCard");
|
||||
checkData();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Command sayPreviousCard = new Command() {
|
||||
public void execute() {
|
||||
try {
|
||||
getWizardWindow().previousCard();
|
||||
getWizardWindow().removeCard(thisCard);
|
||||
Log.info("Remove RuleOnTableNewDefinitionCard");
|
||||
} catch (Exception e) {
|
||||
Log.error("sayPreviousCard :" + e.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
getWizardWindow().setPreviousButtonCommand(sayPreviousCard);
|
||||
getWizardWindow().setNextButtonCommand(sayNextCard);
|
||||
|
||||
setEnableBackButton(false);
|
||||
setBackButtonVisible(false);
|
||||
setEnableNextButton(true);
|
||||
}
|
||||
|
||||
protected void checkData() {
|
||||
getWizardWindow().setEnableNextButton(false);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
|
||||
HideHandler hideHandler = new HideHandler() {
|
||||
|
||||
public void onHide(HideEvent event) {
|
||||
getWizardWindow().setEnableNextButton(true);
|
||||
getWizardWindow().setEnableBackButton(false);
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
//TODO
|
||||
//ruleDescriptionData = getSelectedItem();
|
||||
ArrayList<RuleColumnPlaceHolderDescriptor> ruleColumnPlaceHolderDescriptors=new ArrayList<RuleColumnPlaceHolderDescriptor>();
|
||||
RuleColumnPlaceHolderDescriptor r1=new RuleColumnPlaceHolderDescriptor("Test1", "Test1", ColumnDataType.Text);
|
||||
RuleColumnPlaceHolderDescriptor r2=new RuleColumnPlaceHolderDescriptor("Test2", "Test2", ColumnDataType.Integer);
|
||||
ruleColumnPlaceHolderDescriptors.add(r1);
|
||||
ruleColumnPlaceHolderDescriptors.add(r2);
|
||||
TDRuleType tdRuleType=new TDRuleTableType(ruleColumnPlaceHolderDescriptors);
|
||||
|
||||
ruleDescriptionData =new RuleDescriptionData(1, "Test", "Test Description", "2015-01-01 18:45", null, null, RuleScopeType.TABLE, new C_Expression(),
|
||||
tdRuleType);
|
||||
|
||||
if (ruleDescriptionData == null) {
|
||||
AlertMessageBox d = new AlertMessageBox("Attention",
|
||||
"Select one rule!");
|
||||
d.addHideHandler(hideHandler);
|
||||
d.setModal(false);
|
||||
d.show();
|
||||
return;
|
||||
}
|
||||
|
||||
applyTableRuleSession.setRuleDescriptionData(ruleDescriptionData);
|
||||
|
||||
goNext();
|
||||
}
|
||||
|
||||
protected void goNext(){
|
||||
try {
|
||||
RuleOnTableApplyMapColumnCard ruleOnTableApplyMapColumnCard = new RuleOnTableApplyMapColumnCard(
|
||||
applyTableRuleSession);
|
||||
getWizardWindow().addCard(ruleOnTableApplyMapColumnCard);
|
||||
getWizardWindow().nextCard();
|
||||
} catch (Exception e) {
|
||||
Log.error("sayNextCard :" + e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void dispose() {
|
||||
|
||||
}
|
||||
|
||||
protected void createContextMenu() {
|
||||
Menu contextMenu = new Menu();
|
||||
|
||||
MenuItem infoItem = new MenuItem();
|
||||
infoItem.setText("Info");
|
||||
infoItem.setIcon(ResourceBundle.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);
|
||||
|
||||
}
|
||||
|
||||
protected void requestInfo(RuleDescriptionData rule) {
|
||||
|
||||
final RuleInfoDialog infoRuleDialog = new RuleInfoDialog(rule);
|
||||
infoRuleDialog.show();
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected boolean select(RuleDescriptionData item, String searchTerm) {
|
||||
if (item.getName() != null
|
||||
&& item.getName().toLowerCase()
|
||||
.contains(searchTerm.toLowerCase()))
|
||||
return true;
|
||||
if (item.getDescription() != null
|
||||
&& item.getDescription().toLowerCase()
|
||||
.contains(searchTerm.toLowerCase()))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
protected class ExtendedListStore<M> extends ListStore<M> {
|
||||
|
||||
public ExtendedListStore(ModelKeyProvider<? super M> keyProvider) {
|
||||
super(keyProvider);
|
||||
}
|
||||
|
||||
public void applyFilters() {
|
||||
super.applyFilters();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package org.gcube.portlets.user.td.rulewidget.client.multicolumn;
|
||||
|
||||
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.ApplyTableRuleSession;
|
||||
import org.gcube.portlets.user.td.rulewidget.client.resources.ResourceBundle;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.user.td.wizardwidget.client.WizardWindow;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class RuleOnTableApplyWizard extends WizardWindow {
|
||||
private static final String WIZARDWIDTH = "770px";
|
||||
private static final String WIZARDHEIGHT = "520px";
|
||||
private TRId trId;
|
||||
/**
|
||||
*
|
||||
* @param title
|
||||
* @param eventBus
|
||||
*/
|
||||
public RuleOnTableApplyWizard(TRId trId, EventBus eventBus) {
|
||||
super("Apply Rule On Table",eventBus);
|
||||
this.trId=trId;
|
||||
Log.debug("RuleOnTableApplyWizard");
|
||||
setWidth(WIZARDWIDTH);
|
||||
setHeight(WIZARDHEIGHT);
|
||||
getHeader().setIcon(ResourceBundle.INSTANCE.ruleTableApply());
|
||||
create();
|
||||
}
|
||||
|
||||
|
||||
private void create() {
|
||||
ApplyTableRuleSession applyTableRuleSession=new ApplyTableRuleSession();
|
||||
applyTableRuleSession.setTrId(trId);
|
||||
|
||||
RuleOnTableApplySelectRuleCard ruleOnTableApplySelectRuleCard=new RuleOnTableApplySelectRuleCard(applyTableRuleSession);
|
||||
addCard(ruleOnTableApplySelectRuleCard);
|
||||
ruleOnTableApplySelectRuleCard.setup();
|
||||
show();
|
||||
}
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,90 @@
|
|||
package org.gcube.portlets.user.td.rulewidget.client.multicolumn.data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleColumnPlaceHolderDescriptor;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo email: <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class MapPlaceHolderToColumnRow implements Serializable {
|
||||
|
||||
private int id;
|
||||
private RuleColumnPlaceHolderDescriptor ruleColumnPlaceHolderDescriptor;
|
||||
private ColumnData column;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 3124977633549118003L;
|
||||
|
||||
public MapPlaceHolderToColumnRow() {
|
||||
super();
|
||||
|
||||
}
|
||||
|
||||
public MapPlaceHolderToColumnRow(int id,
|
||||
RuleColumnPlaceHolderDescriptor ruleColumnPlaceHolderDescriptor,
|
||||
ColumnData column) {
|
||||
super();
|
||||
this.id = id;
|
||||
this.ruleColumnPlaceHolderDescriptor = ruleColumnPlaceHolderDescriptor;
|
||||
this.column = column;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public RuleColumnPlaceHolderDescriptor getRuleColumnPlaceHolderDescriptor() {
|
||||
return ruleColumnPlaceHolderDescriptor;
|
||||
}
|
||||
|
||||
public void setRuleColumnPlaceHolderDescriptor(
|
||||
RuleColumnPlaceHolderDescriptor ruleColumnPlaceHolderDescriptor) {
|
||||
this.ruleColumnPlaceHolderDescriptor = ruleColumnPlaceHolderDescriptor;
|
||||
}
|
||||
|
||||
public ColumnData getColumn() {
|
||||
return column;
|
||||
}
|
||||
|
||||
public void setColumn(ColumnData column) {
|
||||
this.column = column;
|
||||
}
|
||||
|
||||
public String getPlaceHolderLabel(){
|
||||
if(ruleColumnPlaceHolderDescriptor!=null){
|
||||
return ruleColumnPlaceHolderDescriptor.getLabel();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public String getColumnLabel(){
|
||||
if(column!=null){
|
||||
return column.getLabel();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "MapPlaceHolderToColumnRow [id=" + id
|
||||
+ ", ruleColumnPlaceHolderDescriptor="
|
||||
+ ruleColumnPlaceHolderDescriptor + ", column=" + column + "]";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package org.gcube.portlets.user.td.rulewidget.client.multicolumn.data;
|
||||
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
|
||||
|
||||
import com.google.gwt.editor.client.Editor.Path;
|
||||
import com.sencha.gxt.core.client.ValueProvider;
|
||||
import com.sencha.gxt.data.shared.ModelKeyProvider;
|
||||
import com.sencha.gxt.data.shared.PropertyAccess;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface MapPlaceHolderToColumnRowProperties extends PropertyAccess<MapPlaceHolderToColumnRow> {
|
||||
|
||||
@Path("id")
|
||||
ModelKeyProvider<MapPlaceHolderToColumnRow> id();
|
||||
|
||||
ValueProvider<MapPlaceHolderToColumnRow,String> placeHolderLabel();
|
||||
|
||||
ValueProvider<MapPlaceHolderToColumnRow,ColumnData> column();
|
||||
|
||||
}
|
Loading…
Reference in New Issue