Updated Filter

git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@113679 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
Giancarlo Panichi 2015-03-20 16:43:36 +00:00
parent da2dc8beeb
commit 3f62196aba
6 changed files with 400 additions and 218 deletions

View File

@ -178,7 +178,7 @@ public class ColumnExpressionPanel extends FramedPanel {
public void onSelect(SelectEvent event) {
Log.debug("Pressed Apply");
applyRule();
applySeleceted();
}
});
@ -305,7 +305,7 @@ public class ColumnExpressionPanel extends FramedPanel {
public void onSelect(SelectEvent event) {
Log.debug("Pressed Apply");
applyRule();
applySeleceted();
}
});
@ -391,10 +391,11 @@ public class ColumnExpressionPanel extends FramedPanel {
if (event.getSelectedItem() != null) {
ColumnData col = event.getSelectedItem();
Log.debug("Col selected:" + col.toString());
column=col;
btnApply.enable();
conditionWidget.update(col);
} else {
column=null;
btnApply.disable();
conditionWidget.update(null);
}
@ -453,7 +454,7 @@ public class ColumnExpressionPanel extends FramedPanel {
public void onSelect(SelectEvent event) {
Log.debug("Pressed Add Filter");
applyRule();
applySeleceted();
}
});
@ -470,7 +471,9 @@ public class ColumnExpressionPanel extends FramedPanel {
}
protected void applyRule() {
protected void applySeleceted() {
Log.debug("Apply: "+column);
C_Expression exp;
try {
exp = conditionWidget.getExpression();
@ -499,7 +502,7 @@ public class ColumnExpressionPanel extends FramedPanel {
eventBus.fireEvent(expressionEvent);
break;
case ColumnFilter:
parentFilterDialog.applyFilter(exp);
parentFilterDialog.applyFilter(column,exp);
break;
case MultiColumnFilter:
parentMultiColumnFilterTabPanel.applyFilter(column, exp);

View File

@ -92,8 +92,6 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
eventBus);
add(columnExpressionPanel);
}
@ -108,8 +106,9 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
this.exp = exp;
}
protected void applyFilter(C_Expression exp) {
protected void applyFilter(ColumnData column,C_Expression exp) {
this.exp = exp;
this.column= column;
callApplyFilter();
}
@ -139,6 +138,15 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
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||
@ -151,12 +159,8 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
}
}
columns.removeAll(removableColumn);
create();
}
});
}
protected void callApplyFilter() {
filterColumnSession = new FilterColumnSession(column, exp);
@ -252,4 +256,6 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
}
}

View File

