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:
parent
da2dc8beeb
commit
3f62196aba
|
@ -178,7 +178,7 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
|
|
||||||
public void onSelect(SelectEvent event) {
|
public void onSelect(SelectEvent event) {
|
||||||
Log.debug("Pressed Apply");
|
Log.debug("Pressed Apply");
|
||||||
applyRule();
|
applySeleceted();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -305,7 +305,7 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
|
|
||||||
public void onSelect(SelectEvent event) {
|
public void onSelect(SelectEvent event) {
|
||||||
Log.debug("Pressed Apply");
|
Log.debug("Pressed Apply");
|
||||||
applyRule();
|
applySeleceted();
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -391,10 +391,11 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
if (event.getSelectedItem() != null) {
|
if (event.getSelectedItem() != null) {
|
||||||
ColumnData col = event.getSelectedItem();
|
ColumnData col = event.getSelectedItem();
|
||||||
Log.debug("Col selected:" + col.toString());
|
Log.debug("Col selected:" + col.toString());
|
||||||
|
column=col;
|
||||||
btnApply.enable();
|
btnApply.enable();
|
||||||
conditionWidget.update(col);
|
conditionWidget.update(col);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
column=null;
|
||||||
btnApply.disable();
|
btnApply.disable();
|
||||||
conditionWidget.update(null);
|
conditionWidget.update(null);
|
||||||
}
|
}
|
||||||
|
@ -453,7 +454,7 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
|
|
||||||
public void onSelect(SelectEvent event) {
|
public void onSelect(SelectEvent event) {
|
||||||
Log.debug("Pressed Add Filter");
|
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;
|
C_Expression exp;
|
||||||
try {
|
try {
|
||||||
exp = conditionWidget.getExpression();
|
exp = conditionWidget.getExpression();
|
||||||
|
@ -499,7 +502,7 @@ public class ColumnExpressionPanel extends FramedPanel {
|
||||||
eventBus.fireEvent(expressionEvent);
|
eventBus.fireEvent(expressionEvent);
|
||||||
break;
|
break;
|
||||||
case ColumnFilter:
|
case ColumnFilter:
|
||||||
parentFilterDialog.applyFilter(exp);
|
parentFilterDialog.applyFilter(column,exp);
|
||||||
break;
|
break;
|
||||||
case MultiColumnFilter:
|
case MultiColumnFilter:
|
||||||
parentMultiColumnFilterTabPanel.applyFilter(column, exp);
|
parentMultiColumnFilterTabPanel.applyFilter(column, exp);
|
||||||
|
|
|
@ -92,8 +92,6 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
|
||||||
eventBus);
|
eventBus);
|
||||||
add(columnExpressionPanel);
|
add(columnExpressionPanel);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -108,8 +106,9 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
|
||||||
this.exp = exp;
|
this.exp = exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void applyFilter(C_Expression exp) {
|
protected void applyFilter(ColumnData column,C_Expression exp) {
|
||||||
this.exp = exp;
|
this.exp = exp;
|
||||||
|
this.column= column;
|
||||||
callApplyFilter();
|
callApplyFilter();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -139,6 +138,15 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
|
||||||
public void onSuccess(ArrayList<ColumnData> result) {
|
public void onSuccess(ArrayList<ColumnData> result) {
|
||||||
Log.debug("Retrived column: " + result);
|
Log.debug("Retrived column: " + result);
|
||||||
columns = result;
|
columns = result;
|
||||||
|
sanitizesColumns();
|
||||||
|
create();
|
||||||
|
}
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void sanitizesColumns() {
|
||||||
removableColumn=new ArrayList<ColumnData>();
|
removableColumn=new ArrayList<ColumnData>();
|
||||||
for(ColumnData c:columns){
|
for(ColumnData c:columns){
|
||||||
if(c.getTypeCode().compareTo(ColumnTypeCode.DIMENSION.toString())==0||
|
if(c.getTypeCode().compareTo(ColumnTypeCode.DIMENSION.toString())==0||
|
||||||
|
@ -151,12 +159,8 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
columns.removeAll(removableColumn);
|
columns.removeAll(removableColumn);
|
||||||
create();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void callApplyFilter() {
|
protected void callApplyFilter() {
|
||||||
filterColumnSession = new FilterColumnSession(column, exp);
|
filterColumnSession = new FilterColumnSession(column, exp);
|
||||||
|
@ -252,4 +256,6 @@ public class ColumnFilterDialog extends Window implements MonitorDialogListener
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,6 +72,8 @@ public class ConditionWidget extends SimpleContainer {
|
||||||
protected ColumnData column;
|
protected ColumnData column;
|
||||||
|
|
||||||
protected String readableExpression;
|
protected String readableExpression;
|
||||||
|
private Radio radioAll;
|
||||||
|
private Radio radioAny;
|
||||||
|
|
||||||
public ConditionWidget(ColumnData column) {
|
public ConditionWidget(ColumnData column) {
|
||||||
super();
|
super();
|
||||||
|
@ -84,11 +86,12 @@ public class ConditionWidget extends SimpleContainer {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(ColumnData newColumn){
|
public void update(ColumnData newColumn){
|
||||||
int count=vert.getWidgetCount();
|
vert.clear();
|
||||||
for(int i=0; i<count;i++){
|
|
||||||
vert.remove(i);
|
|
||||||
}
|
|
||||||
this.column=newColumn;
|
this.column=newColumn;
|
||||||
|
radioAll.setValue(true);
|
||||||
|
radioAny.setValue(false);
|
||||||
|
groupMatch.setValue(radioAll);
|
||||||
|
matchLabel.setVisible(false);
|
||||||
setup();
|
setup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,12 +122,12 @@ public class ConditionWidget extends SimpleContainer {
|
||||||
|
|
||||||
VerticalLayoutContainer baseLayout = new VerticalLayoutContainer();
|
VerticalLayoutContainer baseLayout = new VerticalLayoutContainer();
|
||||||
|
|
||||||
Radio radioAll = new Radio();
|
radioAll = new Radio();
|
||||||
radioAll.setName("All");
|
radioAll.setName("All");
|
||||||
radioAll.setBoxLabel("All conditions");
|
radioAll.setBoxLabel("All conditions");
|
||||||
radioAll.setValue(true);
|
radioAll.setValue(true);
|
||||||
|
|
||||||
Radio radioAny = new Radio();
|
radioAny = new Radio();
|
||||||
radioAny.setName("Any");
|
radioAny.setName("Any");
|
||||||
radioAny.setBoxLabel("Any condition");
|
radioAny.setBoxLabel("Any condition");
|
||||||
|
|
||||||
|
|
|
@ -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.OperationResult;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
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.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 org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
import com.allen_sauer.gwt.log.client.Log;
|
||||||
import com.google.gwt.user.client.rpc.AsyncCallback;
|
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.google.web.bindery.event.shared.EventBus;
|
||||||
import com.sencha.gxt.widget.core.client.Window;
|
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;
|
||||||
|
@ -43,17 +41,17 @@ public class ReplaceColumnByExpressionDialog extends Window implements
|
||||||
MonitorDialogListener {
|
MonitorDialogListener {
|
||||||
private static final String WIDTH = "880px";
|
private static final String WIDTH = "880px";
|
||||||
private static final String HEIGHT = "490px";
|
private static final String HEIGHT = "490px";
|
||||||
private static final String HEIGHT_REDUCE = "404px";
|
//private static final String HEIGHT_REDUCE = "404px";
|
||||||
|
|
||||||
private ReplaceColumnByExpressionPanel replaceColumnByExpressionPanel;
|
private ReplaceColumnByExpressionPanel replaceColumnByExpressionPanel;
|
||||||
private C_Expression cConditionExpression=null;
|
private C_Expression cConditionExpression = null;
|
||||||
private ColumnData column = null;
|
private ColumnData column = null;
|
||||||
private ArrayList<ColumnData> columns;
|
private ArrayList<ColumnData> columns;
|
||||||
|
|
||||||
//private String columnName = null;
|
|
||||||
private EventBus eventBus;
|
private EventBus eventBus;
|
||||||
private ReplaceColumnByExpressionType replaceColumnByExpressionType;
|
private ReplaceColumnByExpressionType replaceColumnByExpressionType;
|
||||||
|
private String columnLocalId;
|
||||||
|
private TRId trId;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -81,12 +79,14 @@ public class ReplaceColumnByExpressionDialog extends Window implements
|
||||||
* @param columnName
|
* @param columnName
|
||||||
* @param eventBus
|
* @param eventBus
|
||||||
*/
|
*/
|
||||||
public ReplaceColumnByExpressionDialog(TRId trId, String columnName,
|
public ReplaceColumnByExpressionDialog(TRId trId, String columnLocalId,
|
||||||
EventBus eventBus) {
|
EventBus eventBus) {
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
|
this.columnLocalId = columnLocalId;
|
||||||
|
this.trId = trId;
|
||||||
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Replace;
|
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Replace;
|
||||||
initWindow();
|
initWindow();
|
||||||
load(trId, columnName);
|
load();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -118,67 +118,13 @@ public class ReplaceColumnByExpressionDialog extends Window implements
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
protected void create() {
|
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(
|
replaceColumnByExpressionPanel = new ReplaceColumnByExpressionPanel(
|
||||||
this, column, eventBus);
|
this, column, columns, eventBus, replaceColumnByExpressionType);
|
||||||
break;
|
|
||||||
case Template:
|
|
||||||
replaceColumnByExpressionPanel = new ReplaceColumnByExpressionPanel(
|
|
||||||
this, column, columns, eventBus);
|
|
||||||
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
add(replaceColumnByExpressionPanel);
|
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() {
|
public C_Expression getExpression() {
|
||||||
return cConditionExpression;
|
return cConditionExpression;
|
||||||
|
@ -189,19 +135,19 @@ public class ReplaceColumnByExpressionDialog extends Window implements
|
||||||
this.cConditionExpression = exp;
|
this.cConditionExpression = exp;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void applyReplaceColumnByExpression(
|
protected void applyReplaceColumnByExpression(ColumnData column,boolean allRows,
|
||||||
boolean allRows,C_Expression cConditionExpression, String replaceValue) {
|
C_Expression cConditionExpression, String replaceValue) {
|
||||||
|
this.column=column;
|
||||||
this.cConditionExpression = cConditionExpression;
|
this.cConditionExpression = cConditionExpression;
|
||||||
|
|
||||||
|
|
||||||
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(
|
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(
|
||||||
column, allRows,cConditionExpression, replaceValue);
|
column, allRows, cConditionExpression, replaceValue);
|
||||||
callApplyReplaceByExpression(replaceColumnByExpressionSession);
|
callApplyReplaceByExpression(replaceColumnByExpressionSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void applyReplaceColumnByExpression(boolean allRows,
|
protected void applyReplaceColumnByExpression(ColumnData column, boolean allRows,
|
||||||
C_Expression cConditionExpression, C_Expression cReplaceExpression) {
|
C_Expression cConditionExpression, C_Expression cReplaceExpression) {
|
||||||
|
this.column=column;
|
||||||
this.cConditionExpression = cConditionExpression;
|
this.cConditionExpression = cConditionExpression;
|
||||||
|
|
||||||
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(
|
ReplaceColumnByExpressionSession replaceColumnByExpressionSession = new ReplaceColumnByExpressionSession(
|
||||||
|
@ -209,9 +155,9 @@ public class ReplaceColumnByExpressionDialog extends Window implements
|
||||||
callApplyReplaceByExpression(replaceColumnByExpressionSession);
|
callApplyReplaceByExpression(replaceColumnByExpressionSession);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void load(TRId trId, String columnName) {
|
protected void load() {
|
||||||
TDGWTServiceAsync.INSTANCE.getColumn(trId, columnName,
|
TDGWTServiceAsync.INSTANCE.getColumns(trId,
|
||||||
new AsyncCallback<ColumnData>() {
|
new AsyncCallback<ArrayList<ColumnData>>() {
|
||||||
|
|
||||||
public void onFailure(Throwable caught) {
|
public void onFailure(Throwable caught) {
|
||||||
if (caught instanceof TDGWTSessionExpiredException) {
|
if (caught instanceof TDGWTSessionExpiredException) {
|
||||||
|
@ -231,9 +177,10 @@ public class ReplaceColumnByExpressionDialog extends Window implements
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSuccess(ColumnData result) {
|
public void onSuccess(ArrayList<ColumnData> result) {
|
||||||
Log.debug("Retrived column: " + result);
|
Log.debug("Retrived columns: " + result);
|
||||||
column = result;
|
columns = result;
|
||||||
|
sanitizesColumns();
|
||||||
create();
|
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(
|
protected void callApplyReplaceByExpression(
|
||||||
ReplaceColumnByExpressionSession replaceColumnByExpressionSession) {
|
ReplaceColumnByExpressionSession replaceColumnByExpressionSession) {
|
||||||
Log.debug("Replace Column By Expression Session "
|
Log.debug("Replace Column By Expression Session "
|
||||||
|
@ -303,7 +272,8 @@ public class ReplaceColumnByExpressionDialog extends Window implements
|
||||||
public void operationComplete(OperationResult operationResult) {
|
public void operationComplete(OperationResult operationResult) {
|
||||||
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
|
ChangeTableWhy why = ChangeTableWhy.TABLEUPDATED;
|
||||||
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
||||||
ChangeTableRequestType.COLUMNFILTER, operationResult.getTrId(), why);
|
ChangeTableRequestType.COLUMNFILTER, operationResult.getTrId(),
|
||||||
|
why);
|
||||||
eventBus.fireEvent(changeTableRequestEvent);
|
eventBus.fireEvent(changeTableRequestEvent);
|
||||||
close();
|
close();
|
||||||
}
|
}
|
||||||
|
@ -316,10 +286,12 @@ public class ReplaceColumnByExpressionDialog extends Window implements
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void operationStopped(OperationResult operationResult, String reason, String details) {
|
public void operationStopped(OperationResult operationResult,
|
||||||
|
String reason, String details) {
|
||||||
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
|
ChangeTableWhy why = ChangeTableWhy.TABLECURATION;
|
||||||
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
ChangeTableRequestEvent changeTableRequestEvent = new ChangeTableRequestEvent(
|
||||||
ChangeTableRequestType.COLUMNFILTER, operationResult.getTrId(), why);
|
ChangeTableRequestType.COLUMNFILTER, operationResult.getTrId(),
|
||||||
|
why);
|
||||||
eventBus.fireEvent(changeTableRequestEvent);
|
eventBus.fireEvent(changeTableRequestEvent);
|
||||||
close();
|
close();
|
||||||
|
|
||||||
|
@ -337,4 +309,6 @@ public class ReplaceColumnByExpressionDialog extends Window implements
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ package org.gcube.portlets.user.td.expressionwidget.client;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
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.resources.ExpressionResources;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceColumnByExpressionType;
|
import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceColumnByExpressionType;
|
||||||
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ConditionTypeMapException;
|
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_Expression;
|
||||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_ExpressionContainer;
|
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.ColumnDataType;
|
||||||
|
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeCode;
|
||||||
|
|
||||||
import com.allen_sauer.gwt.log.client.Log;
|
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.ValueChangeEvent;
|
||||||
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
import com.google.gwt.event.logical.shared.ValueChangeHandler;
|
||||||
import com.google.gwt.i18n.client.DateTimeFormat;
|
import com.google.gwt.i18n.client.DateTimeFormat;
|
||||||
import com.google.gwt.regexp.shared.MatchResult;
|
import com.google.gwt.regexp.shared.MatchResult;
|
||||||
import com.google.gwt.regexp.shared.RegExp;
|
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.HasHorizontalAlignment;
|
||||||
import com.google.gwt.user.client.ui.HasValue;
|
import com.google.gwt.user.client.ui.HasValue;
|
||||||
import com.google.gwt.user.client.ui.HorizontalPanel;
|
import com.google.gwt.user.client.ui.HorizontalPanel;
|
||||||
import com.google.web.bindery.event.shared.EventBus;
|
import com.google.web.bindery.event.shared.EventBus;
|
||||||
import com.sencha.gxt.cell.core.client.ButtonCell.IconAlign;
|
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.Margins;
|
||||||
import com.sencha.gxt.core.client.util.ToggleGroup;
|
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.FramedPanel;
|
||||||
import com.sencha.gxt.widget.core.client.button.TextButton;
|
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.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.container.VerticalLayoutContainer.VerticalLayoutData;
|
||||||
import com.sencha.gxt.widget.core.client.event.SelectEvent;
|
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.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.DateField;
|
||||||
import com.sencha.gxt.widget.core.client.form.FieldLabel;
|
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.FieldSet;
|
||||||
|
@ -57,10 +66,12 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
||||||
private static final String WIDTH = "868px";
|
private static final String WIDTH = "868px";
|
||||||
private static final String HEIGHT = "454px";
|
private static final String HEIGHT = "454px";
|
||||||
private static final String HEIGHT_REDUCE = "368px";
|
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 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 REPLACEWIDTH = "832px";
|
||||||
private static final String REPLACEHEIGHT = "120px";
|
private static final String REPLACEHEIGHT = "120px";
|
||||||
private static final String ALL_ROWS_FIELD_WIDTH = "832px";
|
private static final String ALL_ROWS_FIELD_WIDTH = "832px";
|
||||||
|
@ -82,6 +93,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
||||||
private TextButton btnApply;
|
private TextButton btnApply;
|
||||||
private TextButton btnClose;
|
private TextButton btnClose;
|
||||||
|
|
||||||
|
private ComboBox<ColumnData> comboCols;
|
||||||
|
|
||||||
private FieldSet conditionsFieldSet;
|
private FieldSet conditionsFieldSet;
|
||||||
private ConditionWidget conditionWidget;
|
private ConditionWidget conditionWidget;
|
||||||
|
|
||||||
|
@ -93,28 +106,84 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
||||||
private FieldLabel allRowsField;
|
private FieldLabel allRowsField;
|
||||||
private boolean allRows;
|
private boolean allRows;
|
||||||
|
|
||||||
public ReplaceColumnByExpressionPanel(
|
private FieldSet replaceValueFieldSet;
|
||||||
ReplaceColumnByExpressionDialog parent, ColumnData column,
|
|
||||||
EventBus eventBus) {
|
protected void createPArent() {
|
||||||
super();
|
if (column == null) {
|
||||||
this.parent = parent;
|
UtilsGXT3.info("Attention ", "You must select a column!");
|
||||||
this.column = column;
|
hide();
|
||||||
this.eventBus = eventBus;
|
return;
|
||||||
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Replace;
|
}
|
||||||
Log.debug("Column: " + column);
|
|
||||||
init();
|
if (column.isViewColumn()) {
|
||||||
create();
|
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(
|
public ReplaceColumnByExpressionPanel(
|
||||||
ReplaceColumnByExpressionDialog parent, ColumnData column,
|
ReplaceColumnByExpressionDialog parent, ColumnData column,
|
||||||
ArrayList<ColumnData> columns, EventBus eventBus) {
|
ArrayList<ColumnData> columns, EventBus eventBus,
|
||||||
|
ReplaceColumnByExpressionType replaceColumnByExpressionType) {
|
||||||
super();
|
super();
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.column = column;
|
this.column = column;
|
||||||
this.columns = columns;
|
this.columns = columns;
|
||||||
this.eventBus = eventBus;
|
this.eventBus = eventBus;
|
||||||
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Template;
|
this.replaceColumnByExpressionType = replaceColumnByExpressionType;
|
||||||
Log.debug("Column: " + column);
|
Log.debug("Column: " + column);
|
||||||
Log.debug("Columns: " + columns);
|
Log.debug("Columns: " + columns);
|
||||||
init();
|
init();
|
||||||
|
@ -123,6 +192,16 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
||||||
|
|
||||||
protected void init() {
|
protected void init() {
|
||||||
setWidth(WIDTH);
|
setWidth(WIDTH);
|
||||||
|
calcHeight();
|
||||||
|
|
||||||
|
setBodyBorder(false);
|
||||||
|
setHeaderVisible(false);
|
||||||
|
// Important: fixed rendering of widgets
|
||||||
|
forceLayoutOnResize = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void calcHeight() {
|
||||||
if (column != null
|
if (column != null
|
||||||
&& (column.getDataTypeName().compareTo(
|
&& (column.getDataTypeName().compareTo(
|
||||||
ColumnDataType.Text.toString()) == 0
|
ColumnDataType.Text.toString()) == 0
|
||||||
|
@ -132,15 +211,13 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
||||||
ColumnDataType.Numeric.toString()) == 0 || column
|
ColumnDataType.Numeric.toString()) == 0 || column
|
||||||
.getDataTypeName().compareTo(
|
.getDataTypeName().compareTo(
|
||||||
ColumnDataType.Geometry.toString()) == 0)) {
|
ColumnDataType.Geometry.toString()) == 0)) {
|
||||||
|
parent.setHeight(PARENT_HEIGHT);
|
||||||
setHeight(HEIGHT);
|
setHeight(HEIGHT);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
parent.setHeight(PARENT_HEIGHT_REDUCE);
|
||||||
setHeight(HEIGHT_REDUCE);
|
setHeight(HEIGHT_REDUCE);
|
||||||
}
|
}
|
||||||
setBodyBorder(false);
|
|
||||||
setHeaderVisible(false);
|
|
||||||
// Important: fixed rendering of widgets
|
|
||||||
forceLayoutOnResize = true;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void create() {
|
protected void create() {
|
||||||
|
@ -160,11 +237,29 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
||||||
VerticalLayoutContainer propertiesLayout = new VerticalLayoutContainer();
|
VerticalLayoutContainer propertiesLayout = new VerticalLayoutContainer();
|
||||||
properties.add(propertiesLayout);
|
properties.add(propertiesLayout);
|
||||||
|
|
||||||
TextField columnName = new TextField();
|
// Combo Column
|
||||||
columnName.setToolTip("Column");
|
ColumnDataPropertiesCombo propsCols = GWT
|
||||||
columnName.setReadOnly(true);
|
.create(ColumnDataPropertiesCombo.class);
|
||||||
columnName.setValue(column.getLabel());
|
Log.debug("Props: " + propsCols);
|
||||||
propertiesLayout.add(new FieldLabel(columnName, "Column"),
|
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));
|
new VerticalLayoutData(1, -1));
|
||||||
|
|
||||||
// Conditions
|
// Conditions
|
||||||
|
@ -221,57 +316,11 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
||||||
conditionsFieldSet.add(conditionsVerticalLayout);
|
conditionsFieldSet.add(conditionsVerticalLayout);
|
||||||
|
|
||||||
// Value
|
// Value
|
||||||
FieldSet replaceValueFieldSet = new FieldSet();
|
replaceValueFieldSet = new FieldSet();
|
||||||
replaceValueFieldSet.setHeadingText("Replace Value");
|
replaceValueFieldSet.setHeadingText("Replace Value");
|
||||||
replaceValueFieldSet.setCollapsible(false);
|
replaceValueFieldSet.setCollapsible(false);
|
||||||
|
|
||||||
VerticalLayoutContainer replaceValueFieldSetLayout = new VerticalLayoutContainer();
|
calcReplaceValue();
|
||||||
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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
btnApply = new TextButton("Apply");
|
btnApply = new TextButton("Apply");
|
||||||
|
@ -287,6 +336,11 @@ public class ReplaceColumnByExpressionPanel 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());
|
||||||
|
@ -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) {
|
protected void callAllRowChange(ValueChangeEvent<HasValue<Boolean>> event) {
|
||||||
ToggleGroup group = (ToggleGroup) event.getSource();
|
ToggleGroup group = (ToggleGroup) event.getSource();
|
||||||
Radio radio = (Radio) group.getValue();
|
Radio radio = (Radio) group.getValue();
|
||||||
|
@ -402,6 +585,12 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
||||||
|
|
||||||
protected void callApplyReplaceColumnByExpression(
|
protected void callApplyReplaceColumnByExpression(
|
||||||
C_Expression cConditionExpression, String replaceValue) {
|
C_Expression cConditionExpression, String replaceValue) {
|
||||||
|
if(column==null){
|
||||||
|
UtilsGXT3.alert("Attention", "Select a valid column!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
switch (replaceColumnByExpressionType) {
|
switch (replaceColumnByExpressionType) {
|
||||||
case Template:
|
case Template:
|
||||||
ExpressionEvent expressionEvent = new ExpressionEvent(
|
ExpressionEvent expressionEvent = new ExpressionEvent(
|
||||||
|
@ -409,9 +598,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
||||||
C_ExpressionContainer container;
|
C_ExpressionContainer container;
|
||||||
if (allRows) {
|
if (allRows) {
|
||||||
container = new C_ExpressionContainer(
|
container = new C_ExpressionContainer(
|
||||||
C_ExpressionContainer.Contains.C_Expression,
|
C_ExpressionContainer.Contains.C_Expression, true,
|
||||||
true,null,
|
null, "AllRows()");
|
||||||
"AllRows()");
|
|
||||||
} else {
|
} else {
|
||||||
container = new C_ExpressionContainer(
|
container = new C_ExpressionContainer(
|
||||||
C_ExpressionContainer.Contains.C_Expression,
|
C_ExpressionContainer.Contains.C_Expression,
|
||||||
|
@ -429,8 +617,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
||||||
eventBus.fireEvent(expressionEvent);
|
eventBus.fireEvent(expressionEvent);
|
||||||
break;
|
break;
|
||||||
case Replace:
|
case Replace:
|
||||||
parent.applyReplaceColumnByExpression(allRows,cConditionExpression,
|
parent.applyReplaceColumnByExpression(column,allRows,
|
||||||
replaceValue);
|
cConditionExpression, replaceValue);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -440,6 +628,11 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
||||||
|
|
||||||
protected void callApplyReplaceColumnByExpression(
|
protected void callApplyReplaceColumnByExpression(
|
||||||
C_Expression cConditionExpression, C_Expression cReplaceExpression) {
|
C_Expression cConditionExpression, C_Expression cReplaceExpression) {
|
||||||
|
if(column==null){
|
||||||
|
UtilsGXT3.alert("Attention", "Select a valid column!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (replaceColumnByExpressionType) {
|
switch (replaceColumnByExpressionType) {
|
||||||
case Template:
|
case Template:
|
||||||
ExpressionEvent expressionEvent = new ExpressionEvent(
|
ExpressionEvent expressionEvent = new ExpressionEvent(
|
||||||
|
@ -447,9 +640,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
||||||
C_ExpressionContainer conditionExpressionContainer;
|
C_ExpressionContainer conditionExpressionContainer;
|
||||||
if (allRows) {
|
if (allRows) {
|
||||||
conditionExpressionContainer = new C_ExpressionContainer(
|
conditionExpressionContainer = new C_ExpressionContainer(
|
||||||
C_ExpressionContainer.Contains.C_Expression,
|
C_ExpressionContainer.Contains.C_Expression, true,
|
||||||
true,null,
|
null, "AllRows()");
|
||||||
"AllRows()");
|
|
||||||
} else {
|
} else {
|
||||||
conditionExpressionContainer = new C_ExpressionContainer(
|
conditionExpressionContainer = new C_ExpressionContainer(
|
||||||
C_ExpressionContainer.Contains.C_Expression,
|
C_ExpressionContainer.Contains.C_Expression,
|
||||||
|
@ -473,8 +665,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
||||||
eventBus.fireEvent(expressionEvent);
|
eventBus.fireEvent(expressionEvent);
|
||||||
break;
|
break;
|
||||||
case Replace:
|
case Replace:
|
||||||
parent.applyReplaceColumnByExpression(allRows,cConditionExpression,
|
parent.applyReplaceColumnByExpression(column, allRows,
|
||||||
cReplaceExpression);
|
cConditionExpression, cReplaceExpression);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -986,11 +986,11 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
ComboBox<ColumnData> comboColumns = (ComboBox<ColumnData>) horiz
|
ComboBox<ColumnData> comboColumns = (ComboBox<ColumnData>) horiz
|
||||||
.getItemByItemId(itemIdComboColumns);
|
.getItemByItemId(itemIdComboColumns);
|
||||||
Log.debug("combo columns: " + comboColumns.getCurrentValue());
|
Log.debug("combo columns: " + comboColumns.getCurrentValue());
|
||||||
ColumnData column = comboColumns.getCurrentValue();
|
ColumnData columnOfCombo = comboColumns.getCurrentValue();
|
||||||
|
|
||||||
firstArg = (TextField) horiz.getItemByItemId(itemIdFirstArg);
|
firstArg = (TextField) horiz.getItemByItemId(itemIdFirstArg);
|
||||||
secondArg = (TextField) horiz.getItemByItemId(itemIdSecondArg);
|
secondArg = (TextField) horiz.getItemByItemId(itemIdSecondArg);
|
||||||
Log.debug("[column: " + column + ", firstArg: "
|
Log.debug("[combo column: " + columnOfCombo + ", firstArg: "
|
||||||
+ firstArg.getCurrentValue() + ", secondArg: "
|
+ firstArg.getCurrentValue() + ", secondArg: "
|
||||||
+ secondArg.getCurrentValue() + "]");
|
+ secondArg.getCurrentValue() + "]");
|
||||||
|
|
||||||
|
@ -1015,7 +1015,7 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
switch (replaceColumnByExpressionType) {
|
switch (replaceColumnByExpressionType) {
|
||||||
case Replace:
|
case Replace:
|
||||||
expLeaf = mapReplace.map(
|
expLeaf = mapReplace.map(
|
||||||
column,
|
columnOfCombo,
|
||||||
ColumnDataType.Text,
|
ColumnDataType.Text,
|
||||||
comboLeafReplaceType,
|
comboLeafReplaceType,
|
||||||
firstArg == null ? null : firstArg
|
firstArg == null ? null : firstArg
|
||||||
|
@ -1025,7 +1025,7 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
break;
|
break;
|
||||||
case Template:
|
case Template:
|
||||||
expLeaf = mapReplace.map(
|
expLeaf = mapReplace.map(
|
||||||
column,
|
columnOfCombo,
|
||||||
ColumnDataType.Text,
|
ColumnDataType.Text,
|
||||||
comboLeafReplaceType,
|
comboLeafReplaceType,
|
||||||
firstArg == null ? null : firstArg
|
firstArg == null ? null : firstArg
|
||||||
|
@ -1035,7 +1035,7 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
expLeaf = mapReplace.map(
|
expLeaf = mapReplace.map(
|
||||||
column,
|
columnOfCombo,
|
||||||
ColumnDataType.Text,
|
ColumnDataType.Text,
|
||||||
comboLeafReplaceType,
|
comboLeafReplaceType,
|
||||||
firstArg == null ? null : firstArg
|
firstArg == null ? null : firstArg
|
||||||
|
@ -1059,7 +1059,7 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
switch (replaceColumnByExpressionType) {
|
switch (replaceColumnByExpressionType) {
|
||||||
case Replace:
|
case Replace:
|
||||||
exp = mapReplace.map(
|
exp = mapReplace.map(
|
||||||
column,
|
columnOfCombo,
|
||||||
targetType,
|
targetType,
|
||||||
comboOperationsReplaceType,
|
comboOperationsReplaceType,
|
||||||
firstArg == null ? null : firstArg
|
firstArg == null ? null : firstArg
|
||||||
|
@ -1072,7 +1072,7 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
break;
|
break;
|
||||||
case Template:
|
case Template:
|
||||||
exp = mapReplace.map(
|
exp = mapReplace.map(
|
||||||
column,
|
columnOfCombo,
|
||||||
targetType,
|
targetType,
|
||||||
comboOperationsReplaceType,
|
comboOperationsReplaceType,
|
||||||
firstArg == null ? null : firstArg
|
firstArg == null ? null : firstArg
|
||||||
|
@ -1085,7 +1085,7 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
exp = mapReplace.map(
|
exp = mapReplace.map(
|
||||||
column,
|
columnOfCombo,
|
||||||
targetType,
|
targetType,
|
||||||
comboOperationsReplaceType,
|
comboOperationsReplaceType,
|
||||||
firstArg == null ? null : firstArg
|
firstArg == null ? null : firstArg
|
||||||
|
@ -1123,13 +1123,17 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
|
|
||||||
comboLeafReplaceType = comboLeaf.getCurrentValue()
|
comboLeafReplaceType = comboLeaf.getCurrentValue()
|
||||||
.getReplaceType();
|
.getReplaceType();
|
||||||
cType = ColumnDataType.getColumnDataTypeFromId(column
|
|
||||||
|
if(columnOfCombo==null){
|
||||||
|
throw new ReplaceTypeMapException("Selected a valid column!");
|
||||||
|
}
|
||||||
|
cType = ColumnDataType.getColumnDataTypeFromId(columnOfCombo
|
||||||
.getDataTypeName());
|
.getDataTypeName());
|
||||||
|
|
||||||
switch (replaceColumnByExpressionType) {
|
switch (replaceColumnByExpressionType) {
|
||||||
case Replace:
|
case Replace:
|
||||||
expLeaf = mapReplace.map(
|
expLeaf = mapReplace.map(
|
||||||
column,
|
columnOfCombo,
|
||||||
cType,
|
cType,
|
||||||
comboLeafReplaceType,
|
comboLeafReplaceType,
|
||||||
firstArg == null ? null : firstArg
|
firstArg == null ? null : firstArg
|
||||||
|
@ -1139,7 +1143,7 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
break;
|
break;
|
||||||
case Template:
|
case Template:
|
||||||
expLeaf = mapReplace.map(
|
expLeaf = mapReplace.map(
|
||||||
column,
|
columnOfCombo,
|
||||||
cType,
|
cType,
|
||||||
comboLeafReplaceType,
|
comboLeafReplaceType,
|
||||||
firstArg == null ? null : firstArg
|
firstArg == null ? null : firstArg
|
||||||
|
@ -1149,7 +1153,7 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
expLeaf = mapReplace.map(
|
expLeaf = mapReplace.map(
|
||||||
column,
|
columnOfCombo,
|
||||||
cType,
|
cType,
|
||||||
comboLeafReplaceType,
|
comboLeafReplaceType,
|
||||||
firstArg == null ? null : firstArg
|
firstArg == null ? null : firstArg
|
||||||
|
@ -1172,7 +1176,7 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
switch (replaceColumnByExpressionType) {
|
switch (replaceColumnByExpressionType) {
|
||||||
case Replace:
|
case Replace:
|
||||||
exp = mapReplace.map(
|
exp = mapReplace.map(
|
||||||
column,
|
columnOfCombo,
|
||||||
targetType,
|
targetType,
|
||||||
comboOperationsReplaceType,
|
comboOperationsReplaceType,
|
||||||
firstArg == null ? null : firstArg
|
firstArg == null ? null : firstArg
|
||||||
|
@ -1186,7 +1190,7 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
break;
|
break;
|
||||||
case Template:
|
case Template:
|
||||||
exp = mapReplace.map(
|
exp = mapReplace.map(
|
||||||
column,
|
columnOfCombo,
|
||||||
targetType,
|
targetType,
|
||||||
comboOperationsReplaceType,
|
comboOperationsReplaceType,
|
||||||
firstArg == null ? null : firstArg
|
firstArg == null ? null : firstArg
|
||||||
|
@ -1200,7 +1204,7 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
exp = mapReplace.map(
|
exp = mapReplace.map(
|
||||||
column,
|
columnOfCombo,
|
||||||
targetType,
|
targetType,
|
||||||
comboOperationsReplaceType,
|
comboOperationsReplaceType,
|
||||||
firstArg == null ? null : firstArg
|
firstArg == null ? null : firstArg
|
||||||
|
@ -1226,7 +1230,7 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
switch (replaceColumnByExpressionType) {
|
switch (replaceColumnByExpressionType) {
|
||||||
case Replace:
|
case Replace:
|
||||||
exp = mapReplace.map(
|
exp = mapReplace.map(
|
||||||
column,
|
columnOfCombo,
|
||||||
targetType,
|
targetType,
|
||||||
comboOperationsReplaceType,
|
comboOperationsReplaceType,
|
||||||
firstArg == null ? null : firstArg
|
firstArg == null ? null : firstArg
|
||||||
|
@ -1236,7 +1240,7 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
break;
|
break;
|
||||||
case Template:
|
case Template:
|
||||||
exp = mapReplace.map(
|
exp = mapReplace.map(
|
||||||
column,
|
columnOfCombo,
|
||||||
targetType,
|
targetType,
|
||||||
comboOperationsReplaceType,
|
comboOperationsReplaceType,
|
||||||
firstArg == null ? null : firstArg
|
firstArg == null ? null : firstArg
|
||||||
|
@ -1246,7 +1250,7 @@ public class ReplaceWidget extends SimpleContainer {
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
exp = mapReplace.map(
|
exp = mapReplace.map(
|
||||||
column,
|
columnOfCombo,
|
||||||
targetType,
|
targetType,
|
||||||
comboOperationsReplaceType,
|
comboOperationsReplaceType,
|
||||||
firstArg == null ? null : firstArg
|
firstArg == null ? null : firstArg
|
||||||
|
|
Loading…
Reference in New Issue