81: Allow the creation and use of expressions on multi column in TDM portlet
Task-Url: https://support.d4science.org/issues/81 Updated replace on column to support condition on multi column git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@114767 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
9ef48c5c21
commit
7e519cd53c
|
@ -58,6 +58,9 @@ import com.sencha.gxt.widget.core.client.info.Info;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MultiColumnExpressionPanel extends FramedPanel {
|
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 RULE_DESCRIPTION_HEIGHT = "44px";
|
private static final String RULE_DESCRIPTION_HEIGHT = "44px";
|
||||||
private static final String RULE_PLACE_HOLDER_ID = "Column";
|
private static final String RULE_PLACE_HOLDER_ID = "Column";
|
||||||
|
|
||||||
|
@ -65,15 +68,13 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
||||||
ColumnFilter, RowDeleteByExpression, Template, Rule;
|
ColumnFilter, RowDeleteByExpression, Template, Rule;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final String WIDTH = "920px";
|
|
||||||
private static final String HEIGHT = "352px";
|
|
||||||
private static final String RULE_HEIGHT = "388px";
|
|
||||||
|
|
||||||
private MultiColumnExpressionPanelType type;
|
private MultiColumnExpressionPanelType type;
|
||||||
|
|
||||||
private TemplateColumnExpressionDialog parentTemplateDialog;
|
private TemplateMultiColumnExpressionDialog parentTemplateDialog;
|
||||||
private MultiColumnFilterDialog parentMultiFilterDialog;
|
private MultiColumnFilterDialog parentMultiFilterDialog;
|
||||||
private RowsDeleteByExpressionDialog parentRowsDeleteByExpressionDialog;
|
private RowsDeleteByMultiColumnExpressionDialog parentRowsDeleteByExpressionDialog;
|
||||||
|
|
||||||
private ColumnData column;
|
private ColumnData column;
|
||||||
private ArrayList<ColumnData> columns;
|
private ArrayList<ColumnData> columns;
|
||||||
|
@ -100,80 +101,71 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param parentMultiColumnFilterDialog
|
* @param parent
|
||||||
* @param column
|
* @param column
|
||||||
* @param columns
|
* @param columns
|
||||||
* @param eventBus
|
* @param eventBus
|
||||||
*/
|
*/
|
||||||
public MultiColumnExpressionPanel(MultiColumnFilterDialog parentMultiColumnFilterDialog,
|
public MultiColumnExpressionPanel(MultiColumnFilterDialog parent,
|
||||||
ArrayList<ColumnData> columns, EventBus eventBus) {
|
ArrayList<ColumnData> columns, EventBus eventBus) {
|
||||||
super();
|
super();
|
||||||
setWidth(WIDTH);
|
setWidth(WIDTH);
|
||||||
setHeight(HEIGHT);
|
setHeight(HEIGHT);
|
||||||
type = MultiColumnExpressionPanelType.ColumnFilter;
|
type = MultiColumnExpressionPanelType.ColumnFilter;
|
||||||
this.parentMultiFilterDialog = parentMultiColumnFilterDialog;
|
this.parentMultiFilterDialog = parent;
|
||||||
this.columns = columns;
|
this.columns = columns;
|
||||||
Log.debug("Column:" + column);
|
|
||||||
createOnFilter();
|
createOnFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param parentRowsDeleteByExpressionDialog
|
* @param parent
|
||||||
* @param column
|
* @param column
|
||||||
* @param columns
|
* @param columns
|
||||||
* @param eventBus
|
* @param eventBus
|
||||||
*/
|
*/
|
||||||
public MultiColumnExpressionPanel(
|
public MultiColumnExpressionPanel(
|
||||||
RowsDeleteByExpressionDialog parentRowsDeleteByExpressionDialog,
|
RowsDeleteByMultiColumnExpressionDialog parent,
|
||||||
ColumnData column, ArrayList<ColumnData> columns, EventBus eventBus) {
|
ArrayList<ColumnData> columns, EventBus eventBus) {
|
||||||
super();
|
super();
|
||||||
setWidth(WIDTH);
|
setWidth(WIDTH);
|
||||||
setHeight(RULE_HEIGHT);
|
setHeight(ROW_DELETE_BY_EXPRESSION_HEIGHT);
|
||||||
type = MultiColumnExpressionPanelType.RowDeleteByExpression;
|
type = MultiColumnExpressionPanelType.RowDeleteByExpression;
|
||||||
this.parentRowsDeleteByExpressionDialog = parentRowsDeleteByExpressionDialog;
|
this.parentRowsDeleteByExpressionDialog = parent;
|
||||||
this.column = column;
|
|
||||||
this.columns = columns;
|
this.columns = columns;
|
||||||
Log.debug("Column:" + column);
|
|
||||||
createOnRowsDeleteByExpression();
|
createOnRowsDeleteByExpression();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param parentColumnExpressionDialog
|
* @param parent
|
||||||
* @param column
|
* @param column
|
||||||
* @param eventBus
|
* @param eventBus
|
||||||
*/
|
*/
|
||||||
public MultiColumnExpressionPanel(
|
public MultiColumnExpressionPanel(
|
||||||
TemplateColumnExpressionDialog parentColumnExpressionDialog,
|
TemplateMultiColumnExpressionDialog parent,
|
||||||
ColumnData column, EventBus eventBus) {
|
ArrayList<ColumnData> columns, EventBus eventBus) {
|
||||||
super();
|
super();
|
||||||
setWidth(WIDTH);
|
setWidth(WIDTH);
|
||||||
setHeight(HEIGHT);
|
setHeight(HEIGHT);
|
||||||
type = MultiColumnExpressionPanelType.Template;
|
type = MultiColumnExpressionPanelType.Template;
|
||||||
this.parentTemplateDialog = parentColumnExpressionDialog;
|
this.parentTemplateDialog = parent;
|
||||||
this.column = column;
|
this.columns = columns;
|
||||||
this.columns = null;
|
|
||||||
Log.debug("Column:" + column);
|
|
||||||
|
|
||||||
createOnTemplate();
|
createOnTemplate();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param parentRuleDialog
|
* @param parent
|
||||||
* @param eventBus
|
* @param eventBus
|
||||||
*/
|
*/
|
||||||
public MultiColumnExpressionPanel(RuleDialog parentRuleDialog, EventBus eventBus) {
|
public MultiColumnExpressionPanel(RuleDialog parent, EventBus eventBus) {
|
||||||
super();
|
super();
|
||||||
setWidth(WIDTH);
|
setWidth(WIDTH);
|
||||||
setHeight(HEIGHT);
|
setHeight(HEIGHT);
|
||||||
type = MultiColumnExpressionPanelType.Rule;
|
type = MultiColumnExpressionPanelType.Rule;
|
||||||
this.parentRuleDialog = parentRuleDialog;
|
this.parentRuleDialog = parent;
|
||||||
this.column = null;
|
|
||||||
this.columns = null;
|
this.columns = null;
|
||||||
Log.debug("Column:" + column);
|
|
||||||
|
|
||||||
createOnRule();
|
createOnRule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -205,14 +197,11 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
||||||
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||||
flowButton.setPack(BoxLayoutPack.CENTER);
|
flowButton.setPack(BoxLayoutPack.CENTER);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
conditionsField = new FieldSet();
|
conditionsField = new FieldSet();
|
||||||
conditionsField.setHeadingText("Conditions");
|
conditionsField.setHeadingText("Conditions");
|
||||||
conditionsField.setCollapsible(false);
|
conditionsField.setCollapsible(false);
|
||||||
|
|
||||||
conditionWidget = new ConditionOnMultiColumnWidget(columns);
|
conditionWidget = new ConditionOnMultiColumnWidget(columns);
|
||||||
Log.debug("ConditionWidget" + conditionWidget);
|
|
||||||
conditionsField.add(conditionWidget);
|
conditionsField.add(conditionWidget);
|
||||||
|
|
||||||
btnApply = new TextButton("Save");
|
btnApply = new TextButton("Save");
|
||||||
|
@ -543,7 +532,7 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
||||||
setHeaderVisible(false);
|
setHeaderVisible(false);
|
||||||
|
|
||||||
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
|
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
|
||||||
basicLayout.setAdjustForScroll(false);
|
basicLayout.setAdjustForScroll(true);
|
||||||
|
|
||||||
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
|
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
|
||||||
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||||
|
@ -554,7 +543,6 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
||||||
conditionsField.setCollapsible(false);
|
conditionsField.setCollapsible(false);
|
||||||
|
|
||||||
conditionWidget = new ConditionOnMultiColumnWidget(columns);
|
conditionWidget = new ConditionOnMultiColumnWidget(columns);
|
||||||
Log.debug("ConditionWidget" + conditionWidget);
|
|
||||||
conditionsField.add(conditionWidget);
|
conditionsField.add(conditionWidget);
|
||||||
|
|
||||||
btnApply = new TextButton("Apply");
|
btnApply = new TextButton("Apply");
|
||||||
|
@ -585,7 +573,7 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
||||||
flowButton.add(btnClose, 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,
|
basicLayout.add(conditionsField, new VerticalLayoutData(-1, -1,
|
||||||
new Margins(1)));
|
new Margins(1)));
|
||||||
basicLayout.add(flowButton, new VerticalLayoutData(1, 36, new Margins(
|
basicLayout.add(flowButton, new VerticalLayoutData(1, 36, new Margins(
|
||||||
5, 2, 5, 2)));
|
5, 2, 5, 2)));
|
||||||
|
@ -603,16 +591,10 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
||||||
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
|
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
|
||||||
basicLayout.setAdjustForScroll(true);
|
basicLayout.setAdjustForScroll(true);
|
||||||
|
|
||||||
|
|
||||||
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
|
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
|
||||||
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||||
flowButton.setPack(BoxLayoutPack.CENTER);
|
flowButton.setPack(BoxLayoutPack.CENTER);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//
|
|
||||||
conditionsField = new FieldSet();
|
conditionsField = new FieldSet();
|
||||||
conditionsField.setHeadingText("Conditions");
|
conditionsField.setHeadingText("Conditions");
|
||||||
conditionsField.setCollapsible(false);
|
conditionsField.setCollapsible(false);
|
||||||
|
@ -621,6 +603,7 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
||||||
Log.debug("ConditionWidget" + conditionWidget);
|
Log.debug("ConditionWidget" + conditionWidget);
|
||||||
conditionsField.add(conditionWidget);
|
conditionsField.add(conditionWidget);
|
||||||
|
|
||||||
|
|
||||||
btnApply = new TextButton("Delete");
|
btnApply = new TextButton("Delete");
|
||||||
btnApply.setIcon(ExpressionResources.INSTANCE
|
btnApply.setIcon(ExpressionResources.INSTANCE
|
||||||
.tableRowDeleteByExpression());
|
.tableRowDeleteByExpression());
|
||||||
|
@ -634,14 +617,12 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (column == null) {
|
|
||||||
btnApply.disable();
|
|
||||||
}
|
|
||||||
|
|
||||||
btnClose = new TextButton("Close");
|
btnClose = new TextButton("Close");
|
||||||
btnClose.setIcon(ExpressionResources.INSTANCE.close());
|
btnClose.setIcon(ExpressionResources.INSTANCE.close());
|
||||||
btnClose.setIconAlign(IconAlign.RIGHT);
|
btnClose.setIconAlign(IconAlign.RIGHT);
|
||||||
btnClose.setToolTip("Cancel filter");
|
btnClose.setToolTip("Cancel");
|
||||||
btnClose.addSelectHandler(new SelectHandler() {
|
btnClose.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
public void onSelect(SelectEvent event) {
|
public void onSelect(SelectEvent event) {
|
||||||
|
@ -652,6 +633,7 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
||||||
flowButton.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
flowButton.add(btnApply, new BoxLayoutData(new Margins(2, 4, 2, 4)));
|
||||||
flowButton.add(btnClose, 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,
|
basicLayout.add(conditionsField, new VerticalLayoutData(1, -1,
|
||||||
new Margins(1)));
|
new Margins(1)));
|
||||||
basicLayout.add(flowButton, new VerticalLayoutData(1, 36, new Margins(
|
basicLayout.add(flowButton, new VerticalLayoutData(1, 36, new Margins(
|
||||||
|
@ -659,6 +641,8 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
||||||
|
|
||||||
add(basicLayout);
|
add(basicLayout);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setSelectedColumn() {
|
protected void setSelectedColumn() {
|
||||||
|
@ -792,7 +776,7 @@ public class MultiColumnExpressionPanel extends FramedPanel {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
C_Expression notExp = new C_Not(exp);
|
C_Expression notExp = new C_Not(exp);
|
||||||
parentRowsDeleteByExpressionDialog.deleteRowsByExpression(column,
|
parentRowsDeleteByExpressionDialog.deleteRowsByExpression(
|
||||||
notExp);
|
notExp);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -37,13 +37,11 @@ import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MultiColumnFilterDialog extends Window implements MonitorDialogListener {
|
public class MultiColumnFilterDialog extends Window implements MonitorDialogListener {
|
||||||
private static final String WIDTH = "932px";
|
private static final String WIDTH = "940px";
|
||||||
private static final String HEIGHT = "388px";
|
private static final String HEIGHT = "388px";
|
||||||
private MultiColumnExpressionPanel multiColumnExpressionPanel;
|
private MultiColumnExpressionPanel multiColumnExpressionPanel;
|
||||||
private C_Expression exp = null;
|
private C_Expression exp = null;
|
||||||
private TRId trId;
|
private TRId trId;
|
||||||
private ColumnData column = null;
|
|
||||||
private String columnLocalId = null;
|
|
||||||
private ArrayList<ColumnData> columns=null;
|
private ArrayList<ColumnData> columns=null;
|
||||||
private ArrayList<ColumnData> removableColumn=null;
|
private ArrayList<ColumnData> removableColumn=null;
|
||||||
private EventBus eventBus;
|
private EventBus eventBus;
|
||||||
|
@ -151,9 +149,7 @@ public class MultiColumnFilterDialog extends Window implements MonitorDialogList
|
||||||
c.getTypeCode().compareTo(ColumnTypeCode.TIMEDIMENSION.toString())==0 ){
|
c.getTypeCode().compareTo(ColumnTypeCode.TIMEDIMENSION.toString())==0 ){
|
||||||
removableColumn.add(c);
|
removableColumn.add(c);
|
||||||
} else {
|
} else {
|
||||||
if(columnLocalId!=null && c.getColumnId().compareTo(columnLocalId)==0){
|
|
||||||
column=c;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
columns.removeAll(removableColumn);
|
columns.removeAll(removableColumn);
|
||||||
|
|
|
@ -242,7 +242,6 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
||||||
conditionWidget = new ConditionWidget(column, CONDITIONWIDTH,
|
conditionWidget = new ConditionWidget(column, CONDITIONWIDTH,
|
||||||
CONDITIONHEIGHT);
|
CONDITIONHEIGHT);
|
||||||
conditionWidget.setEnabled(false);
|
conditionWidget.setEnabled(false);
|
||||||
Log.debug("ConditionWidget" + conditionWidget);
|
|
||||||
|
|
||||||
conditionsVerticalLayout.add(allRowsField, new VerticalLayoutData(100,
|
conditionsVerticalLayout.add(allRowsField, new VerticalLayoutData(100,
|
||||||
-1, new Margins(0)));
|
-1, new Margins(0)));
|
||||||
|
@ -371,10 +370,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
||||||
.getColumnTypeCodeFromId(column.getTypeCode());
|
.getColumnTypeCodeFromId(column.getTypeCode());
|
||||||
HTML errorMessage;
|
HTML errorMessage;
|
||||||
if (typeCode == null) {
|
if (typeCode == null) {
|
||||||
errorMessage = new HTML(
|
Log.debug(
|
||||||
"This column has column type code null!");
|
"This column has column type code null, Dimension and TimeDimesion not supported for now!");
|
||||||
UtilsGXT3.alert("Error",
|
|
||||||
"This column has column type code null!!");
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,330 @@
|
||||||
|
package org.gcube.portlets.user.td.expressionwidget.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceExpressionType;
|
||||||
|
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.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.tr.column.ReplaceColumnByExpressionSession;
|
||||||
|
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.ChangeTableRequestEvent;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
|
||||||
|
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.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.ColumnMockUp;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
import com.sencha.gxt.widget.core.client.Window;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ReplaceColumnByMultiColumnExpressionDialog extends Window implements
|
||||||
|
MonitorDialogListener {
|
||||||
|
private static final String WIDTH = "950px";
|
||||||
|
private static final String HEIGHT = "490px";
|
||||||
|
// private static final String HEIGHT_REDUCE = "404px";
|
||||||
|
|
||||||
|
private ReplaceColumnByMultiColumnExpressionPanel replaceColumnByMultiColumnExpressionPanel;
|
||||||
|
private C_Expression cConditionExpression = null;
|
||||||
|
private ColumnData column = null;
|
||||||
|
private ArrayList<ColumnData> columns;
|
||||||
|
|
||||||
|
private EventBus eventBus;
|
||||||
|
private ReplaceExpressionType replaceExpressionType;
|
||||||
|
// private String columnLocalId;
|
||||||
|
private TRId trId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* Columns must have set columnId, label, columnTypeCode and ColumnDataType
|
||||||
|
*
|
||||||
|
* @param column
|
||||||
|
* The column selected
|
||||||
|
* @param columns
|
||||||
|
* @param eventBus
|
||||||
|
*/
|
||||||
|
public ReplaceColumnByMultiColumnExpressionDialog(ColumnMockUp columnMockUp,
|
||||||
|
ArrayList<ColumnMockUp> columnMockUpList, EventBus eventBus) {
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
column = new ColumnData();
|
||||||
|
column.setColumnId(columnMockUp.getColumnId());
|
||||||
|
column.setLabel(columnMockUp.getLabel());
|
||||||
|
column.setDataTypeName(columnMockUp.getColumnDataType().toString());
|
||||||
|
column.setTypeCode(columnMockUp.getColumnType().toString());
|
||||||
|
|
||||||
|
columns = new ArrayList<ColumnData>();
|
||||||
|
for (ColumnMockUp colMock : columnMockUpList) {
|
||||||
|
ColumnData col = new ColumnData();
|
||||||
|
col.setColumnId(colMock.getColumnId());
|
||||||
|
col.setLabel(colMock.getLabel());
|
||||||
|
col.setDataTypeName(colMock.getColumnDataType().toString());
|
||||||
|
col.setTypeCode(colMock.getColumnType().toString());
|
||||||
|
columns.add(col);
|
||||||
|
}
|
||||||
|
|
||||||
|
replaceExpressionType = ReplaceExpressionType.Template;
|
||||||
|
initWindow();
|
||||||
|
sanitizesColumns();
|
||||||
|
create();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param trId
|
||||||
|
* @param columnName
|
||||||
|
* @param eventBus
|
||||||
|
*/
|
||||||
|
public ReplaceColumnByMultiColumnExpressionDialog(TRId trId, String columnId,
|
||||||
|
EventBus eventBus) {
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
this.trId = trId;
|
||||||
|
if (columnId == null) {
|
||||||
|
column=null;
|
||||||
|
} else {
|
||||||
|
column = new ColumnData();
|
||||||
|
column.setColumnId(columnId);
|
||||||
|
}
|
||||||
|
replaceExpressionType = ReplaceExpressionType.Replace;
|
||||||
|
initWindow();
|
||||||
|
load();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initWindow() {
|
||||||
|
setWidth(WIDTH);
|
||||||
|
setHeight(HEIGHT);
|
||||||
|
setBodyBorder(false);
|
||||||
|
setResizable(false);
|
||||||
|
setHeadingText("Replace Column By Expression");
|
||||||
|
setClosable(true);
|
||||||
|
getHeader().setIcon(
|
||||||
|
ExpressionResources.INSTANCE.columnReplaceByExpression());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void initTools() {
|
||||||
|
super.initTools();
|
||||||
|
|
||||||
|
closeBtn.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void create() {
|
||||||
|
replaceColumnByMultiColumnExpressionPanel = new ReplaceColumnByMultiColumnExpressionPanel(
|
||||||
|
this, column, columns, eventBus, replaceExpressionType);
|
||||||
|
add(replaceColumnByMultiColumnExpressionPanel);
|
||||||
|
}
|
||||||
|
|
||||||
|
public C_Expression getExpression() {
|
||||||
|
return cConditionExpression;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setExpression(C_Expression exp) {
|
||||||
|
Log.debug("New Expression set:" + exp.toString());
|
||||||
|
this.cConditionExpression = exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void applyReplaceColumnByExpression(ColumnData column,
|
||||||
|
boolean allRows, C_Expression cConditionExpression,
|
||||||
|
String replaceValue) {
|
||||||
|
this.column = column;
|
||||||
|
this.cConditionExpression = cConditionExpression;
|
||||||
|
|
||||||
|
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(
|
||||||
|
column, allRows, cConditionExpression, replaceValue);
|
||||||
|
callApplyReplaceByExpression(replaceColumnByExpressionSession);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void applyReplaceColumnByExpression(ColumnData column,
|
||||||
|
boolean allRows, C_Expression cConditionExpression,
|
||||||
|
C_Expression cReplaceExpression) {
|
||||||
|
this.column = column;
|
||||||
|
this.cConditionExpression = cConditionExpression;
|
||||||
|
|
||||||
|
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(
|
||||||
|
column, allRows, cConditionExpression, cReplaceExpression);
|
||||||
|
callApplyReplaceByExpression(replaceColumnByExpressionSession);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void load() {
|
||||||
|
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||||
|
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||||
|
|
||||||
|
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.error("Error retrieving column: "
|
||||||
|
+ caught.getMessage());
|
||||||
|
UtilsGXT3.alert("Error retrieving column",
|
||||||
|
caught.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onSuccess(ArrayList<ColumnData> result) {
|
||||||
|
Log.debug("Retrived columns: " + 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 {
|
||||||
|
if (c.getColumnId() != null && column != null
|
||||||
|
&& column.getColumnId() != null
|
||||||
|
&& !column.getColumnId().isEmpty()
|
||||||
|
&& c.getColumnId().compareTo(column.getColumnId()) == 0) {
|
||||||
|
column = c;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
columns.removeAll(removableColumn);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void callApplyReplaceByExpression(
|
||||||
|
ReplaceColumnByExpressionSession replaceColumnByExpressionSession) {
|
||||||
|
Log.debug("Replace Column By Expression Session "
|
||||||
|
+ replaceColumnByExpressionSession);
|
||||||
|
|
||||||
|
ExpressionServiceAsync.INSTANCE.startReplaceColumnByExpression(
|
||||||
|
replaceColumnByExpressionSession, new AsyncCallback<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String taskId) {
|
||||||
|
Log.debug("Submitted replace column by expression");
|
||||||
|
openMonitorDialog(taskId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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.error("Error submitting replace column by expression: "
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
|
caught.printStackTrace();
|
||||||
|
UtilsGXT3
|
||||||
|
.alert("Error submitting replace column by expression",
|
||||||
|
caught.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void close() {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
// /
|
||||||
|
protected void openMonitorDialog(String taskId) {
|
||||||
|
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
|
||||||
|
monitorDialog.addProgressDialogListener(this);
|
||||||
|
monitorDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationComplete(OperationResult operationResult) {
|
||||||
|
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
|
||||||
|
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
||||||
|
ChangeTableRequestType.COLUMNFILTER, operationResult.getTrId(),
|
||||||
|
why);
|
||||||
|
eventBus.fireEvent(changeTableRequestEvent);
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationFailed(Throwable caught, String reason, String details) {
|
||||||
|
UtilsGXT3.alert(reason, details);
|
||||||
|
close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationStopped(OperationResult operationResult,
|
||||||
|
String reason, String details) {
|
||||||
|
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
|
||||||
|
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
||||||
|
ChangeTableRequestType.COLUMNFILTER, operationResult.getTrId(),
|
||||||
|
why);
|
||||||
|
eventBus.fireEvent(changeTableRequestEvent);
|
||||||
|
close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationAborted() {
|
||||||
|
close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationPutInBackground() {
|
||||||
|
close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,699 @@
|
||||||
|
package org.gcube.portlets.user.td.expressionwidget.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.expression.ConditionOnMultiColumnWidget;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.expression.ReplaceWidget;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.properties.ColumnDataPropertiesCombo;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceExpressionType;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ConditionTypeMapException;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ReplaceTypeMapException;
|
||||||
|
import org.gcube.portlets.user.td.monitorwidget.client.utils.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.ExpressionWrapperEvent;
|
||||||
|
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.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.event.logical.shared.ValueChangeEvent;
|
||||||
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||||
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||||
|
import com.google.gwt.regexp.shared.MatchResult;
|
||||||
|
import com.google.gwt.regexp.shared.RegExp;
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
import com.google.gwt.user.client.ui.HasHorizontalAlignment;
|
||||||
|
import com.google.gwt.user.client.ui.HasValue;
|
||||||
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
|
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.core.client.util.ToggleGroup;
|
||||||
|
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;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.BoxLayoutContainer.BoxLayoutPack;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.HBoxLayoutContainer.HBoxLayoutAlign;
|
||||||
|
import com.sencha.gxt.widget.core.client.container.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.ComboBox;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.DateField;
|
||||||
|
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.Radio;
|
||||||
|
import com.sencha.gxt.widget.core.client.form.TextField;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class ReplaceColumnByMultiColumnExpressionPanel extends FramedPanel {
|
||||||
|
private static final String GEOMETRY_REGEXPR = "(\\s*POINT\\s*\\(\\s*(-)?\\d+(\\.\\d+)?\\s+(-)?\\d+(\\.\\d+)?\\s*\\)\\s*$)"
|
||||||
|
+ "|(\\s*LINESTRING\\s*\\((\\s*(-)?\\d+(\\.\\d+)?\\s+(-)?\\d+(\\.\\d+)?\\s*,)+\\s*((-)?\\d+(\\.\\d+)?\\s+(-)?\\d+(\\.\\d+)?\\s*)\\)\\s*$)";
|
||||||
|
|
||||||
|
private static final String WIDTH = "938px";
|
||||||
|
private static final String HEIGHT = "454px";
|
||||||
|
private static final String HEIGHT_REDUCE = "368px";
|
||||||
|
private static final String PARENT_HEIGHT = "490px";
|
||||||
|
private static final String PARENT_HEIGHT_REDUCE = "404px";
|
||||||
|
|
||||||
|
private static final String CONDITIONWIDTH = "890px";
|
||||||
|
private static final String CONDITIONHEIGHT = "120px";
|
||||||
|
private static final String CONDITION_LAYOUT_WIDTH = "890px";
|
||||||
|
private static final String REPLACEWIDTH = "894px";
|
||||||
|
private static final String REPLACEHEIGHT = "120px";
|
||||||
|
private static final String ALL_ROWS_FIELD_WIDTH = "884px";
|
||||||
|
|
||||||
|
private static final String RADIO_LABEL_BY_CONDITION = "By Condition";
|
||||||
|
private static final String RADIO_LABEL_ALL_ROWS = "All Rows";
|
||||||
|
|
||||||
|
private EventBus eventBus;
|
||||||
|
|
||||||
|
private ReplaceColumnByMultiColumnExpressionDialog parent;
|
||||||
|
|
||||||
|
private ColumnData column;
|
||||||
|
private ArrayList<ColumnData> columns;
|
||||||
|
|
||||||
|
private ReplaceExpressionType replaceExpressionType;
|
||||||
|
|
||||||
|
private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
||||||
|
|
||||||
|
private TextButton btnApply;
|
||||||
|
private TextButton btnClose;
|
||||||
|
|
||||||
|
private ComboBox<ColumnData> comboCols;
|
||||||
|
|
||||||
|
private FieldSet conditionsFieldSet;
|
||||||
|
private ConditionOnMultiColumnWidget conditionWidget;
|
||||||
|
|
||||||
|
private ReplaceWidget replaceWidget;
|
||||||
|
private TextField replaceValue;
|
||||||
|
private DateField replaceValueDate;
|
||||||
|
|
||||||
|
private FieldSet replaceValueFieldSet;
|
||||||
|
|
||||||
|
private VerticalLayoutContainer conditionsVerticalLayout;
|
||||||
|
|
||||||
|
private boolean allRows;
|
||||||
|
|
||||||
|
private FieldLabel allRowsField;
|
||||||
|
|
||||||
|
public ReplaceColumnByMultiColumnExpressionPanel(
|
||||||
|
ReplaceColumnByMultiColumnExpressionDialog parent,
|
||||||
|
ColumnData column, ArrayList<ColumnData> columns,
|
||||||
|
EventBus eventBus, ReplaceExpressionType replaceExpressionType) {
|
||||||
|
super();
|
||||||
|
this.parent = parent;
|
||||||
|
this.column = column;
|
||||||
|
this.columns = columns;
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
this.replaceExpressionType = replaceExpressionType;
|
||||||
|
Log.debug("Column: " + column);
|
||||||
|
Log.debug("Columns: " + columns);
|
||||||
|
init();
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void init() {
|
||||||
|
setWidth(WIDTH);
|
||||||
|
calcHeight();
|
||||||
|
|
||||||
|
setBodyBorder(false);
|
||||||
|
setHeaderVisible(false);
|
||||||
|
// Important: fixed rendering of widgets
|
||||||
|
forceLayoutOnResize = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void calcHeight() {
|
||||||
|
if (column != null
|
||||||
|
&& column.getDataTypeName() != null
|
||||||
|
&& !column.getDataTypeName().isEmpty()
|
||||||
|
&& (column.getDataTypeName().compareTo(
|
||||||
|
ColumnDataType.Text.toString()) == 0
|
||||||
|
|| column.getDataTypeName().compareTo(
|
||||||
|
ColumnDataType.Integer.toString()) == 0
|
||||||
|
|| column.getDataTypeName().compareTo(
|
||||||
|
ColumnDataType.Numeric.toString()) == 0 || column
|
||||||
|
.getDataTypeName().compareTo(
|
||||||
|
ColumnDataType.Geometry.toString()) == 0)) {
|
||||||
|
parent.setHeight(PARENT_HEIGHT);
|
||||||
|
setHeight(HEIGHT);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
parent.setHeight(PARENT_HEIGHT_REDUCE);
|
||||||
|
setHeight(HEIGHT_REDUCE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void create() {
|
||||||
|
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
|
||||||
|
basicLayout.setAdjustForScroll(true);
|
||||||
|
// basicLayout.setScrollMode(ScrollMode.AUTO);
|
||||||
|
|
||||||
|
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
|
||||||
|
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||||
|
flowButton.setPack(BoxLayoutPack.CENTER);
|
||||||
|
|
||||||
|
// Properties
|
||||||
|
FieldSet properties = new FieldSet();
|
||||||
|
properties.setHeadingText("Properties");
|
||||||
|
properties.setCollapsible(false);
|
||||||
|
|
||||||
|
VerticalLayoutContainer propertiesLayout = new VerticalLayoutContainer();
|
||||||
|
properties.add(propertiesLayout);
|
||||||
|
|
||||||
|
// Combo Column
|
||||||
|
ColumnDataPropertiesCombo propsCols = GWT
|
||||||
|
.create(ColumnDataPropertiesCombo.class);
|
||||||
|
Log.debug("Props: " + propsCols);
|
||||||
|
final ListStore<ColumnData> storeCols = new ListStore<ColumnData>(
|
||||||
|
propsCols.id());
|
||||||
|
Log.debug("Store Col: " + storeCols);
|
||||||
|
storeCols.addAll(columns);
|
||||||
|
|
||||||
|
Log.debug("StoreCol created");
|
||||||
|
comboCols = new ComboBox<ColumnData>(storeCols, propsCols.label());
|
||||||
|
|
||||||
|
Log.debug("Combo Threshold created");
|
||||||
|
|
||||||
|
comboCols.addSelectionHandler(comboColsSelection());
|
||||||
|
|
||||||
|
comboCols.setEmptyText("Select a column...");
|
||||||
|
comboCols.setEditable(false);
|
||||||
|
comboCols.setTriggerAction(TriggerAction.ALL);
|
||||||
|
|
||||||
|
setSelectedColumn();
|
||||||
|
|
||||||
|
propertiesLayout.add(new FieldLabel(comboCols, "Column"),
|
||||||
|
new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
|
// Conditions
|
||||||
|
conditionsFieldSet = new FieldSet();
|
||||||
|
conditionsFieldSet.setHeadingText("Conditions");
|
||||||
|
conditionsFieldSet.setCollapsible(false);
|
||||||
|
|
||||||
|
conditionsVerticalLayout = new VerticalLayoutContainer();
|
||||||
|
conditionsVerticalLayout.setWidth(CONDITION_LAYOUT_WIDTH);
|
||||||
|
conditionsVerticalLayout.setAdjustForScroll(false);
|
||||||
|
|
||||||
|
Radio radioAllRowsTrue = new Radio();
|
||||||
|
radioAllRowsTrue.setBoxLabel(RADIO_LABEL_ALL_ROWS);
|
||||||
|
|
||||||
|
Radio radioAllRowsFalse = new Radio();
|
||||||
|
radioAllRowsFalse.setBoxLabel(RADIO_LABEL_BY_CONDITION);
|
||||||
|
|
||||||
|
radioAllRowsTrue.setValue(true);
|
||||||
|
allRows = true;
|
||||||
|
|
||||||
|
ToggleGroup toggleGroup = new ToggleGroup();
|
||||||
|
toggleGroup.add(radioAllRowsTrue);
|
||||||
|
toggleGroup.add(radioAllRowsFalse);
|
||||||
|
|
||||||
|
toggleGroup
|
||||||
|
.addValueChangeHandler(new ValueChangeHandler<HasValue<Boolean>>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onValueChange(
|
||||||
|
ValueChangeEvent<HasValue<Boolean>> event) {
|
||||||
|
callAllRowChange(event);
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
HorizontalPanel hp = new HorizontalPanel();
|
||||||
|
hp.setHorizontalAlignment(HasHorizontalAlignment.ALIGN_LEFT);
|
||||||
|
hp.add(radioAllRowsTrue);
|
||||||
|
hp.add(radioAllRowsFalse);
|
||||||
|
hp.setWidth("140px");
|
||||||
|
|
||||||
|
allRowsField = new FieldLabel(hp, "Select");
|
||||||
|
allRowsField.setWidth(ALL_ROWS_FIELD_WIDTH);
|
||||||
|
|
||||||
|
conditionWidget = new ConditionOnMultiColumnWidget(columns,CONDITIONWIDTH,
|
||||||
|
CONDITIONHEIGHT);
|
||||||
|
|
||||||
|
conditionWidget.setEnabled(false);
|
||||||
|
|
||||||
|
conditionsVerticalLayout.add(allRowsField, new VerticalLayoutData(100,
|
||||||
|
-1, new Margins(0)));
|
||||||
|
conditionsVerticalLayout.add(conditionWidget, new VerticalLayoutData(
|
||||||
|
-1, -1, new Margins(0)));
|
||||||
|
|
||||||
|
conditionsFieldSet.add(conditionsVerticalLayout);
|
||||||
|
|
||||||
|
// Value
|
||||||
|
replaceValueFieldSet = new FieldSet();
|
||||||
|
replaceValueFieldSet.setHeadingText("Replace Value");
|
||||||
|
replaceValueFieldSet.setCollapsible(false);
|
||||||
|
|
||||||
|
calcReplaceValue();
|
||||||
|
|
||||||
|
//
|
||||||
|
btnApply = new TextButton("Apply");
|
||||||
|
btnApply.setIcon(ExpressionResources.INSTANCE
|
||||||
|
.columnReplaceByExpression());
|
||||||
|
btnApply.setIconAlign(IconAlign.RIGHT);
|
||||||
|
btnApply.setToolTip("Apply replace by expression");
|
||||||
|
btnApply.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
Log.debug("Pressed Apply");
|
||||||
|
applyReplaceColumnByExpression();
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
if (column == null) {
|
||||||
|
btnApply.disable();
|
||||||
|
}
|
||||||
|
|
||||||
|
btnClose = new TextButton("Close");
|
||||||
|
btnClose.setIcon(ExpressionResources.INSTANCE.close());
|
||||||
|
btnClose.setIconAlign(IconAlign.RIGHT);
|
||||||
|
btnClose.setToolTip("Close");
|
||||||
|
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)));
|
||||||
|
|
||||||
|
// Add to basic layout
|
||||||
|
basicLayout.add(properties, new VerticalLayoutData(1, -1,
|
||||||
|
new Margins(1)));
|
||||||
|
basicLayout.add(conditionsFieldSet, new VerticalLayoutData(1, -1,
|
||||||
|
new Margins(1)));
|
||||||
|
basicLayout.add(replaceValueFieldSet, new VerticalLayoutData(1, -1,
|
||||||
|
new Margins(1)));
|
||||||
|
|
||||||
|
basicLayout.add(flowButton, new VerticalLayoutData(1, 36, new Margins(
|
||||||
|
5, 2, 5, 2)));
|
||||||
|
add(basicLayout);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void calcReplaceValue() {
|
||||||
|
replaceValueFieldSet.clear();
|
||||||
|
VerticalLayoutContainer replaceValueFieldSetLayout = new VerticalLayoutContainer();
|
||||||
|
replaceValueFieldSet.add(replaceValueFieldSetLayout);
|
||||||
|
|
||||||
|
if (column == null || column.getDataTypeName() == null
|
||||||
|
|| column.getDataTypeName().isEmpty()) {
|
||||||
|
replaceValue = new TextField();
|
||||||
|
replaceValue.setToolTip("Replace Value");
|
||||||
|
replaceValue.setValue("");
|
||||||
|
replaceValueFieldSetLayout.add(new FieldLabel(replaceValue,
|
||||||
|
"Replace Value"), new VerticalLayoutData(1, -1));
|
||||||
|
} else {
|
||||||
|
if (column.getDataTypeName().compareTo(
|
||||||
|
ColumnDataType.Date.toString()) == 0) {
|
||||||
|
replaceValueDate = new DateField();
|
||||||
|
replaceValueDate.setToolTip("Replace Value");
|
||||||
|
replaceValueFieldSetLayout.add(new FieldLabel(replaceValueDate,
|
||||||
|
"Replace Value"), new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (column.getDataTypeName().compareTo(
|
||||||
|
ColumnDataType.Text.toString()) == 0
|
||||||
|
|| column.getDataTypeName().compareTo(
|
||||||
|
ColumnDataType.Integer.toString()) == 0
|
||||||
|
|| column.getDataTypeName().compareTo(
|
||||||
|
ColumnDataType.Numeric.toString()) == 0
|
||||||
|
|| column.getDataTypeName().compareTo(
|
||||||
|
ColumnDataType.Geometry.toString()) == 0) {
|
||||||
|
switch (replaceExpressionType) {
|
||||||
|
case Replace:
|
||||||
|
replaceWidget = new ReplaceWidget(column, REPLACEWIDTH,
|
||||||
|
REPLACEHEIGHT, eventBus);
|
||||||
|
break;
|
||||||
|
case Template:
|
||||||
|
replaceWidget = new ReplaceWidget(column, columns,
|
||||||
|
REPLACEWIDTH, REPLACEHEIGHT, eventBus);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
Log.debug("Attention Replace Widget have not a valid type");
|
||||||
|
UtilsGXT3
|
||||||
|
.alert("Attention",
|
||||||
|
"Attention Replace Widget have not a valid type");
|
||||||
|
return;
|
||||||
|
|
||||||
|
}
|
||||||
|
replaceValueFieldSetLayout.add(replaceWidget,
|
||||||
|
new VerticalLayoutData(1, -1));
|
||||||
|
} else {
|
||||||
|
replaceValue = new TextField();
|
||||||
|
replaceValue.setToolTip("Replace Value");
|
||||||
|
replaceValue.setValue("");
|
||||||
|
replaceValueFieldSetLayout.add(new FieldLabel(replaceValue,
|
||||||
|
"Replace Value"), new VerticalLayoutData(1, -1));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setSelectedColumn() {
|
||||||
|
if (column == null) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
ColumnTypeCode typeCode = ColumnTypeCode
|
||||||
|
.getColumnTypeCodeFromId(column.getTypeCode());
|
||||||
|
HTML errorMessage;
|
||||||
|
if (typeCode == null) {
|
||||||
|
Log.debug("This column has column type code null, Dimension and TimeDimesion not supported for now!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (typeCode) {
|
||||||
|
case ANNOTATION:
|
||||||
|
case ATTRIBUTE:
|
||||||
|
case CODE:
|
||||||
|
case CODEDESCRIPTION:
|
||||||
|
case CODENAME:
|
||||||
|
case MEASURE:
|
||||||
|
comboCols.setValue(column);
|
||||||
|
break;
|
||||||
|
case DIMENSION:
|
||||||
|
case TIMEDIMENSION:
|
||||||
|
errorMessage = new HTML(
|
||||||
|
"This type of column is not supported for now!");
|
||||||
|
add(errorMessage);
|
||||||
|
UtilsGXT3.alert("Error",
|
||||||
|
"This type of column is not supported for now!");
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
errorMessage = new HTML(
|
||||||
|
"This type of column is not supported for now!");
|
||||||
|
add(errorMessage);
|
||||||
|
UtilsGXT3.alert("Error",
|
||||||
|
"This type of column is not supported for now!");
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected SelectionHandler<ColumnData> comboColsSelection() {
|
||||||
|
SelectionHandler<ColumnData> selectionHandler = new SelectionHandler<ColumnData>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSelection(SelectionEvent<ColumnData> event) {
|
||||||
|
if (event.getSelectedItem() != null) {
|
||||||
|
ColumnData col = event.getSelectedItem();
|
||||||
|
Log.debug("Col selected:" + col.toString());
|
||||||
|
column = col;
|
||||||
|
btnApply.enable();
|
||||||
|
conditionWidget.resetCondition();
|
||||||
|
calcReplaceValue();
|
||||||
|
|
||||||
|
} else {
|
||||||
|
column = null;
|
||||||
|
btnApply.disable();
|
||||||
|
conditionWidget.resetCondition();
|
||||||
|
calcReplaceValue();
|
||||||
|
}
|
||||||
|
calcHeight();
|
||||||
|
parent.forceLayout();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
return selectionHandler;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void callAllRowChange(ValueChangeEvent<HasValue<Boolean>> event) {
|
||||||
|
ToggleGroup group = (ToggleGroup) event.getSource();
|
||||||
|
Radio radio = (Radio) group.getValue();
|
||||||
|
if (radio.getBoxLabel().compareTo(RADIO_LABEL_ALL_ROWS) == 0) {
|
||||||
|
conditionWidget.setEnabled(false);
|
||||||
|
allRows = true;
|
||||||
|
} else {
|
||||||
|
conditionWidget.setEnabled(true);
|
||||||
|
allRows = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void applyReplaceColumnByExpression() {
|
||||||
|
C_Expression cConditionExpression = null;
|
||||||
|
if (allRows) {
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
try {
|
||||||
|
cConditionExpression = conditionWidget.getExpression();
|
||||||
|
} catch (ConditionTypeMapException e) {
|
||||||
|
Log.debug(e.getLocalizedMessage());
|
||||||
|
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
String value = null;
|
||||||
|
if (column.getDataTypeName().compareTo(ColumnDataType.Date.toString()) == 0) {
|
||||||
|
|
||||||
|
Date valueDate = replaceValueDate.getCurrentValue();
|
||||||
|
if (valueDate == null) {
|
||||||
|
UtilsGXT3.alert("Error replace value",
|
||||||
|
"Select a valid date as replace value!");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
try {
|
||||||
|
value = sdf.format(valueDate);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
UtilsGXT3.alert("Error replace value",
|
||||||
|
"Select a valid date as replace value!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callApplyReplaceColumnByExpression(cConditionExpression, value);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (column.getDataTypeName().compareTo(
|
||||||
|
ColumnDataType.Text.toString()) == 0
|
||||||
|
|| column.getDataTypeName().compareTo(
|
||||||
|
ColumnDataType.Integer.toString()) == 0
|
||||||
|
|| column.getDataTypeName().compareTo(
|
||||||
|
ColumnDataType.Numeric.toString()) == 0
|
||||||
|
|| column.getDataTypeName().compareTo(
|
||||||
|
ColumnDataType.Geometry.toString()) == 0) {
|
||||||
|
C_Expression cReplaceExpression = null;
|
||||||
|
try {
|
||||||
|
cReplaceExpression = replaceWidget.getExpression();
|
||||||
|
if (cReplaceExpression == null) {
|
||||||
|
UtilsGXT3.alert("Attention",
|
||||||
|
"Replace expression is not valid!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (ReplaceTypeMapException e) {
|
||||||
|
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
callApplyReplaceColumnByExpression(cConditionExpression,
|
||||||
|
cReplaceExpression);
|
||||||
|
} else {
|
||||||
|
value = replaceValue.getCurrentValue();
|
||||||
|
if (checkValue(value)) {
|
||||||
|
callApplyReplaceColumnByExpression(cConditionExpression,
|
||||||
|
value);
|
||||||
|
} else {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void callApplyReplaceColumnByExpression(
|
||||||
|
C_Expression cConditionExpression, String replaceValue) {
|
||||||
|
if (column == null) {
|
||||||
|
UtilsGXT3.alert("Attention", "Select a valid column!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (replaceExpressionType) {
|
||||||
|
case Template:
|
||||||
|
C_ExpressionContainer conditionExpressionContainer;
|
||||||
|
if (allRows) {
|
||||||
|
conditionExpressionContainer = new C_ExpressionContainer(
|
||||||
|
C_ExpressionContainer.Contains.C_Expression, true,
|
||||||
|
null, "AllRows()");
|
||||||
|
} else {
|
||||||
|
conditionExpressionContainer = new C_ExpressionContainer(
|
||||||
|
C_ExpressionContainer.Contains.C_Expression,
|
||||||
|
cConditionExpression,
|
||||||
|
cConditionExpression.getReadableExpression());
|
||||||
|
}
|
||||||
|
|
||||||
|
ExpressionWrapper exWrapper = new ExpressionWrapper(
|
||||||
|
column.getTrId(), column, conditionExpressionContainer,
|
||||||
|
replaceValue);
|
||||||
|
ExpressionWrapperEvent expressionEvent = new ExpressionWrapperEvent(
|
||||||
|
exWrapper);
|
||||||
|
Log.debug(expressionEvent.toString());
|
||||||
|
parent.hide();
|
||||||
|
eventBus.fireEvent(expressionEvent);
|
||||||
|
break;
|
||||||
|
case Replace:
|
||||||
|
parent.applyReplaceColumnByExpression(column, allRows,
|
||||||
|
cConditionExpression, replaceValue);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void callApplyReplaceColumnByExpression(
|
||||||
|
C_Expression cConditionExpression, C_Expression cReplaceExpression) {
|
||||||
|
if (column == null) {
|
||||||
|
UtilsGXT3.alert("Attention", "Select a valid column!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (replaceExpressionType) {
|
||||||
|
case Template:
|
||||||
|
C_ExpressionContainer conditionExpressionContainer;
|
||||||
|
if (allRows) {
|
||||||
|
conditionExpressionContainer = new C_ExpressionContainer(
|
||||||
|
C_ExpressionContainer.Contains.C_Expression, true,
|
||||||
|
null, "AllRows()");
|
||||||
|
} else {
|
||||||
|
conditionExpressionContainer = new C_ExpressionContainer(
|
||||||
|
C_ExpressionContainer.Contains.C_Expression,
|
||||||
|
cConditionExpression,
|
||||||
|
cConditionExpression.getReadableExpression());
|
||||||
|
}
|
||||||
|
C_ExpressionContainer replaceExpressionContainer = new C_ExpressionContainer(
|
||||||
|
C_ExpressionContainer.Contains.C_Expression,
|
||||||
|
cReplaceExpression, replaceWidget.getReadableExpression());
|
||||||
|
|
||||||
|
ExpressionWrapper exWrapper = new ExpressionWrapper(
|
||||||
|
column.getTrId(), column, conditionExpressionContainer,
|
||||||
|
replaceExpressionContainer);
|
||||||
|
ExpressionWrapperEvent expressionEvent = new ExpressionWrapperEvent(
|
||||||
|
exWrapper);
|
||||||
|
|
||||||
|
Log.debug(expressionEvent.toString());
|
||||||
|
parent.hide();
|
||||||
|
eventBus.fireEvent(expressionEvent);
|
||||||
|
break;
|
||||||
|
case Replace:
|
||||||
|
parent.applyReplaceColumnByExpression(column, allRows,
|
||||||
|
cConditionExpression, cReplaceExpression);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean checkValue(String value) {
|
||||||
|
try {
|
||||||
|
boolean ok = false;
|
||||||
|
ColumnDataType columnDataType = ColumnDataType
|
||||||
|
.getColumnDataTypeFromId(column.getDataTypeName());
|
||||||
|
switch (columnDataType) {
|
||||||
|
case Boolean:
|
||||||
|
Boolean.valueOf(value);
|
||||||
|
ok = true;
|
||||||
|
break;
|
||||||
|
case Date:
|
||||||
|
ok = true;
|
||||||
|
break;
|
||||||
|
case Geometry:
|
||||||
|
try {
|
||||||
|
RegExp regExp = RegExp.compile(GEOMETRY_REGEXPR);
|
||||||
|
MatchResult matcher = regExp.exec(value);
|
||||||
|
boolean matchFound = matcher != null;
|
||||||
|
if (matchFound) {
|
||||||
|
ok = true;
|
||||||
|
} else {
|
||||||
|
ok = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
} catch (Throwable e) {
|
||||||
|
UtilsGXT3.alert("Error replace value",
|
||||||
|
"Insert a valid replace value for Geometry type! ");
|
||||||
|
e.printStackTrace();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case Integer:
|
||||||
|
try {
|
||||||
|
Integer.parseInt(value);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
UtilsGXT3.alert("Error replace value",
|
||||||
|
"Insert a valid replace value for Integer type! ");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ok = true;
|
||||||
|
break;
|
||||||
|
case Numeric:
|
||||||
|
try {
|
||||||
|
Double.parseDouble(value);
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
UtilsGXT3.alert("Error replace value",
|
||||||
|
"Insert a valid replace value for Numeric type! ");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
ok = true;
|
||||||
|
break;
|
||||||
|
case Text:
|
||||||
|
ok = true;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return ok;
|
||||||
|
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
UtilsGXT3.alert("Error replace value",
|
||||||
|
"Insert a valid replace value! " + e.getLocalizedMessage());
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void close() {
|
||||||
|
switch (replaceExpressionType) {
|
||||||
|
case Template:
|
||||||
|
ExpressionWrapper exWrapper = new ExpressionWrapper();
|
||||||
|
ExpressionWrapperEvent expressionEvent = new ExpressionWrapperEvent(
|
||||||
|
exWrapper);
|
||||||
|
Log.debug(expressionEvent.toString());
|
||||||
|
parent.close();
|
||||||
|
eventBus.fireEvent(expressionEvent);
|
||||||
|
break;
|
||||||
|
case Replace:
|
||||||
|
if (parent != null) {
|
||||||
|
parent.close();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,255 @@
|
||||||
|
package org.gcube.portlets.user.td.expressionwidget.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.rpc.ExpressionServiceAsync;
|
||||||
|
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.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.tr.column.FilterColumnSession;
|
||||||
|
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.ChangeTableRequestEvent;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredEvent;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableRequestType;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.client.type.ChangeTableWhy;
|
||||||
|
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.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.ColumnTypeCode;
|
||||||
|
|
||||||
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
|
import com.google.gwt.user.client.rpc.AsyncCallback;
|
||||||
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
import com.sencha.gxt.widget.core.client.Window;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class RowsDeleteByMultiColumnExpressionDialog extends Window implements MonitorDialogListener {
|
||||||
|
private static final String WIDTH = "940px";
|
||||||
|
private static final String HEIGHT = "388px";
|
||||||
|
private MultiColumnExpressionPanel multiColumnExpressionPanel;
|
||||||
|
private C_Expression exp = null;
|
||||||
|
private TRId trId;
|
||||||
|
private ArrayList<ColumnData> columns=null;
|
||||||
|
private ArrayList<ColumnData> removableColumn=null;
|
||||||
|
private EventBus eventBus;
|
||||||
|
private FilterColumnSession filterColumnSession;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public RowsDeleteByMultiColumnExpressionDialog(TRId trId, EventBus eventBus) {
|
||||||
|
initWindow();
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
this.trId = trId;
|
||||||
|
loadColumns();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initWindow() {
|
||||||
|
setWidth(WIDTH);
|
||||||
|
setHeight(HEIGHT);
|
||||||
|
setBodyBorder(false);
|
||||||
|
setResizable(false);
|
||||||
|
setHeadingText("Delete Rows By Expression");
|
||||||
|
setClosable(true);
|
||||||
|
getHeader().setIcon(ExpressionResources.INSTANCE.tableRowDeleteByExpression());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void initTools() {
|
||||||
|
super.initTools();
|
||||||
|
|
||||||
|
closeBtn.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void create() {
|
||||||
|
multiColumnExpressionPanel = new MultiColumnExpressionPanel(this, columns,
|
||||||
|
eventBus);
|
||||||
|
add(multiColumnExpressionPanel);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public C_Expression getExpression() {
|
||||||
|
return exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setExpression(C_Expression exp) {
|
||||||
|
Log.debug("New Expression set:" + exp.toString());
|
||||||
|
this.exp = exp;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void deleteRowsByExpression(C_Expression exp) {
|
||||||
|
this.exp = exp;
|
||||||
|
callDeleteRows();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void loadColumns() {
|
||||||
|
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||||
|
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||||
|
|
||||||
|
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.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() {
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected void callDeleteRows() {
|
||||||
|
filterColumnSession = new FilterColumnSession(trId, exp);
|
||||||
|
Log.debug(filterColumnSession.toString());
|
||||||
|
|
||||||
|
ExpressionServiceAsync.INSTANCE.startFilterColumn(filterColumnSession,
|
||||||
|
new AsyncCallback<String>() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onSuccess(String taskId) {
|
||||||
|
Log.debug("Submitted column filter");
|
||||||
|
openMonitorDialog(taskId);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@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.error("Error submitting the column filter: "
|
||||||
|
+ caught.getLocalizedMessage());
|
||||||
|
caught.printStackTrace();
|
||||||
|
UtilsGXT3
|
||||||
|
.alert("Error submitting the column filter",
|
||||||
|
caught.getLocalizedMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void close() {
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
// /
|
||||||
|
protected void openMonitorDialog(String taskId) {
|
||||||
|
MonitorDialog monitorDialog = new MonitorDialog(taskId, eventBus);
|
||||||
|
monitorDialog.addProgressDialogListener(this);
|
||||||
|
monitorDialog.show();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationComplete(OperationResult operationResult) {
|
||||||
|
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
|
||||||
|
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
||||||
|
ChangeTableRequestType.COLUMNFILTER, operationResult.getTrId(), why);
|
||||||
|
eventBus.fireEvent(changeTableRequestEvent);
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationFailed(Throwable caught, String reason, String details) {
|
||||||
|
UtilsGXT3.alert(reason, details);
|
||||||
|
close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationStopped(OperationResult operationResult, String reason, String details) {
|
||||||
|
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
|
||||||
|
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
||||||
|
ChangeTableRequestType.COLUMNFILTER, operationResult.getTrId(), why);
|
||||||
|
eventBus.fireEvent(changeTableRequestEvent);
|
||||||
|
close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationAborted() {
|
||||||
|
close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void operationPutInBackground() {
|
||||||
|
close();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,168 @@
|
||||||
|
package org.gcube.portlets.user.td.expressionwidget.client;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.notification.ExpressionWrapperNotification;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.notification.ExpressionWrapperNotification.ExpressionWrapperNotificationListener;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.notification.ExpressionWrapperNotification.HasExpressionWrapperNotificationListener;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
||||||
|
import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnData;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnMockUp;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
|
||||||
|
|
||||||
|
import com.google.gwt.user.client.ui.HTML;
|
||||||
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
|
import com.sencha.gxt.widget.core.client.Window;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
||||||
|
import com.sencha.gxt.widget.core.client.event.SelectEvent.SelectHandler;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author "Giancarlo Panichi" <a
|
||||||
|
* href="mailto:g.panichi@isti.cnr.it">g.panichi@isti.cnr.it</a>
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class TemplateMultiColumnExpressionDialog extends Window implements
|
||||||
|
HasExpressionWrapperNotificationListener {
|
||||||
|
private static final String WIDTH = "940px";
|
||||||
|
private static final String HEIGHT = "388px";
|
||||||
|
private ArrayList<ExpressionWrapperNotificationListener> listeners;
|
||||||
|
private MultiColumnExpressionPanel multiColumnExpressionPanel;
|
||||||
|
private ArrayList<ColumnData> columns;
|
||||||
|
private EventBus eventBus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @param columnsMockUp
|
||||||
|
* @param eventBus
|
||||||
|
*/
|
||||||
|
public TemplateMultiColumnExpressionDialog(
|
||||||
|
ArrayList<ColumnMockUp> columnsMockUp, EventBus eventBus) {
|
||||||
|
listeners = new ArrayList<ExpressionWrapperNotificationListener>();
|
||||||
|
this.eventBus = eventBus;
|
||||||
|
columns = new ArrayList<ColumnData>();
|
||||||
|
for (ColumnMockUp columnMockUp : columnsMockUp) {
|
||||||
|
ColumnData column = new ColumnData();
|
||||||
|
column.setColumnId(columnMockUp.getColumnId());
|
||||||
|
column.setLabel(columnMockUp.getLabel());
|
||||||
|
column.setDataTypeName(columnMockUp.getColumnDataType().toString());
|
||||||
|
column.setTypeCode(columnMockUp.getColumnType().toString());
|
||||||
|
columns.add(column);
|
||||||
|
}
|
||||||
|
sanitizesColumns();
|
||||||
|
initWindow();
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void initWindow() {
|
||||||
|
setWidth(WIDTH);
|
||||||
|
setHeight(HEIGHT);
|
||||||
|
setBodyBorder(false);
|
||||||
|
setResizable(false);
|
||||||
|
setHeadingText("New Rule");
|
||||||
|
setClosable(true);
|
||||||
|
setModal(true);
|
||||||
|
forceLayoutOnResize = true;
|
||||||
|
getHeader().setIcon(ExpressionResources.INSTANCE.ruleAdd());
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
protected void initTools() {
|
||||||
|
super.initTools();
|
||||||
|
|
||||||
|
closeBtn.addSelectHandler(new SelectHandler() {
|
||||||
|
|
||||||
|
public void onSelect(SelectEvent event) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void close() {
|
||||||
|
fireAborted();
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void create() {
|
||||||
|
if(columns.size()>0){
|
||||||
|
multiColumnExpressionPanel = new MultiColumnExpressionPanel(this,columns,
|
||||||
|
eventBus);
|
||||||
|
add(multiColumnExpressionPanel);
|
||||||
|
} else {
|
||||||
|
HTML errorMessage = new HTML(
|
||||||
|
"Attention no columns with a type supported(Dimension and TimeDimension is not supported)!");
|
||||||
|
add(errorMessage);
|
||||||
|
UtilsGXT3.alert("Attention","Attention no columns with a type supported(Dimension and TimeDimension is not supported)!");
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void onExpression(
|
||||||
|
ExpressionWrapperNotification expressionWrapperNotification) {
|
||||||
|
fireNotification(expressionWrapperNotification);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void addExpressionWrapperNotificationListener(
|
||||||
|
ExpressionWrapperNotificationListener handler) {
|
||||||
|
listeners.add(handler);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removeExpressionWrapperNotificationListener(
|
||||||
|
ExpressionWrapperNotificationListener handler) {
|
||||||
|
listeners.remove(handler);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fireNotification(
|
||||||
|
ExpressionWrapperNotification expressionWrapperNotification) {
|
||||||
|
if (listeners != null) {
|
||||||
|
for (ExpressionWrapperNotificationListener listener : listeners) {
|
||||||
|
listener.onExpression(expressionWrapperNotification);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fireAborted() {
|
||||||
|
if (listeners != null) {
|
||||||
|
for (ExpressionWrapperNotificationListener listener : listeners) {
|
||||||
|
listener.aborted();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fireFailed(Throwable caught) {
|
||||||
|
if (listeners != null) {
|
||||||
|
for (ExpressionWrapperNotificationListener listener : listeners) {
|
||||||
|
listener.failed(caught);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
hide();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -61,7 +61,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
|
|
||||||
private static final String SIGN = "ConditionOnMultiColumns";
|
private static final String SIGN = "ConditionOnMultiColumns";
|
||||||
private static final String HEIGHT = "268px";
|
private static final String HEIGHT = "268px";
|
||||||
private static final String WIDTH = "664px";
|
private static final String WIDTH = "890px";
|
||||||
private static final String COMBO_DEPTH_WIDTH = "64px";
|
private static final String COMBO_DEPTH_WIDTH = "64px";
|
||||||
private static final String COMBO_FIRST_ELEMENT_COLUMN_WIDTH = "150px";
|
private static final String COMBO_FIRST_ELEMENT_COLUMN_WIDTH = "150px";
|
||||||
private static final String COMBO_OPERATOR_WIDTH = "130px";
|
private static final String COMBO_OPERATOR_WIDTH = "130px";
|
||||||
|
@ -116,6 +116,11 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetCondition(){
|
||||||
|
vert.clear();
|
||||||
|
setup();
|
||||||
|
}
|
||||||
|
|
||||||
protected void init(String width, String height) {
|
protected void init(String width, String height) {
|
||||||
setWidth(width);
|
setWidth(width);
|
||||||
setHeight(height);
|
setHeight(height);
|
||||||
|
@ -466,7 +471,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
secondArgDate.setVisible(false);
|
secondArgDate.setVisible(false);
|
||||||
thresholdText.setVisible(false);
|
thresholdText.setVisible(false);
|
||||||
comboThreshold.setVisible(false);
|
comboThreshold.setVisible(false);
|
||||||
btnAdd.setVisible(true);
|
btnAdd.setVisible(false);
|
||||||
btnDel.setVisible(false);
|
btnDel.setVisible(false);
|
||||||
removeCondition(source);
|
removeCondition(source);
|
||||||
break;
|
break;
|
||||||
|
@ -516,7 +521,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
thresholdText.setVisible(false);
|
thresholdText.setVisible(false);
|
||||||
comboThreshold.setVisible(false);
|
comboThreshold.setVisible(false);
|
||||||
btnAdd.setVisible(true);
|
btnAdd.setVisible(true);
|
||||||
btnDel.setVisible(true);
|
btnDel.setVisible(false);
|
||||||
removeCondition(source);
|
removeCondition(source);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
@ -559,8 +564,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
secondArgDate.setVisible(false);
|
secondArgDate.setVisible(false);
|
||||||
thresholdText.setVisible(false);
|
thresholdText.setVisible(false);
|
||||||
comboThreshold.setVisible(false);
|
comboThreshold.setVisible(false);
|
||||||
btnAdd.setVisible(false);
|
|
||||||
btnDel.setVisible(false);
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
Log.debug("ComboFirstElement selected: "
|
Log.debug("ComboFirstElement selected: "
|
||||||
|
@ -586,8 +590,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
secondArgDate.setVisible(false);
|
secondArgDate.setVisible(false);
|
||||||
thresholdText.setVisible(false);
|
thresholdText.setVisible(false);
|
||||||
comboThreshold.setVisible(false);
|
comboThreshold.setVisible(false);
|
||||||
btnAdd.setVisible(false);
|
|
||||||
btnDel.setVisible(false);
|
|
||||||
} else {
|
} else {
|
||||||
OperationsStore operationStore = new OperationsStore();
|
OperationsStore operationStore = new OperationsStore();
|
||||||
storeOperator.clear();
|
storeOperator.clear();
|
||||||
|
@ -609,8 +612,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
secondArgDate.setVisible(false);
|
secondArgDate.setVisible(false);
|
||||||
thresholdText.setVisible(false);
|
thresholdText.setVisible(false);
|
||||||
comboThreshold.setVisible(false);
|
comboThreshold.setVisible(false);
|
||||||
btnAdd.setVisible(true);
|
|
||||||
btnDel.setVisible(false);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -638,8 +640,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
secondArgDate.setVisible(false);
|
secondArgDate.setVisible(false);
|
||||||
thresholdText.setVisible(false);
|
thresholdText.setVisible(false);
|
||||||
comboThreshold.setVisible(false);
|
comboThreshold.setVisible(false);
|
||||||
btnAdd.setVisible(false);
|
|
||||||
btnDel.setVisible(false);
|
|
||||||
} else {
|
} else {
|
||||||
Log.debug("Operator selected:" + op.toString());
|
Log.debug("Operator selected:" + op.toString());
|
||||||
switch (op.getOperatorType()) {
|
switch (op.getOperatorType()) {
|
||||||
|
@ -674,8 +675,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
secondArgDate.setVisible(false);
|
secondArgDate.setVisible(false);
|
||||||
thresholdText.setVisible(false);
|
thresholdText.setVisible(false);
|
||||||
comboThreshold.setVisible(false);
|
comboThreshold.setVisible(false);
|
||||||
btnAdd.setVisible(true);
|
|
||||||
btnDel.setVisible(false);
|
|
||||||
break;
|
break;
|
||||||
case BETWEEN:
|
case BETWEEN:
|
||||||
case NOT_BETWEEN:
|
case NOT_BETWEEN:
|
||||||
|
@ -693,8 +693,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
secondArgDate.setVisible(false);
|
secondArgDate.setVisible(false);
|
||||||
thresholdText.setVisible(false);
|
thresholdText.setVisible(false);
|
||||||
comboThreshold.setVisible(false);
|
comboThreshold.setVisible(false);
|
||||||
btnAdd.setVisible(true);
|
|
||||||
btnDel.setVisible(false);
|
|
||||||
break;
|
break;
|
||||||
case SOUNDEX:
|
case SOUNDEX:
|
||||||
comboFirstArgType.reset();
|
comboFirstArgType.reset();
|
||||||
|
@ -711,8 +710,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
secondArgDate.setVisible(false);
|
secondArgDate.setVisible(false);
|
||||||
thresholdText.setVisible(false);
|
thresholdText.setVisible(false);
|
||||||
comboThreshold.setVisible(false);
|
comboThreshold.setVisible(false);
|
||||||
btnAdd.setVisible(true);
|
|
||||||
btnDel.setVisible(false);
|
|
||||||
break;
|
break;
|
||||||
case LEVENSHTEIN:
|
case LEVENSHTEIN:
|
||||||
comboFirstArgType.reset();
|
comboFirstArgType.reset();
|
||||||
|
@ -735,8 +733,6 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
secondArgDate.setVisible(false);
|
secondArgDate.setVisible(false);
|
||||||
thresholdText.setVisible(true);
|
thresholdText.setVisible(true);
|
||||||
comboThreshold.setVisible(true);
|
comboThreshold.setVisible(true);
|
||||||
btnAdd.setVisible(true);
|
|
||||||
btnDel.setVisible(false);
|
|
||||||
|
|
||||||
comboThreshold.setValue(ThresholdStore
|
comboThreshold.setValue(ThresholdStore
|
||||||
.defaultThresholdLevenshtein());
|
.defaultThresholdLevenshtein());
|
||||||
|
@ -763,12 +759,9 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
secondArgDate.setVisible(false);
|
secondArgDate.setVisible(false);
|
||||||
thresholdText.setVisible(true);
|
thresholdText.setVisible(true);
|
||||||
comboThreshold.setVisible(true);
|
comboThreshold.setVisible(true);
|
||||||
btnAdd.setVisible(true);
|
|
||||||
btnDel.setVisible(false);
|
|
||||||
|
|
||||||
comboThreshold.setValue(ThresholdStore
|
comboThreshold.setValue(ThresholdStore
|
||||||
.defaultThresholdSimilarity());
|
.defaultThresholdSimilarity());
|
||||||
|
|
||||||
break;
|
break;
|
||||||
case IS_NULL:
|
case IS_NULL:
|
||||||
case IS_NOT_NULL:
|
case IS_NOT_NULL:
|
||||||
|
@ -783,8 +776,6 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
secondArgDate.setVisible(false);
|
secondArgDate.setVisible(false);
|
||||||
thresholdText.setVisible(false);
|
thresholdText.setVisible(false);
|
||||||
comboThreshold.setVisible(false);
|
comboThreshold.setVisible(false);
|
||||||
btnAdd.setVisible(true);
|
|
||||||
btnDel.setVisible(false);
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
comboFirstArgType.setVisible(false);
|
comboFirstArgType.setVisible(false);
|
||||||
|
@ -798,8 +789,6 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
secondArgDate.setVisible(false);
|
secondArgDate.setVisible(false);
|
||||||
thresholdText.setVisible(false);
|
thresholdText.setVisible(false);
|
||||||
comboThreshold.setVisible(false);
|
comboThreshold.setVisible(false);
|
||||||
btnAdd.setVisible(false);
|
|
||||||
btnDel.setVisible(false);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -852,9 +841,11 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
comboFirstArgColumn.setVisible(false);
|
comboFirstArgColumn.setVisible(false);
|
||||||
if (columnDataType
|
if (columnDataType
|
||||||
.compareTo(ColumnDataType.Date) == 0) {
|
.compareTo(ColumnDataType.Date) == 0) {
|
||||||
|
firstArgDate.reset();
|
||||||
firstArgValue.setVisible(false);
|
firstArgValue.setVisible(false);
|
||||||
firstArgDate.setVisible(true);
|
firstArgDate.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
firstArgValue.reset();
|
||||||
firstArgValue.setVisible(true);
|
firstArgValue.setVisible(true);
|
||||||
firstArgDate.setVisible(false);
|
firstArgDate.setVisible(false);
|
||||||
}
|
}
|
||||||
|
@ -917,9 +908,11 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
comboSecondArgColumn.setVisible(false);
|
comboSecondArgColumn.setVisible(false);
|
||||||
if (columnDataType
|
if (columnDataType
|
||||||
.compareTo(ColumnDataType.Date) == 0) {
|
.compareTo(ColumnDataType.Date) == 0) {
|
||||||
|
secondArgDate.reset();
|
||||||
secondArgValue.setVisible(false);
|
secondArgValue.setVisible(false);
|
||||||
secondArgDate.setVisible(true);
|
secondArgDate.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
secondArgValue.reset();
|
||||||
secondArgValue.setVisible(true);
|
secondArgValue.setVisible(true);
|
||||||
secondArgDate.setVisible(false);
|
secondArgDate.setVisible(false);
|
||||||
}
|
}
|
||||||
|
@ -963,7 +956,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
secondArgDate.setVisible(false);
|
secondArgDate.setVisible(false);
|
||||||
thresholdText.setVisible(false);
|
thresholdText.setVisible(false);
|
||||||
comboThreshold.setVisible(false);
|
comboThreshold.setVisible(false);
|
||||||
btnAdd.setVisible(true);
|
btnAdd.setVisible(false);
|
||||||
btnDel.setVisible(false);
|
btnDel.setVisible(false);
|
||||||
|
|
||||||
horiz.add(comboDepth, new BoxLayoutData(new Margins(0)));
|
horiz.add(comboDepth, new BoxLayoutData(new Margins(0)));
|
||||||
|
@ -1647,9 +1640,11 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
comboFirstArgColumn.setVisible(false);
|
comboFirstArgColumn.setVisible(false);
|
||||||
if (columnDataType
|
if (columnDataType
|
||||||
.compareTo(ColumnDataType.Date) == 0) {
|
.compareTo(ColumnDataType.Date) == 0) {
|
||||||
|
firstArgDate.reset();
|
||||||
firstArgValue.setVisible(false);
|
firstArgValue.setVisible(false);
|
||||||
firstArgDate.setVisible(true);
|
firstArgDate.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
firstArgValue.reset();
|
||||||
firstArgValue.setVisible(true);
|
firstArgValue.setVisible(true);
|
||||||
firstArgDate.setVisible(false);
|
firstArgDate.setVisible(false);
|
||||||
}
|
}
|
||||||
|
@ -1712,9 +1707,11 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
comboSecondArgColumn.setVisible(false);
|
comboSecondArgColumn.setVisible(false);
|
||||||
if (columnDataType
|
if (columnDataType
|
||||||
.compareTo(ColumnDataType.Date) == 0) {
|
.compareTo(ColumnDataType.Date) == 0) {
|
||||||
|
secondArgDate.reset();
|
||||||
secondArgValue.setVisible(false);
|
secondArgValue.setVisible(false);
|
||||||
secondArgDate.setVisible(true);
|
secondArgDate.setVisible(true);
|
||||||
} else {
|
} else {
|
||||||
|
secondArgValue.reset();
|
||||||
secondArgValue.setVisible(true);
|
secondArgValue.setVisible(true);
|
||||||
secondArgDate.setVisible(false);
|
secondArgDate.setVisible(false);
|
||||||
}
|
}
|
||||||
|
@ -1824,23 +1821,23 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
.getCurrentValue();
|
.getCurrentValue();
|
||||||
|
|
||||||
if (depthOfExpressionElement == null) {
|
if (depthOfExpressionElement == null) {
|
||||||
return null;
|
throw new ConditionTypeMapException("Fill all field and creates a valid expression!");
|
||||||
}
|
}
|
||||||
|
|
||||||
DepthOfExpressionType depth = depthOfExpressionElement.getType();
|
DepthOfExpressionType depth = depthOfExpressionElement.getType();
|
||||||
|
|
||||||
if (depth == null) {
|
if (depth == null) {
|
||||||
return null;
|
throw new ConditionTypeMapException("Fill all field and creates a valid expression!");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (expSet) {
|
if (expSet) {
|
||||||
return null;
|
throw new ConditionTypeMapException("Expression is invalid!");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch (depth) {
|
switch (depth) {
|
||||||
case BOTTOM:
|
case BOTTOM:
|
||||||
if (vert.getWidgetCount() != 1) {
|
if (vert.getWidgetCount() != 1) {
|
||||||
return null;
|
throw new ConditionTypeMapException("Expression is invalid!");
|
||||||
}
|
}
|
||||||
C_Expression singleCondition = calcExpression(horiz);
|
C_Expression singleCondition = calcExpression(horiz);
|
||||||
exp = singleCondition;
|
exp = singleCondition;
|
||||||
|
@ -1862,7 +1859,7 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
break;
|
break;
|
||||||
case ENDAND:
|
case ENDAND:
|
||||||
if (depthStack.isEmpty()) {
|
if (depthStack.isEmpty()) {
|
||||||
return null;
|
throw new ConditionTypeMapException("Expression is invalid!");
|
||||||
} else {
|
} else {
|
||||||
LogicalDepth endAndPopped = depthStack.pop();
|
LogicalDepth endAndPopped = depthStack.pop();
|
||||||
if (endAndPopped.getType().compareTo(
|
if (endAndPopped.getType().compareTo(
|
||||||
|
@ -1879,17 +1876,17 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
.getArguments();
|
.getArguments();
|
||||||
args.add(cAnd);
|
args.add(cAnd);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
throw new ConditionTypeMapException("Expression is invalid!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return null;
|
throw new ConditionTypeMapException("Expression is invalid, brackets do not match!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case ENDOR:
|
case ENDOR:
|
||||||
if (depthStack.isEmpty()) {
|
if (depthStack.isEmpty()) {
|
||||||
return null;
|
throw new ConditionTypeMapException("Expression is invalid!");
|
||||||
} else {
|
} else {
|
||||||
LogicalDepth endOrPopped = depthStack.pop();
|
LogicalDepth endOrPopped = depthStack.pop();
|
||||||
if (endOrPopped.getType().compareTo(
|
if (endOrPopped.getType().compareTo(
|
||||||
|
@ -1906,11 +1903,11 @@ public class ConditionOnMultiColumnWidget extends SimpleContainer {
|
||||||
.getArguments();
|
.getArguments();
|
||||||
args.add(cOr);
|
args.add(cOr);
|
||||||
} else {
|
} else {
|
||||||
return null;
|
throw new ConditionTypeMapException("Expression is invalid!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return null;
|
throw new ConditionTypeMapException("Expression is invalid, brackets do not match!");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
Loading…
Reference in New Issue