Updated Replace on Arithmetic value
git-svn-id: https://svn.d4science.research-infrastructures.eu/gcube/trunk/portlets/user/tabular-data-expression-widget@111729 82a268e6-3cf1-43bd-a215-b396298e98cf
This commit is contained in:
parent
21e6656ffe
commit
889ec53bd1
|
@ -6,14 +6,11 @@ import org.gcube.portlets.user.td.expressionwidget.client.properties.ColumnDataP
|
|||
import org.gcube.portlets.user.td.expressionwidget.client.properties.ReplaceArithmeticElement;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.properties.ReplaceArithmeticElementProperties;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.properties.ReplaceArithmeticElementStore;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.properties.ReplaceElement;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.properties.ReplaceElementProperties;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.properties.ReplaceElementStore;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceColumnByExpressionType;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.utils.UtilsGXT3;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.exception.ReplaceTypeMapException;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.replace.ReplaceType;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.replace.ReplaceTypeMap;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.replace.ReplaceArithmeticType;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.replace.ReplaceArithmeticTypeMap;
|
||||
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;
|
||||
|
@ -23,6 +20,8 @@ import org.gcube.portlets.user.td.widgetcommonevent.client.event.SessionExpiredE
|
|||
import org.gcube.portlets.user.td.widgetcommonevent.client.type.SessionExpiredType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.TRId;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.expression.C_Expression;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnDataType;
|
||||
import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeMap;
|
||||
|
||||
import com.allen_sauer.gwt.log.client.Log;
|
||||
import com.google.gwt.core.client.GWT;
|
||||
|
@ -68,13 +67,10 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
|
||||
private EventBus eventBus;
|
||||
private TRId trId;
|
||||
private ColumnDataType targetColumnDataType;
|
||||
private ArrayList<ColumnData> columns;
|
||||
|
||||
// private FieldLabel matchLabel;
|
||||
// private ToggleGroup groupMatch;
|
||||
|
||||
private VerticalLayoutContainer vert;
|
||||
// protected ColumnData column;
|
||||
|
||||
private String readableExpression;
|
||||
private String itemIdComboArithmetic;
|
||||
|
@ -117,39 +113,50 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
public ReplaceArithmeticWidget(ColumnData column, EventBus eventBus) {
|
||||
super();
|
||||
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Replace;
|
||||
create(column.getTrId(), WIDTH, HEIGHT, eventBus);
|
||||
ColumnDataType targetColumnDataType = ColumnTypeMap
|
||||
.getColumnDataType(column.getDataTypeName());
|
||||
create(column.getTrId(), WIDTH, HEIGHT, eventBus, targetColumnDataType);
|
||||
retrieveColumns();
|
||||
}
|
||||
|
||||
public ReplaceArithmeticWidget(ColumnData column, String width, String height,
|
||||
EventBus eventBus) {
|
||||
public ReplaceArithmeticWidget(ColumnData column, String width,
|
||||
String height, EventBus eventBus) {
|
||||
super();
|
||||
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Replace;
|
||||
create(column.getTrId(), width, height, eventBus);
|
||||
ColumnDataType targetColumnDataType = ColumnTypeMap
|
||||
.getColumnDataType(column.getDataTypeName());
|
||||
|
||||
create(column.getTrId(), width, height, eventBus, targetColumnDataType);
|
||||
retrieveColumns();
|
||||
}
|
||||
|
||||
public ReplaceArithmeticWidget(ColumnData column, ArrayList<ColumnData> columns,
|
||||
EventBus eventBus) {
|
||||
public ReplaceArithmeticWidget(ColumnData column,
|
||||
ArrayList<ColumnData> columns, EventBus eventBus) {
|
||||
super();
|
||||
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Template;
|
||||
this.columns = columns;
|
||||
create(column.getTrId(), WIDTH, HEIGHT, eventBus);
|
||||
ColumnDataType targetColumnDataType = ColumnTypeMap
|
||||
.getColumnDataType(column.getDataTypeName());
|
||||
create(column.getTrId(), WIDTH, HEIGHT, eventBus, targetColumnDataType);
|
||||
setup();
|
||||
}
|
||||
|
||||
public ReplaceArithmeticWidget(ColumnData column, ArrayList<ColumnData> columns,
|
||||
String width, String height, EventBus eventBus) {
|
||||
public ReplaceArithmeticWidget(ColumnData column,
|
||||
ArrayList<ColumnData> columns, String width, String height,
|
||||
EventBus eventBus) {
|
||||
super();
|
||||
replaceColumnByExpressionType = ReplaceColumnByExpressionType.Template;
|
||||
this.columns = columns;
|
||||
create(column.getTrId(), width, height, eventBus);
|
||||
ColumnDataType targetColumnDataType = ColumnTypeMap
|
||||
.getColumnDataType(column.getDataTypeName());
|
||||
create(column.getTrId(), width, height, eventBus, targetColumnDataType);
|
||||
setup();
|
||||
}
|
||||
|
||||
protected void create(TRId trId, String width, String height,
|
||||
EventBus eventBus) {
|
||||
EventBus eventBus, ColumnDataType targetColumnDataType) {
|
||||
this.trId = trId;
|
||||
this.targetColumnDataType = targetColumnDataType;
|
||||
setBorders(true);
|
||||
setWidth(width);
|
||||
setHeight(height);
|
||||
|
@ -214,7 +221,7 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
itemIdHoriz = "Horiz" + trId.getId();
|
||||
|
||||
vert = new VerticalLayoutContainer();
|
||||
//vert.setScrollMode(ScrollMode.AUTO); Set in GXT 3.0.1
|
||||
// vert.setScrollMode(ScrollMode.AUTO); Set in GXT 3.0.1
|
||||
|
||||
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
||||
|
||||
|
@ -246,31 +253,34 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
|
||||
comboColumns.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
// Replace Elemet Store
|
||||
ReplaceArithmeticElementStore factory = new ReplaceArithmeticElementStore();
|
||||
// Replace Arithmetic Elemet Store
|
||||
ReplaceArithmeticElementStore replaceArithmeticElementStore = new ReplaceArithmeticElementStore();
|
||||
|
||||
ReplaceArithmeticElementProperties props = GWT
|
||||
.create(ReplaceArithmeticElementProperties.class);
|
||||
Log.debug("Props: " + props);
|
||||
|
||||
// Combo Leaf
|
||||
ListStore<ReplaceArithmeticElement> storeReplaceElementsLeaf = new ListStore<ReplaceArithmeticElement>(
|
||||
ListStore<ReplaceArithmeticElement> storeReplaceArithmeticElementsLeaf = new ListStore<ReplaceArithmeticElement>(
|
||||
props.id());
|
||||
Log.debug("Store Leaf: " + storeReplaceElementsLeaf);
|
||||
storeReplaceElementsLeaf.addAll(factory.replaceArithmeticElements);
|
||||
Log.debug("Store Leaf: " + storeReplaceArithmeticElementsLeaf);
|
||||
storeReplaceArithmeticElementsLeaf
|
||||
.addAll(replaceArithmeticElementStore.replaceArithmeticElements);
|
||||
|
||||
Log.debug("Store created");
|
||||
final ComboBox<ReplaceArithmeticElement> comboReplaceElementsLeaf = new ComboBox<ReplaceArithmeticElement>(
|
||||
storeReplaceElementsLeaf, props.label());
|
||||
final ComboBox<ReplaceArithmeticElement> comboReplaceArithmeticElementsLeaf = new ComboBox<ReplaceArithmeticElement>(
|
||||
storeReplaceArithmeticElementsLeaf, props.label());
|
||||
|
||||
Log.debug("Combo created");
|
||||
|
||||
comboReplaceElementsLeaf
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.addSelectionHandler(new SelectionHandler<ReplaceArithmeticElement>() {
|
||||
|
||||
public void onSelection(SelectionEvent<ReplaceArithmeticElement> event) {
|
||||
public void onSelection(
|
||||
SelectionEvent<ReplaceArithmeticElement> event) {
|
||||
if (event.getSelectedItem() != null) {
|
||||
ReplaceArithmeticElement re = event.getSelectedItem();
|
||||
ReplaceArithmeticElement re = event
|
||||
.getSelectedItem();
|
||||
Log.debug("Condition selected:" + re.toString());
|
||||
switch (re.getReplaceArithmeticType()) {
|
||||
case Value:
|
||||
|
@ -289,7 +299,11 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
break;
|
||||
case Concat:
|
||||
case Addition:
|
||||
case Subtraction:
|
||||
case Modulus:
|
||||
case Multiplication:
|
||||
case Division:
|
||||
break;
|
||||
case SubstringByRegex:
|
||||
comboColumns.clear();
|
||||
|
@ -336,48 +350,53 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
|
||||
});
|
||||
|
||||
comboReplaceElementsLeaf.setEmptyText("Select...");
|
||||
comboReplaceElementsLeaf.setItemId(itemIdComboLeaf);
|
||||
comboReplaceElementsLeaf.setWidth(COMBO_WIDTH);
|
||||
comboReplaceElementsLeaf.setEditable(false);
|
||||
comboReplaceArithmeticElementsLeaf.setEmptyText("Select...");
|
||||
comboReplaceArithmeticElementsLeaf.setItemId(itemIdComboLeaf);
|
||||
comboReplaceArithmeticElementsLeaf.setWidth(COMBO_WIDTH);
|
||||
comboReplaceArithmeticElementsLeaf.setEditable(false);
|
||||
|
||||
comboReplaceElementsLeaf.setTriggerAction(TriggerAction.ALL);
|
||||
comboReplaceArithmeticElementsLeaf.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
// ComboConcat
|
||||
ListStore<ReplaceElement> storeReplaceElementsConcat = new ListStore<ReplaceElement>(
|
||||
ListStore<ReplaceArithmeticElement> storeReplaceArithmeticElementsOperators = new ListStore<ReplaceArithmeticElement>(
|
||||
props.id());
|
||||
Log.debug("Store Concat: " + storeReplaceElementsConcat);
|
||||
storeReplaceElementsConcat.addAll(factory.replaceElementsConcat);
|
||||
Log.debug("Store Operator: " + storeReplaceArithmeticElementsOperators);
|
||||
storeReplaceArithmeticElementsOperators
|
||||
.addAll(replaceArithmeticElementStore.replaceArithmeticElementsOperators);
|
||||
|
||||
Log.debug("Store created");
|
||||
final ComboBox<ReplaceElement> comboReplaceElementsConcat = new ComboBox<ReplaceElement>(
|
||||
storeReplaceElementsConcat, props.label());
|
||||
final ComboBox<ReplaceArithmeticElement> comboReplaceArithmeticElementsOperators = new ComboBox<ReplaceArithmeticElement>(
|
||||
storeReplaceArithmeticElementsOperators, props.label());
|
||||
|
||||
Log.debug("Combo created");
|
||||
|
||||
comboReplaceElementsConcat
|
||||
.addSelectionHandler(new SelectionHandler<ReplaceElement>() {
|
||||
comboReplaceArithmeticElementsOperators
|
||||
.addSelectionHandler(new SelectionHandler<ReplaceArithmeticElement>() {
|
||||
|
||||
public void onSelection(SelectionEvent<ReplaceElement> event) {
|
||||
public void onSelection(
|
||||
SelectionEvent<ReplaceArithmeticElement> event) {
|
||||
if (event.getSelectedItem() != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ComboBox<ReplaceElement> source = (ComboBox<ReplaceElement>) event
|
||||
ComboBox<ReplaceArithmeticElement> source = (ComboBox<ReplaceArithmeticElement>) event
|
||||
.getSource();
|
||||
ReplaceElement re = event.getSelectedItem();
|
||||
ReplaceArithmeticElement re = event
|
||||
.getSelectedItem();
|
||||
Log.debug("Condition selected:" + re.toString());
|
||||
switch (re.getReplaceType()) {
|
||||
switch (re.getReplaceArithmeticType()) {
|
||||
case Value:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.setVisible(false);
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(false);
|
||||
firstArg.setEmptyText(EMPTY_TEXT_INSERT_A_STRING);
|
||||
firstArg.setVisible(true);
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
removeConcat(source);
|
||||
removeOperator(source);
|
||||
break;
|
||||
case ColumnValue:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.setVisible(false);
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(true);
|
||||
firstArg.setVisible(false);
|
||||
|
@ -385,51 +404,60 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
break;
|
||||
case Concat:
|
||||
if (!existConcat(source)) {
|
||||
comboReplaceElementsLeaf.clear();
|
||||
comboReplaceElementsLeaf.setVisible(true);
|
||||
case Addition:
|
||||
case Subtraction:
|
||||
case Modulus:
|
||||
case Multiplication:
|
||||
case Division:
|
||||
if (!existOperator(source)) {
|
||||
comboReplaceArithmeticElementsLeaf.clear();
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.setVisible(true);
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(false);
|
||||
firstArg.setVisible(false);
|
||||
firstArg.setEmptyText("");
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
addConcat();
|
||||
addOperator();
|
||||
}
|
||||
break;
|
||||
case SubstringByRegex:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.setVisible(false);
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(true);
|
||||
firstArg.setVisible(true);
|
||||
firstArg.setEmptyText(EMPTY_TEXT_REGEXP);
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
removeConcat(source);
|
||||
removeOperator(source);
|
||||
break;
|
||||
case SubstringByIndex:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.setVisible(false);
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(true);
|
||||
firstArg.setVisible(true);
|
||||
firstArg.setEmptyText(EMPTY_TEXT_FROM_INDEX);
|
||||
secondArg.setVisible(true);
|
||||
secondArg.setEmptyText(EMPTY_TEXT_TO_INDEX);
|
||||
removeConcat(source);
|
||||
removeOperator(source);
|
||||
break;
|
||||
case SubstringByCharSeq:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.setVisible(false);
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(true);
|
||||
firstArg.setVisible(true);
|
||||
firstArg.setEmptyText(EMPTY_TEXT_FROM_STRING);
|
||||
secondArg.setVisible(true);
|
||||
secondArg.setEmptyText(EMPTY_TEXT_TO_STRING);
|
||||
removeConcat(source);
|
||||
removeOperator(source);
|
||||
break;
|
||||
case TextReplaceMatchingRegex:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.setVisible(false);
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(true);
|
||||
firstArg.setVisible(true);
|
||||
|
@ -437,7 +465,7 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
secondArg.setVisible(true);
|
||||
secondArg
|
||||
.setEmptyText(EMPTY_TEXT_REPLACE_REPLACING);
|
||||
removeConcat(source);
|
||||
removeOperator(source);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -450,18 +478,22 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
|
||||
});
|
||||
|
||||
comboReplaceElementsConcat.setEmptyText("Select...");
|
||||
comboReplaceElementsConcat.setItemId(itemIdComboConcat);
|
||||
comboReplaceElementsConcat.setWidth(COMBO_WIDTH);
|
||||
comboReplaceElementsConcat.setEditable(false);
|
||||
comboReplaceElementsConcat.setTriggerAction(TriggerAction.ALL);
|
||||
comboReplaceArithmeticElementsOperators.setEmptyText("Select...");
|
||||
comboReplaceArithmeticElementsOperators
|
||||
.setItemId(itemIdComboArithmetic);
|
||||
comboReplaceArithmeticElementsOperators.setWidth(COMBO_WIDTH);
|
||||
comboReplaceArithmeticElementsOperators.setEditable(false);
|
||||
comboReplaceArithmeticElementsOperators
|
||||
.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
comboReplaceElementsConcat.setValue(storeReplaceElementsConcat.get(0),
|
||||
true);
|
||||
comboReplaceArithmeticElementsOperators.setValue(
|
||||
storeReplaceArithmeticElementsOperators.get(0), true);
|
||||
|
||||
//
|
||||
horiz.add(comboReplaceElementsConcat, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(comboReplaceElementsLeaf, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(comboReplaceArithmeticElementsOperators, new BoxLayoutData(
|
||||
new Margins(0)));
|
||||
horiz.add(comboReplaceArithmeticElementsLeaf, new BoxLayoutData(
|
||||
new Margins(0)));
|
||||
horiz.add(comboColumns, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(firstArg, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(secondArg, new BoxLayoutData(new Margins(0)));
|
||||
|
@ -473,12 +505,12 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
firstArg.setVisible(true);
|
||||
secondArg.setVisible(false);
|
||||
comboColumns.setVisible(false);
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceElementsConcat.setVisible(true);
|
||||
comboReplaceArithmeticElementsLeaf.setVisible(false);
|
||||
comboReplaceArithmeticElementsOperators.setVisible(true);
|
||||
forceLayout();
|
||||
}
|
||||
|
||||
protected void addConcat() {
|
||||
protected void addOperator() {
|
||||
final HBoxLayoutContainer horiz = new HBoxLayoutContainer();
|
||||
|
||||
final TextField firstArg = new TextField();
|
||||
|
@ -508,32 +540,35 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
comboColumns.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
//
|
||||
ReplaceElementStore factory = new ReplaceElementStore();
|
||||
ReplaceArithmeticElementStore replaceArithmeticElementStore = new ReplaceArithmeticElementStore();
|
||||
|
||||
ReplaceElementProperties props = GWT
|
||||
.create(ReplaceElementProperties.class);
|
||||
ReplaceArithmeticElementProperties props = GWT
|
||||
.create(ReplaceArithmeticElementProperties.class);
|
||||
Log.debug("Props: " + props);
|
||||
|
||||
// Combo Leaf
|
||||
ListStore<ReplaceElement> storeReplaceElementsLeaf = new ListStore<ReplaceElement>(
|
||||
ListStore<ReplaceArithmeticElement> storeReplaceArithmeticElementsLeaf = new ListStore<ReplaceArithmeticElement>(
|
||||
props.id());
|
||||
Log.debug("Store Leaf: " + storeReplaceElementsLeaf);
|
||||
storeReplaceElementsLeaf.addAll(factory.replaceElements);
|
||||
Log.debug("Store Leaf: " + storeReplaceArithmeticElementsLeaf);
|
||||
storeReplaceArithmeticElementsLeaf
|
||||
.addAll(replaceArithmeticElementStore.replaceArithmeticElements);
|
||||
|
||||
Log.debug("Store created");
|
||||
final ComboBox<ReplaceElement> comboReplaceElementsLeaf = new ComboBox<ReplaceElement>(
|
||||
storeReplaceElementsLeaf, props.label());
|
||||
final ComboBox<ReplaceArithmeticElement> comboReplaceArithmeticElementsLeaf = new ComboBox<ReplaceArithmeticElement>(
|
||||
storeReplaceArithmeticElementsLeaf, props.label());
|
||||
|
||||
Log.debug("Combo created");
|
||||
|
||||
comboReplaceElementsLeaf
|
||||
.addSelectionHandler(new SelectionHandler<ReplaceElement>() {
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.addSelectionHandler(new SelectionHandler<ReplaceArithmeticElement>() {
|
||||
|
||||
public void onSelection(SelectionEvent<ReplaceElement> event) {
|
||||
public void onSelection(
|
||||
SelectionEvent<ReplaceArithmeticElement> event) {
|
||||
if (event.getSelectedItem() != null) {
|
||||
ReplaceElement re = event.getSelectedItem();
|
||||
ReplaceArithmeticElement re = event
|
||||
.getSelectedItem();
|
||||
Log.debug("Condition selected:" + re.toString());
|
||||
switch (re.getReplaceType()) {
|
||||
switch (re.getReplaceArithmeticType()) {
|
||||
case Value:
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(false);
|
||||
|
@ -550,7 +585,11 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
break;
|
||||
case Concat:
|
||||
case Addition:
|
||||
case Subtraction:
|
||||
case Modulus:
|
||||
case Multiplication:
|
||||
case Division:
|
||||
break;
|
||||
case SubstringByRegex:
|
||||
comboColumns.clear();
|
||||
|
@ -596,49 +635,54 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
|
||||
});
|
||||
|
||||
comboReplaceElementsLeaf.setEmptyText("Select...");
|
||||
comboReplaceElementsLeaf.setItemId(itemIdComboLeaf);
|
||||
comboReplaceElementsLeaf.setWidth(COMBO_WIDTH);
|
||||
comboReplaceElementsLeaf.setEditable(false);
|
||||
comboReplaceArithmeticElementsLeaf.setEmptyText("Select...");
|
||||
comboReplaceArithmeticElementsLeaf.setItemId(itemIdComboLeaf);
|
||||
comboReplaceArithmeticElementsLeaf.setWidth(COMBO_WIDTH);
|
||||
comboReplaceArithmeticElementsLeaf.setEditable(false);
|
||||
|
||||
comboReplaceElementsLeaf.setTriggerAction(TriggerAction.ALL);
|
||||
comboReplaceArithmeticElementsLeaf.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
// ComboConcat
|
||||
ListStore<ReplaceElement> storeReplaceElementsConcat = new ListStore<ReplaceElement>(
|
||||
// Combo Operator
|
||||
ListStore<ReplaceArithmeticElement> storeReplaceArithmeticElementsOperator = new ListStore<ReplaceArithmeticElement>(
|
||||
props.id());
|
||||
Log.debug("Store Concat: " + storeReplaceElementsConcat);
|
||||
storeReplaceElementsConcat.addAll(factory.replaceElementsConcat);
|
||||
Log.debug("Store Concat: " + storeReplaceArithmeticElementsOperator);
|
||||
storeReplaceArithmeticElementsOperator
|
||||
.addAll(replaceArithmeticElementStore.replaceArithmeticElementsOperators);
|
||||
|
||||
Log.debug("Store created");
|
||||
final ComboBox<ReplaceElement> comboReplaceElementsConcat = new ComboBox<ReplaceElement>(
|
||||
storeReplaceElementsConcat, props.label());
|
||||
final ComboBox<ReplaceArithmeticElement> comboReplaceArithmeticElementsOperator = new ComboBox<ReplaceArithmeticElement>(
|
||||
storeReplaceArithmeticElementsOperator, props.label());
|
||||
|
||||
Log.debug("Combo created");
|
||||
|
||||
comboReplaceElementsConcat
|
||||
.addSelectionHandler(new SelectionHandler<ReplaceElement>() {
|
||||
comboReplaceArithmeticElementsOperator
|
||||
.addSelectionHandler(new SelectionHandler<ReplaceArithmeticElement>() {
|
||||
|
||||
public void onSelection(SelectionEvent<ReplaceElement> event) {
|
||||
public void onSelection(
|
||||
SelectionEvent<ReplaceArithmeticElement> event) {
|
||||
|
||||
if (event.getSelectedItem() != null) {
|
||||
@SuppressWarnings("unchecked")
|
||||
ComboBox<ReplaceElement> source = (ComboBox<ReplaceElement>) event
|
||||
ComboBox<ReplaceArithmeticElement> source = (ComboBox<ReplaceArithmeticElement>) event
|
||||
.getSource();
|
||||
ReplaceElement re = event.getSelectedItem();
|
||||
ReplaceArithmeticElement re = event
|
||||
.getSelectedItem();
|
||||
Log.debug("Condition selected:" + re.toString());
|
||||
switch (re.getReplaceType()) {
|
||||
switch (re.getReplaceArithmeticType()) {
|
||||
case Value:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.setVisible(false);
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(false);
|
||||
firstArg.setEmptyText(EMPTY_TEXT_INSERT_A_STRING);
|
||||
firstArg.setVisible(true);
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
removeConcat(source);
|
||||
removeOperator(source);
|
||||
break;
|
||||
case ColumnValue:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.setVisible(false);
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(true);
|
||||
firstArg.setVisible(false);
|
||||
|
@ -646,51 +690,60 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
break;
|
||||
case Concat:
|
||||
if (!existConcat(source)) {
|
||||
comboReplaceElementsLeaf.clear();
|
||||
comboReplaceElementsLeaf.setVisible(true);
|
||||
case Addition:
|
||||
case Subtraction:
|
||||
case Modulus:
|
||||
case Multiplication:
|
||||
case Division:
|
||||
if (!existOperator(source)) {
|
||||
comboReplaceArithmeticElementsLeaf.clear();
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.setVisible(true);
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(false);
|
||||
firstArg.setVisible(false);
|
||||
firstArg.setEmptyText("");
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
addConcat();
|
||||
addOperator();
|
||||
}
|
||||
break;
|
||||
case SubstringByRegex:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.setVisible(false);
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(true);
|
||||
firstArg.setVisible(true);
|
||||
firstArg.setEmptyText(EMPTY_TEXT_REGEXP);
|
||||
secondArg.setVisible(false);
|
||||
secondArg.setEmptyText("");
|
||||
removeConcat(source);
|
||||
removeOperator(source);
|
||||
break;
|
||||
case SubstringByIndex:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.setVisible(false);
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(true);
|
||||
firstArg.setVisible(true);
|
||||
firstArg.setEmptyText(EMPTY_TEXT_FROM_INDEX);
|
||||
secondArg.setVisible(true);
|
||||
secondArg.setEmptyText(EMPTY_TEXT_TO_INDEX);
|
||||
removeConcat(source);
|
||||
removeOperator(source);
|
||||
break;
|
||||
case SubstringByCharSeq:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.setVisible(false);
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(true);
|
||||
firstArg.setVisible(true);
|
||||
firstArg.setEmptyText(EMPTY_TEXT_FROM_STRING);
|
||||
secondArg.setVisible(true);
|
||||
secondArg.setEmptyText(EMPTY_TEXT_TO_STRING);
|
||||
removeConcat(source);
|
||||
removeOperator(source);
|
||||
break;
|
||||
case TextReplaceMatchingRegex:
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceArithmeticElementsLeaf
|
||||
.setVisible(false);
|
||||
comboColumns.clear();
|
||||
comboColumns.setVisible(true);
|
||||
firstArg.setVisible(true);
|
||||
|
@ -698,7 +751,7 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
secondArg.setVisible(true);
|
||||
secondArg
|
||||
.setEmptyText(EMPTY_TEXT_REPLACE_REPLACING);
|
||||
removeConcat(source);
|
||||
removeOperator(source);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -712,18 +765,21 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
|
||||
});
|
||||
|
||||
comboReplaceElementsConcat.setEmptyText("Select...");
|
||||
comboReplaceElementsConcat.setItemId(itemIdComboConcat);
|
||||
comboReplaceElementsConcat.setWidth(COMBO_WIDTH);
|
||||
comboReplaceElementsConcat.setEditable(false);
|
||||
comboReplaceElementsConcat.setTriggerAction(TriggerAction.ALL);
|
||||
comboReplaceArithmeticElementsOperator.setEmptyText("Select...");
|
||||
comboReplaceArithmeticElementsOperator.setItemId(itemIdComboArithmetic);
|
||||
comboReplaceArithmeticElementsOperator.setWidth(COMBO_WIDTH);
|
||||
comboReplaceArithmeticElementsOperator.setEditable(false);
|
||||
comboReplaceArithmeticElementsOperator
|
||||
.setTriggerAction(TriggerAction.ALL);
|
||||
|
||||
comboReplaceElementsConcat.setValue(storeReplaceElementsConcat.get(0),
|
||||
true);
|
||||
comboReplaceArithmeticElementsOperator.setValue(
|
||||
storeReplaceArithmeticElementsOperator.get(0), true);
|
||||
|
||||
//
|
||||
horiz.add(comboReplaceElementsConcat, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(comboReplaceElementsLeaf, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(comboReplaceArithmeticElementsOperator, new BoxLayoutData(
|
||||
new Margins(0)));
|
||||
horiz.add(comboReplaceArithmeticElementsLeaf, new BoxLayoutData(
|
||||
new Margins(0)));
|
||||
horiz.add(comboColumns, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(firstArg, new BoxLayoutData(new Margins(0)));
|
||||
horiz.add(secondArg, new BoxLayoutData(new Margins(0)));
|
||||
|
@ -733,12 +789,12 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
firstArg.setVisible(true);
|
||||
secondArg.setVisible(false);
|
||||
comboColumns.setVisible(false);
|
||||
comboReplaceElementsLeaf.setVisible(false);
|
||||
comboReplaceElementsConcat.setVisible(true);
|
||||
comboReplaceArithmeticElementsLeaf.setVisible(false);
|
||||
comboReplaceArithmeticElementsOperator.setVisible(true);
|
||||
forceLayout();
|
||||
}
|
||||
|
||||
private void removeConcat(ComboBox<ReplaceElement> source) {
|
||||
private void removeOperator(ComboBox<ReplaceArithmeticElement> source) {
|
||||
HBoxLayoutContainer horiz = (HBoxLayoutContainer) source.getParent();
|
||||
int index = vert.getWidgetIndex(horiz);
|
||||
Log.debug("No concat for index: " + index);
|
||||
|
@ -749,7 +805,7 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
}
|
||||
}
|
||||
|
||||
private boolean existConcat(ComboBox<ReplaceElement> source) {
|
||||
private boolean existOperator(ComboBox<ReplaceArithmeticElement> source) {
|
||||
boolean exist = false;
|
||||
HBoxLayoutContainer horiz = (HBoxLayoutContainer) source.getParent();
|
||||
int index = vert.getWidgetIndex(horiz);
|
||||
|
@ -792,7 +848,7 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
protected ExpressionContainer calcCExpression(int index)
|
||||
throws ReplaceTypeMapException {
|
||||
ExpressionContainer expressionContainer = null;
|
||||
ExpressionContainer expContainerConcat = null;
|
||||
ExpressionContainer expContainerOperator = null;
|
||||
C_Expression exp = null;
|
||||
C_Expression expLeaf = null;
|
||||
String readableExp = "";
|
||||
|
@ -800,15 +856,15 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
TextField firstArg;
|
||||
TextField secondArg;
|
||||
HBoxLayoutContainer horiz;
|
||||
ReplaceTypeMap mapReplace = new ReplaceTypeMap();
|
||||
ReplaceArithmeticTypeMap mapReplaceArithmetic = new ReplaceArithmeticTypeMap();
|
||||
|
||||
horiz = (HBoxLayoutContainer) vert.getWidget(index);
|
||||
@SuppressWarnings("unchecked")
|
||||
ComboBox<ReplaceElement> comboConcat = (ComboBox<ReplaceElement>) horiz
|
||||
.getItemByItemId(itemIdComboConcat);
|
||||
Log.debug("combo Concat: " + comboConcat.getCurrentValue());
|
||||
ComboBox<ReplaceArithmeticElement> comboOperator = (ComboBox<ReplaceArithmeticElement>) horiz
|
||||
.getItemByItemId(itemIdComboArithmetic);
|
||||
Log.debug("combo Operator: " + comboOperator.getCurrentValue());
|
||||
@SuppressWarnings("unchecked")
|
||||
ComboBox<ReplaceElement> comboLeaf = (ComboBox<ReplaceElement>) horiz
|
||||
ComboBox<ReplaceArithmeticElement> comboLeaf = (ComboBox<ReplaceArithmeticElement>) horiz
|
||||
.getItemByItemId(itemIdComboLeaf);
|
||||
Log.debug("combo Leaf: " + comboLeaf.getCurrentValue());
|
||||
|
||||
|
@ -824,93 +880,36 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
+ firstArg.getCurrentValue() + ", secondArg: "
|
||||
+ secondArg.getCurrentValue() + "]");
|
||||
|
||||
ReplaceType comboConcatReplaceType = null;
|
||||
ReplaceType comboLeafReplaceType = null;
|
||||
ReplaceArithmeticType comboOperatorReplaceType = null;
|
||||
ReplaceArithmeticType comboLeafReplaceType = null;
|
||||
|
||||
if (comboConcat.getCurrentValue() == null) {
|
||||
if (index == vert.getWidgetCount() - 1) {
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
exp = mapReplace.map(
|
||||
column,
|
||||
ReplaceType.Null,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false);
|
||||
break;
|
||||
case Template:
|
||||
exp = mapReplace.map(
|
||||
column,
|
||||
ReplaceType.Null,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), true);
|
||||
break;
|
||||
default:
|
||||
exp = mapReplace.map(
|
||||
column,
|
||||
ReplaceType.Null,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false);
|
||||
break;
|
||||
|
||||
}
|
||||
readableExp = mapReplace.getReadableExpression();
|
||||
expressionContainer = new ExpressionContainer(exp, readableExp);
|
||||
|
||||
} else {
|
||||
throw new ReplaceTypeMapException("Fill all field!");
|
||||
}
|
||||
if (comboOperator.getCurrentValue() == null) {
|
||||
throw new ReplaceTypeMapException("Fill all field!");
|
||||
} else {
|
||||
comboConcatReplaceType = comboConcat.getCurrentValue()
|
||||
.getReplaceType();
|
||||
if (comboConcatReplaceType.compareTo(ReplaceType.Concat) == 0) {
|
||||
comboOperatorReplaceType = comboOperator.getCurrentValue()
|
||||
.getReplaceArithmeticType();
|
||||
if (comboOperatorReplaceType
|
||||
.compareTo(ReplaceArithmeticType.Addition) == 0
|
||||
|| comboOperatorReplaceType
|
||||
.compareTo(ReplaceArithmeticType.Subtraction) == 0
|
||||
|| comboOperatorReplaceType
|
||||
.compareTo(ReplaceArithmeticType.Modulus) == 0
|
||||
|| comboOperatorReplaceType
|
||||
.compareTo(ReplaceArithmeticType.Multiplication) == 0
|
||||
|| comboOperatorReplaceType
|
||||
.compareTo(ReplaceArithmeticType.Division) == 0) {
|
||||
|
||||
if (comboLeaf.getCurrentValue() == null) {
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
expLeaf = mapReplace.map(
|
||||
column,
|
||||
ReplaceType.Null,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false);
|
||||
break;
|
||||
case Template:
|
||||
expLeaf = mapReplace.map(
|
||||
column,
|
||||
ReplaceType.Null,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), true);
|
||||
break;
|
||||
default:
|
||||
expLeaf = mapReplace.map(
|
||||
column,
|
||||
ReplaceType.Null,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false);
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
readableExpLeaf = mapReplace.getReadableExpression();
|
||||
throw new ReplaceTypeMapException("Fill all field!");
|
||||
|
||||
} else {
|
||||
comboLeafReplaceType = comboLeaf.getCurrentValue()
|
||||
.getReplaceType();
|
||||
.getReplaceArithmeticType();
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
expLeaf = mapReplace.map(
|
||||
expLeaf = mapReplaceArithmetic.map(
|
||||
column,
|
||||
targetColumnDataType,
|
||||
comboLeafReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
|
@ -918,8 +917,9 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
.getCurrentValue(), false);
|
||||
break;
|
||||
case Template:
|
||||
expLeaf = mapReplace.map(
|
||||
expLeaf = mapReplaceArithmetic.map(
|
||||
column,
|
||||
targetColumnDataType,
|
||||
comboLeafReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
|
@ -927,8 +927,9 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
.getCurrentValue(), true);
|
||||
break;
|
||||
default:
|
||||
expLeaf = mapReplace.map(
|
||||
expLeaf = mapReplaceArithmetic.map(
|
||||
column,
|
||||
targetColumnDataType,
|
||||
comboLeafReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
|
@ -938,55 +939,60 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
|
||||
}
|
||||
|
||||
readableExpLeaf = mapReplace.getReadableExpression();
|
||||
readableExpLeaf = mapReplaceArithmetic
|
||||
.getReadableExpression();
|
||||
}
|
||||
|
||||
index++;
|
||||
if (index < vert.getWidgetCount()) {
|
||||
expContainerConcat = calcCExpression(index);
|
||||
if (expContainerConcat == null) {
|
||||
expContainerOperator = calcCExpression(index);
|
||||
if (expContainerOperator == null) {
|
||||
return null;
|
||||
} else {
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
exp = mapReplace.map(
|
||||
exp = mapReplaceArithmetic.map(
|
||||
column,
|
||||
comboConcatReplaceType,
|
||||
targetColumnDataType,
|
||||
comboOperatorReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false, expLeaf,
|
||||
expContainerConcat.getExpression(),
|
||||
readableExpLeaf, expContainerConcat
|
||||
expContainerOperator.getExpression(),
|
||||
readableExpLeaf, expContainerOperator
|
||||
.getReadableExpression());
|
||||
break;
|
||||
case Template:
|
||||
exp = mapReplace.map(
|
||||
exp = mapReplaceArithmetic.map(
|
||||
column,
|
||||
comboConcatReplaceType,
|
||||
targetColumnDataType,
|
||||
comboOperatorReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), true, expLeaf,
|
||||
expContainerConcat.getExpression(),
|
||||
readableExpLeaf, expContainerConcat
|
||||
expContainerOperator.getExpression(),
|
||||
readableExpLeaf, expContainerOperator
|
||||
.getReadableExpression());
|
||||
break;
|
||||
default:
|
||||
exp = mapReplace.map(
|
||||
exp = mapReplaceArithmetic.map(
|
||||
column,
|
||||
comboConcatReplaceType,
|
||||
targetColumnDataType,
|
||||
comboOperatorReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false, expLeaf,
|
||||
expContainerConcat.getExpression(),
|
||||
readableExpLeaf, expContainerConcat
|
||||
expContainerOperator.getExpression(),
|
||||
readableExpLeaf, expContainerOperator
|
||||
.getReadableExpression());
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
readableExp = mapReplace.getReadableExpression();
|
||||
readableExp = mapReplaceArithmetic
|
||||
.getReadableExpression();
|
||||
expressionContainer = new ExpressionContainer(exp,
|
||||
readableExp);
|
||||
}
|
||||
|
@ -997,26 +1003,38 @@ public class ReplaceArithmeticWidget extends SimpleContainer {
|
|||
} else {
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
exp = mapReplace.map(column, comboConcatReplaceType,
|
||||
firstArg == null ? null : firstArg.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg.getCurrentValue(),
|
||||
false);
|
||||
exp = mapReplaceArithmetic.map(
|
||||
column,
|
||||
targetColumnDataType,
|
||||
comboOperatorReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false);
|
||||
break;
|
||||
case Template:
|
||||
exp = mapReplace.map(column, comboConcatReplaceType,
|
||||
firstArg == null ? null : firstArg.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg.getCurrentValue(),
|
||||
true);
|
||||
exp = mapReplaceArithmetic.map(
|
||||
column,
|
||||
targetColumnDataType,
|
||||
comboOperatorReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), true);
|
||||
break;
|
||||
default:
|
||||
exp = mapReplace.map(column, comboConcatReplaceType,
|
||||
firstArg == null ? null : firstArg.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg.getCurrentValue(),
|
||||
false);
|
||||
exp = mapReplaceArithmetic.map(
|
||||
column,
|
||||
targetColumnDataType,
|
||||
comboOperatorReplaceType,
|
||||
firstArg == null ? null : firstArg
|
||||
.getCurrentValue(),
|
||||
secondArg == null ? null : secondArg
|
||||
.getCurrentValue(), false);
|
||||
break;
|
||||
|
||||
|
||||
}
|
||||
readableExp = mapReplace.getReadableExpression();
|
||||
readableExp = mapReplaceArithmetic.getReadableExpression();
|
||||
expressionContainer = new ExpressionContainer(exp, readableExp);
|
||||
|
||||
}
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package org.gcube.portlets.user.td.expressionwidget.client;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.resources.ExpressionResources;
|
||||
import org.gcube.portlets.user.td.expressionwidget.client.type.ReplaceColumnByExpressionType;
|
||||
|
@ -20,7 +19,6 @@ import org.gcube.portlets.user.td.widgetcommonevent.shared.tr.column.ColumnTypeM
|
|||
import com.allen_sauer.gwt.log.client.Log;
|
||||
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.HasHorizontalAlignment;
|
||||
|
@ -40,7 +38,6 @@ 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.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;
|
||||
|
@ -79,7 +76,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
|||
|
||||
private ReplaceColumnByExpressionType replaceColumnByExpressionType;
|
||||
|
||||
private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
||||
// private DateTimeFormat sdf = DateTimeFormat.getFormat("yyyy-MM-dd");
|
||||
|
||||
private TextButton btnApply;
|
||||
private TextButton btnClose;
|
||||
|
@ -88,15 +85,14 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
|||
private ConditionWidget conditionWidget;
|
||||
|
||||
private ReplaceWidget replaceWidget;
|
||||
private ReplaceArithmeticWidget replaceArithmeticWidget;
|
||||
private TextField replaceValue;
|
||||
private DateField replaceValueDate;
|
||||
// private DateField replaceValueDate;
|
||||
|
||||
private VerticalLayoutContainer conditionsVerticalLayout;
|
||||
private FieldLabel allRowsField;
|
||||
private boolean allRows;
|
||||
|
||||
|
||||
|
||||
public ReplaceColumnByExpressionPanel(
|
||||
ReplaceColumnByExpressionDialog parent, ColumnData column,
|
||||
EventBus eventBus) {
|
||||
|
@ -128,8 +124,16 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
|||
protected void init() {
|
||||
setWidth(WIDTH);
|
||||
if (column != null
|
||||
&& column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Text.toString()) == 0) {
|
||||
&& (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 || column
|
||||
.getDataTypeName().compareTo(
|
||||
ColumnDataType.Date.toString()) == 0)) {
|
||||
setHeight(HEIGHT);
|
||||
} else {
|
||||
setHeight(HEIGHT_REDUCE);
|
||||
|
@ -144,7 +148,7 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
|||
protected void create() {
|
||||
VerticalLayoutContainer basicLayout = new VerticalLayoutContainer();
|
||||
basicLayout.setAdjustForScroll(true);
|
||||
//basicLayout.setScrollMode(ScrollMode.AUTO);
|
||||
// basicLayout.setScrollMode(ScrollMode.AUTO);
|
||||
|
||||
HBoxLayoutContainer flowButton = new HBoxLayoutContainer();
|
||||
flowButton.setHBoxLayoutAlign(HBoxLayoutAlign.MIDDLE);
|
||||
|
@ -226,32 +230,64 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
|||
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));
|
||||
if (column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Integer.toString()) == 0
|
||||
|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Numeric.toString()) == 0
|
||||
|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Geometry.toString()) == 0
|
||||
|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Date.toString()) == 0) {
|
||||
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
replaceArithmeticWidget = new ReplaceArithmeticWidget(column,
|
||||
REPLACEWIDTH, REPLACEHEIGHT, eventBus);
|
||||
break;
|
||||
case Template:
|
||||
replaceArithmeticWidget = new ReplaceArithmeticWidget(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(replaceArithmeticWidget,
|
||||
new VerticalLayoutData(1, -1));
|
||||
/*
|
||||
* 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) {
|
||||
switch(replaceColumnByExpressionType){
|
||||
switch (replaceColumnByExpressionType) {
|
||||
case Replace:
|
||||
replaceWidget = new ReplaceWidget(column, REPLACEWIDTH,
|
||||
REPLACEHEIGHT, eventBus);
|
||||
break;
|
||||
case Template:
|
||||
replaceWidget = new ReplaceWidget(column, columns, REPLACEWIDTH,
|
||||
REPLACEHEIGHT, eventBus);
|
||||
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){
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Attention Replace Widget have not a valid type");
|
||||
if (parent != null) {
|
||||
parent.hide();
|
||||
}
|
||||
return;
|
||||
|
||||
|
||||
|
||||
}
|
||||
replaceValueFieldSetLayout.add(replaceWidget,
|
||||
new VerticalLayoutData(1, -1));
|
||||
|
@ -294,8 +330,8 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
|||
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(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,
|
||||
|
@ -336,23 +372,40 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
|||
|
||||
}
|
||||
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!");
|
||||
if (column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Integer.toString()) == 0
|
||||
|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Numeric.toString()) == 0
|
||||
|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Geometry.toString()) == 0
|
||||
|| column.getDataTypeName().compareTo(
|
||||
ColumnDataType.Date.toString()) == 0) {
|
||||
|
||||
C_Expression cReplaceExpression = null;
|
||||
try {
|
||||
cReplaceExpression = replaceArithmeticWidget.getExpression();
|
||||
if (cReplaceExpression == null) {
|
||||
UtilsGXT3.alert("Attention",
|
||||
"Replace expression is not valid!");
|
||||
return;
|
||||
}
|
||||
callApplyReplaceColumnByExpression(cConditionExpression, value);
|
||||
|
||||
} catch (ReplaceTypeMapException e) {
|
||||
UtilsGXT3.alert("Attention", e.getLocalizedMessage());
|
||||
return;
|
||||
}
|
||||
callApplyReplaceColumnByExpression(cConditionExpression,
|
||||
cReplaceExpression);
|
||||
/*
|
||||
* 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(
|
||||
|
@ -424,13 +477,15 @@ public class ReplaceColumnByExpressionPanel extends FramedPanel {
|
|||
C_ExpressionContainer.Contains.C_Expression,
|
||||
cConditionExpression,
|
||||
conditionWidget.getReadableExpression());
|
||||
expressionEvent.setC_ConditionExpressionContainer(conditionExpressionContainer);
|
||||
expressionEvent
|
||||
.setC_ConditionExpressionContainer(conditionExpressionContainer);
|
||||
expressionEvent.setReplaceByValue(false);
|
||||
C_ExpressionContainer replaceExpressionContainer = new C_ExpressionContainer(
|
||||
C_ExpressionContainer.Contains.C_Expression,
|
||||
cReplaceExpression,
|
||||
replaceWidget.getReadableExpression());
|
||||
expressionEvent.setC_ReplaceExpressionContainer(replaceExpressionContainer);;
|
||||
cReplaceExpression, replaceWidget.getReadableExpression());
|
||||
expressionEvent
|
||||
.setC_ReplaceExpressionContainer(replaceExpressionContainer);
|
||||
;
|
||||
expressionEvent.setTrId(column.getTrId());
|
||||
expressionEvent.setColumnId(column.getColumnId());
|
||||
expressionEvent.setColumnName(column.getName());
|
||||
|
|
|
@ -14,6 +14,11 @@ import org.gcube.data.analysis.tabulardata.expression.composite.aggregation.Max;
|
|||
import org.gcube.data.analysis.tabulardata.expression.composite.aggregation.Min;
|
||||
import org.gcube.data.analysis.tabulardata.expression.composite.aggregation.ST_Extent;
|
||||
import org.gcube.data.analysis.tabulardata.expression.composite.aggregation.Sum;
|
||||
import org.gcube.data.analysis.tabulardata.expression.composite.arithmetic.Addition;
|
||||
import org.gcube.data.analysis.tabulardata.expression.composite.arithmetic.Division;
|
||||
import org.gcube.data.analysis.tabulardata.expression.composite.arithmetic.Modulus;
|
||||
import org.gcube.data.analysis.tabulardata.expression.composite.arithmetic.Multiplication;
|
||||
import org.gcube.data.analysis.tabulardata.expression.composite.arithmetic.Subtraction;
|
||||
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.Equals;
|
||||
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.GreaterOrEquals;
|
||||
import org.gcube.data.analysis.tabulardata.expression.composite.comparable.GreaterThan;
|
||||
|
@ -67,6 +72,11 @@ import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggreg
|
|||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggregation.C_Min;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggregation.C_ST_Extent;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.aggregation.C_Sum;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_Addition;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_Division;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_Modulus;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_Multiplication;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.arithmetic.C_Subtraction;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.comparable.C_Equals;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.comparable.C_GreaterOrEquals;
|
||||
import org.gcube.portlets.user.td.expressionwidget.shared.model.composite.comparable.C_GreaterThan;
|
||||
|
@ -222,6 +232,21 @@ public class C_ExpressionParser {
|
|||
case "Cast":
|
||||
ex = getCast(exp);
|
||||
break;
|
||||
case "Addition":
|
||||
ex = getAddition(exp);
|
||||
break;
|
||||
case "Subtraction":
|
||||
ex = getSubtraction(exp);
|
||||
break;
|
||||
case "Modulus":
|
||||
ex = getModulus(exp);
|
||||
break;
|
||||
case "Multiplication":
|
||||
ex = getMultiplication(exp);
|
||||
break;
|
||||
case "Division":
|
||||
ex = getDivision(exp);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -686,4 +711,44 @@ public class C_ExpressionParser {
|
|||
return sm;
|
||||
}
|
||||
|
||||
private Expression getAddition(C_Expression exp)
|
||||
throws ExpressionParserException {
|
||||
C_Addition addition = (C_Addition) exp;
|
||||
Addition add = new Addition(parse(addition.getLeftArgument()),
|
||||
parse(addition.getRightArgument()));
|
||||
return add;
|
||||
}
|
||||
|
||||
private Expression getSubtraction(C_Expression exp)
|
||||
throws ExpressionParserException {
|
||||
C_Subtraction subtraction = (C_Subtraction) exp;
|
||||
Subtraction sub = new Subtraction(parse(subtraction.getLeftArgument()),
|
||||
parse(subtraction.getRightArgument()));
|
||||
return sub;
|
||||
}
|
||||
|
||||
private Expression getModulus(C_Expression exp)
|
||||
throws ExpressionParserException {
|
||||
C_Modulus modulus = (C_Modulus) exp;
|
||||
Modulus modu = new Modulus(parse(modulus.getLeftArgument()),
|
||||
parse(modulus.getRightArgument()));
|
||||
return modu;
|
||||
}
|
||||
|
||||
private Expression getMultiplication(C_Expression exp)
|
||||
throws ExpressionParserException {
|
||||
C_Multiplication multiplication = (C_Multiplication) exp;
|
||||
Multiplication multi = new Multiplication(parse(multiplication.getLeftArgument()),
|
||||
parse(multiplication.getRightArgument()));
|
||||
return multi;
|
||||
}
|
||||
|
||||
private Expression getDivision(C_Expression exp)
|
||||
throws ExpressionParserException {
|
||||
C_Division division = (C_Division) exp;
|
||||
Division divi = new Division(parse(division.getLeftArgument()),
|
||||
parse(division.getRightArgument()));
|
||||
return divi;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue