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/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties
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/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties')
-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
23 files changed, 1296 insertions, 29 deletions
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;
}

Back to the top