Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrschnekenbu2013-05-03 09:16:12 +0000
committerrschnekenbu2013-05-03 09:16:12 +0000
commitdd8ba6c0fced800e422a93fb481d28f053ab4322 (patch)
tree2d55244bf20ef536c6bb82bd80b490ec054474c2 /plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties
parent5a32ed77886af55369ed21a0bcb1e98c59ed9909 (diff)
downloadorg.eclipse.papyrus-dd8ba6c0fced800e422a93fb481d28f053ab4322.tar.gz
org.eclipse.papyrus-dd8ba6c0fced800e422a93fb481d28f053ab4322.tar.xz
org.eclipse.papyrus-dd8ba6c0fced800e422a93fb481d28f053ab4322.zip
394893: [All Diagrams] Papyrus shall support symbols in the diagrams
https://bugs.eclipse.org/bugs/show_bug.cgi?id=394893
Diffstat (limited to 'plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties')
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi35
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/notation.ctx15
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleDecorableElement.xwt20
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/constraint/IsDecorableElementConstraint.java59
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/Messages.java18
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/messages.properties9
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/DecoratedModelElement.java158
-rw-r--r--plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/DecoratedModelElementFactory.java44
8 files changed, 333 insertions, 25 deletions
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 b35d2881598..7c44093d06f 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,27 +1,12 @@
<?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">
- <constraintTypes
- label="GMF Appearance Constraint"
- constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.AppearanceConstraint"/>
- <constraintTypes
- label="HasEditPolicy"
- constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.HasEditPolicy"/>
- <constraintTypes
- label="isGMFEditPart"
- constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.IsEditPartConstraint"/>
- <constraintTypes
- label="GMF Notation Constraint"
- constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.GMFNotationConstraint"/>
- <modelElementFactories
- name="GMF Appearance Factory"
- factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.AppearanceModelElementFactory"/>
- <modelElementFactories
- name="GMF Custom Style"
- factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.CustomStyleModelElementFactory"/>
- <modelElementFactories
- name="GMF Notation Factory"
- factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.NotationModelElementFactory"/>
+<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 Appearance Constraint" constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.AppearanceConstraint"/>
+ <constraintTypes label="HasEditPolicy" constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.HasEditPolicy"/>
+ <constraintTypes label="isGMFEditPart" constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.IsEditPartConstraint"/>
+ <constraintTypes label="GMF Notation Constraint" constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.GMFNotationConstraint"/>
+ <constraintTypes label="isDecorableElementConstraint" constraintClass="org.eclipse.papyrus.infra.gmfdiag.properties.constraint.IsDecorableElementConstraint"/>
+ <modelElementFactories name="GMF Appearance Factory" factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.AppearanceModelElementFactory"/>
+ <modelElementFactories name="GMF Custom Style" factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.CustomStyleModelElementFactory"/>
+ <modelElementFactories name="GMF Notation Factory" factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.NotationModelElementFactory"/>
+ <modelElementFactories name="Decorated Element Factory" factoryClass="org.eclipse.papyrus.infra.gmfdiag.properties.modelelement.DecoratedModelElementFactory"/>
</environment:Environment>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/notation.ctx b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/notation.ctx
index 41490475b08..244e96c83c8 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/notation.ctx
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/notation.ctx
@@ -175,6 +175,9 @@
<sections name="Multiple SemanticListCompartment" sectionFile="ui/MultipleSemanticListCompartment.xwt">
<widget href="ui/MultipleSemanticListCompartment.xwt#/"/>
</sections>
+ <sections name="SingleDecorableElement" sectionFile="ui/SingleDecorableElement.xwt">
+ <widget href="ui/SingleDecorableElement.xwt#/"/>
+ </sections>
</tabs>
<views name="Single Diagram" sections="//@tabs.0/@sections.12" automaticContext="true" datacontexts="//@dataContexts.0/@elements.12">
<constraints xsi:type="constraints:SimpleConstraint" name="isSingleDiagram">
@@ -183,6 +186,11 @@
<properties xsi:type="constraints:ValueProperty" name="className" value="Diagram"/>
</constraints>
</views>
+ <views name="Single Decorable Element" sections="//@tabs.0/@sections.58" automaticContext="true" datacontexts="//@dataContexts.1/@elements.0">
+ <constraints xsi:type="constraints:SimpleConstraint" name="isDecorableElementConstraint">
+ <constraintType href="ppe:/environment/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi#//@constraintTypes.4"/>
+ </constraints>
+ </views>
<views name="Single Edge" sections="//@tabs.0/@sections.0" automaticContext="true" datacontexts="//@dataContexts.0/@elements.0">
<constraints xsi:type="constraints:SimpleConstraint" name="isSingleEdge">
<constraintType href="ppe:/environment/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi#//@constraintTypes.3"/>
@@ -664,4 +672,11 @@
<elements name="SemanticListCompartment" supertypes="//@dataContexts.0/@elements.27"/>
<modelElementFactory href="ppe:/environment/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi#//@modelElementFactories.2"/>
</dataContexts>
+ <dataContexts name="decoratedElement" label="decoratedElement">
+ <elements name="ShapeDecorableElement">
+ <properties name="shape_visibility" label="" type="Boolean" description="Boolean that indicates if the decorations should be visible or not"/>
+ <properties name="shape_direction" type="Reference" description="Direction where the decorations should be placed."/>
+ </elements>
+ <modelElementFactory href="ppe:/environment/org.eclipse.papyrus.infra.gmfdiag.properties/model/Environment.xmi#//@modelElementFactories.3"/>
+ </dataContexts>
</contexts:Context>
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleDecorableElement.xwt b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleDecorableElement.xwt
new file mode 100644
index 00000000000..bd207f160d5
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/model/notation/ui/SingleDecorableElement.xwt
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<Composite xmlns:ppe="clr-namespace:org.eclipse.papyrus.views.properties.widgets"
+ xmlns:ppel="clr-namespace:org.eclipse.papyrus.views.properties.widgets.layout"
+ xmlns:j="clr-namespace:java.lang" xmlns="http://www.eclipse.org/xwt/presentation"
+ xmlns:x="http://www.eclipse.org/xwt">
+ <Composite.layout>
+ <ppel:PropertiesLayout></ppel:PropertiesLayout>
+ </Composite.layout>
+ <Group text="Shape Decoration">
+ <Group.layout>
+ <ppel:PropertiesLayout numColumns="2"></ppel:PropertiesLayout>
+ </Group.layout>
+ <ppe:BooleanRadio input="{Binding}"
+ property="decoratedElement:ShapeDecorableElement:shape_visibility"
+ customLabel="Visible"></ppe:BooleanRadio>
+ <ppe:ReferenceCombo input="{Binding}"
+ property="decoratedElement:ShapeDecorableElement:shape_direction"
+ customLabel="Position"></ppe:ReferenceCombo>
+ </Group>
+</Composite> \ No newline at end of file
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/constraint/IsDecorableElementConstraint.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/constraint/IsDecorableElementConstraint.java
new file mode 100644
index 00000000000..b45654d5e0f
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/constraint/IsDecorableElementConstraint.java
@@ -0,0 +1,59 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.constraint;
+
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.gmf.runtime.notation.DescriptionStyle;
+import org.eclipse.gmf.runtime.notation.Diagram;
+import org.eclipse.gmf.runtime.notation.NotationPackage;
+import org.eclipse.gmf.runtime.notation.View;
+import org.eclipse.papyrus.infra.constraints.constraints.AbstractConstraint;
+import org.eclipse.papyrus.infra.constraints.constraints.Constraint;
+//import org.eclipse.papyrus.infra.gmfdiag.common.providers.ShapeDecorator;
+
+
+/**
+ * Constraint that test if selection can be decorated
+ */
+public class IsDecorableElementConstraint extends AbstractConstraint {
+
+ /**
+ * {@inheritDoc}
+ */
+ public boolean match(Object selection) {
+ if(selection instanceof IAdaptable) {
+ View node = (View)((IAdaptable)selection).getAdapter(View.class);
+ if(node != null && !(node instanceof Diagram)) {
+ DescriptionStyle descStyle = (DescriptionStyle)node.getStyle(NotationPackage.eINSTANCE.getDescriptionStyle());
+ if(descStyle != null) {
+ return true;
+ }
+ }
+ }
+
+ return false;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected boolean equivalent(Constraint constraint) {
+ if(constraint == null) {
+ return false;
+ }
+
+ return constraint instanceof IsDecorableElementConstraint;
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/Messages.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/Messages.java
index c11acda4ea4..6efd7d9683c 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/Messages.java
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/Messages.java
@@ -17,6 +17,24 @@ public class Messages extends NLS {
private static final String BUNDLE_NAME = "org.eclipse.papyrus.infra.gmfdiag.properties.messages.messages"; //$NON-NLS-1$
+ public static String DecoratedModelElement_CENTER;
+
+ public static String DecoratedModelElement_EAST;
+
+ public static String DecoratedModelElement_NORTH;
+
+ public static String DecoratedModelElement_NORTH_EAST;
+
+ public static String DecoratedModelElement_NORTH_WEST;
+
+ public static String DecoratedModelElement_SOUTH;
+
+ public static String DecoratedModelElement_SOUTH_EAST;
+
+ public static String DecoratedModelElement_SOUTH_WEST;
+
+ public static String DecoratedModelElement_WEST;
+
public static String GradientDataModelElement_Horizontal;
public static String GradientDataModelElement_Vertical;
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/messages.properties b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/messages.properties
index a18c5148bd8..2c1a13cf3d3 100644
--- a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/messages.properties
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/messages/messages.properties
@@ -1,2 +1,11 @@
+DecoratedModelElement_CENTER=Center
+DecoratedModelElement_EAST=Right
+DecoratedModelElement_NORTH=Top
+DecoratedModelElement_NORTH_EAST=Top Right
+DecoratedModelElement_NORTH_WEST=Top Left
+DecoratedModelElement_SOUTH=Bottom
+DecoratedModelElement_SOUTH_EAST=Bottom Right
+DecoratedModelElement_SOUTH_WEST=Bottom Left
+DecoratedModelElement_WEST=Left
GradientDataModelElement_Horizontal=Horizontal
GradientDataModelElement_Vertical=Vertical
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/DecoratedModelElement.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/DecoratedModelElement.java
new file mode 100644
index 00000000000..5e3ed3f7cb9
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/DecoratedModelElement.java
@@ -0,0 +1,158 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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:
+ *
+ * CEA LIST - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.infra.gmfdiag.properties.modelelement;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.eclipse.core.databinding.observable.IObservable;
+import org.eclipse.emf.ecore.EObject;
+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.common.databinding.custom.CustomBooleanStyleObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.common.databinding.custom.CustomIntStyleObservableValue;
+import org.eclipse.papyrus.infra.gmfdiag.common.providers.ShapeDecorator;
+import org.eclipse.papyrus.infra.gmfdiag.properties.messages.Messages;
+import org.eclipse.papyrus.infra.widgets.providers.AbstractStaticContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.IStaticContentProvider;
+import org.eclipse.papyrus.infra.widgets.providers.MapLabelProvider;
+import org.eclipse.papyrus.views.properties.modelelement.AbstractModelElement;
+
+/**
+ * Model element for the decorated view in GMF. This is not a model element, as the properties to search are non-EMF Properties
+ */
+public class DecoratedModelElement extends AbstractModelElement {
+
+ private final static Map<Object, String> labels = new HashMap<Object, String>();
+ static {
+ labels.put(0, Messages.DecoratedModelElement_NORTH_WEST);
+ labels.put(1, Messages.DecoratedModelElement_NORTH);
+ labels.put(2, Messages.DecoratedModelElement_NORTH_EAST);
+ labels.put(3, Messages.DecoratedModelElement_WEST);
+ labels.put(4, Messages.DecoratedModelElement_CENTER);
+ labels.put(5, Messages.DecoratedModelElement_EAST);
+ labels.put(6, Messages.DecoratedModelElement_SOUTH_WEST);
+ labels.put(7, Messages.DecoratedModelElement_SOUTH);
+ labels.put(8, Messages.DecoratedModelElement_SOUTH_EAST);
+ }
+
+ /**
+ * The EObject manipulated by this ModelElement
+ */
+ protected EObject source;
+
+ /**
+ * The Editing Domain of the EObject for this ModelElement
+ */
+ protected EditingDomain domain;
+
+ /**
+ *
+ * Constructs a new EMFModelElement for the given EObject
+ *
+ * @param source
+ */
+ public DecoratedModelElement(EObject source) {
+ this(source, null);
+ }
+
+ /**
+ *
+ * Constructs a new EMFModelElement for the given EObject and Editing Domain
+ *
+ * @param source
+ * @param domain
+ */
+ public DecoratedModelElement(EObject source, EditingDomain domain) {
+ this.source = source;
+ this.domain = domain;
+ }
+
+ /**
+ * @return the EditingDomain for this ModelElement
+ */
+ public EditingDomain getDomain() {
+ return domain;
+ }
+
+ /**
+ * @return the EObject for this ModelElement
+ */
+ public EObject getSource() {
+ return source;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ protected IObservable doGetObservable(String propertyPath) {
+ if(ShapeDecorator.SHAPE_DECORATOR_VISIBILITY.equals(propertyPath)) {
+ return new CustomBooleanStyleObservableValue((View)source, domain, ShapeDecorator.SHAPE_DECORATOR_VISIBILITY);
+ }
+
+ if(ShapeDecorator.SHAPE_DECORATOR_DIRECTION.equals(propertyPath)) {
+ return new CustomIntStyleObservableValue((View)source, domain, ShapeDecorator.SHAPE_DECORATOR_DIRECTION);
+ }
+ return super.getObservable(propertyPath);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public boolean isEditable(String propertyPath) {
+ if(ShapeDecorator.SHAPE_DECORATOR_DIRECTION.equals(propertyPath)) {
+ return true;
+ }
+
+ if(ShapeDecorator.SHAPE_DECORATOR_VISIBILITY.equals(propertyPath)) {
+ return true;
+ }
+
+ return super.isEditable(propertyPath);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public ILabelProvider getLabelProvider(String propertyPath) {
+ if(ShapeDecorator.SHAPE_DECORATOR_DIRECTION.equals(propertyPath)) {
+ return new MapLabelProvider(labels);
+ }
+ return super.getLabelProvider(propertyPath);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public IStaticContentProvider getContentProvider(String propertyPath) {
+ if(ShapeDecorator.SHAPE_DECORATOR_DIRECTION.equals(propertyPath)) {
+ return new AbstractStaticContentProvider() {
+
+ /**
+ * {@inheritDoc}
+ */
+ public Object[] getElements() {
+ return labels.keySet().toArray(new Integer[0]);
+ }
+ };
+ }
+
+ return super.getContentProvider(propertyPath);
+ }
+}
diff --git a/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/DecoratedModelElementFactory.java b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/DecoratedModelElementFactory.java
new file mode 100644
index 00000000000..e549d8f8dd4
--- /dev/null
+++ b/plugins/infra/gmfdiag/org.eclipse.papyrus.infra.gmfdiag.properties/src/org/eclipse/papyrus/infra/gmfdiag/properties/modelelement/DecoratedModelElementFactory.java
@@ -0,0 +1,44 @@
+/*****************************************************************************
+ * Copyright (c) 2011 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.common.providers.ShapeDecorator;
+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;
+
+/**
+ * A factory for handling the GMF decorated elements
+ */
+public class DecoratedModelElementFactory implements ModelElementFactory {
+
+ public ModelElement createFromSource(Object sourceElement, DataContextElement context) {
+ View view = NotationHelper.findView(sourceElement);
+
+ if(view != null) {
+ EditingDomain domain = AdapterFactoryEditingDomain.getEditingDomainFor(view);
+ if(ShapeDecorator.isDecorable(view)) {
+ return new DecoratedModelElement(view, domain);
+ }
+
+ }
+
+ Activator.log.warn("The selected element cannot be resolved to a Decorated element");
+ return null;
+ }
+
+}

Back to the top