Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Bégaudeau2016-12-15 04:05:38 -0500
committerStéphane Bégaudeau2017-01-27 03:58:27 -0500
commit31c25928c9d3a7250c49e61da8ec932481dd267e (patch)
tree54ac5af1b1f8cf6a395aa01ae3f0d411f5897804 /samples
parent525c08d3fe109ce3f1ad573aeb054c04ccad49b9 (diff)
downloadorg.eclipse.eef-31c25928c9d3a7250c49e61da8ec932481dd267e.tar.gz
org.eclipse.eef-31c25928c9d3a7250c49e61da8ec932481dd267e.tar.xz
org.eclipse.eef-31c25928c9d3a7250c49e61da8ec932481dd267e.zip
[refactoring] Improve some code thanks to JavaSE-8.0
Change-Id: If0cb48804b274f430b6aa7b30750c242c366643e 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.java48
-rw-r--r--samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java15
2 files changed, 26 insertions, 37 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 4d1d6e036..60d197478 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
@@ -83,24 +83,21 @@ public class ColorPickerController extends AbstractEEFCustomWidgetController imp
super.refresh();
String valueExpression = getCustomExpression(VALUE_EXPRESSION_ID);
- this.newEval().logIfInvalidType(String.class).call(valueExpression, new IConsumer<String>() {
- @Override
- public void apply(String value) {
- int red = DEFAULT_COLOR_CODE;
- int green = DEFAULT_COLOR_CODE;
- int blue = DEFAULT_COLOR_CODE;
- if (value != null) {
- String[] rgb = value.split(SEPARATOR);
- if (rgb.length == 3) {
- try {
- red = Integer.parseInt(rgb[0]);
- green = Integer.parseInt(rgb[1]);
- blue = Integer.parseInt(rgb[2]);
- Color color = ColorHelper.getColor(red, green, blue);
- ColorPickerController.this.newValueConsumer.apply(color);
- } catch (NumberFormatException e) {
- // TODO Log warning about unexpected result format from the expression.
- }
+ this.newEval().logIfInvalidType(String.class).call(valueExpression, (value) -> {
+ int red = DEFAULT_COLOR_CODE;
+ int green = DEFAULT_COLOR_CODE;
+ int blue = DEFAULT_COLOR_CODE;
+ if (value != null) {
+ String[] rgb = value.split(SEPARATOR);
+ if (rgb.length == 3) {
+ try {
+ red = Integer.parseInt(rgb[0]);
+ green = Integer.parseInt(rgb[1]);
+ blue = Integer.parseInt(rgb[2]);
+ Color color = ColorHelper.getColor(red, green, blue);
+ ColorPickerController.this.newValueConsumer.apply(color);
+ } catch (NumberFormatException e) {
+ // TODO Log warning about unexpected result format from the expression.
}
}
}
@@ -124,17 +121,14 @@ public class ColorPickerController extends AbstractEEFCustomWidgetController imp
@Override
public void updateValue(final RGB color) {
- contextAdapter.performModelChange(new Runnable() {
- @Override
- public void run() {
- String editExpression = getCustomExpression(EDIT_EXPRESSION_ID);
+ contextAdapter.performModelChange(() -> {
+ String editExpression = getCustomExpression(EDIT_EXPRESSION_ID);
- 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);
+ Map<String, Object> variables = new HashMap<String, Object>();
+ variables.putAll(this.variableManager.getVariables());
+ variables.put(EEFExpressionUtils.EEFText.NEW_VALUE, color.red + SEPARATOR + color.green + SEPARATOR + color.blue);
- EvalFactory.of(ColorPickerController.this.interpreter, variables).call(editExpression);
- }
+ EvalFactory.of(this.interpreter, variables).call(editExpression);
});
}
diff --git a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java
index 8ec8e2374..b70e08bf1 100644
--- a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java
+++ b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java
@@ -15,7 +15,6 @@ import org.eclipse.eef.EEFWidgetDescription;
import org.eclipse.eef.common.ui.api.EEFWidgetFactory;
import org.eclipse.eef.common.ui.api.IEEFFormContainer;
import org.eclipse.eef.core.api.EditingContextAdapter;
-import org.eclipse.eef.core.api.controllers.IConsumer;
import org.eclipse.eef.core.api.controllers.IEEFWidgetController;
import org.eclipse.eef.ide.ui.api.widgets.AbstractEEFWidgetLifecycleManager;
import org.eclipse.sirius.common.interpreter.api.IInterpreter;
@@ -23,7 +22,6 @@ import org.eclipse.sirius.common.interpreter.api.IVariableManager;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.MouseAdapter;
import org.eclipse.swt.events.MouseEvent;
-import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.widgets.ColorDialog;
import org.eclipse.swt.widgets.Composite;
@@ -131,14 +129,11 @@ public class ColorPickerLifecycleManager extends AbstractEEFWidgetLifecycleManag
};
this.colorPicker.addMouseListener(mouseListener);
- this.controller.onNewValue(new IConsumer<Color>() {
- @Override
- public void apply(Color value) {
- if (!colorPicker.isDisposed() && !(colorPicker.getBackground() != null && colorPicker.getBackground().equals(value))) {
- colorPicker.setImage(colorPicker.getColorImage(value));
- if (!colorPicker.isEnabled()) {
- colorPicker.setEnabled(true);
- }
+ this.controller.onNewValue((value) -> {
+ if (!colorPicker.isDisposed() && !(colorPicker.getBackground() != null && colorPicker.getBackground().equals(value))) {
+ colorPicker.setImage(colorPicker.getColorImage(value));
+ if (!colorPicker.isEnabled()) {
+ colorPicker.setEnabled(true);
}
}
});

Back to the top