Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStéphane Bégaudeau2016-04-21 05:04:38 -0400
committerStéphane Bégaudeau2016-04-28 09:34:21 -0400
commit73797362ca3ca073156f6de1113a8113abf39129 (patch)
treee13c016e2df6637ebbca068c9a2aecaad27aa504 /samples
parentd405a1d16c71226d7ad47663f93d1f1e37351977 (diff)
downloadorg.eclipse.eef-73797362ca3ca073156f6de1113a8113abf39129.tar.gz
org.eclipse.eef-73797362ca3ca073156f6de1113a8113abf39129.tar.xz
org.eclipse.eef-73797362ca3ca073156f6de1113a8113abf39129.zip
Improve the APIs
1) Improve the documentation of two extension points (Lifecycle Manager Provider and Tab Descriptor Provider) 2) Remove two useless extension points along with their code (View Description Provider and Interpreter Provider) 3) Move some interfaces related to Lifecycle Managers in order to have all APIs for the Lifecycle Managers (2 abstract classes and 2 interfaces) in the same package. 4) Move the two classes of o.e.eef.properties.ui.legacy in an internal package since they are only used in this bundle (I18N & Messages) 5) Update the behavior of the Lifecycle Manager Provider extension point to let contibutors replace existing Lifecycle Managers Change-Id: I76aa69e0650cbc6d34e56baaadbc33bdacbcb957 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/META-INF/MANIFEST.MF1
-rw-r--r--samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerController.java220
-rw-r--r--samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java2
-rw-r--r--samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerProvider.java26
4 files changed, 131 insertions, 118 deletions
diff --git a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/META-INF/MANIFEST.MF b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/META-INF/MANIFEST.MF
index aba9cf50d..ced5f2380 100644
--- a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/META-INF/MANIFEST.MF
+++ b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/META-INF/MANIFEST.MF
@@ -6,7 +6,6 @@ Bundle-Version: 1.6.0.qualifier
Bundle-Vendor: %providerName
Bundle-RequiredExecutionEnvironment: JavaSE-1.6
Import-Package: org.eclipse.eef;version="[1.6.0,2.0.0)",
- org.eclipse.eef.api;version="[1.6.0,2.0.0)",
org.eclipse.eef.core.api;version="[1.6.0,2.0.0)",
org.eclipse.eef.core.api.controllers;version="[1.6.0,2.0.0)",
org.eclipse.eef.core.api.utils;version="[1.6.0,2.0.0)",
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 c23cc3332..9404720c2 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
@@ -27,120 +27,120 @@ import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.RGB;
/**
- * This class is used to provide utilities to single reference viewer
- * controller.
+ * This class is used to provide utilities to single reference viewer controller.
*
* @author mbats
*/
public class ColorPickerController extends AbstractEEFCustomWidgetController implements IColorPickerController {
- /**
- * Default color code.
- */
- private static final int DEFAULT_COLOR_CODE = 255;
-
- /**
- * Value expression id.
- */
- private static final String VALUE_EXPRESSION_ID = "valueExpression";
-
- /**
- * Add expression id.
- */
- private static final String EDIT_EXPRESSION_ID = "editExpression";
-
- /**
- * Separator.
- */
- private static final String SEPARATOR = ",";
-
- /**
- * The consumer of a new value of the color.
- */
- private IConsumer<Color> newValueConsumer;
-
- /**
- * The constructor.
- *
- * @param description
- * The description
- * @param variableManager
- * The variable manager
- * @param interpreter
- * The interpreter
- * @param contextAdapter
- * The editing context adapter
- */
- public ColorPickerController(EEFCustomWidgetDescription description, IVariableManager variableManager, IInterpreter interpreter, EditingContextAdapter contextAdapter) {
- super(description, variableManager, interpreter, contextAdapter);
- }
-
- /**
- * {@inheritDoc}
- *
- * @see org.eclipse.eef.core.api.controllers.AbstractEEFWidgetController.refresh()
- */
- @Override
- public void refresh() {
- 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>() {
- @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.
- }
- }
- }
- }
- });
- }
-
- @Override
- public void onNewValue(IConsumer<Color> consumer) {
- this.newValueConsumer = consumer;
- }
-
- @Override
- public void removeNewValueConsumer() {
- this.newValueConsumer = null;
- }
-
- @Override
- protected EEFCustomWidgetDescription getDescription() {
- return this.description;
- }
-
- @Override
- public void updateValue(final RGB color) {
- contextAdapter.performModelChange(new Runnable() {
- @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);
- }
- });
- }
+ /**
+ * Default color code.
+ */
+ private static final int DEFAULT_COLOR_CODE = 255;
+
+ /**
+ * Value expression id.
+ */
+ private static final String VALUE_EXPRESSION_ID = "valueExpression"; //$NON-NLS-1$
+
+ /**
+ * Add expression id.
+ */
+ private static final String EDIT_EXPRESSION_ID = "editExpression"; //$NON-NLS-1$
+
+ /**
+ * Separator.
+ */
+ private static final String SEPARATOR = ","; //$NON-NLS-1$
+
+ /**
+ * The consumer of a new value of the color.
+ */
+ private IConsumer<Color> newValueConsumer;
+
+ /**
+ * The constructor.
+ *
+ * @param description
+ * The description
+ * @param variableManager
+ * The variable manager
+ * @param interpreter
+ * The interpreter
+ * @param contextAdapter
+ * The editing context adapter
+ */
+ public ColorPickerController(EEFCustomWidgetDescription description, IVariableManager variableManager, IInterpreter interpreter,
+ EditingContextAdapter contextAdapter) {
+ super(description, variableManager, interpreter, contextAdapter);
+ }
+
+ /**
+ * {@inheritDoc}
+ *
+ * @see org.eclipse.eef.core.api.controllers.AbstractEEFWidgetController.refresh()
+ */
+ @Override
+ public void refresh() {
+ 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>() {
+ @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.
+ }
+ }
+ }
+ }
+ });
+ }
+
+ @Override
+ public void onNewValue(IConsumer<Color> consumer) {
+ this.newValueConsumer = consumer;
+ }
+
+ @Override
+ public void removeNewValueConsumer() {
+ this.newValueConsumer = null;
+ }
+
+ @Override
+ protected EEFCustomWidgetDescription getDescription() {
+ return this.description;
+ }
+
+ @Override
+ public void updateValue(final RGB color) {
+ contextAdapter.performModelChange(new Runnable() {
+ @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);
+ }
+ });
+ }
}
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 90651fd6c..1af398898 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
@@ -197,7 +197,7 @@ public class ColorPickerLifecycleManager extends AbstractEEFWidgetLifecycleManag
/**
* {@inheritDoc}
*
- * @see org.eclipse.eef.ide.ui.api.ILifecycleManager#aboutToBeHidden()
+ * @see org.eclipse.eef.ide.ui.api.widgets.IEEFLifecycleManager#aboutToBeHidden()
*/
@Override
public void aboutToBeHidden() {
diff --git a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerProvider.java b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerProvider.java
index db28f13c1..bfd54f496 100644
--- a/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerProvider.java
+++ b/samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerProvider.java
@@ -10,10 +10,11 @@
*******************************************************************************/
package org.eclipse.eef.sample.custom.widget.colorpicker;
+import org.eclipse.eef.EEFControlDescription;
import org.eclipse.eef.EEFCustomWidgetDescription;
import org.eclipse.eef.core.api.EditingContextAdapter;
-import org.eclipse.eef.ide.ui.api.IEEFLifecycleManagerProvider;
-import org.eclipse.eef.ide.ui.api.ILifecycleManager;
+import org.eclipse.eef.ide.ui.api.widgets.IEEFLifecycleManager;
+import org.eclipse.eef.ide.ui.api.widgets.IEEFLifecycleManagerProvider;
import org.eclipse.sirius.common.interpreter.api.IInterpreter;
import org.eclipse.sirius.common.interpreter.api.IVariableManager;
@@ -23,9 +24,22 @@ import org.eclipse.sirius.common.interpreter.api.IVariableManager;
* @author mbats
*/
public class ColorPickerProvider implements IEEFLifecycleManagerProvider {
+ /**
+ * The identifier of the control description supported.
+ */
+ private static final String SUPPORTED_ID = "org.eclipse.eef.sample.custom.widget.colorpicker"; //$NON-NLS-1$
- @Override
- public ILifecycleManager getLifecycleManager(EEFCustomWidgetDescription customWidgetDescription, IVariableManager variableManager, IInterpreter interpreter, EditingContextAdapter contextAdapter) {
- return new ColorPickerLifecycleManager(customWidgetDescription, variableManager, interpreter, contextAdapter);
- }
+ @Override
+ public boolean canHandle(EEFControlDescription controlDescription) {
+ return SUPPORTED_ID.equals(controlDescription.getIdentifier()) && controlDescription instanceof EEFCustomWidgetDescription;
+ }
+
+ @Override
+ public IEEFLifecycleManager getLifecycleManager(EEFControlDescription controlDescription, IVariableManager variableManager,
+ IInterpreter interpreter, EditingContextAdapter contextAdapter) {
+ if (controlDescription instanceof EEFCustomWidgetDescription) {
+ return new ColorPickerLifecycleManager((EEFCustomWidgetDescription) controlDescription, variableManager, interpreter, contextAdapter);
+ }
+ throw new IllegalArgumentException();
+ }
}

Back to the top