Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Bégaudeau2016-05-03 04:35:30 -0400
committerStéphane Bégaudeau2016-05-04 08:00:50 -0400
commitb9d3994e3c5a0489e85f2abe28d4e7561abd6e25 (patch)
tree1b52a7736d7862e06c5e0b4d570d89ef3dc4bb14 /samples
parent6c83556399d91f3925425db6942f28490a0b5f7e (diff)
downloadorg.eclipse.eef-b9d3994e3c5a0489e85f2abe28d4e7561abd6e25.tar.gz
org.eclipse.eef-b9d3994e3c5a0489e85f2abe28d4e7561abd6e25.tar.xz
org.eclipse.eef-b9d3994e3c5a0489e85f2abe28d4e7561abd6e25.zip
Improve the API of Eval
1) The API of Eval has been modified in order to simplify its use by reducing the number of methods with a similar signature that can be called. The new methods have also a much more explicit name. 2) Simplify some usage of Eval in order to reduce the number of message logged for the end users. If the absence of an expression does not prevent the proper execution of the code, nothing is logged Change-Id: I67566cdb1c56c0e1505d64cb36a0d81b4df63908 Signed-off-by: Stéphane Bégaudeau <stephane.begaudeau@obeo.fr>
Diffstat (limited to 'samples')
-rw-r--r--samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerController.java11
1 files changed, 3 insertions, 8 deletions
diff --git a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerController.java b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerController.java
index 9404720c2..4d1d6e036 100644
--- a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerController.java
+++ b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerController.java
@@ -14,13 +14,11 @@ import java.util.HashMap;
import java.util.Map;
import org.eclipse.eef.EEFCustomWidgetDescription;
-import org.eclipse.eef.EefPackage;
import org.eclipse.eef.core.api.EEFExpressionUtils;
import org.eclipse.eef.core.api.EditingContextAdapter;
import org.eclipse.eef.core.api.controllers.AbstractEEFCustomWidgetController;
import org.eclipse.eef.core.api.controllers.IConsumer;
-import org.eclipse.eef.core.api.utils.Eval;
-import org.eclipse.emf.ecore.EAttribute;
+import org.eclipse.eef.core.api.utils.EvalFactory;
import org.eclipse.sirius.common.interpreter.api.IInterpreter;
import org.eclipse.sirius.common.interpreter.api.IVariableManager;
import org.eclipse.swt.graphics.Color;
@@ -85,9 +83,7 @@ public class ColorPickerController extends AbstractEEFCustomWidgetController imp
super.refresh();
String valueExpression = getCustomExpression(VALUE_EXPRESSION_ID);
- EAttribute eAttribute = EefPackage.Literals.EEF_CUSTOM_EXPRESSION__CUSTOM_EXPRESSION;
-
- this.newEval().call(eAttribute, valueExpression, String.class, new IConsumer<String>() {
+ this.newEval().logIfInvalidType(String.class).call(valueExpression, new IConsumer<String>() {
@Override
public void apply(String value) {
int red = DEFAULT_COLOR_CODE;
@@ -132,13 +128,12 @@ public class ColorPickerController extends AbstractEEFCustomWidgetController imp
@Override
public void run() {
String editExpression = getCustomExpression(EDIT_EXPRESSION_ID);
- EAttribute eAttribute = EefPackage.Literals.EEF_CUSTOM_EXPRESSION__CUSTOM_EXPRESSION;
Map<String, Object> variables = new HashMap<String, Object>();
variables.putAll(ColorPickerController.this.variableManager.getVariables());
variables.put(EEFExpressionUtils.EEFText.NEW_VALUE, color.red + SEPARATOR + color.green + SEPARATOR + color.blue);
- new Eval(ColorPickerController.this.interpreter, variables).call(eAttribute, editExpression);
+ EvalFactory.of(ColorPickerController.this.interpreter, variables).call(editExpression);
}
});
}

Back to the top