Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcletavernie2012-02-29 12:47:49 +0000
committercletavernie2012-02-29 12:47:49 +0000
commitbddc13bbb5a8c6e252d111b89364e3e2814c5b67 (patch)
tree788c033b37d63ccfb99fbdc6c4eb5f70b56b4c11 /plugins
parent42593b3c1f703fb980ee56d9017db87a5fcaea20 (diff)
downloadorg.eclipse.papyrus-bddc13bbb5a8c6e252d111b89364e3e2814c5b67.tar.gz
org.eclipse.papyrus-bddc13bbb5a8c6e252d111b89364e3e2814c5b67.tar.xz
org.eclipse.papyrus-bddc13bbb5a8c6e252d111b89364e3e2814c5b67.zip
370797: [Theme] Papyrus should provide a support for CSS files on its diagrams
https://bugs.eclipse.org/bugs/show_bug.cgi?id=370797
Diffstat (limited to 'plugins')
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java24
-rw-r--r--plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableValue.java5
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/NotationHelper.java5
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF5
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi29
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AbstractCustomStyleListValueCommand.java84
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AbstractCustomStyleObservableValue.java114
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AddAllCustomStyleListValueCommand.java47
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AddCustomStyleListValueCommand.java44
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomBooleanStyleObservableList.java24
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomBooleanStyleObservableValue.java48
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomEObjectStyleObservableList.java25
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomEObjectStyleObservableValue.java49
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomIntStyleObservableList.java24
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomIntStyleObservableValue.java48
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStringStyleObservableList.java24
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStringStyleObservableValue.java48
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStyleListener.java134
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStyleObservableList.java148
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStyleValueCommand.java86
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/RemoveAllCustomStyleListValueCommand.java39
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/RemoveCustomStyleListValueCommand.java36
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/SetCustomStyleListValueCommand.java39
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/CustomStyleModelElement.java169
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/CustomStyleModelElementFactory.java38
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/NotationModelElementFactory.java23
-rw-r--r--plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ListHelper.java18
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/creation/StringEditionFactory.java10
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractListEditor.java14
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractValueEditor.java15
-rw-r--r--plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleStringEditor.java12
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/AbstractModelElement.java13
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/EMFModelElement.java6
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/AbstractPropertyEditor.java8
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/MultiString.java1
-rw-r--r--plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/ViewEditor.java8
36 files changed, 1409 insertions, 55 deletions
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java
index a94c345801a..dc2f6e4c1b2 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableList.java
@@ -18,7 +18,6 @@ import java.util.List;
import org.eclipse.core.databinding.observable.list.ObservableList;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
-import org.eclipse.emf.common.command.StrictCompoundCommand;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.edit.command.AddCommand;
@@ -98,7 +97,7 @@ public class EMFObservableList extends ObservableList implements ICommitListener
return;
}
- CompoundCommand compoundCommand = new StrictCompoundCommand() {
+ CompoundCommand compoundCommand = new CompoundCommand() {
@Override
public void execute() {
@@ -117,6 +116,19 @@ public class EMFObservableList extends ObservableList implements ICommitListener
super.redo();
refreshCacheList();
}
+
+ @Override
+ protected boolean prepare() {
+ if(commandList.isEmpty()) {
+ return false;
+ } else {
+ //We only test the first command, as the following ones might depend
+ //on the first command's execution. StrictCompoundCommands don't seem
+ //to be compatible with emf transaction (execute() is called by
+ //canExecute(), before the transaction is started)
+ return commandList.get(0).canExecute();
+ }
+ }
};
for(Command cmd : commands) {
@@ -131,6 +143,14 @@ public class EMFObservableList extends ObservableList implements ICommitListener
* Refresh the cached list by copying the real list
*/
protected void refreshCacheList() {
+ if(isDisposed()) {
+ //This observable can be disposed, but the commands might still be
+ //in the command stack. Undo() or Redo() will call this method, which
+ //should be ignored. The command should probably not call refresh directly ;
+ //we should have listeners on the concrete list... but it is not necessarily
+ //observable
+ return;
+ }
wrappedList.clear();
wrappedList.addAll(concreteList);
fireListChange(null);
diff --git a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableValue.java b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableValue.java
index 0bfe953ee4b..30f8d76208b 100644
--- a/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableValue.java
+++ b/plugins/infra/emf/org.eclipse.papyrus.infra.emf/src/org/eclipse/papyrus/infra/emf/databinding/EMFObservableValue.java
@@ -12,6 +12,7 @@
package org.eclipse.papyrus.infra.emf.databinding;
import org.eclipse.core.databinding.observable.Realm;
+import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.databinding.EObjectObservableValue;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
@@ -70,7 +71,7 @@ public class EMFObservableValue extends EObjectObservableValue {
value = eObject;
}
- SetCommand command = getSetCommand(value);
+ Command command = getSetCommand(value);
domain.getCommandStack().execute(command);
}
@@ -82,7 +83,7 @@ public class EMFObservableValue extends EObjectObservableValue {
* @return
* The Set command used to edit the value
*/
- protected SetCommand getSetCommand(Object value) {
+ protected Command getSetCommand(Object value) {
return new SetCommand(domain, eObject, eStructuralFeature, value);
}
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/NotationHelper.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/NotationHelper.java
index f771f3ffb4d..02048f7eb7d 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/NotationHelper.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.common/src/org/eclipse/papyrus/infra/gmfdiag/common/helper/NotationHelper.java
@@ -12,6 +12,7 @@
package org.eclipse.papyrus.infra.gmfdiag.common.helper;
import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.emf.ecore.EObject;
import org.eclipse.gmf.runtime.notation.View;
/**
@@ -38,6 +39,10 @@ public class NotationHelper {
if(adapter != null) {
return (View)adapter;
}
+ adapter = adaptable.getAdapter(EObject.class);
+ if(adapter instanceof View) {
+ return (View)adapter;
+ }
}
return null;
}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF
index 4632849b758..69252d4cbc2 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/META-INF/MANIFEST.MF
@@ -17,7 +17,8 @@ Require-Bundle: org.eclipse.ui,
org.eclipse.papyrus.infra.emf;bundle-version="0.9.0",
org.eclipse.papyrus.uml.tools;bundle-version="0.9.0",
org.eclipse.gmf.runtime.diagram.ui;bundle-version="1.5.0",
- org.eclipse.papyrus.infra.constraints;bundle-version="0.9.0"
+ org.eclipse.papyrus.infra.constraints;bundle-version="0.9.0",
+ org.eclipse.papyrus.infra.gmfdiag.common;bundle-version="0.9.0"
Bundle-Vendor: %Bundle-Vendor
Bundle-ActivationPolicy: lazy
Bundle-Version: 0.9.0.qualifier
@@ -26,3 +27,5 @@ Bundle-ManifestVersion: 2
Bundle-Activator: org.eclipse.papyrus.infra.gmfdiag.properties.Activator
Bundle-SymbolicName: org.eclipse.papyrus.infra.gmfdiag.properties;singleton:=true
Bundle-RequiredExecutionEnvironment: J2SE-1.5
+Export-Package: org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom,
+ org.eclipse.papyrus.infra.gmfdiag.properties.modelelement
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi
index 491515a84cd..89a03a34c7c 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi
@@ -1,12 +1,21 @@
<?xml version="1.0" encoding="ASCII"?>
-<environment:Environment xmi:version="2.0"
- xmlns:xmi="http://www.omg.org/XMI" xmlns:environment="http://www.eclipse.org/papyrus/properties/environment/0.9">
- <modelElementFactories name="GMF Notation"
- factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.NotationModelElementFactory" />
- <constraintTypes label="GMF Notation Constraint"
- constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.GMFNotationConstraint" />
- <constraintTypes label="HasEditPolicy"
- constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.HasEditPolicy" />
- <constraintTypes label="isGMFEditPart"
- constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.IsEditPartConstraint" />
+<environment:Environment
+ xmi:version="2.0"
+ xmlns:xmi="http://www.omg.org/XMI"
+ xmlns:environment="http://www.eclipse.org/papyrus/properties/environment/0.9">
+ <constraintTypes
+ label="GMF Notation Constraint"
+ constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.GMFNotationConstraint"/>
+ <constraintTypes
+ label="HasEditPolicy"
+ constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.HasEditPolicy"/>
+ <constraintTypes
+ label="isGMFEditPart"
+ constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.IsEditPartConstraint"/>
+ <modelElementFactories
+ name="GMF Notation"
+ factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.NotationModelElementFactory"/>
+ <modelElementFactories
+ name="GMF Custom Style"
+ factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.CustomStyleModelElementFactory"/>
</environment:Environment>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AbstractCustomStyleListValueCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AbstractCustomStyleListValueCommand.java
new file mode 100644
index 00000000000..4ca1b9037fb
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AbstractCustomStyleListValueCommand.java
@@ -0,0 +1,84 @@
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import org.eclipse.emf.common.command.AbstractCommand;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.NamedStyle;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
+import org.eclipse.gmf.runtime.notation.View;
+
+
+public abstract class AbstractCustomStyleListValueCommand extends AbstractCommand {
+
+ protected View view;
+
+ protected EClass styleClass;
+
+ protected String styleName;
+
+ protected boolean needsCreate;
+
+ protected EStructuralFeature styleFeature;
+
+ protected EditingDomain domain;
+
+ protected Command command;
+
+ protected NamedStyle style;
+
+ public AbstractCustomStyleListValueCommand(EditingDomain domain, View view, String styleName, EClass styleClass, EStructuralFeature styleFeature) {
+ this.view = view;
+ this.styleName = styleName;
+ this.styleClass = styleClass;
+ this.styleFeature = styleFeature;
+ this.domain = domain;
+ }
+
+ public void execute() {
+ //FIXME: Related to CompoundCommand vs StrictCompoundCommand.
+ //Sometimes, canExecute() is not called, and the command is not prepared
+ if(!isPrepared) {
+ prepare();
+ isPrepared = true;
+ }
+
+ if(needsCreate) {
+ view.getStyles().add(style);
+ }
+ command.execute();
+ }
+
+ public void redo() {
+ execute();
+ }
+
+ @Override
+ public boolean prepare() {
+ style = view.getNamedStyle(styleClass, styleName);
+
+ if(needsCreate = (style == null)) {
+ style = (NamedStyle)NotationFactory.eINSTANCE.create(styleClass);
+ style.setName(styleName);
+ }
+
+ command = createCommand();
+
+ // return true;
+ return command.canExecute();
+ }
+
+ protected abstract Command createCommand();
+
+ @Override
+ public void undo() {
+ EList currentList = (EList)(style.eGet(styleFeature));
+ command.undo();
+ if(needsCreate) {
+ view.getStyles().remove(style);
+ }
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AbstractCustomStyleObservableValue.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AbstractCustomStyleObservableValue.java
new file mode 100644
index 00000000000..42838376495
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AbstractCustomStyleObservableValue.java
@@ -0,0 +1,114 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
+import org.eclipse.core.databinding.observable.value.AbstractObservableValue;
+import org.eclipse.core.databinding.observable.value.ValueDiff;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.NamedStyle;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.uml.tools.databinding.CommandBasedObservableValue;
+
+/**
+ * Abstract implementation for an ObservableValue associated to a GMF custom
+ * style (NamedStyle).
+ *
+ * @author Camille Letavernier
+ *
+ */
+public abstract class AbstractCustomStyleObservableValue extends AbstractObservableValue implements CommandBasedObservableValue, IChangeListener {
+
+ protected View source;
+
+ protected EditingDomain domain;
+
+ protected String styleName;
+
+ protected Object lastValue;
+
+ protected CustomStyleListener listener;
+
+ protected EClass styleClass;
+
+ protected EStructuralFeature styleFeature;
+
+ public AbstractCustomStyleObservableValue(View source, EditingDomain domain, String styleName, EClass styleClass, EStructuralFeature styleFeature) {
+ this.source = source;
+ this.domain = domain;
+ this.styleName = styleName;
+ this.styleClass = styleClass;
+ this.styleFeature = styleFeature;
+ source.eAdapters().add(listener = new CustomStyleListener(source, styleFeature, this, styleName));
+ }
+
+ public void handleChange(ChangeEvent event) {
+
+ final Object oldValue = lastValue;
+ final Object newValue = doGetValue();
+
+ fireValueChange(new ValueDiff() {
+
+ @Override
+ public Object getOldValue() {
+ return oldValue;
+ }
+
+ @Override
+ public Object getNewValue() {
+ return newValue;
+ }
+
+ });
+ }
+
+ @Override
+ protected Object doGetValue() {
+ NamedStyle valueStyle = source.getNamedStyle(styleClass, styleName);
+ if(valueStyle != null) {
+ lastValue = valueStyle.eGet(styleFeature);
+ } else {
+ lastValue = getDefaultValue();
+ }
+ return lastValue;
+ }
+
+ /**
+ * Gets the default value when this style is not set.
+ *
+ * @return The default value for this NamedStyle
+ */
+ protected abstract Object getDefaultValue();
+
+ @Override
+ protected void doSetValue(Object value) {
+ Command command = getCommand(value);
+ domain.getCommandStack().execute(command);
+ doGetValue(); //Refresh the lastValue
+ }
+
+ public Command getCommand(Object value) {
+ return new CustomStyleValueCommand(source, value, styleClass, styleFeature, styleName);
+ }
+
+ @Override
+ public void dispose() {
+ source.eAdapters().remove(listener);
+ listener.dispose();
+ listener = null;
+ super.dispose();
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AddAllCustomStyleListValueCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AddAllCustomStyleListValueCommand.java
new file mode 100644
index 00000000000..cb4bfdefb9b
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AddAllCustomStyleListValueCommand.java
@@ -0,0 +1,47 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.CommandParameter;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.View;
+
+
+public class AddAllCustomStyleListValueCommand extends AbstractCustomStyleListValueCommand {
+
+ protected int index = CommandParameter.NO_INDEX;
+
+ protected Collection<?> values;
+
+ protected Command command;
+
+ public AddAllCustomStyleListValueCommand(EditingDomain domain, View view, String styleName, EClass styleClass, EStructuralFeature styleFeature, Collection<?> values, int index) {
+ super(domain, view, styleName, styleClass, styleFeature);
+ this.index = index;
+ this.values = values;
+ }
+
+ public AddAllCustomStyleListValueCommand(EditingDomain domain, View view, String styleName, EClass styleClass, EStructuralFeature feature, Collection<?> values) {
+ this(domain, view, styleName, styleClass, feature, values, CommandParameter.NO_INDEX);
+ }
+
+ @Override
+ protected Command createCommand() {
+ return AddCommand.create(domain, style, styleFeature, values, index);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AddCustomStyleListValueCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AddCustomStyleListValueCommand.java
new file mode 100644
index 00000000000..9ea23b3bb0c
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/AddCustomStyleListValueCommand.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.AddCommand;
+import org.eclipse.emf.edit.command.CommandParameter;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.View;
+
+
+public class AddCustomStyleListValueCommand extends AbstractCustomStyleListValueCommand {
+
+ protected int index = CommandParameter.NO_INDEX;
+
+ protected Object value;
+
+ public AddCustomStyleListValueCommand(EditingDomain domain, View view, String styleName, EClass styleClass, EStructuralFeature styleFeature, Object value, int index) {
+ super(domain, view, styleName, styleClass, styleFeature);
+ this.index = index;
+ this.value = value;
+ }
+
+ public AddCustomStyleListValueCommand(EditingDomain domain, View view, String styleName, EClass styleClass, EStructuralFeature styleFeature, Object value) {
+ this(domain, view, styleName, styleClass, styleFeature, value, CommandParameter.NO_INDEX);
+ }
+
+ @Override
+ protected Command createCommand() {
+ return AddCommand.create(domain, style, styleFeature, value, index);
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomBooleanStyleObservableList.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomBooleanStyleObservableList.java
new file mode 100644
index 00000000000..40d8555196f
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomBooleanStyleObservableList.java
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+
+public class CustomBooleanStyleObservableList extends CustomStyleObservableList {
+
+ public CustomBooleanStyleObservableList(View view, EditingDomain domain, String styleName) {
+ super(view, styleName, domain, NotationPackage.eINSTANCE.getBooleanListValueStyle(), NotationPackage.eINSTANCE.getBooleanListValueStyle_BooleanListValue());
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomBooleanStyleObservableValue.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomBooleanStyleObservableValue.java
new file mode 100644
index 00000000000..007625bfea6
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomBooleanStyleObservableValue.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+
+
+public class CustomBooleanStyleObservableValue extends AbstractCustomStyleObservableValue {
+
+ public CustomBooleanStyleObservableValue(View source, EditingDomain domain, String styleName) {
+ super(source, domain, styleName, NotationPackage.eINSTANCE.getBooleanValueStyle(), NotationPackage.eINSTANCE.getBooleanValueStyle_BooleanValue());
+ }
+
+ public Object getValueType() {
+ return Boolean.class;
+ }
+
+ /**
+ * Gets the default value when this style is not set.
+ * Subclasses may override
+ *
+ * @return The default value for this BooleanStyleValue
+ */
+ @Override
+ protected Boolean getDefaultValue() {
+ return false;
+ }
+
+ @Override
+ public Command getCommand(Object value) {
+ if(value instanceof Boolean) {
+ return super.getCommand(value);
+ }
+ throw new IllegalArgumentException("The value " + value + " is not a valid Boolean Value");
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomEObjectStyleObservableList.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomEObjectStyleObservableList.java
new file mode 100644
index 00000000000..eb18e625667
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomEObjectStyleObservableList.java
@@ -0,0 +1,25 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+
+public class CustomEObjectStyleObservableList extends CustomStyleObservableList {
+
+ //TODO: The super class is probably powerful enough to handle EObjects.
+ public CustomEObjectStyleObservableList(View view, EditingDomain domain, String styleName) {
+ super(view, styleName, domain, NotationPackage.eINSTANCE.getEObjectListValueStyle(), NotationPackage.eINSTANCE.getEObjectListValueStyle_EObjectListValue());
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomEObjectStyleObservableValue.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomEObjectStyleObservableValue.java
new file mode 100644
index 00000000000..15513e59f37
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomEObjectStyleObservableValue.java
@@ -0,0 +1,49 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+
+
+public class CustomEObjectStyleObservableValue extends AbstractCustomStyleObservableValue {
+
+ public CustomEObjectStyleObservableValue(View source, EditingDomain domain, String styleName) {
+ super(source, domain, styleName, NotationPackage.eINSTANCE.getEObjectValueStyle(), NotationPackage.eINSTANCE.getEObjectValueStyle_EObjectValue());
+ }
+
+ public Object getValueType() {
+ return EObject.class;
+ }
+
+ /**
+ * Gets the default value when this style is not set.
+ * Subclasses may override
+ *
+ * @return The default value for this EObjectStyleValue
+ */
+ @Override
+ protected EObject getDefaultValue() {
+ return null;
+ }
+
+ @Override
+ public Command getCommand(Object value) {
+ if(value instanceof EObject) {
+ return super.getCommand(value);
+ }
+ throw new IllegalArgumentException("The value " + value + " is not a valid EObject Value");
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomIntStyleObservableList.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomIntStyleObservableList.java
new file mode 100644
index 00000000000..5db23b5b195
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomIntStyleObservableList.java
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+
+public class CustomIntStyleObservableList extends CustomStyleObservableList {
+
+ public CustomIntStyleObservableList(View view, EditingDomain domain, String styleName) {
+ super(view, styleName, domain, NotationPackage.eINSTANCE.getIntListValueStyle(), NotationPackage.eINSTANCE.getIntListValueStyle_IntListValue());
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomIntStyleObservableValue.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomIntStyleObservableValue.java
new file mode 100644
index 00000000000..2443e8136b2
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomIntStyleObservableValue.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+
+
+public class CustomIntStyleObservableValue extends AbstractCustomStyleObservableValue {
+
+ public CustomIntStyleObservableValue(View source, EditingDomain domain, String styleName) {
+ super(source, domain, styleName, NotationPackage.eINSTANCE.getIntValueStyle(), NotationPackage.eINSTANCE.getIntValueStyle_IntValue());
+ }
+
+ public Object getValueType() {
+ return Integer.class;
+ }
+
+ /**
+ * Gets the default value when this style is not set.
+ * Subclasses may override
+ *
+ * @return The default value for this IntegerStyleValue
+ */
+ @Override
+ protected Integer getDefaultValue() {
+ return 0;
+ }
+
+ @Override
+ public Command getCommand(Object value) {
+ if(value instanceof Integer) {
+ return super.getCommand(value);
+ }
+ throw new IllegalArgumentException("The value " + value + " is not a valid Integer Value");
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStringStyleObservableList.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStringStyleObservableList.java
new file mode 100644
index 00000000000..84dc817e020
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStringStyleObservableList.java
@@ -0,0 +1,24 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+
+public class CustomStringStyleObservableList extends CustomStyleObservableList {
+
+ public CustomStringStyleObservableList(View view, EditingDomain domain, String styleName) {
+ super(view, styleName, domain, NotationPackage.eINSTANCE.getStringListValueStyle(), NotationPackage.eINSTANCE.getStringListValueStyle_StringListValue());
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStringStyleObservableValue.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStringStyleObservableValue.java
new file mode 100644
index 00000000000..f4d32f89dd2
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStringStyleObservableValue.java
@@ -0,0 +1,48 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+
+
+public class CustomStringStyleObservableValue extends AbstractCustomStyleObservableValue {
+
+ public CustomStringStyleObservableValue(View source, EditingDomain domain, String styleName) {
+ super(source, domain, styleName, NotationPackage.eINSTANCE.getStringValueStyle(), NotationPackage.eINSTANCE.getStringValueStyle_StringValue());
+ }
+
+ public Object getValueType() {
+ return String.class;
+ }
+
+ /**
+ * Gets the default value when this style is not set.
+ * Subclasses may override
+ *
+ * @return The default value for this StringStyleValue
+ */
+ @Override
+ protected String getDefaultValue() {
+ return ""; //$NON-NLS-1$
+ }
+
+ @Override
+ public Command getCommand(Object value) {
+ if(value instanceof String) {
+ return super.getCommand(value);
+ }
+ throw new IllegalArgumentException("The value " + value + " is not a valid String Value");
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStyleListener.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStyleListener.java
new file mode 100644
index 00000000000..6a0019a16b4
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStyleListener.java
@@ -0,0 +1,134 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import java.util.List;
+
+import org.eclipse.core.databinding.observable.IChangeListener;
+import org.eclipse.emf.common.notify.Adapter;
+import org.eclipse.emf.common.notify.Notification;
+import org.eclipse.emf.common.notify.Notifier;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.notation.NamedStyle;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+
+
+public class CustomStyleListener implements Adapter {
+
+ private Notifier target;
+
+ private String styleName;
+
+ private IChangeListener listener;
+
+ private boolean disposed;
+
+ private View source;
+
+ private EStructuralFeature listenedFeature;
+
+ public CustomStyleListener(View source, EStructuralFeature listenedFeature, IChangeListener listener, String styleName) {
+ this.styleName = styleName;
+ this.listener = listener;
+ this.source = source;
+ this.listenedFeature = listenedFeature;
+ for(Object styleObject : source.getStyles()) {
+ if(styleObject instanceof NamedStyle) {
+ NamedStyle style = (NamedStyle)styleObject;
+ if(styleName.equals(style.getName())) {
+ //FIXME: If a style's name is change, we won't be notified. We should probably listen on all styles
+ style.eAdapters().add(this);
+ }
+ }
+ }
+ }
+
+ public void notifyChanged(Notification notification) {
+ if(disposed) {
+ ((Notifier)notification.getNotifier()).eAdapters().remove(this);
+ return;
+ }
+
+ if(notification.getFeature() == NotationPackage.eINSTANCE.getView_Styles()) {
+ switch(notification.getEventType()) {
+ case Notification.ADD:
+ handleAdd((EObject)notification.getNewValue());
+ break;
+ case Notification.ADD_MANY:
+ for(Object object : (List<?>)notification.getNewValue()) {
+ handleAdd((EObject)object);
+ }
+ break;
+ case Notification.REMOVE:
+ handleRemove((EObject)notification.getOldValue());
+ break;
+ case Notification.REMOVE_MANY:
+ for(Object object : (List<?>)notification.getOldValue()) {
+ handleRemove((EObject)object);
+ }
+ break;
+ }
+ }
+
+ if(notification.getFeature() == listenedFeature) {
+ if(notification.getNotifier() instanceof NamedStyle && styleName.equals(((NamedStyle)notification.getNotifier()).getName())) {
+ if(!notification.isTouch()) {
+ listener.handleChange(null);
+ }
+ }
+ }
+ }
+
+ private void handleRemove(EObject oldValue) {
+ oldValue.eAdapters().remove(this);
+ handleChange(oldValue);
+ }
+
+ private void handleAdd(EObject newValue) {
+ newValue.eAdapters().add(this);
+ handleChange(newValue);
+ }
+
+ private void handleChange(EObject value) {
+ if(value instanceof NamedStyle) {
+ if(styleName.equals(((NamedStyle)value).getName())) {
+ listener.handleChange(null);
+ return;
+ }
+ }
+ }
+
+ public Notifier getTarget() {
+ return target;
+ }
+
+ public void setTarget(Notifier newTarget) {
+ if(disposed) {
+ return;
+ }
+ this.target = newTarget;
+ }
+
+ public boolean isAdapterForType(Object type) {
+ return false;
+ }
+
+ public void dispose() {
+ this.disposed = true;
+ listener = null;
+ target = null;
+ source = null;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStyleObservableList.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStyleObservableList.java
new file mode 100644
index 00000000000..3b044c8923c
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStyleObservableList.java
@@ -0,0 +1,148 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import java.util.Collection;
+
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
+import org.eclipse.core.databinding.observable.list.IObservableList;
+import org.eclipse.core.databinding.observable.list.WritableList;
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.databinding.EMFProperties;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.NamedStyle;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.emf.databinding.EMFObservableList;
+import org.eclipse.papyrus.infra.widgets.editors.AbstractEditor;
+
+
+public class CustomStyleObservableList extends EMFObservableList implements IChangeListener {
+
+ protected EClass eClass;
+
+ protected EStructuralFeature feature;
+
+ protected String styleName;
+
+ protected View view;
+
+ protected EditingDomain domain;
+
+ protected CustomStyleListener listener;
+
+ protected boolean styleExists;
+
+ protected boolean changing = false;
+
+ //Equals to concreteList
+ protected IObservableList observableConcreteList;
+
+ // protected final List<?> transientList;
+
+ public CustomStyleObservableList(View view, String styleName, EditingDomain domain, EClass eClass, EStructuralFeature feature) {
+ super(getWrappedList(view, styleName, eClass, feature), domain, null, null);
+ this.eClass = eClass;
+ this.feature = feature;
+ this.styleName = styleName;
+ this.view = view;
+ this.domain = domain;
+ observableConcreteList = (IObservableList)concreteList;
+ styleExists = isStyleCreated();
+
+ view.eAdapters().add(listener = new CustomStyleListener(view, feature, this, styleName));
+ }
+
+ @Override
+ public void commit(AbstractEditor editor) {
+ changing = true;
+ super.commit(editor);
+ changing = false;
+ }
+
+ private boolean isStyleCreated() {
+ return view.getNamedStyle(eClass, styleName) != null;
+ }
+
+ private static IObservableList getWrappedList(View view, String styleName, EClass eClass, EStructuralFeature feature) {
+ NamedStyle style = view.getNamedStyle(eClass, styleName);
+
+ if(style != null) {
+ return EMFProperties.list(feature).observe(style);
+ }
+
+ //The style doesn't exist yet, we need to simulate it
+ //(With an empty list)
+ return new WritableList();
+ }
+
+ @Override
+ public Command getAddCommand(int index, Object value) {
+ return new AddCustomStyleListValueCommand(domain, view, styleName, eClass, feature, value, index);
+ }
+
+ @Override
+ public Command getAddCommand(Object value) {
+ return new AddCustomStyleListValueCommand(domain, view, styleName, eClass, feature, value);
+ }
+
+ @Override
+ public Command getAddAllCommand(Collection<?> values) {
+ return new AddAllCustomStyleListValueCommand(domain, view, styleName, eClass, feature, values);
+ }
+
+ @Override
+ public Command getAddAllCommand(int index, Collection<?> values) {
+ return new AddCustomStyleListValueCommand(domain, view, styleName, eClass, feature, values, index);
+ }
+
+ @Override
+ public Command getRemoveCommand(Object value) {
+ return new RemoveCustomStyleListValueCommand(domain, view, styleName, eClass, feature, value);
+ }
+
+ @Override
+ public Command getRemoveAllCommand(Collection<?> values) {
+ return new RemoveAllCustomStyleListValueCommand(domain, view, styleName, eClass, feature, values);
+ }
+
+ @Override
+ public Command getSetCommand(int index, Object value) {
+ return new SetCustomStyleListValueCommand(domain, view, styleName, eClass, feature, index, value);
+ }
+
+ public void handleChange(ChangeEvent event) {
+ //If the ListValueStyle has been created or removed, we need to resync
+ //the concrete list with it
+ if(styleExists != (styleExists = isStyleCreated())) {
+ observableConcreteList.dispose();
+ concreteList = observableConcreteList = getWrappedList(view, styleName, eClass, feature);
+ }
+
+ //If this observable is not the source of the change, the wrapped
+ //list should also be refreshed.
+ if(!changing) {
+ refreshCacheList();
+ }
+ }
+
+ @Override
+ public void dispose() {
+ view.eAdapters().remove(listener);
+ listener.dispose();
+ listener = null;
+ observableConcreteList.dispose();
+ super.dispose();
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStyleValueCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStyleValueCommand.java
new file mode 100644
index 00000000000..ab1dce124e1
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/CustomStyleValueCommand.java
@@ -0,0 +1,86 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import org.eclipse.emf.common.command.AbstractCommand;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.gmf.runtime.notation.NamedStyle;
+import org.eclipse.gmf.runtime.notation.NotationFactory;
+import org.eclipse.gmf.runtime.notation.View;
+
+public class CustomStyleValueCommand extends AbstractCommand {
+
+ private boolean createStyle;
+
+ private Object value;
+
+ private Object oldValue;
+
+ private EClass styleClass;
+
+ private View view;
+
+ private String styleName;
+
+ private EStructuralFeature styleFeature;
+
+ public CustomStyleValueCommand(View view, Object value, EClass styleClass, EStructuralFeature styleFeature, String styleName) {
+ this.value = value;
+ this.styleClass = styleClass;
+ this.view = view;
+ this.styleName = styleName;
+ this.styleFeature = styleFeature;
+ }
+
+ public void execute() {
+ NamedStyle valueStyle = view.getNamedStyle(styleClass, styleName);
+ createStyle = valueStyle == null;
+ if(createStyle) {
+ valueStyle = createStyle();
+ System.out.println("Create a new " + styleClass.getName());
+ } else {
+ oldValue = valueStyle.eGet(styleFeature);
+ }
+
+ valueStyle.eSet(styleFeature, value);
+ if(createStyle) {
+ view.getStyles().add(valueStyle);
+ }
+ }
+
+ protected NamedStyle createStyle() {
+ NamedStyle result = (NamedStyle)NotationFactory.eINSTANCE.create(styleClass);
+ result.setName(styleName);
+ return result;
+ }
+
+ public void redo() {
+ execute();
+ }
+
+ @Override
+ public void undo() {
+ NamedStyle valueStyle = view.getNamedStyle(styleClass, styleName);;
+ if(createStyle) {
+ view.getStyles().remove(valueStyle);
+ System.out.println("Remove the new " + styleClass.getName());
+ } else {
+ valueStyle.eSet(styleFeature, oldValue);
+ }
+ }
+
+ @Override
+ public boolean prepare() {
+ return true;
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/RemoveAllCustomStyleListValueCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/RemoveAllCustomStyleListValueCommand.java
new file mode 100644
index 00000000000..a1813377652
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/RemoveAllCustomStyleListValueCommand.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import java.util.Collection;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.View;
+
+
+public class RemoveAllCustomStyleListValueCommand extends AbstractCustomStyleListValueCommand {
+
+ protected Collection<?> values;
+
+ public RemoveAllCustomStyleListValueCommand(EditingDomain domain, View view, String styleName, EClass eClass, EStructuralFeature feature, Collection<?> values) {
+ super(domain, view, styleName, eClass, feature);
+ this.values = values;
+ }
+
+ @Override
+ protected Command createCommand() {
+ return RemoveCommand.create(domain, style, styleFeature, values);
+ }
+
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/RemoveCustomStyleListValueCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/RemoveCustomStyleListValueCommand.java
new file mode 100644
index 00000000000..22adf4ae199
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/RemoveCustomStyleListValueCommand.java
@@ -0,0 +1,36 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.RemoveCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.View;
+
+
+public class RemoveCustomStyleListValueCommand extends AbstractCustomStyleListValueCommand {
+
+ protected Object value;
+
+ public RemoveCustomStyleListValueCommand(EditingDomain domain, View view, String styleName, EClass eClass, EStructuralFeature feature, Object value) {
+ super(domain, view, styleName, eClass, feature);
+ this.value = value;
+ }
+
+ @Override
+ protected Command createCommand() {
+ return RemoveCommand.create(domain, style, styleFeature, value);
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/SetCustomStyleListValueCommand.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/SetCustomStyleListValueCommand.java
new file mode 100644
index 00000000000..6e9df507e7d
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/databinding/custom/SetCustomStyleListValueCommand.java
@@ -0,0 +1,39 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom;
+
+import org.eclipse.emf.common.command.Command;
+import org.eclipse.emf.ecore.EClass;
+import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.edit.command.SetCommand;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.View;
+
+
+public class SetCustomStyleListValueCommand extends AbstractCustomStyleListValueCommand {
+
+ private int index;
+
+ private Object value;
+
+ public SetCustomStyleListValueCommand(EditingDomain domain, View view, String styleName, EClass eClass, EStructuralFeature feature, int index, Object value) {
+ super(domain, view, styleName, eClass, feature);
+ this.index = index;
+ this.value = value;
+ }
+
+ @Override
+ protected Command createCommand() {
+ return SetCommand.create(domain, style, styleFeature, value, index);
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/CustomStyleModelElement.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/CustomStyleModelElement.java
new file mode 100644
index 00000000000..6b2f340f712
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/CustomStyleModelElement.java
@@ -0,0 +1,169 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement;
+
+import org.eclipse.core.databinding.observable.IObservable;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.jface.viewers.ILabelProvider;
+import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom.CustomBooleanStyleObservableList;
+import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom.CustomBooleanStyleObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom.CustomEObjectStyleObservableList;
+import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom.CustomEObjectStyleObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom.CustomIntStyleObservableList;
+import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom.CustomIntStyleObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom.CustomStringStyleObservableList;
+import org.eclipse.papyrus.infra.gmfdiag.properties.databinding.custom.CustomStringStyleObservableValue;
+import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
+import org.eclipse.papyrus.infra.widgets.creation.StringEditionFactory;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
+import org.eclipse.papyrus.views.properties.contexts.Property;
+import org.eclipse.papyrus.views.properties.environment.Type;
+import org.eclipse.papyrus.views.properties.modelelement.EMFModelElement;
+
+
+public class CustomStyleModelElement extends EMFModelElement {
+
+ private DataContextElement element;
+
+ //this.view == super.source
+ private View view;
+
+ public CustomStyleModelElement(View source, DataContextElement context) {
+ this(source, null, context);
+ }
+
+ public CustomStyleModelElement(View source, EditingDomain domain, DataContextElement element) {
+ super(source, domain);
+ this.element = element;
+ this.view = source;
+ }
+
+ protected Property findProperty(String propertyPath) {
+ for(Property property : element.getProperties()) {
+ if(propertyPath.equals(property.getName())) {
+ return property;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public IObservable doGetObservable(String propertyPath) {
+ Property property = findProperty(propertyPath);
+ if(property == null) {
+ return null;
+ }
+ if(property.getMultiplicity() == 1) {
+ switch(property.getType()) {
+ case BOOLEAN:
+ return new CustomBooleanStyleObservableValue(view, domain, propertyPath);
+ case INTEGER:
+ return new CustomIntStyleObservableValue(view, domain, propertyPath);
+ case REFERENCE:
+ return new CustomEObjectStyleObservableValue(view, domain, propertyPath);
+ case STRING:
+ return new CustomStringStyleObservableValue(view, domain, propertyPath);
+ default:
+ return null;
+ }
+ } else {
+ switch(property.getType()) {
+ case BOOLEAN:
+ return new CustomBooleanStyleObservableList(view, domain, propertyPath);
+ case INTEGER:
+ return new CustomIntStyleObservableList(view, domain, propertyPath);
+ case REFERENCE:
+ return new CustomEObjectStyleObservableList(view, domain, propertyPath);
+ case STRING:
+ return new CustomStringStyleObservableList(view, domain, propertyPath);
+ default:
+ return null;
+ }
+ }
+ }
+
+ @Override
+ public boolean isEditable(String propertyPath) {
+ return findProperty(propertyPath) != null;
+ }
+
+
+ //TODO: Implement these methods for multivalued properties (XxxListStyle)
+
+ @Override
+ public IStaticContentProvider getContentProvider(String propertyPath) {
+ return super.getContentProvider(propertyPath);
+ }
+
+ @Override
+ public ILabelProvider getLabelProvider(String propertyPath) {
+ return super.getLabelProvider(propertyPath);
+ }
+
+ @Override
+ public boolean isOrdered(String propertyPath) {
+ return true;
+ }
+
+ @Override
+ public boolean isUnique(String propertyPath) {
+ return false;
+ }
+
+ @Override
+ public boolean isMandatory(String propertyPath) {
+ return false;
+ }
+
+ @Override
+ public boolean forceRefresh(String propertyPath) {
+ return false;
+ }
+
+ @Override
+ public ReferenceValueFactory getValueFactory(String propertyPath) {
+ Property property = findProperty(propertyPath);
+ if(property == null) {
+ return null;
+ }
+
+ switch(property.getType()) {
+ case STRING:
+ return new StringEditionFactory();
+ case INTEGER:
+ case BOOLEAN:
+ return null;
+ case REFERENCE:
+ return null;
+ default:
+ return null;
+ }
+ }
+
+ @Override
+ public Object getDefaultValue(String propertyPath) {
+ return null;
+ }
+
+ @Override
+ public boolean getDirectCreation(String propertyPath) {
+ Property property = findProperty(propertyPath);
+ if(property == null) {
+ return false;
+ }
+
+ return property.getType() != Type.REFERENCE;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/CustomStyleModelElementFactory.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/CustomStyleModelElementFactory.java
new file mode 100644
index 00000000000..87769b7b6d4
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/CustomStyleModelElementFactory.java
@@ -0,0 +1,38 @@
+/*****************************************************************************
+ * Copyright (c) 2012 CEA LIST.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Camille Letavernier (CEA LIST) camille.letavernier@cea.fr - Initial API and implementation
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement;
+
+import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
+import org.eclipse.emf.edit.domain.EditingDomain;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper;
+import org.eclipse.papyrus.infra.gmfdiag.properties.Activator;
+import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
+import org.eclipse.papyrus.views.properties.modelelement.ModelElement;
+import org.eclipse.papyrus.views.properties.modelelement.ModelElementFactory;
+
+
+public class CustomStyleModelElementFactory implements ModelElementFactory {
+
+ public ModelElement createFromSource(Object sourceElement, DataContextElement context) {
+ View view = NotationHelper.findView(sourceElement);
+
+ if(view != null) {
+ EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(view);
+ return new CustomStyleModelElement(view, domain, context);
+ }
+
+ Activator.log.warn("The selected element cannot be resolved to a GMF View");
+ return null;
+ }
+
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/NotationModelElementFactory.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/NotationModelElementFactory.java
index 9d04e7fb594..5bcd44621e2 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/NotationModelElementFactory.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/NotationModelElementFactory.java
@@ -11,13 +11,12 @@
*****************************************************************************/
package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement;
-import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.edit.domain.AdapterFactoryEditingDomain;
import org.eclipse.emf.edit.domain.EditingDomain;
-import org.eclipse.gef.EditPart;
import org.eclipse.gmf.runtime.notation.View;
import org.eclipse.gmf.runtime.notation.datatype.GradientData;
-import org.eclipse.papyrus.infra.emf.utils.EMFHelper;
+import org.eclipse.papyrus.infra.gmfdiag.common.helper.NotationHelper;
+import org.eclipse.papyrus.infra.gmfdiag.properties.Activator;
import org.eclipse.papyrus.views.properties.contexts.DataContextElement;
import org.eclipse.papyrus.views.properties.modelelement.ModelElement;
import org.eclipse.papyrus.views.properties.modelelement.ModelElementFactory;
@@ -31,29 +30,17 @@ public class NotationModelElementFactory implements ModelElementFactory {
public ModelElement createFromSource(Object sourceElement, DataContextElement context) {
- View view = null;
-
- if(sourceElement instanceof EditPart) {
- EditPart part = (EditPart)sourceElement;
- Object model = part.getModel();
-
- if(model instanceof View) {
- view = (View)model;
- }
- } else if(sourceElement instanceof GradientData) {
+ if(sourceElement instanceof GradientData) {
return new GradientDataModelElement((GradientData)sourceElement);
- } else {
- EObject eObject = EMFHelper.getEObject(sourceElement);
- if(eObject instanceof View) {
- view = (View)eObject;
- }
}
+ View view = NotationHelper.findView(sourceElement);
if(view != null) {
EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(view);
return new GMFModelElement(view, domain);
}
+ Activator.log.warn("The selected element cannot be resolved to a GMF View");
return null;
}
diff --git a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ListHelper.java b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ListHelper.java
index 196a7e346bf..ae55a0d1565 100644
--- a/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ListHelper.java
+++ b/plugins/infra/org.eclipse.papyrus.infra.tools/src/org/eclipse/papyrus/infra/tools/util/ListHelper.java
@@ -38,4 +38,22 @@ public class ListHelper {
}
return result;
}
+
+ public static String deepToString(List<?> list) {
+ return deepToString(list, ", ");
+ }
+
+ public static String deepToString(List<?> list, String separator) {
+ boolean firstElement = true;
+ String result = "";
+ for(Object item : list) {
+ if(firstElement) {
+ firstElement = false;
+ } else {
+ result += separator;
+ }
+ result += item == null ? null : item.toString();
+ }
+ return result;
+ }
}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/creation/StringEditionFactory.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/creation/StringEditionFactory.java
index bd82e1940a1..48b4f5a4f9a 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/creation/StringEditionFactory.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/creation/StringEditionFactory.java
@@ -83,10 +83,18 @@ public class StringEditionFactory implements ReferenceValueFactory {
}
public boolean canCreateObject() {
- return false;
+ return true;
}
public Object createObject(Control widget) {
+ InputDialog dialog = new InputDialog(widget.getShell(), title, label, "", validator); //$NON-NLS-1$
+
+ int result = dialog.open();
+ if(result == Window.OK) {
+ String newValue = dialog.getText();
+ return newValue;
+ }
+
return null;
}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractListEditor.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractListEditor.java
index f91c35bdb5e..c8d598a3c15 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractListEditor.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractListEditor.java
@@ -13,7 +13,12 @@ package org.eclipse.papyrus.infra.widgets.editors;
import org.eclipse.core.databinding.UpdateListStrategy;
import org.eclipse.core.databinding.conversion.IConverter;
+import org.eclipse.core.databinding.observable.ChangeEvent;
+import org.eclipse.core.databinding.observable.IChangeListener;
import org.eclipse.core.databinding.observable.list.IObservableList;
+import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.papyrus.infra.widgets.Activator;
import org.eclipse.swt.widgets.Composite;
/**
@@ -141,5 +146,14 @@ public abstract class AbstractListEditor extends AbstractEditor {
}
binding = getBindingContext().bindList(widgetObservable, modelProperty, targetToModelStrategy, modelToTargetStrategy);
+ binding.getValidationStatus().addChangeListener(new IChangeListener() {
+
+ public void handleChange(ChangeEvent event) {
+ Status status = (Status)((IObservableValue)event.getObservable()).getValue();
+ if(status.getSeverity() != Status.OK) {
+ Activator.log.error("Binding error (" + status.getSeverity() + ") : " + status.getMessage(), status.getException());
+ }
+ }
+ });
}
}
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractValueEditor.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractValueEditor.java
index 016ca92ca9a..d2a8df94857 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractValueEditor.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/AbstractValueEditor.java
@@ -16,6 +16,8 @@ import org.eclipse.core.databinding.conversion.IConverter;
import org.eclipse.core.databinding.observable.ChangeEvent;
import org.eclipse.core.databinding.observable.IChangeListener;
import org.eclipse.core.databinding.observable.value.IObservableValue;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.papyrus.infra.widgets.Activator;
import org.eclipse.swt.widgets.Composite;
/**
@@ -153,7 +155,20 @@ public abstract class AbstractValueEditor extends AbstractEditor {
return;
}
+ if(targetToModelStrategy == null) {
+ targetToModelStrategy = new UpdateValueStrategy();
+ }
+
binding = getBindingContext().bindValue(widgetObservable, modelProperty, targetToModelStrategy, modelToTargetStrategy);
+ binding.getValidationStatus().addChangeListener(new IChangeListener() {
+
+ public void handleChange(ChangeEvent event) {
+ Status status = (Status)((IObservableValue)event.getObservable()).getValue();
+ if(status.getSeverity() != Status.OK) {
+ Activator.log.error("Binding error (" + status.getSeverity() + ") : " + status.getMessage(), status.getException());
+ }
+ }
+ });
}
/**
diff --git a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleStringEditor.java b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleStringEditor.java
index d5940e99da6..55cc84786ae 100644
--- a/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleStringEditor.java
+++ b/plugins/infra/widget/org.eclipse.papyrus.infra.widgets/src/org/eclipse/papyrus/infra/widgets/editors/MultipleStringEditor.java
@@ -36,7 +36,7 @@ public class MultipleStringEditor extends MultipleValueEditor {
*/
public MultipleStringEditor(Composite parent, int style) {
super(parent, style, new StringSelector());
- setFactory(new StringEditionFactory());
+ init();
}
/**
@@ -55,6 +55,7 @@ public class MultipleStringEditor extends MultipleValueEditor {
*/
public MultipleStringEditor(Composite parent, int style, boolean ordered, boolean unique) {
super(parent, style, new StringSelector(), ordered, unique, null);
+ init();
}
/**
@@ -75,6 +76,7 @@ public class MultipleStringEditor extends MultipleValueEditor {
*/
public MultipleStringEditor(Composite parent, int style, boolean ordered, boolean unique, String label) {
super(parent, style, new StringSelector(), ordered, unique, label);
+ init();
}
/**
@@ -97,6 +99,7 @@ public class MultipleStringEditor extends MultipleValueEditor {
*/
public MultipleStringEditor(Composite parent, int style, IElementSelector selector, boolean ordered, boolean unique, String label) {
super(parent, style, selector, ordered, unique, label);
+ init();
}
/**
@@ -113,6 +116,7 @@ public class MultipleStringEditor extends MultipleValueEditor {
*/
public MultipleStringEditor(Composite parent, int style, IElementSelector selector) {
super(parent, style, selector);
+ init();
}
/**
@@ -131,6 +135,7 @@ public class MultipleStringEditor extends MultipleValueEditor {
*/
public MultipleStringEditor(Composite parent, int style, IElementSelector selector, String label) {
super(parent, style, selector, label);
+ init();
}
/**
@@ -147,6 +152,11 @@ public class MultipleStringEditor extends MultipleValueEditor {
*/
public MultipleStringEditor(Composite parent, int style, String label) {
super(parent, style, new StringSelector(), label);
+ init();
+ }
+
+ private void init() {
+ setFactory(new StringEditionFactory());
}
}
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/AbstractModelElement.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/AbstractModelElement.java
index cc6adff3b7b..c5d0a8f1628 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/AbstractModelElement.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/AbstractModelElement.java
@@ -19,9 +19,7 @@ import org.eclipse.jface.viewers.ILabelProvider;
import org.eclipse.papyrus.infra.widgets.creation.ReferenceValueFactory;
import org.eclipse.papyrus.infra.widgets.providers.EmptyContentProvider;
import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
-import org.eclipse.papyrus.views.properties.contexts.Property;
import org.eclipse.papyrus.views.properties.creation.PropertyEditorFactory;
-import org.eclipse.papyrus.views.properties.runtime.ConfigurationManager;
/**
* Provides a default implementation for ModelElement methods applied on the
@@ -77,17 +75,6 @@ public abstract class AbstractModelElement implements ModelElement {
}
/**
- * Finds the property associated to the given propertyPath
- *
- * @param propertyPath
- * The name of the property to retrieve
- * @return the property associated to the given propertyPath
- */
- protected Property getProperty(String propertyPath) {
- return ConfigurationManager.instance.getProperty(propertyPath, dataSource.getView().getContext());
- }
-
- /**
* @see org.eclipse.papyrus.views.properties.modelelement.ModelElement#getValueFactory(java.lang.String)
*
* @param propertyPath
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/EMFModelElement.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/EMFModelElement.java
index d233e84b95d..81bfa96e9bf 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/EMFModelElement.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/modelelement/EMFModelElement.java
@@ -187,8 +187,10 @@ public class EMFModelElement extends AbstractModelElement {
public IStaticContentProvider getContentProvider(String propertyPath) {
FeaturePath featurePath = getFeaturePath(propertyPath);
EStructuralFeature feature = getFeature(featurePath);
-
- return new EMFContentProvider(getSource(featurePath), feature);
+ if(feature != null) {
+ return new EMFContentProvider(getSource(featurePath), feature);
+ }
+ return super.getContentProvider(propertyPath);
}
@Override
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/AbstractPropertyEditor.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/AbstractPropertyEditor.java
index 3f10a1f0b8b..b0c89cbc8a0 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/AbstractPropertyEditor.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/AbstractPropertyEditor.java
@@ -48,9 +48,9 @@ public abstract class AbstractPropertyEditor implements IChangeListener, Customi
*/
protected DataSource input;
- private boolean readOnly = false;
+ protected boolean readOnly = false;
- private boolean isEditable = true;
+ protected boolean isEditable = true;
/**
* The SWT Widget (For list properties only)
@@ -377,7 +377,7 @@ public abstract class AbstractPropertyEditor implements IChangeListener, Customi
try {
observableList = (IObservableList)input.getObservable(propertyPath);
} catch (Exception ex) {
- Activator.log.error("Cannot find a valid IObservable for " + propertyPath, ex); //$NON-NLS-1$
+ Activator.log.error("Cannot find a valid IObservableList for " + propertyPath, ex); //$NON-NLS-1$
}
}
@@ -393,7 +393,7 @@ public abstract class AbstractPropertyEditor implements IChangeListener, Customi
try {
observableValue = (IObservableValue)input.getObservable(propertyPath);
} catch (Exception ex) {
- Activator.log.error("Cannot find a valid IObservable for " + propertyPath, ex); //$NON-NLS-1$
+ Activator.log.error("Cannot find a valid IObservableValue for " + propertyPath, ex); //$NON-NLS-1$
}
}
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/MultiString.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/MultiString.java
index 1469b893014..5c9a9fe3332 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/MultiString.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/MultiString.java
@@ -47,6 +47,7 @@ public class MultiString extends AbstractPropertyEditor {
protected void doBinding() {
editor.setOrdered(input.isOrdered(propertyPath));
editor.setUnique(input.isUnique(propertyPath));
+ editor.setDirectCreation(input.getDirectCreation(propertyPath));
if(getInputObservableList() instanceof ICommitListener) {
editor.addCommitListener((ICommitListener)getInputObservableList());
diff --git a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/ViewEditor.java b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/ViewEditor.java
index 25ec219ebbf..e4d5c3bd02f 100644
--- a/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/ViewEditor.java
+++ b/plugins/views/properties/org.eclipse.papyrus.views.properties/src/org/eclipse/papyrus/views/properties/widgets/ViewEditor.java
@@ -133,7 +133,7 @@ public class ViewEditor extends AbstractPropertyEditor {
return;
}
- IObservable observable = input.getObservable(propertyPath);
+ IObservable observable = getInputObservable();
if(observable == null) {
return;
}
@@ -222,6 +222,12 @@ public class ViewEditor extends AbstractPropertyEditor {
}
@Override
+ protected IObservable getInputObservable() {
+ //Override the generic behavior: ViewEditor doesn't rely on an AbstractEditor
+ return input.getObservable(propertyPath);
+ }
+
+ @Override
public void setReadOnly(boolean readOnly) {
super.setReadOnly(readOnly);
updateControls();

Back to the top