Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPierre-Charles David2016-04-18 08:49:33 -0400
committerPierre-Charles David2016-04-19 08:27:03 -0400
commitc67128ae4e8a3055ed3da96044a82aa44a7fdc56 (patch)
tree6d68a3a860ec4cda90a60a3ef4bbf85037d676c1 /samples
parent7e4d64ec215c0b13fcc0cea3ef91c21181d60d51 (diff)
downloadorg.eclipse.eef-c67128ae4e8a3055ed3da96044a82aa44a7fdc56.tar.gz
org.eclipse.eef-c67128ae4e8a3055ed3da96044a82aa44a7fdc56.tar.xz
org.eclipse.eef-c67128ae4e8a3055ed3da96044a82aa44a7fdc56.zip
Remove dependency to EMF Transaction
Introduce EditingContextAdapter interface to allow client code to provide the appropriate hooks for EEF to: 1. execute model-changing operations in an appropriate context; 2. detect when the model being displayed by EEF has been modified so that we can refresh our views. Bug: 490594 Change-Id: I3c3ffd62773107ddc59024e173c918d0eb6c53a4 Signed-off-by: Pierre-Charles David <pierre-charles.david@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.java34
-rw-r--r--samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerLifecycleManager.java12
-rw-r--r--samples/org.eclipse.eef.sample.custom.widget.colorpicker/src/org/eclipse/eef/sample/custom/widget/colorpicker/ColorPickerProvider.java7
3 files changed, 17 insertions, 36 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 d13b07a73..c23cc3332 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
@@ -16,14 +16,11 @@ 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.common.command.Command;
-import org.eclipse.emf.common.command.CommandStack;
import org.eclipse.emf.ecore.EAttribute;
-import org.eclipse.emf.transaction.RecordingCommand;
-import org.eclipse.emf.transaction.TransactionalEditingDomain;
import org.eclipse.sirius.common.interpreter.api.IInterpreter;
import org.eclipse.sirius.common.interpreter.api.IVariableManager;
import org.eclipse.swt.graphics.Color;
@@ -71,11 +68,11 @@ public class ColorPickerController extends AbstractEEFCustomWidgetController imp
* The variable manager
* @param interpreter
* The interpreter
- * @param editingDomain
- * The editing domain
+ * @param contextAdapter
+ * The editing context adapter
*/
- public ColorPickerController(EEFCustomWidgetDescription description, IVariableManager variableManager, IInterpreter interpreter, TransactionalEditingDomain editingDomain) {
- super(description, variableManager, interpreter, editingDomain);
+ public ColorPickerController(EEFCustomWidgetDescription description, IVariableManager variableManager, IInterpreter interpreter, EditingContextAdapter contextAdapter) {
+ super(description, variableManager, interpreter, contextAdapter);
}
/**
@@ -131,10 +128,9 @@ public class ColorPickerController extends AbstractEEFCustomWidgetController imp
@Override
public void updateValue(final RGB color) {
-
- final Command command = new RecordingCommand(this.editingDomain) {
+ contextAdapter.performModelChange(new Runnable() {
@Override
- protected void doExecute() {
+ public void run() {
String editExpression = getCustomExpression(EDIT_EXPRESSION_ID);
EAttribute eAttribute = EefPackage.Literals.EEF_CUSTOM_EXPRESSION__CUSTOM_EXPRESSION;
@@ -144,21 +140,7 @@ public class ColorPickerController extends AbstractEEFCustomWidgetController imp
new Eval(ColorPickerController.this.interpreter, variables).call(eAttribute, editExpression);
}
-
- @Override
- public boolean canExecute() {
- return true;
- }
- };
-
- Runnable runnable = new Runnable() {
- @Override
- public void run() {
- CommandStack commandStack = ColorPickerController.this.editingDomain.getCommandStack();
- commandStack.execute(command);
- }
- };
- runnable.run();
+ });
}
}
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 b5e6041e5..87a8e114c 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
@@ -20,10 +20,10 @@ import org.eclipse.eef.EEFWidgetDescription;
import org.eclipse.eef.EEFWidgetStyle;
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.emf.transaction.TransactionalEditingDomain;
import org.eclipse.sirius.common.interpreter.api.IInterpreter;
import org.eclipse.sirius.common.interpreter.api.IVariableManager;
import org.eclipse.swt.SWT;
@@ -74,12 +74,12 @@ public class ColorPickerLifecycleManager extends AbstractEEFWidgetLifecycleManag
* The variable manager
* @param interpreter
* The interpreter
- * @param editingDomain
- * The editing domain
+ * @param contextAdapter
+ * The editing context adapter
* @param singleReferenceViewerProvider
*/
- public ColorPickerLifecycleManager(EEFCustomWidgetDescription description, IVariableManager variableManager, IInterpreter interpreter, TransactionalEditingDomain editingDomain) {
- super(variableManager, interpreter, editingDomain);
+ public ColorPickerLifecycleManager(EEFCustomWidgetDescription description, IVariableManager variableManager, IInterpreter interpreter, EditingContextAdapter contextAdapter) {
+ super(variableManager, interpreter, contextAdapter);
this.description = description;
}
@@ -97,7 +97,7 @@ public class ColorPickerLifecycleManager extends AbstractEEFWidgetLifecycleManag
this.colorPicker.setLayoutData(formData);
- this.controller = new ColorPickerController(this.description, this.variableManager, this.interpreter, this.editingDomain);
+ this.controller = new ColorPickerController(this.description, this.variableManager, this.interpreter, this.contextAdapter);
}
/**
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 53ff07071..db28f13c1 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
@@ -11,9 +11,9 @@
package org.eclipse.eef.sample.custom.widget.colorpicker;
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.emf.transaction.TransactionalEditingDomain;
import org.eclipse.sirius.common.interpreter.api.IInterpreter;
import org.eclipse.sirius.common.interpreter.api.IVariableManager;
@@ -25,8 +25,7 @@ import org.eclipse.sirius.common.interpreter.api.IVariableManager;
public class ColorPickerProvider implements IEEFLifecycleManagerProvider {
@Override
- public ILifecycleManager getLifecycleManager(EEFCustomWidgetDescription customWidgetDescription, IVariableManager variableManager, IInterpreter interpreter,
- TransactionalEditingDomain editingDomain) {
- return new ColorPickerLifecycleManager(customWidgetDescription, variableManager, interpreter, editingDomain);
+ public ILifecycleManager getLifecycleManager(EEFCustomWidgetDescription customWidgetDescription, IVariableManager variableManager, IInterpreter interpreter, EditingContextAdapter contextAdapter) {
+ return new ColorPickerLifecycleManager(customWidgetDescription, variableManager, interpreter, contextAdapter);
}
}

Back to the top