81: Allow the creation and use of expressions on multi column in TDM portlet
Task-Url: https://support.d4science.org/issues/81 Updated MultiColumnExpressionPanel git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@114888 82a268e6-3cf1-43bd-a215-b396298e98cf
|
@ -508,14 +508,14 @@ public class ColumnExpressionPanel extends FramedPanel {
|
|||
Log.debug("ConditionWidget" + conditionWidget);
|
||||
conditionsField.add(conditionWidget);
|
||||
|
||||
btnApply = new TextButton("Apply");
|
||||
btnApply.setIcon(ExpressionResources.INSTANCE.apply());
|
||||
btnApply = new TextButton("Add");
|
||||
btnApply.setIcon(ExpressionResources.INSTANCE.ruleColumnAdd());
|
||||
btnApply.setIconAlign(IconAlign.RIGHT);
|
||||
btnApply.setToolTip("Apply rule");
|
||||
btnApply.setToolTip("Add");
|
||||
btnApply.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Apply");
|
||||
Log.debug("Pressed Add");
|
||||
applySeleceted();
|
||||
|
||||
}
|
||||
|
|
|
@ -3,38 +3,32 @@ package org.gcube.portlets.user.td.expressionwidget.client;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.exception.MultiColumnExpressionPanelException;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.expression.ConditionOnMultiColumnWidget;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.notification.ExpressionWrapperNotification;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.properties.ColumnDataTypeProperties;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.store.ColumnDataTypeElement;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.store.ColumnDataTypeStore;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ConditionTypeMapException;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.logical.C_Not;
|
||||
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.monitorwidget.client.utils.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.expression.C_ExpressionContainer;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.client.expression.ExpressionWrapper;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnMockUp;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.event.logical.shared.SelectionEvent;
|
||||
import com.google.gwt.event.logical.shared.SelectionHandler;
|
||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||
import com.google.gwt.user.client.ui.HTML;
|
||||
import com.google.web.bindery.event.shared.EventBus;
|
||||
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
||||
import com.sencha.gxt.cell.core.client.form.ComboBoxCell.TriggerAction;
|
||||
import com.sencha.gxt.core.client.util.Margins;
|
||||
import com.sencha.gxt.data.shared.LabelProvider;
|
||||
import com.sencha.gxt.data.shared.ListStore;
|
||||
import com.sencha.gxt.widget.core.client.FramedPanel;
|
||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
||||
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutData;
|
||||
|
@ -50,7 +44,7 @@ import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
|||
import com.sencha.gxt.widget.core.client.form.FieldSet;
|
||||
import com.sencha.gxt.widget.core.client.form.TextArea;
|
||||
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||
import com.sencha.gxt.widget.core.client.info.Info;
|
||||
import com.sencha.gxt.widget.core.client.form.validator.EmptyValidator;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -61,9 +55,14 @@ import com.sencha.gxt.widget.core.client.info.Info;
|
|||
public class MultiColumnExpressionPanel extends FramedPanel {
|
||||
private static final String WIDTH = "929px";
|
||||
private static final String HEIGHT = "352px";
|
||||
private static final String ROW_DELETE_BY_EXPRESSION_HEIGHT = "388px";
|
||||
private static final String ROWS_DELETE_HEIGHT = "388px";
|
||||
private static final String RULE_HEIGHT= "312px";
|
||||
|
||||
private static final String RULE_MULTI_CONDITION_WIDTH = "890px";
|
||||
private static final String RULE_MULTI_CONDITION_HEIGHT = "228px";
|
||||
|
||||
|
||||
private static final String RULE_DESCRIPTION_HEIGHT = "44px";
|
||||
private static final String RULE_PLACE_HOLDER_ID = "Column";
|
||||
|
||||
private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd HH:mm");
|
||||
|
||||
|
@ -71,8 +70,6 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
ColumnFilter, RowDeleteByExpression, Template, RuleOnTable;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private MultiColumnExpressionPanelType type;
|
||||
|
||||
private TemplateMultiColumnExpressionDialog parentTemplateDialog;
|
||||
|
@ -95,14 +92,6 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
private TextField ruleName;
|
||||
private TextArea ruleDescription;
|
||||
|
||||
private ComboBox<ColumnDataTypeElement> comboDataType;
|
||||
|
||||
private FieldLabel comboDataTypeLabel;
|
||||
//private RuleDescriptionData ruleDescriptionData;
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param parent
|
||||
|
@ -130,10 +119,10 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
*/
|
||||
public MultiColumnExpressionPanel(
|
||||
RowsDeleteByMultiColumnExpressionDialog parent,
|
||||
ArrayList<ColumnData> columns, EventBus eventBus) {
|
||||
ArrayList<ColumnData> columns, EventBus eventBus) {
|
||||
super();
|
||||
setWidth(WIDTH);
|
||||
setHeight(ROW_DELETE_BY_EXPRESSION_HEIGHT);
|
||||
setHeight(ROWS_DELETE_HEIGHT);
|
||||
type = MultiColumnExpressionPanelType.RowDeleteByExpression;
|
||||
this.parentRowsDeleteByExpressionDialog = parent;
|
||||
this.columns = columns;
|
||||
|
@ -163,86 +152,151 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
* @param parent
|
||||
* @param eventBus
|
||||
*/
|
||||
public MultiColumnExpressionPanel(RuleOnTableCreateDialog parent, RuleDescriptionData initialRuleDescriptionData, EventBus eventBus) {
|
||||
public MultiColumnExpressionPanel(RuleOnTableCreateDialog parent,
|
||||
RuleDescriptionData initialRuleDescriptionData)
|
||||
throws MultiColumnExpressionPanelException {
|
||||
super();
|
||||
Log.debug("MultiColumnExpressionPanel");
|
||||
setWidth(WIDTH);
|
||||
setHeight(HEIGHT);
|
||||
setHeight(RULE_HEIGHT);
|
||||
type = MultiColumnExpressionPanelType.RuleOnTable;
|
||||
this.parentRuleOnTableCreateDialog = parent;
|
||||
this.initialRuleDescriptionData=initialRuleDescriptionData;
|
||||
this.columns = null;
|
||||
createOnRule();
|
||||
this.initialRuleDescriptionData = initialRuleDescriptionData;
|
||||
retrieveColumns();
|
||||
}
|
||||
|
||||
|
||||
protected void createOnRule() {
|
||||
forceLayoutOnResize = true;
|
||||
|
||||
setBodyBorder(false);
|
||||
setHeaderVisible(false);
|
||||
|
||||
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
|
||||
basicLayout.setAdjustForScroll(true);
|
||||
|
||||
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
|
||||
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||
flowButton.setPack(BoxLayoutPack.CENTER);
|
||||
|
||||
conditionsField = new FieldSet();
|
||||
conditionsField.setHeadingText("Conditions");
|
||||
conditionsField.setCollapsible(false);
|
||||
|
||||
conditionWidget = new ConditionOnMultiColumnWidget(columns);
|
||||
conditionsField.add(conditionWidget);
|
||||
|
||||
btnApply = new TextButton("Save");
|
||||
btnApply.setIcon(ExpressionResources.INSTANCE.ruleColumnAdd());
|
||||
btnApply.setIconAlign(IconAlign.RIGHT);
|
||||
btnApply.setToolTip("Save rule");
|
||||
btnApply.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Save");
|
||||
applySeleceted();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
btnClose = new TextButton("Close");
|
||||
btnClose.setIcon(ExpressionResources.INSTANCE.close());
|
||||
btnClose.setIconAlign(IconAlign.RIGHT);
|
||||
btnClose.setToolTip("Cancel rule");
|
||||
btnClose.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Close");
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
flowButton.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
|
||||
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
|
||||
basicLayout.add(conditionsField, new VerticalLayoutData(1, -1,
|
||||
new Margins(1)));
|
||||
basicLayout.add(flowButton, new VerticalLayoutData(1, 36, new Margins(
|
||||
5, 2, 5, 2)));
|
||||
add(basicLayout);
|
||||
|
||||
protected void retrieveColumns() throws MultiColumnExpressionPanelException {
|
||||
if (initialRuleDescriptionData == null) {
|
||||
conditionWidget.disable();
|
||||
} else {
|
||||
updateCondition();
|
||||
Log.error("No rules description data present!");
|
||||
throw new MultiColumnExpressionPanelException(
|
||||
"No rules description data present!");
|
||||
}
|
||||
|
||||
TDRuleType tdRuleType = initialRuleDescriptionData.getTdRuleType();
|
||||
if (tdRuleType == null) {
|
||||
Log.error("No Rule Type present!");
|
||||
throw new MultiColumnExpressionPanelException(
|
||||
"No Rule Type present!");
|
||||
}
|
||||
|
||||
if (tdRuleType instanceof TDRuleTableType) {
|
||||
TDRuleTableType tdRuleTableType = (TDRuleTableType) tdRuleType;
|
||||
ArrayList<RuleColumnPlaceHolderDescriptor> listDescriptors = tdRuleTableType
|
||||
.getRuleColumnPlaceHolderDescriptors();
|
||||
columns = new ArrayList<ColumnData>();
|
||||
for (RuleColumnPlaceHolderDescriptor ruleColumnPlaceHolderDescriptor : listDescriptors) {
|
||||
ColumnData col = new ColumnData();
|
||||
col.setId(ruleColumnPlaceHolderDescriptor.getId());
|
||||
col.setColumnId(ruleColumnPlaceHolderDescriptor.getLabel());
|
||||
col.setLabel(ruleColumnPlaceHolderDescriptor.getLabel());
|
||||
col.setDataTypeName(ruleColumnPlaceHolderDescriptor
|
||||
.getColumnDataType().getId());
|
||||
columns.add(col);
|
||||
}
|
||||
|
||||
createOnRule();
|
||||
|
||||
} else {
|
||||
Log.error("No Table Rule Type present!");
|
||||
throw new MultiColumnExpressionPanelException(
|
||||
"No Table Rule Type present!");
|
||||
}
|
||||
}
|
||||
|
||||
protected void createOnRule() throws MultiColumnExpressionPanelException {
|
||||
try {
|
||||
forceLayoutOnResize = true;
|
||||
|
||||
setBodyBorder(false);
|
||||
setHeaderVisible(false);
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void createColumnMockUp(VerticalLayoutContainer propertiesLayout) {
|
||||
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
|
||||
basicLayout.setAdjustForScroll(true);
|
||||
|
||||
FieldSet propertiesField = new FieldSet();
|
||||
propertiesField.setHeadingText("Properties");
|
||||
propertiesField.setCollapsible(false);
|
||||
|
||||
VerticalLayoutContainer propertiesLayout = new VerticalLayoutContainer();
|
||||
createRuleOnTableDecription(propertiesLayout);
|
||||
propertiesField.add(propertiesLayout);
|
||||
|
||||
conditionsField = new FieldSet();
|
||||
conditionsField.setHeadingText("Conditions");
|
||||
conditionsField.setCollapsible(false);
|
||||
|
||||
conditionWidget = new ConditionOnMultiColumnWidget(columns,RULE_MULTI_CONDITION_WIDTH,RULE_MULTI_CONDITION_HEIGHT);
|
||||
conditionsField.add(conditionWidget);
|
||||
|
||||
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
|
||||
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||
flowButton.setPack(BoxLayoutPack.CENTER);
|
||||
|
||||
btnApply = new TextButton("Save");
|
||||
btnApply.setIcon(ExpressionResources.INSTANCE.ruleColumnAdd());
|
||||
btnApply.setIconAlign(IconAlign.RIGHT);
|
||||
btnApply.setToolTip("Save rule");
|
||||
btnApply.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Save");
|
||||
applySeleceted();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
btnClose = new TextButton("Close");
|
||||
btnClose.setIcon(ExpressionResources.INSTANCE.close());
|
||||
btnClose.setIconAlign(IconAlign.RIGHT);
|
||||
btnClose.setToolTip("Cancel rule");
|
||||
btnClose.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Close");
|
||||
close();
|
||||
}
|
||||
});
|
||||
|
||||
flowButton
|
||||
.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
|
||||
flowButton
|
||||
.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
|
||||
basicLayout.add(propertiesField, new VerticalLayoutData(1, -1,
|
||||
new Margins(1)));
|
||||
|
||||
basicLayout.add(conditionsField, new VerticalLayoutData(1, -1,
|
||||
new Margins(1)));
|
||||
|
||||
if (parentRuleOnTableCreateDialog != null) {
|
||||
basicLayout.add(flowButton, new VerticalLayoutData(1, 36,
|
||||
new Margins(5, 2, 5, 2)));
|
||||
}
|
||||
add(basicLayout);
|
||||
|
||||
if (initialRuleDescriptionData == null) {
|
||||
conditionWidget.disable();
|
||||
} else {
|
||||
if (initialRuleDescriptionData.getExpression() == null) {
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Log.debug("Error in createOnRule(): "+e.getLocalizedMessage());
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
private void createRuleOnTableDecription(
|
||||
VerticalLayoutContainer propertiesLayout) {
|
||||
ruleName = new TextField();
|
||||
ruleName.addValidator(new EmptyValidator<String>());
|
||||
ruleName.setToolTip("Rule Name");
|
||||
if (initialRuleDescriptionData != null) {
|
||||
ruleName.setValue(initialRuleDescriptionData.getName());
|
||||
|
@ -250,6 +304,7 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
FieldLabel ruleNameLabel = new FieldLabel(ruleName, "Rule Name");
|
||||
|
||||
ruleDescription = new TextArea();
|
||||
ruleDescription.addValidator(new EmptyValidator<String>());
|
||||
ruleDescription.setHeight(RULE_DESCRIPTION_HEIGHT);
|
||||
ruleDescription.setToolTip("Rule Description");
|
||||
if (initialRuleDescriptionData != null) {
|
||||
|
@ -259,193 +314,38 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
FieldLabel ruleDescriptionLabel = new FieldLabel(ruleDescription,
|
||||
"Rule Description");
|
||||
|
||||
|
||||
// comboDataType
|
||||
ColumnDataTypeProperties propsDataType = GWT
|
||||
.create(ColumnDataTypeProperties.class);
|
||||
ListStore<ColumnDataTypeElement> storeComboDataType = new ListStore<ColumnDataTypeElement>(
|
||||
propsDataType.id());
|
||||
storeComboDataType.addAll(ColumnDataTypeStore.getAttributeType());
|
||||
|
||||
comboDataType = new ComboBox<ColumnDataTypeElement>(
|
||||
storeComboDataType, propsDataType.label());
|
||||
Log.trace("ComboDataType created");
|
||||
|
||||
addHandlersForComboAttributeType(propsDataType.label());
|
||||
|
||||
comboDataType.setEmptyText("Select a column type...");
|
||||
comboDataType.setWidth(191);
|
||||
comboDataType.setTypeAhead(true);
|
||||
comboDataType.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
if (initialRuleDescriptionData != null) {
|
||||
Log.debug("Initial RuleDescriptionData: "
|
||||
+ initialRuleDescriptionData);
|
||||
ColumnDataType cdt = retrieveColumnDataType();
|
||||
if (cdt != null) {
|
||||
Log.debug("Retrieved column data type: " + cdt);
|
||||
ColumnDataTypeElement cdte = ColumnDataTypeStore
|
||||
.selectedAttributeElement(cdt);
|
||||
if (cdte != null) {
|
||||
comboDataType.setValue(cdte);
|
||||
|
||||
}
|
||||
} else {
|
||||
Log.debug("Retrieved column data type null");
|
||||
}
|
||||
}
|
||||
|
||||
comboDataTypeLabel = new FieldLabel(comboDataType,
|
||||
"Data Type");
|
||||
|
||||
propertiesLayout.add(ruleNameLabel, new VerticalLayoutData(1, -1,
|
||||
new Margins(0)));
|
||||
propertiesLayout.add(ruleDescriptionLabel, new VerticalLayoutData(1,
|
||||
-1, new Margins(0)));
|
||||
|
||||
propertiesLayout.add(comboDataTypeLabel, new VerticalLayoutData(1,
|
||||
-1, new Margins(0)));
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
private ColumnDataType retrieveColumnDataType() {
|
||||
TDRuleType tdRuleTableType = initialRuleDescriptionData
|
||||
.getTdRuleType();
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
protected void addHandlersForComboAttributeType(
|
||||
final LabelProvider<ColumnDataTypeElement> labelProvider) {
|
||||
comboDataType
|
||||
.addSelectionHandler(new SelectionHandler<ColumnDataTypeElement>() {
|
||||
public void onSelection(
|
||||
SelectionEvent<ColumnDataTypeElement> event) {
|
||||
Info.display(
|
||||
"Attribute Type Selected",
|
||||
"You selected "
|
||||
+ (event.getSelectedItem() == null ? "nothing"
|
||||
: labelProvider.getLabel(event
|
||||
.getSelectedItem())
|
||||
+ "!"));
|
||||
Log.debug("ComboAttributeType selected: "
|
||||
+ event.getSelectedItem());
|
||||
ColumnDataTypeElement attributeType = event
|
||||
.getSelectedItem();
|
||||
updateDataType(attributeType.getType());
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
protected void updateCondition() {
|
||||
ColumnMockUp columnMockUp = retrieveColumnMockUp();
|
||||
if (columnMockUp != null) {
|
||||
column = new ColumnData();
|
||||
column.setId(columnMockUp.getId());
|
||||
column.setColumnId(columnMockUp.getColumnId());
|
||||
column.setLabel(columnMockUp.getLabel());
|
||||
column.setDataTypeName(columnMockUp.getColumnDataType().toString());
|
||||
conditionWidget.update(columns);
|
||||
conditionWidget.enable();
|
||||
} else {
|
||||
conditionWidget.disable();
|
||||
}
|
||||
forceLayout();
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected ColumnMockUp retrieveColumnMockUp() {
|
||||
ColumnMockUp columnMockUp = null;
|
||||
|
||||
ColumnDataTypeElement columnDataTypeElement = comboDataType
|
||||
.getCurrentValue();
|
||||
if (columnDataTypeElement != null) {
|
||||
ColumnDataType dataType = columnDataTypeElement.getType();
|
||||
if (dataType != null) {
|
||||
columnMockUp = new ColumnMockUp(null, RULE_PLACE_HOLDER_ID,
|
||||
dataType, RULE_PLACE_HOLDER_ID);
|
||||
|
||||
} else {
|
||||
|
||||
}
|
||||
} else {
|
||||
|
||||
}
|
||||
|
||||
return columnMockUp;
|
||||
}
|
||||
|
||||
protected ColumnMockUp checkEnterData() {
|
||||
ColumnMockUp columnMockUp = null;
|
||||
|
||||
String ruleNameS = ruleName.getCurrentValue();
|
||||
|
||||
if (ruleNameS != null && !ruleNameS.isEmpty()) {
|
||||
|
||||
String ruleDescriptionS = ruleDescription.getCurrentValue();
|
||||
|
||||
if (ruleDescriptionS != null && !ruleDescriptionS.isEmpty()) {
|
||||
ColumnDataTypeElement columnDataTypeElement = comboDataType
|
||||
.getCurrentValue();
|
||||
if (columnDataTypeElement != null) {
|
||||
ColumnDataType dataType = columnDataTypeElement.getType();
|
||||
if (dataType != null) {
|
||||
columnMockUp = new ColumnMockUp(null,
|
||||
RULE_PLACE_HOLDER_ID, dataType,
|
||||
RULE_PLACE_HOLDER_ID);
|
||||
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Column data type not selected!");
|
||||
}
|
||||
protected RuleDescriptionData retrieveRuleDescriptionData(C_Expression exp)
|
||||
throws MultiColumnExpressionPanelException {
|
||||
if (ruleName.validate()) {
|
||||
if (ruleDescription.validate()) {
|
||||
if (exp != null) {
|
||||
String ruleNameS = ruleName.getCurrentValue();
|
||||
String ruleDescriptionS = ruleDescription.getCurrentValue();
|
||||
RuleDescriptionData ruleDescriptionData = new RuleDescriptionData(
|
||||
0, ruleNameS, ruleDescriptionS,
|
||||
sdf.format(new Date()), null, null,
|
||||
RuleScopeType.TABLE, exp,
|
||||
initialRuleDescriptionData.getTdRuleType());
|
||||
return ruleDescriptionData;
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Column data type not selected!");
|
||||
throw new MultiColumnExpressionPanelException(
|
||||
"Enter a valid condition!");
|
||||
}
|
||||
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention",
|
||||
throw new MultiColumnExpressionPanelException(
|
||||
"Enter a valid description for the rule!");
|
||||
}
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention", "Enter a valid name for the rule!");
|
||||
throw new MultiColumnExpressionPanelException(
|
||||
"Enter a valid name for the rule!");
|
||||
}
|
||||
return columnMockUp;
|
||||
|
||||
}
|
||||
|
||||
protected RuleDescriptionData retrieveRuleDescriptionData(C_Expression exp) {
|
||||
ColumnMockUp columnMockUp = checkEnterData();
|
||||
if (columnMockUp != null) {
|
||||
if (exp != null) {
|
||||
String ruleNameS = ruleName.getCurrentValue();
|
||||
String ruleDescriptionS = ruleDescription.getCurrentValue();
|
||||
//TODO
|
||||
RuleDescriptionData ruleDescriptionData = new RuleDescriptionData(
|
||||
0, ruleNameS, ruleDescriptionS, sdf.format(new Date()), null, null,
|
||||
RuleScopeType.TABLE, exp,initialRuleDescriptionData.getTdRuleType());
|
||||
return ruleDescriptionData;
|
||||
} else {
|
||||
UtilsGXT3.alert("Attention", "Enter a valid condition!");
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected void updateDataType(ColumnDataType type) {
|
||||
Log.debug("Update ColumnDataType: " + type);
|
||||
updateCondition();
|
||||
|
||||
}
|
||||
|
||||
|
@ -464,7 +364,6 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||
flowButton.setPack(BoxLayoutPack.CENTER);
|
||||
|
||||
|
||||
conditionsField = new FieldSet();
|
||||
conditionsField.setHeadingText("Conditions");
|
||||
conditionsField.setCollapsible(false);
|
||||
|
@ -473,14 +372,14 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
Log.debug("ConditionWidget" + conditionWidget);
|
||||
conditionsField.add(conditionWidget);
|
||||
|
||||
btnApply = new TextButton("Apply");
|
||||
btnApply.setIcon(ExpressionResources.INSTANCE.apply());
|
||||
btnApply = new TextButton("Add");
|
||||
btnApply.setIcon(ExpressionResources.INSTANCE.ruleTableAdd());
|
||||
btnApply.setIconAlign(IconAlign.RIGHT);
|
||||
btnApply.setToolTip("Apply rule");
|
||||
btnApply.setToolTip("Add rule");
|
||||
btnApply.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
Log.debug("Pressed Apply");
|
||||
Log.debug("Pressed Add");
|
||||
applySeleceted();
|
||||
|
||||
}
|
||||
|
@ -489,7 +388,7 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
btnClose = new TextButton("Close");
|
||||
btnClose.setIcon(ExpressionResources.INSTANCE.close());
|
||||
btnClose.setIconAlign(IconAlign.RIGHT);
|
||||
btnClose.setToolTip("Cancel rule");
|
||||
btnClose.setToolTip("Close");
|
||||
btnClose.addSelectHandler(new SelectHandler() {
|
||||
|
||||
public void onSelect(SelectEvent event) {
|
||||
|
@ -557,7 +456,6 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
flowButton.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
|
||||
|
||||
basicLayout.add(conditionsField, new VerticalLayoutData(1, -1,
|
||||
new Margins(1)));
|
||||
basicLayout.add(flowButton, new VerticalLayoutData(1, 36, new Margins(
|
||||
|
@ -588,7 +486,6 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
Log.debug("ConditionWidget" + conditionWidget);
|
||||
conditionsField.add(conditionWidget);
|
||||
|
||||
|
||||
btnApply = new TextButton("Delete");
|
||||
btnApply.setIcon(ExpressionResources.INSTANCE
|
||||
.tableRowDeleteByExpression());
|
||||
|
@ -603,7 +500,6 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
}
|
||||
});
|
||||
|
||||
|
||||
btnClose = new TextButton("Close");
|
||||
btnClose.setIcon(ExpressionResources.INSTANCE.close());
|
||||
btnClose.setIconAlign(IconAlign.RIGHT);
|
||||
|
@ -618,7 +514,6 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
flowButton.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
flowButton.add(btnClose, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||
|
||||
|
||||
basicLayout.add(conditionsField, new VerticalLayoutData(1, -1,
|
||||
new Margins(1)));
|
||||
basicLayout.add(flowButton, new VerticalLayoutData(1, 36, new Margins(
|
||||
|
@ -626,8 +521,6 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
|
||||
add(basicLayout);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
protected void setSelectedColumn() {
|
||||
|
@ -696,10 +589,8 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
return selectionHandler;
|
||||
}
|
||||
|
||||
|
||||
protected void applySeleceted() {
|
||||
|
||||
|
||||
C_Expression exp;
|
||||
C_ExpressionContainer condContainer = null;
|
||||
ExpressionWrapper exWrapper = null;
|
||||
|
@ -717,12 +608,11 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
condContainer.setId(C_ExpressionContainer.Contains.C_Expression);
|
||||
condContainer.setExp(exp);
|
||||
condContainer.setReadableExpression(exp.getReadableExpression());
|
||||
exWrapper = new ExpressionWrapper(column.getTrId(), column,
|
||||
condContainer);
|
||||
exWrapper = new ExpressionWrapper(null, null, condContainer);
|
||||
|
||||
ExpressionWrapperNotification expressionWrapperNotification = new ExpressionWrapperNotification(
|
||||
exWrapper);
|
||||
Log.debug("Apply: "+expressionWrapperNotification);
|
||||
Log.debug("Apply: " + expressionWrapperNotification);
|
||||
parentTemplateDialog.onExpression(expressionWrapperNotification);
|
||||
break;
|
||||
case RuleOnTable:
|
||||
|
@ -737,9 +627,19 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
|
||||
return;
|
||||
}
|
||||
RuleDescriptionData ruleDescriptionData = retrieveRuleDescriptionData(exp);
|
||||
|
||||
RuleDescriptionData ruleDescriptionData = null;
|
||||
try {
|
||||
ruleDescriptionData = retrieveRuleDescriptionData(exp);
|
||||
} catch (MultiColumnExpressionPanelException e1) {
|
||||
Log.debug(e1.getLocalizedMessage());
|
||||
UtilsGXT3.alert("Attention", e1.getLocalizedMessage());
|
||||
return;
|
||||
}
|
||||
if (ruleDescriptionData != null) {
|
||||
parentRuleOnTableCreateDialog.addRule(ruleDescriptionData);
|
||||
if (parentRuleOnTableCreateDialog != null) {
|
||||
parentRuleOnTableCreateDialog.addRule(ruleDescriptionData);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case ColumnFilter:
|
||||
|
@ -750,7 +650,7 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
|
||||
return;
|
||||
}
|
||||
Log.debug("Apply: "+exp);
|
||||
Log.debug("Apply: " + exp);
|
||||
parentMultiFilterDialog.applyFilter(exp);
|
||||
break;
|
||||
case RowDeleteByExpression:
|
||||
|
@ -762,9 +662,8 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
return;
|
||||
}
|
||||
C_Expression notExp = new C_Not(exp);
|
||||
Log.debug("Apply: "+exp);
|
||||
parentRowsDeleteByExpressionDialog.deleteRowsByExpression(
|
||||
notExp);
|
||||
Log.debug("Apply: " + exp);
|
||||
parentRowsDeleteByExpressionDialog.deleteRowsByExpression(notExp);
|
||||
|
||||
break;
|
||||
|
||||
|
@ -774,13 +673,35 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
|||
|
||||
}
|
||||
|
||||
public RuleDescriptionData getRuleOnTable()
|
||||
throws MultiColumnExpressionPanelException {
|
||||
if (!conditionWidget.isEnabled()) {
|
||||
throw new MultiColumnExpressionPanelException("Fill all field!");
|
||||
}
|
||||
|
||||
C_Expression exp;
|
||||
|
||||
try {
|
||||
exp = conditionWidget.getExpression();
|
||||
} catch (ConditionTypeMapException e) {
|
||||
Log.debug(e.getLocalizedMessage());
|
||||
throw new MultiColumnExpressionPanelException(
|
||||
e.getLocalizedMessage());
|
||||
}
|
||||
RuleDescriptionData ruleDescriptionData = retrieveRuleDescriptionData(exp);
|
||||
return ruleDescriptionData;
|
||||
|
||||
}
|
||||
|
||||
protected void close() {
|
||||
switch (type) {
|
||||
case Template:
|
||||
parentTemplateDialog.close();
|
||||
break;
|
||||
case RuleOnTable:
|
||||
parentRuleOnTableCreateDialog.close();
|
||||
if (parentRuleOnTableCreateDialog != null) {
|
||||
parentRuleOnTableCreateDialog.close();
|
||||
}
|
||||
break;
|
||||
case ColumnFilter:
|
||||
parentMultiFilterDialog.close();
|
||||
|
|
|
@ -2,6 +2,7 @@ package org.gcube.portlets.user.td.expressionwidget.client;
|
|||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.exception.MultiColumnExpressionPanelException;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.notification.RuleDialogNotification;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.notification.RuleDialogNotification.HasRuleDialogNotificationListener;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.notification.RuleDialogNotification.RuleDialogNotificationListener;
|
||||
|
@ -46,8 +47,13 @@ public class RuleOnTableCreateDialog extends Window implements
|
|||
initWindow();
|
||||
this.eventBus = eventBus;
|
||||
this.initialRuleDescriptionData=ruleDescriptionData;
|
||||
multiColumnExpressionPanel = new MultiColumnExpressionPanel(this, ruleDescriptionData,eventBus);
|
||||
add(multiColumnExpressionPanel);
|
||||
try {
|
||||
multiColumnExpressionPanel = new MultiColumnExpressionPanel(this, ruleDescriptionData);
|
||||
add(multiColumnExpressionPanel);
|
||||
} catch (MultiColumnExpressionPanelException e) {
|
||||
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
@ -60,7 +66,7 @@ public class RuleOnTableCreateDialog extends Window implements
|
|||
setClosable(true);
|
||||
setModal(true);
|
||||
forceLayoutOnResize = true;
|
||||
getHeader().setIcon(ExpressionResources.INSTANCE.ruleColumnAdd());
|
||||
getHeader().setIcon(ExpressionResources.INSTANCE.ruleTableAdd());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -88,7 +88,7 @@ public class TemplateColumnExpressionDialog extends Window implements
|
|||
setClosable(true);
|
||||
setModal(true);
|
||||
forceLayoutOnResize = true;
|
||||
getHeader().setIcon(ExpressionResources.INSTANCE.ruleAdd());
|
||||
getHeader().setIcon(ExpressionResources.INSTANCE.ruleColumnAdd());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -44,6 +44,7 @@ public class TemplateMultiColumnExpressionDialog extends Window implements
|
|||
columns = new ArrayList<ColumnData>();
|
||||
for (ColumnMockUp columnMockUp : columnsMockUp) {
|
||||
ColumnData column = new ColumnData();
|
||||
column.setId(columnMockUp.getColumnId());
|
||||
column.setColumnId(columnMockUp.getColumnId());
|
||||
column.setLabel(columnMockUp.getLabel());
|
||||
column.setDataTypeName(columnMockUp.getColumnDataType().toString());
|
||||
|
@ -78,7 +79,7 @@ public class TemplateMultiColumnExpressionDialog extends Window implements
|
|||
setClosable(true);
|
||||
setModal(true);
|
||||
forceLayoutOnResize = true;
|
||||
getHeader().setIcon(ExpressionResources.INSTANCE.ruleAdd());
|
||||
getHeader().setIcon(ExpressionResources.INSTANCE.ruleTableAdd());
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,21 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.client.exception;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author giancarlo
|
||||
* email: <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public class MultiColumnExpressionPanelException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -4619188268507480346L;
|
||||
|
||||
public MultiColumnExpressionPanelException(String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public MultiColumnExpressionPanelException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,76 +1,84 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.client.resources;
|
||||
|
||||
|
||||
|
||||
import com.google.gwt.core.client.GWT;
|
||||
import com.google.gwt.resources.client.ClientBundle;
|
||||
import com.google.gwt.resources.client.ImageResource;
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @author "Giancarlo Panichi"
|
||||
* <a href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
* @author "Giancarlo Panichi" <a
|
||||
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||
*
|
||||
*/
|
||||
public interface ExpressionResources extends ClientBundle {
|
||||
public interface ExpressionResources extends ClientBundle {
|
||||
|
||||
public static final ExpressionResources INSTANCE = GWT.create(ExpressionResources.class);
|
||||
public static final ExpressionResources INSTANCE = GWT
|
||||
.create(ExpressionResources.class);
|
||||
|
||||
@Source("add.png")
|
||||
ImageResource add();
|
||||
@Source("add.png")
|
||||
ImageResource add();
|
||||
|
||||
@Source("delete.png")
|
||||
ImageResource delete();
|
||||
@Source("delete.png")
|
||||
ImageResource delete();
|
||||
|
||||
@Source("wrench-database.png")
|
||||
ImageResource save();
|
||||
@Source("wrench-database.png")
|
||||
ImageResource save();
|
||||
|
||||
@Source("close-red.png")
|
||||
ImageResource close();
|
||||
@Source("close-red.png")
|
||||
ImageResource close();
|
||||
|
||||
@Source("rule-add.png")
|
||||
ImageResource ruleAdd();
|
||||
@Source("rule-add.png")
|
||||
ImageResource ruleAdd();
|
||||
|
||||
@Source("rule-add_32.png")
|
||||
ImageResource ruleAdd32();
|
||||
@Source("rule-add_32.png")
|
||||
ImageResource ruleAdd32();
|
||||
|
||||
@Source("rule-edit_32.png")
|
||||
ImageResource ruleEdit32();
|
||||
@Source("rule-edit_32.png")
|
||||
ImageResource ruleEdit32();
|
||||
|
||||
@Source("rule-edit.png")
|
||||
ImageResource ruleEdit();
|
||||
@Source("rule-edit.png")
|
||||
ImageResource ruleEdit();
|
||||
|
||||
@Source("rule-column-add.png")
|
||||
ImageResource ruleColumnAdd();
|
||||
|
||||
@Source("rule-column-add.png")
|
||||
ImageResource ruleColumnAdd();
|
||||
@Source("rule-column-add_32.png")
|
||||
ImageResource ruleColumnAdd32();
|
||||
|
||||
@Source("rule-column-add_32.png")
|
||||
ImageResource ruleColumnAdd32();
|
||||
@Source("rule-table-add.png")
|
||||
ImageResource ruleTableAdd();
|
||||
|
||||
@Source("wrench-go.png")
|
||||
ImageResource apply();
|
||||
@Source("rule-table-add_32.png")
|
||||
ImageResource ruleTableAdd32();
|
||||
|
||||
@Source("wrench-manage.png")
|
||||
ImageResource search();
|
||||
@Source("rule-table-apply.png")
|
||||
ImageResource ruleTableApply();
|
||||
|
||||
@Source("column-filter.png")
|
||||
ImageResource filter();
|
||||
@Source("rule-table-apply_32.png")
|
||||
ImageResource ruleTableApply32();
|
||||
|
||||
@Source("column-filter-go.png")
|
||||
ImageResource applyFilter();
|
||||
@Source("wrench-go.png")
|
||||
ImageResource apply();
|
||||
|
||||
@Source("column-replace-by-expression_32.png")
|
||||
ImageResource columnReplaceByExpression32();
|
||||
@Source("wrench-manage.png")
|
||||
ImageResource search();
|
||||
|
||||
@Source("column-replace-by-expression.png")
|
||||
ImageResource columnReplaceByExpression();
|
||||
@Source("column-filter.png")
|
||||
ImageResource filter();
|
||||
|
||||
@Source("column-filter-go.png")
|
||||
ImageResource applyFilter();
|
||||
|
||||
@Source("table-row-delete-byexpression_32.png")
|
||||
ImageResource tableRowDeleteByExpression32();
|
||||
@Source("column-replace-by-expression_32.png")
|
||||
ImageResource columnReplaceByExpression32();
|
||||
|
||||
@Source("table-row-delete-byexpression.png")
|
||||
ImageResource tableRowDeleteByExpression();
|
||||
@Source("column-replace-by-expression.png")
|
||||
ImageResource columnReplaceByExpression();
|
||||
|
||||
@Source("table-row-delete-byexpression_32.png")
|
||||
ImageResource tableRowDeleteByExpression32();
|
||||
|
||||
@Source("table-row-delete-byexpression.png")
|
||||
ImageResource tableRowDeleteByExpression();
|
||||
|
||||
}
|
After Width: | Height: | Size: 889 B |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 872 B |
After Width: | Height: | Size: 1.8 KiB |
After Width: | Height: | Size: 889 B |
After Width: | Height: | Size: 1.9 KiB |
After Width: | Height: | Size: 872 B |
After Width: | Height: | Size: 1.8 KiB |