@ -72,6 +72,8 @@ public class ConditionWidget extends SimpleContainer {
protected ColumnData column;
protected String readableExpression;
private Radio radioAll;
private Radio radioAny;
public ConditionWidget(ColumnData column) {
super();
@ -84,11 +86,12 @@ public class ConditionWidget extends SimpleContainer {
}
public void update(ColumnData newColumn){
int count=vert.getWidgetCount();
for(int i=0; i<count;i++){
vert.remove(i);
}
vert.clear();
this.column=newColumn;
radioAll.setValue(true);
radioAny.setValue(false);
groupMatch.setValue(radioAll);
matchLabel.setVisible(false);
setup();
}
@ -119,12 +122,12 @@ public class ConditionWidget extends SimpleContainer {
VerticalLayoutContainer baseLayout = new VerticalLayoutContainer();
Radio radioAll = new Radio();
radioAll = new Radio();
radioAll.setName("All");
radioAll.setBoxLabel("All conditions");
radioAll.setValue(true);
Radio radioAny = new Radio();
radioAny = new Radio();
radioAny.setName("Any");
radioAny.setBoxLabel("Any condition");

View File

@ -22,12 +22,10 @@ import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredTy
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.ColumnDataType;
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.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;
@ -43,17 +41,17 @@ public class ReplaceColumnByExpressionDialog extends Window implements
MonitorDialogListener {
private static final String WIDTH = "880px";
private static final String HEIGHT = "490px";
private static final String HEIGHT_REDUCE = "404px";
//private static final String HEIGHT_REDUCE = "404px";
private ReplaceColumnByExpressionPanel replaceColumnByExpressionPanel;
private C_Expression cConditionExpression = null;
private ColumnData column = null;
private ArrayList<ColumnData> columns;
//private String columnName = null;
private EventBus eventBus;
private ReplaceColumnByExpressionType replaceColumnByExpressionType;
private String columnLocalId;
private TRId trId;
/**
*
@ -81,12 +79,14 @@ public class ReplaceColumnByExpressionDialog extends Window implements
* @param columnName
* @param eventBus
*/
public ReplaceColumnByExpressionDialog(TRId trId, String columnName,
public ReplaceColumnByExpressionDialog(TRId trId, String columnLocalId,
EventBus eventBus) {
this.eventBus = eventBus;
this.columnLocalId = columnLocalId;
this.trId = trId;
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Replace;
initWindow();
load(trId, columnName);
load();
}
@ -118,67 +118,13 @@ public class ReplaceColumnByExpressionDialog extends Window implements
}
protected void create() {
if (column == null) {
UtilsGXT3.info("Attention ",
"You must select a column!");
hide();
return;
}
if (column.isViewColumn()) {
UtilsGXT3.info("Attention is View Column",
"You can not make expressions on view column for now!");
hide();
return;
}
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
) {
setHeight(HEIGHT);
} else {
setHeight(HEIGHT_REDUCE);
}
if (column.getTypeCode()
.compareTo(ColumnTypeCode.ANNOTATION.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.ATTRIBUTE.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.CODE.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.CODEDESCRIPTION.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.CODENAME.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.MEASURE.toString()) == 0) {
switch (replaceColumnByExpressionType) {
case Replace:
replaceColumnByExpressionPanel = new ReplaceColumnByExpressionPanel(
this, column, eventBus);
break;
case Template:
replaceColumnByExpressionPanel = new ReplaceColumnByExpressionPanel(
this, column, columns, eventBus);
break;
default:
break;
}
this, column, columns, eventBus, replaceColumnByExpressionType);
add(replaceColumnByExpressionPanel);
}
} else {
HTML 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!");
}
}
public C_Expression getExpression() {
return cConditionExpression;
@ -189,19 +135,19 @@ public class ReplaceColumnByExpressionDialog extends Window implements
this.cConditionExpression = exp;
}
protected void applyReplaceColumnByExpression(
boolean allRows,C_Expression cConditionExpression, String replaceValue) {
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(boolean allRows,
protected void applyReplaceColumnByExpression(ColumnData column, boolean allRows,
C_Expression cConditionExpression, C_Expression cReplaceExpression) {
this.column=column;
this.cConditionExpression = cConditionExpression;
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(
@ -209,9 +155,9 @@ public class ReplaceColumnByExpressionDialog extends Window implements
callApplyReplaceByExpression(replaceColumnByExpressionSession);
}
protected void load(TRId trId, String columnName) {
TDGWTServiceAsync.INSTANCE.getColumn(trId, columnName,
new AsyncCallback<ColumnData>() {
protected void load() {
TDGWTServiceAsync.INSTANCE.getColumns(trId,
new AsyncCallback<ArrayList<ColumnData>>() {
public void onFailure(Throwable caught) {
if (caught instanceof TDGWTSessionExpiredException) {
@ -231,9 +177,10 @@ public class ReplaceColumnByExpressionDialog extends Window implements
}
}
public void onSuccess(ColumnData result) {
Log.debug("Retrived column: " + result);
column = result;
public void onSuccess(ArrayList<ColumnData> result) {
Log.debug("Retrived columns: " + result);
columns = result;
sanitizesColumns();
create();
}
@ -242,6 +189,28 @@ public class ReplaceColumnByExpressionDialog extends Window implements
}
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 (columnLocalId != null
&& c.getColumnId().compareTo(
columnLocalId) == 0) {
column = c;
}
}
}
columns.removeAll(removableColumn);
}
protected void callApplyReplaceByExpression(
ReplaceColumnByExpressionSession replaceColumnByExpressionSession) {
Log.debug("Replace Column By Expression Session "
@ -303,7 +272,8 @@ public class ReplaceColumnByExpressionDialog extends Window implements
public void operationComplete(OperationResult operationResult) {
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.COLUMNFILTER, operationResult.getTrId(), why);
ChangeTableRequestType.COLUMNFILTER, operationResult.getTrId(),
why);
eventBus.fireEvent(changeTableRequestEvent);
close();
}
@ -316,10 +286,12 @@ public class ReplaceColumnByExpressionDialog extends Window implements
}
@Override
public void operationStopped(OperationResult operationResult, String reason, String details) {
public void operationStopped(OperationResult operationResult,
String reason, String details) {
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
ChangeTableRequestType.COLUMNFILTER, operationResult.getTrId(), why);
ChangeTableRequestType.COLUMNFILTER, operationResult.getTrId(),
why);
eventBus.fireEvent(changeTableRequestEvent);
close();
@ -337,4 +309,6 @@ public class ReplaceColumnByExpressionDialog extends Window implements
}
}

View File

@ -3,6 +3,7 @@ package org.gcube.portlets.user.td.expressionwidget.client;
import java.util.ArrayList;
import java.util.Date;
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.ReplaceColumnByExpressionType;
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ConditionTypeMapException;
@ -14,20 +15,27 @@ import org.gcube.portlets.user.td.widgetcommonevent.client.type.ExpressionType;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_ExpressionContainer;
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;
@ -38,6 +46,7 @@ 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;
@ -57,10 +66,12 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
private static final String WIDTH = "868px";
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 = "832px";
private static final String CONDITIONWIDTH = "818px";
private static final String CONDITIONHEIGHT = "120px";
private static final String CONDITION_LAYOUT_WIDTH = "832px";
private static final String CONDITION_LAYOUT_WIDTH = "818px";
private static final String REPLACEWIDTH = "832px";
private static final String REPLACEHEIGHT = "120px";
private static final String ALL_ROWS_FIELD_WIDTH = "832px";
@ -82,6 +93,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
private TextButton btnApply;
private TextButton btnClose;
private ComboBox<ColumnData> comboCols;
private FieldSet conditionsFieldSet;
private ConditionWidget conditionWidget;
@ -93,28 +106,84 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
private FieldLabel allRowsField;
private boolean allRows;
public ReplaceColumnByExpressionPanel(
ReplaceColumnByExpressionDialog parent, ColumnData column,
EventBus eventBus) {
super();
this.parent = parent;
this.column = column;
this.eventBus = eventBus;
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Replace;
Log.debug("Column: " + column);
init();
create();
private FieldSet replaceValueFieldSet;
protected void createPArent() {
if (column == null) {
UtilsGXT3.info("Attention ", "You must select a column!");
hide();
return;
}
if (column.isViewColumn()) {
UtilsGXT3.info("Attention is View Column",
"You can not make expressions on view column for now!");
hide();
return;
}
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) {
setHeight(HEIGHT);
} else {
setHeight(HEIGHT_REDUCE);
}
if (column.getTypeCode()
.compareTo(ColumnTypeCode.ANNOTATION.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.ATTRIBUTE.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.CODE.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.CODEDESCRIPTION.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.CODENAME.toString()) == 0
|| column.getTypeCode().compareTo(
ColumnTypeCode.MEASURE.toString()) == 0) {
switch (replaceColumnByExpressionType) {
case Replace:
// replaceColumnByExpressionPanel = new
// ReplaceColumnByExpressionPanel(
// this, column, eventBus);
break;
case Template:
// replaceColumnByExpressionPanel = new
// ReplaceColumnByExpressionPanel(
// this, column, columns, eventBus,
// replaceColumnByExpressionType);
break;
default:
break;
}
// add(replaceColumnByExpressionPanel);
} else {
HTML 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!");
}
}
public ReplaceColumnByExpressionPanel(
ReplaceColumnByExpressionDialog parent, ColumnData column,
ArrayList<ColumnData> columns, EventBus eventBus) {
ArrayList<ColumnData> columns, EventBus eventBus,
ReplaceColumnByExpressionType replaceColumnByExpressionType) {
super();
this.parent = parent;
this.column = column;
this.columns = columns;
this.eventBus = eventBus;
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Template;
this.replaceColumnByExpressionType = replaceColumnByExpressionType;
Log.debug("Column: " + column);
Log.debug("Columns: " + columns);
init();
@ -123,6 +192,16 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
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().compareTo(
ColumnDataType.Text.toString()) == 0
@ -132,15 +211,13 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
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);
}
setBodyBorder(false);
setHeaderVisible(false);
// Important: fixed rendering of widgets
forceLayoutOnResize = true;
}
protected void create() {
@ -160,11 +237,29 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
VerticalLayoutContainer propertiesLayout = new VerticalLayoutContainer();
properties.add(propertiesLayout);
TextField columnName = new TextField();
columnName.setToolTip("Column");
columnName.setReadOnly(true);
columnName.setValue(column.getLabel());
propertiesLayout.add(new FieldLabel(columnName, "Column"),
// 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
@ -221,57 +316,11 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
conditionsFieldSet.add(conditionsVerticalLayout);
// Value
FieldSet replaceValueFieldSet = new FieldSet();
replaceValueFieldSet = new FieldSet();
replaceValueFieldSet.setHeadingText("Replace Value");
replaceValueFieldSet.setCollapsible(false);
VerticalLayoutContainer replaceValueFieldSetLayout = new VerticalLayoutContainer();
replaceValueFieldSet.add(replaceValueFieldSetLayout);
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 (replaceColumnByExpressionType) {
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");
if (parent != null) {
parent.hide();
}
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));
}
}
calcReplaceValue();
//
btnApply = new TextButton("Apply");
@ -287,6 +336,11 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
}
});
if(column==null){
btnApply.disable();
}
btnClose = new TextButton("Close");
btnClose.setIcon(ExpressionResources.INSTANCE.close());
@ -316,6 +370,135 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
}
protected void calcReplaceValue() {
replaceValueFieldSet.clear();
VerticalLayoutContainer replaceValueFieldSetLayout = new VerticalLayoutContainer();
replaceValueFieldSet.add(replaceValueFieldSetLayout);
if (column == null) {
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 (replaceColumnByExpressionType) {
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) {
errorMessage = new HTML(
"This column has column data type null!");
UtilsGXT3.alert("Error",
"This column has column data type null!!");
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.update(col);
calcReplaceValue();
} else {
column=null;
btnApply.disable();
conditionWidget.update(null);
calcReplaceValue();
}
calcHeight();
parent.forceLayout();
}
};
return selectionHandler;
}
protected void callAllRowChange(ValueChangeEvent<HasValue<Boolean>> event) {
ToggleGroup group = (ToggleGroup) event.getSource();
Radio radio = (Radio) group.getValue();
@ -402,6 +585,12 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
protected void callApplyReplaceColumnByExpression(
C_Expression cConditionExpression, String replaceValue) {
if(column==null){
UtilsGXT3.alert("Attention", "Select a valid column!");
return;
}
switch (replaceColumnByExpressionType) {
case Template:
ExpressionEvent expressionEvent = new ExpressionEvent(
@ -409,9 +598,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
C_ExpressionContainer container;
if (allRows) {
container = new C_ExpressionContainer(
C_ExpressionContainer.Contains.C_Expression,
true,null,
"AllRows()");
C_ExpressionContainer.Contains.C_Expression, true,
null, "AllRows()");
} else {
container = new C_ExpressionContainer(
C_ExpressionContainer.Contains.C_Expression,
@ -429,8 +617,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
eventBus.fireEvent(expressionEvent);
break;
case Replace:
parent.applyReplaceColumnByExpression(allRows,cConditionExpression,
replaceValue);
parent.applyReplaceColumnByExpression(column,allRows,
cConditionExpression, replaceValue);
break;
default:
break;
@ -440,6 +628,11 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
protected void callApplyReplaceColumnByExpression(
C_Expression cConditionExpression, C_Expression cReplaceExpression) {
if(column==null){
UtilsGXT3.alert("Attention", "Select a valid column!");
return;
}
switch (replaceColumnByExpressionType) {
case Template:
ExpressionEvent expressionEvent = new ExpressionEvent(
@ -447,9 +640,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
C_ExpressionContainer conditionExpressionContainer;
if (allRows) {
conditionExpressionContainer = new C_ExpressionContainer(
C_ExpressionContainer.Contains.C_Expression,
true,null,
"AllRows()");
C_ExpressionContainer.Contains.C_Expression, true,
null, "AllRows()");
} else {
conditionExpressionContainer = new C_ExpressionContainer(
C_ExpressionContainer.Contains.C_Expression,
@ -473,8 +665,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
eventBus.fireEvent(expressionEvent);
break;
case Replace:
parent.applyReplaceColumnByExpression(allRows,cConditionExpression,
cReplaceExpression);
parent.applyReplaceColumnByExpression(column, allRows,
cConditionExpression, cReplaceExpression);
break;
default:
break;

View File

@ -986,11 +986,11 @@ public class ReplaceWidget extends SimpleContainer {
ComboBox<ColumnData> comboColumns = (ComboBox<ColumnData>) horiz
.getItemByItemId(itemIdComboColumns);
Log.debug("combo columns: " + comboColumns.getCurrentValue());
ColumnData column = comboColumns.getCurrentValue();
ColumnData columnOfCombo = comboColumns.getCurrentValue();
firstArg = (TextField) horiz.getItemByItemId(itemIdFirstArg);
secondArg = (TextField) horiz.getItemByItemId(itemIdSecondArg);
Log.debug("[column: " + column + ", firstArg: "
Log.debug("[combo column: " + columnOfCombo + ", firstArg: "
+ firstArg.getCurrentValue() + ", secondArg: "
+ secondArg.getCurrentValue() + "]");
@ -1015,7 +1015,7 @@ public class ReplaceWidget extends SimpleContainer {
switch (replaceColumnByExpressionType) {
case Replace:
expLeaf = mapReplace.map(
column,
columnOfCombo,
ColumnDataType.Text,
comboLeafReplaceType,
firstArg == null ? null : firstArg
@ -1025,7 +1025,7 @@ public class ReplaceWidget extends SimpleContainer {
break;
case Template:
expLeaf = mapReplace.map(
column,
columnOfCombo,
ColumnDataType.Text,
comboLeafReplaceType,
firstArg == null ? null : firstArg
@ -1035,7 +1035,7 @@ public class ReplaceWidget extends SimpleContainer {
break;
default:
expLeaf = mapReplace.map(
column,
columnOfCombo,
ColumnDataType.Text,
comboLeafReplaceType,
firstArg == null ? null : firstArg
@ -1059,7 +1059,7 @@ public class ReplaceWidget extends SimpleContainer {
switch (replaceColumnByExpressionType) {
case Replace:
exp = mapReplace.map(
column,
columnOfCombo,
targetType,
comboOperationsReplaceType,
firstArg == null ? null : firstArg
@ -1072,7 +1072,7 @@ public class ReplaceWidget extends SimpleContainer {
break;
case Template:
exp = mapReplace.map(
column,
columnOfCombo,
targetType,
comboOperationsReplaceType,
firstArg == null ? null : firstArg
@ -1085,7 +1085,7 @@ public class ReplaceWidget extends SimpleContainer {
break;
default:
exp = mapReplace.map(
column,
columnOfCombo,
targetType,
comboOperationsReplaceType,
firstArg == null ? null : firstArg
@ -1123,13 +1123,17 @@ public class ReplaceWidget extends SimpleContainer {
comboLeafReplaceType = comboLeaf.getCurrentValue()
.getReplaceType();
cType = ColumnDataType.getColumnDataTypeFromId(column
if(columnOfCombo==null){
throw new ReplaceTypeMapException("Selected a valid column!");
}
cType = ColumnDataType.getColumnDataTypeFromId(columnOfCombo
.getDataTypeName());
switch (replaceColumnByExpressionType) {
case Replace:
expLeaf = mapReplace.map(
column,
columnOfCombo,
cType,
comboLeafReplaceType,
firstArg == null ? null : firstArg
@ -1139,7 +1143,7 @@ public class ReplaceWidget extends SimpleContainer {
break;
case Template:
expLeaf = mapReplace.map(
column,
columnOfCombo,
cType,
comboLeafReplaceType,
firstArg == null ? null : firstArg
@ -1149,7 +1153,7 @@ public class ReplaceWidget extends SimpleContainer {
break;
default:
expLeaf = mapReplace.map(
column,
columnOfCombo,
cType,
comboLeafReplaceType,
firstArg == null ? null : firstArg
@ -1172,7 +1176,7 @@ public class ReplaceWidget extends SimpleContainer {
switch (replaceColumnByExpressionType) {
case Replace:
exp = mapReplace.map(
column,
columnOfCombo,
targetType,
comboOperationsReplaceType,
firstArg == null ? null : firstArg
@ -1186,7 +1190,7 @@ public class ReplaceWidget extends SimpleContainer {
break;
case Template:
exp = mapReplace.map(
column,
columnOfCombo,
targetType,
comboOperationsReplaceType,
firstArg == null ? null : firstArg
@ -1200,7 +1204,7 @@ public class ReplaceWidget extends SimpleContainer {
break;
default:
exp = mapReplace.map(
column,
columnOfCombo,
targetType,
comboOperationsReplaceType,
firstArg == null ? null : firstArg
@ -1226,7 +1230,7 @@ public class ReplaceWidget extends SimpleContainer {
switch (replaceColumnByExpressionType) {
case Replace:
exp = mapReplace.map(
column,
columnOfCombo,
targetType,
comboOperationsReplaceType,
firstArg == null ? null : firstArg
@ -1236,7 +1240,7 @@ public class ReplaceWidget extends SimpleContainer {
break;
case Template:
exp = mapReplace.map(
column,
columnOfCombo,
targetType,
comboOperationsReplaceType,
firstArg == null ? null : firstArg
@ -1246,7 +1250,7 @@ public class ReplaceWidget extends SimpleContainer {
break;
default:
exp = mapReplace.map(
column,
columnOfCombo,
targetType,
comboOperationsReplaceType,
firstArg == null ? null : firstArg