Updated Rules
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-portlet@114237 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
c46d685650
commit
55e17e0181
|
@ -58,12 +58,12 @@ 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();
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
package org.gcube.portlets.user.td.client.rule;
|
||||
|
||||
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
|
||||
import org.gcube.portlets.user.td.gwtservice.client.rpc.TDGWTServiceAsync;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTIsFinalException;
|
||||
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.template.TemplateApplySession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.RulesOnColumnApplySession;
|
||||
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialog;
|
||||
import org.gcube.portlets.user.td.monitorwidget.client.MonitorDialogListener;
|
||||
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
|
||||
|
@ -78,41 +78,45 @@ public class RuleApplyDialog extends Window implements
|
|||
hide();
|
||||
}
|
||||
|
||||
protected void applyTemplate(final TemplateApplySession templateApplySession) {
|
||||
|
||||
protected void applyRules(RulesOnColumnApplySession ruleOnColumnApplySession) {
|
||||
ExpressionServiceAsync.INSTANCE.startRulesOnColumnApply(ruleOnColumnApplySession, new AsyncCallback<String>() {
|
||||
|
||||
TDGWTServiceAsync.INSTANCE.startTemplateApply(templateApplySession,
|
||||
new AsyncCallback<String>() {
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsLockedException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsFinalException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Is Final",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsLockedException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsFinalException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Is Final",
|
||||
Log.debug("Apply Rules On Column Error: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3
|
||||
.alert("Apply Rules On Column",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
Log.debug("Apply Template Error: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3
|
||||
.alert("Apply Template Error ",
|
||||
"Error in invocation of apply template operation! "+caught.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onSuccess(String taskId) {
|
||||
openMonitorDialog(taskId);
|
||||
}
|
||||
|
||||
});
|
||||
@Override
|
||||
public void onSuccess(String taskId) {
|
||||
openMonitorDialog(taskId);
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
@ -126,7 +130,7 @@ public class RuleApplyDialog extends Window implements
|
|||
public void operationComplete(OperationResult operationResult) {
|
||||
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
|
||||
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
||||
ChangeTableRequestType.TEMPLATEAPPLY, operationResult.getTrId(), why);
|
||||
ChangeTableRequestType.RULESONCOLUMNAPPLY, operationResult.getTrId(), why);
|
||||
eventBus.fireEvent(changeTableRequestEvent);
|
||||
close();
|
||||
}
|
||||
|
@ -142,7 +146,7 @@ public class RuleApplyDialog extends Window implements
|
|||
public void operationStopped(OperationResult operationResult, String reason, String details) {
|
||||
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
|
||||
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
||||
ChangeTableRequestType.TEMPLATEAPPLY, operationResult.getTrId(), why);
|
||||
ChangeTableRequestType.RULESONCOLUMNAPPLY, operationResult.getTrId(), why);
|
||||
eventBus.fireEvent(changeTableRequestEvent);
|
||||
close();
|
||||
|
||||
|
|
|
@ -4,35 +4,34 @@ import java.util.ArrayList;
|
|||
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.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataPropertiesCombo;
|
||||
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;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateApplySession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.RulesOnColumnApplySession;
|
||||
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
|
||||
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.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.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.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.resources.ThemeStyles;
|
||||
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
||||
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.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;
|
||||
|
@ -48,13 +47,13 @@ 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.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.toolbar.LabelToolItem;
|
||||
import com.sencha.gxt.widget.core.client.toolbar.ToolBar;
|
||||
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.info.Info;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -68,14 +67,17 @@ public class RuleApplyPanel extends FramedPanel {
|
|||
private EventBus eventBus;
|
||||
private RuleApplyDialog parent;
|
||||
private TRId trId;
|
||||
private TemplateApplySession templateApplySession;
|
||||
private ArrayList<ColumnData> columns;
|
||||
private ColumnData column;
|
||||
|
||||
private TextButton btnApply;
|
||||
private TextButton btnClose;
|
||||
|
||||
private ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>> loader;
|
||||
private Grid<RuleDescriptionData> grid;
|
||||
private ExtendedListStore<RuleDescriptionData> store;
|
||||
|
||||
private ComboBox<ColumnData> comboColumns;
|
||||
private ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>> availableRulesLoader;
|
||||
private ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>> appliesRulesLoader;
|
||||
private DualListField<RuleDescriptionData, String> rulesDualList;
|
||||
|
||||
public RuleApplyPanel(RuleApplyDialog parent, TRId trId, EventBus eventBus) {
|
||||
this.parent = parent;
|
||||
|
@ -86,126 +88,148 @@ public class RuleApplyPanel extends FramedPanel {
|
|||
setHeaderVisible(false);
|
||||
setBodyBorder(false);
|
||||
this.eventBus = eventBus;
|
||||
|
||||
create();
|
||||
retrieveColumns();
|
||||
|
||||
}
|
||||
|
||||
protected void retrieveColumns() {
|
||||
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsLockedException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsFinalException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Final",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
Log.debug("Error retrieving columns: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3
|
||||
.alert("Error retrieving columns",
|
||||
"Error retrieving column on server!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSuccess(ArrayList<ColumnData> result) {
|
||||
Log.debug("Retrieved Columns");
|
||||
if (result == null) {
|
||||
UtilsGXT3.alert("Error",
|
||||
"The requested columns is null");
|
||||
}
|
||||
columns = result;
|
||||
create();
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void create() {
|
||||
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(TabularDataResources.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");
|
||||
|
||||
ColumnConfig<RuleDescriptionData, String> descriptionCol = new ColumnConfig<RuleDescriptionData, String>(
|
||||
props.description(), 120, "Description");
|
||||
|
||||
ColumnConfig<RuleDescriptionData, String> readableExpressionCol = new ColumnConfig<RuleDescriptionData, String>(
|
||||
props.readableExpression(), 230, "Expression");
|
||||
|
||||
List<ColumnConfig<RuleDescriptionData, ?>> l = new ArrayList<ColumnConfig<RuleDescriptionData, ?>>();
|
||||
l.add(nameCol);
|
||||
l.add(descriptionCol);
|
||||
l.add(readableExpressionCol);
|
||||
Log.debug("Create RuleApplyPanel(): " + trId);
|
||||
|
||||
ColumnModel<RuleDescriptionData> cm = new ColumnModel<RuleDescriptionData>(
|
||||
l);
|
||||
FieldSet configurationFieldSet = new FieldSet();
|
||||
configurationFieldSet.setHeadingText("Configuration");
|
||||
configurationFieldSet.setCollapsible(false);
|
||||
|
||||
store = new ExtendedListStore<RuleDescriptionData>(props.id());
|
||||
|
||||
VerticalLayoutContainer configurationFieldSetLayout=new VerticalLayoutContainer();
|
||||
configurationFieldSet.add(configurationFieldSetLayout);
|
||||
|
||||
// Column Data
|
||||
ColumnDataPropertiesCombo propsColumnData = GWT
|
||||
.create(ColumnDataPropertiesCombo.class);
|
||||
ListStore<ColumnData> storeCombo = new ListStore<ColumnData>(
|
||||
propsColumnData.id());
|
||||
storeCombo.addAll(columns);
|
||||
|
||||
searchField.addKeyUpHandler(new KeyUpHandler() {
|
||||
Log.trace("StoreCombo created");
|
||||
comboColumns = new ComboBox<ColumnData>(storeCombo,
|
||||
propsColumnData.label());
|
||||
|
||||
public void onKeyUp(KeyUpEvent event) {
|
||||
Log.trace("searchTerm: " + searchField.getCurrentValue());
|
||||
store.applyFilters();
|
||||
}
|
||||
});
|
||||
Log.trace("Combo ColumnData created");
|
||||
|
||||
store.addFilter(new StoreFilter<RuleDescriptionData>() {
|
||||
addHandlersForComboColumn(propsColumnData.label());
|
||||
comboColumns.setEmptyText("Select a column...");
|
||||
comboColumns.setWidth(191);
|
||||
comboColumns.setTypeAhead(false);
|
||||
comboColumns.setEditable(false);
|
||||
comboColumns.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
@Override
|
||||
public boolean select(Store<RuleDescriptionData> store,
|
||||
RuleDescriptionData parent, RuleDescriptionData item) {
|
||||
String searchTerm = searchField.getCurrentValue();
|
||||
if (searchTerm == null)
|
||||
return true;
|
||||
return RuleApplyPanel.this.select(item, searchTerm);
|
||||
}
|
||||
});
|
||||
FieldLabel comboColumnsLabel = new FieldLabel(comboColumns, "Column");
|
||||
configurationFieldSetLayout.add(comboColumnsLabel, new VerticalLayoutData(1, -1,
|
||||
new Margins(0)));
|
||||
|
||||
// Rules
|
||||
RuleDescriptionDataPropertiesCombo propsRules = GWT
|
||||
.create(RuleDescriptionDataPropertiesCombo.class);
|
||||
|
||||
store.setEnableFilters(true);
|
||||
|
||||
RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>> proxy = new RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>>() {
|
||||
ListStore<RuleDescriptionData> availableRulesStore = new ListStore<RuleDescriptionData>(
|
||||
propsRules.id());
|
||||
|
||||
RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>> availableRulesProxy = new RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>>() {
|
||||
|
||||
public void load(
|
||||
ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
|
||||
loadData(loadConfig, callback);
|
||||
loadAvaibleRules(loadConfig, callback);
|
||||
}
|
||||
};
|
||||
loader = new ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>>(
|
||||
proxy);
|
||||
availableRulesLoader = new ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>>(
|
||||
availableRulesProxy);
|
||||
|
||||
loader.setRemoteSort(false);
|
||||
loader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, RuleDescriptionData, ListLoadResult<RuleDescriptionData>>(
|
||||
store) {
|
||||
availableRulesLoader.setRemoteSort(false);
|
||||
availableRulesLoader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, RuleDescriptionData, ListLoadResult<RuleDescriptionData>>(
|
||||
availableRulesStore) {
|
||||
});
|
||||
|
||||
|
||||
SelectHandler sh = new SelectHandler() {
|
||||
public void onSelect(SelectEvent event) {
|
||||
loader.load();
|
||||
ListStore<RuleDescriptionData> appliesRulesStore = new ListStore<RuleDescriptionData>(
|
||||
propsRules.id());
|
||||
|
||||
RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>> appliesRulesProxy = new RpcProxy<ListLoadConfig, ListLoadResult<RuleDescriptionData>>() {
|
||||
|
||||
public void load(
|
||||
ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
|
||||
loadAppliesRules(loadConfig, callback);
|
||||
}
|
||||
};
|
||||
appliesRulesLoader = new ListLoader<ListLoadConfig, ListLoadResult<RuleDescriptionData>>(
|
||||
appliesRulesProxy);
|
||||
|
||||
btnReload.addSelectHandler(sh);
|
||||
appliesRulesLoader.setRemoteSort(false);
|
||||
appliesRulesLoader.addLoadHandler(new LoadResultListStoreBinding<ListLoadConfig, RuleDescriptionData, ListLoadResult<RuleDescriptionData>>(
|
||||
appliesRulesStore) {
|
||||
});
|
||||
|
||||
|
||||
|
||||
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.setSelectionModel(sm);
|
||||
grid.setHeight("384px");
|
||||
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);
|
||||
|
||||
ToolBar toolBar = new ToolBar();
|
||||
toolBar.add(grid);
|
||||
toolBar.addStyleName(ThemeStyles.get().style().borderTop());
|
||||
toolBar.getElement().getStyle().setProperty("borderBottom", "none");
|
||||
rulesDualList = new DualListField<RuleDescriptionData, String>(
|
||||
availableRulesStore, appliesRulesStore, propsRules.nameProv(), new TextCell());
|
||||
rulesDualList.addValidator(new EmptyValidator<List<RuleDescriptionData>>());
|
||||
rulesDualList.setEnableDnd(true);
|
||||
rulesDualList.setMode(Mode.INSERT);
|
||||
|
||||
FieldLabel ruleDualListLabel = new FieldLabel(rulesDualList, "Rules");
|
||||
|
||||
configurationFieldSetLayout.add(ruleDualListLabel, new VerticalLayoutData(1, -1,
|
||||
new Margins(0)));
|
||||
|
||||
// Button
|
||||
btnApply = new TextButton("Apply");
|
||||
btnApply.setIcon(TabularDataResources.INSTANCE.ruleApply());
|
||||
btnApply.setIconAlign(IconAlign.RIGHT);
|
||||
|
@ -239,19 +263,41 @@ public class RuleApplyPanel extends FramedPanel {
|
|||
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
|
||||
VerticalLayoutContainer v = new VerticalLayoutContainer();
|
||||
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)));
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
protected void loadData(ListLoadConfig loadConfig,
|
||||
private void addHandlersForComboColumn(final LabelProvider<ColumnData> labelProvider) {
|
||||
comboColumns.addSelectionHandler(new SelectionHandler<ColumnData>() {
|
||||
public void onSelection(SelectionEvent<ColumnData> event) {
|
||||
Info.display(
|
||||
"Column Selected",
|
||||
"You selected "
|
||||
+ (event.getSelectedItem() == null ? "nothing"
|
||||
: labelProvider.getLabel(event
|
||||
.getSelectedItem()) + "!"));
|
||||
Log.debug("ComboColumn selected: " + event.getSelectedItem());
|
||||
ColumnData columnData = event.getSelectedItem();
|
||||
updateRulesInDualList(columnData);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
protected void updateRulesInDualList(ColumnData columnData) {
|
||||
column=columnData;
|
||||
availableRulesLoader.load();
|
||||
|
||||
}
|
||||
|
||||
protected void loadAvaibleRules(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
|
||||
|
||||
ExpressionServiceAsync.INSTANCE.getRules(RuleScopeType.COLUMN,
|
||||
ExpressionServiceAsync.INSTANCE.getApplicableBaseColumnRules(column,
|
||||
new AsyncCallback<ArrayList<RuleDescriptionData>>() {
|
||||
|
||||
@Override
|
||||
|
@ -260,10 +306,10 @@ public class RuleApplyPanel extends FramedPanel {
|
|||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
Log.error("Load rules failure:"
|
||||
Log.error("Error retrieving applicable rules:"
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error retrieving rules",
|
||||
"Error retrieving rules");
|
||||
"Error retrieving applicable rules");
|
||||
}
|
||||
callback.onFailure(caught);
|
||||
|
||||
|
@ -279,21 +325,57 @@ public class RuleApplyPanel extends FramedPanel {
|
|||
});
|
||||
|
||||
}
|
||||
|
||||
protected void loadAppliesRules(ListLoadConfig loadConfig,
|
||||
final AsyncCallback<ListLoadResult<RuleDescriptionData>> callback) {
|
||||
|
||||
protected RuleDescriptionData getSelectedItem() {
|
||||
return grid.getSelectionModel().getSelectedItem();
|
||||
ExpressionServiceAsync.INSTANCE.getApplicableBaseColumnRules(column,
|
||||
new AsyncCallback<ArrayList<RuleDescriptionData>>() {
|
||||
|
||||
@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<RuleDescriptionData> result) {
|
||||
Log.trace("loaded " + result.size() + " Rules");
|
||||
callback.onSuccess(new ListLoadResultBean<RuleDescriptionData>(
|
||||
result));
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected ArrayList<RuleDescriptionData> getSelectedItems() {
|
||||
List<RuleDescriptionData> selectedItems=rulesDualList.getValue();
|
||||
ArrayList<RuleDescriptionData> rulesSelected=new ArrayList<RuleDescriptionData>(selectedItems);
|
||||
return rulesSelected;
|
||||
}
|
||||
|
||||
protected void apply() {
|
||||
templateApplySession = new TemplateApplySession();
|
||||
RuleDescriptionData template = getSelectedItem();
|
||||
if (template == null) {
|
||||
UtilsGXT3.info("Attention", "Select the template to apply");
|
||||
ArrayList<RuleDescriptionData> selectedRules = getSelectedItems();
|
||||
ColumnData column=comboColumns.getCurrentValue();
|
||||
if(column!=null){
|
||||
RulesOnColumnApplySession rulesOnColumnApplySession=new RulesOnColumnApplySession(trId, column, selectedRules);
|
||||
parent.applyRules(rulesOnColumnApplySession);
|
||||
} else {
|
||||
//templateApplySession.setRuleDescriptionData(getSelectedItem());
|
||||
templateApplySession.setTrId(trId);
|
||||
Log.debug("applyTemplateSession: " + templateApplySession);
|
||||
parent.applyTemplate(templateApplySession);
|
||||
Log.error("No column selected");
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Select a column");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -301,32 +383,6 @@ public class RuleApplyPanel extends FramedPanel {
|
|||
parent.close();
|
||||
}
|
||||
|
||||
protected class ExtendedListStore<M> extends ListStore<M> {
|
||||
|
||||
public ExtendedListStore(ModelKeyProvider<? super M> keyProvider) {
|
||||
super(keyProvider);
|
||||
}
|
||||
|
||||
public void applyFilters() {
|
||||
super.applyFilters();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void gridReload() {
|
||||
grid.getLoader().load();
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
package org.gcube.portlets.user.td.client.rule;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
|
||||
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.expressionwidget.client.rpc.ExpressionServiceAsync;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
|
@ -69,38 +70,34 @@ public class RuleDeleteDialog extends Window {
|
|||
hide();
|
||||
}
|
||||
|
||||
protected void templatesDelete(
|
||||
final TemplateDeleteSession templateDeleteSession) {
|
||||
|
||||
protected void removeRule(
|
||||
ArrayList<RuleDescriptionData> rules) {
|
||||
|
||||
TDGWTServiceAsync.INSTANCE.templateDelete(templateDeleteSession,
|
||||
ExpressionServiceAsync.INSTANCE.removeRulesById(rules,
|
||||
new AsyncCallback<Void>() {
|
||||
|
||||
@Override
|
||||
public void onSuccess(Void v) {
|
||||
Log.debug("Rule is deleted!");
|
||||
UtilsGXT3.info("Delete Rule", "The rule is deleted!");
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Throwable caught) {
|
||||
if (caught instanceof TDGWTSessionExpiredException) {
|
||||
eventBus.fireEvent(new SessionExpiredEvent(
|
||||
SessionExpiredType.EXPIREDONSERVER));
|
||||
} else {
|
||||
if (caught instanceof TDGWTIsLockedException) {
|
||||
Log.error(caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Error Locked",
|
||||
caught.getLocalizedMessage());
|
||||
} else {
|
||||
Log.debug("Delete Template Error: "
|
||||
+ caught.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Apply Template Error ",
|
||||
"Error in invocation of delete template operation! "
|
||||
+ caught.getLocalizedMessage());
|
||||
}
|
||||
Log.error("Error deleting column rule: "
|
||||
+ caught.getLocalizedMessage());
|
||||
caught.printStackTrace();
|
||||
UtilsGXT3.alert("Error deleting column rule",
|
||||
caught.getLocalizedMessage());
|
||||
}
|
||||
}
|
||||
|
||||
public void onSuccess(Void result) {
|
||||
UtilsGXT3.info("Delete Template", "Template deleted!");
|
||||
close();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -5,11 +5,10 @@ import java.util.List;
|
|||
|
||||
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.template.TemplateDeleteSession;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleScopeType;
|
||||
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
|
@ -70,7 +69,7 @@ public class RuleDeletePanel extends FramedPanel {
|
|||
|
||||
private EventBus eventBus;
|
||||
private RuleDeleteDialog parent;
|
||||
private TemplateDeleteSession templateDeleteSession;
|
||||
|
||||
|
||||
private TextButton btnDelete;
|
||||
private TextButton btnClose;
|
||||
|
@ -252,7 +251,7 @@ public class RuleDeletePanel extends FramedPanel {
|
|||
btnDelete = new TextButton("Delete");
|
||||
btnDelete.setIcon(TabularDataResources.INSTANCE.ruleDelete());
|
||||
btnDelete.setIconAlign(IconAlign.RIGHT);
|
||||
btnDelete.setToolTip("Delete Template");
|
||||
btnDelete.setToolTip("Delete");
|
||||
btnDelete.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
|
@ -341,23 +340,21 @@ public class RuleDeletePanel extends FramedPanel {
|
|||
*/
|
||||
|
||||
protected ArrayList<RuleDescriptionData> getSelectedItem() {
|
||||
ArrayList<RuleDescriptionData> templates = new ArrayList<RuleDescriptionData>();
|
||||
for (RuleDescriptionData template : grid.getSelectionModel()
|
||||
ArrayList<RuleDescriptionData> rules = new ArrayList<RuleDescriptionData>();
|
||||
for (RuleDescriptionData rule : grid.getSelectionModel()
|
||||
.getSelectedItems()) {
|
||||
templates.add(template);
|
||||
rules.add(rule);
|
||||
}
|
||||
return templates;
|
||||
return rules;
|
||||
}
|
||||
|
||||
protected void delete() {
|
||||
templateDeleteSession = new TemplateDeleteSession();
|
||||
ArrayList<RuleDescriptionData> templates = getSelectedItem();
|
||||
if (templates == null || templates.size() == 0) {
|
||||
UtilsGXT3.info("Attention", "Select the template to be deleted");
|
||||
ArrayList<RuleDescriptionData> rules = getSelectedItem();
|
||||
if (rules == null || rules.size() == 0) {
|
||||
UtilsGXT3.info("Attention", "Select the rule to be deleted");
|
||||
} else {
|
||||
// templateDeleteSession.setTemplates(getSelectedItem());
|
||||
Log.debug("templateDeleteSession: " + templateDeleteSession);
|
||||
parent.templatesDelete(templateDeleteSession);
|
||||
Log.debug("Rules Delete: " + rules);
|
||||
parent.removeRule(rules);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@ 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 org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
|
|
|
@ -5,10 +5,10 @@ import java.util.List;
|
|||
|
||||
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleScopeType;
|
||||
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
|
|
|
@ -5,10 +5,10 @@ import java.util.List;
|
|||
|
||||
import org.gcube.portlets.user.td.client.resource.TabularDataResources;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleDescriptionDataProperties;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.rule.RuleScopeType;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.exception.TDGWTSessionExpiredException;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleDescriptionData;
|
||||
import org.gcube.portlets.user.td.gwtservice.shared.rule.RuleScopeType;
|
||||
import org.gcube.portlets.user.td.tablewidget.client.util.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
|
|
Loading…
Reference in New Issue