From 44689e90adf4724399b430d10a8fe9372197fbeb Mon Sep 17 00:00:00 2001 From: Mickael ADAM Date: Tue, 18 Nov 2014 17:40:47 +0100 Subject: 440201: [Diagram] Class diagram shapes shall be refactored https://bugs.eclipse.org/bugs/show_bug.cgi?id=440201 Patch Set 1: -Improve GmfGenExtension: Now override createNodePlate throught gmfgen add edit policy for external label -Clean and fix some bug in roundedCompartment Patch Set 2: - Used of RoundedRectangleNodePlate for all node by default, let the possibility to override it. Change-Id: Ie64ad8e049bd4d11cb9075987fee555ba4b97a3c Signed-off-by: Mickael ADAM 440201: [Diagram] Class diagram shapes shall be refactored https://bugs.eclipse.org/bugs/show_bug.cgi?id=440201 -Improve GmfGenExtension: Now override createNodePlate throught gmfgen add edit policy for external label -Clean and fix some bug in roundedCompartment Change-Id: Ie64ad8e049bd4d11cb9075987fee555ba4b97a3c Signed-off-by: Mickael ADAM --- .../META-INF/MANIFEST.MF | 3 +- .../model/papyrusGmfgenExtension.ecore | 10 + .../org.eclipse.papyrus.gmfgenextension/plugin.xml | 4 +- .../PapyrusgmfgenextensionFactory.java | 10 + .../PapyrusgmfgenextensionPackage.java | 147 +++++++++++ .../papyrusgmfgenextension/SpecificNodePlate.java | 108 ++++++++ .../impl/PapyrusgmfgenextensionFactoryImpl.java | 15 ++ .../impl/PapyrusgmfgenextensionPackageImpl.java | 66 +++++ .../impl/SpecificNodePlateImpl.java | 282 +++++++++++++++++++++ ...ddExternalNodeFloatingLabelDisplayBehavior.java | 223 ++++++++++++++++ ...AddExternalNodeFloatingNameDisplayBehavior.java | 214 ---------------- .../util/PapyrusgmfgenextensionAdapterFactory.java | 21 ++ .../util/PapyrusgmfgenextensionSwitch.java | 29 +++ 13 files changed, 914 insertions(+), 218 deletions(-) create mode 100644 plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/SpecificNodePlate.java create mode 100644 plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/impl/SpecificNodePlateImpl.java create mode 100644 plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddExternalNodeFloatingLabelDisplayBehavior.java delete mode 100644 plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddExternalNodeFloatingNameDisplayBehavior.java (limited to 'plugins/developer/org.eclipse.papyrus.gmfgenextension') diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/META-INF/MANIFEST.MF b/plugins/developer/org.eclipse.papyrus.gmfgenextension/META-INF/MANIFEST.MF index d5bb01d1bae..669489a7f60 100644 --- a/plugins/developer/org.eclipse.papyrus.gmfgenextension/META-INF/MANIFEST.MF +++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/META-INF/MANIFEST.MF @@ -19,7 +19,6 @@ Bundle-Version: 1.1.0.qualifier Bundle-Localization: plugin Bundle-Name: %pluginName Bundle-ManifestVersion: 2 -Bundle-SymbolicName: org.eclipse.papyrus.gmfgenextension;singleton:=tr - ue +Bundle-SymbolicName: org.eclipse.papyrus.gmfgenextension;singleton:=true Bundle-RequiredExecutionEnvironment: J2SE-1.5 diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/model/papyrusGmfgenExtension.ecore b/plugins/developer/org.eclipse.papyrus.gmfgenextension/model/papyrusGmfgenExtension.ecore index 4286563ba12..8e4b2714324 100644 --- a/plugins/developer/org.eclipse.papyrus.gmfgenextension/model/papyrusGmfgenExtension.ecore +++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/model/papyrusGmfgenExtension.ecore @@ -178,4 +178,14 @@ + + +
+ + + + + diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/plugin.xml b/plugins/developer/org.eclipse.papyrus.gmfgenextension/plugin.xml index 70ab2fb840b..8c851cfef10 100644 --- a/plugins/developer/org.eclipse.papyrus.gmfgenextension/plugin.xml +++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/plugin.xml @@ -115,10 +115,10 @@ Specific Node Plate'. + * + * + * + * @return a new object of class 'Specific Node Plate'. + * @generated + */ + SpecificNodePlate createSpecificNodePlate(); + /** * Returns the package supported by this factory. * diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/PapyrusgmfgenextensionPackage.java b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/PapyrusgmfgenextensionPackage.java index 5601eebbe91..f8b5c162c7b 100644 --- a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/PapyrusgmfgenextensionPackage.java +++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/PapyrusgmfgenextensionPackage.java @@ -1585,6 +1585,68 @@ public interface PapyrusgmfgenextensionPackage extends EPackage { int CUSTOM_DIAGRAM_UPDATER_SINGLETON_FEATURE_COUNT = COMMENTED_ELEMENT_FEATURE_COUNT + 1; + /** + * The meta object id for the '{@link org.eclipse.papyrus.papyrusgmfgenextension.impl.SpecificNodePlateImpl Specific Node Plate}' class. + * + * + * + * @see org.eclipse.papyrus.papyrusgmfgenextension.impl.SpecificNodePlateImpl + * @see org.eclipse.papyrus.papyrusgmfgenextension.impl.PapyrusgmfgenextensionPackageImpl#getSpecificNodePlate() + * @generated + */ + int SPECIFIC_NODE_PLATE = 25; + + /** + * The feature id for the 'Comment' attribute. + * + * + * + * @generated + * @ordered + */ + int SPECIFIC_NODE_PLATE__COMMENT = COMMENTED_ELEMENT__COMMENT; + + /** + * The feature id for the 'Edit Parts' reference list. + * + * + * + * @generated + * @ordered + */ + int SPECIFIC_NODE_PLATE__EDIT_PARTS = COMMENTED_ELEMENT_FEATURE_COUNT + 0; + + /** + * The feature id for the 'Name' attribute. + * + * + * + * @generated + * @ordered + */ + int SPECIFIC_NODE_PLATE__NAME = COMMENTED_ELEMENT_FEATURE_COUNT + 1; + + /** + * The feature id for the 'Node Plate Qualified Name' attribute. + * + * + * + * @generated + * @ordered + */ + int SPECIFIC_NODE_PLATE__NODE_PLATE_QUALIFIED_NAME = COMMENTED_ELEMENT_FEATURE_COUNT + 2; + + /** + * The number of structural features of the 'Specific Node Plate' class. + * + * + * + * @generated + * @ordered + */ + int SPECIFIC_NODE_PLATE_FEATURE_COUNT = COMMENTED_ELEMENT_FEATURE_COUNT + 3; + + /** * Returns the meta object for class '{@link org.eclipse.papyrus.papyrusgmfgenextension.ExtendedGenView Extended Gen View}'. * @@ -2376,6 +2438,53 @@ public interface PapyrusgmfgenextensionPackage extends EPackage { */ EAttribute getCustomDiagramUpdaterSingleton_SingletonPath(); + /** + * Returns the meta object for class '{@link org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate Specific Node Plate}'. + * + * + * + * @return the meta object for class 'Specific Node Plate'. + * @see org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate + * @generated + */ + EClass getSpecificNodePlate(); + + /** + * Returns the meta object for the reference list '{@link org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate#getEditParts Edit Parts}'. + * + * + * + * @return the meta object for the reference list 'Edit Parts'. + * @see org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate#getEditParts() + * @see #getSpecificNodePlate() + * @generated + */ + EReference getSpecificNodePlate_EditParts(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate#getName Name}'. + * + * + * + * @return the meta object for the attribute 'Name'. + * @see org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate#getName() + * @see #getSpecificNodePlate() + * @generated + */ + EAttribute getSpecificNodePlate_Name(); + + /** + * Returns the meta object for the attribute '{@link org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate#getNodePlateQualifiedName Node Plate Qualified Name}'. + * + * + * + * @return the meta object for the attribute 'Node Plate Qualified Name'. + * @see org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate#getNodePlateQualifiedName() + * @see #getSpecificNodePlate() + * @generated + */ + EAttribute getSpecificNodePlate_NodePlateQualifiedName(); + /** * Returns the factory that creates the instances of the model. * @@ -3063,6 +3172,44 @@ public interface PapyrusgmfgenextensionPackage extends EPackage { */ EAttribute CUSTOM_DIAGRAM_UPDATER_SINGLETON__SINGLETON_PATH = eINSTANCE.getCustomDiagramUpdaterSingleton_SingletonPath(); + /** + * The meta object literal for the '{@link org.eclipse.papyrus.papyrusgmfgenextension.impl.SpecificNodePlateImpl Specific Node Plate}' class. + * + * + * + * @see org.eclipse.papyrus.papyrusgmfgenextension.impl.SpecificNodePlateImpl + * @see org.eclipse.papyrus.papyrusgmfgenextension.impl.PapyrusgmfgenextensionPackageImpl#getSpecificNodePlate() + * @generated + */ + EClass SPECIFIC_NODE_PLATE = eINSTANCE.getSpecificNodePlate(); + + /** + * The meta object literal for the 'Edit Parts' reference list feature. + * + * + * + * @generated + */ + EReference SPECIFIC_NODE_PLATE__EDIT_PARTS = eINSTANCE.getSpecificNodePlate_EditParts(); + + /** + * The meta object literal for the 'Name' attribute feature. + * + * + * + * @generated + */ + EAttribute SPECIFIC_NODE_PLATE__NAME = eINSTANCE.getSpecificNodePlate_Name(); + + /** + * The meta object literal for the 'Node Plate Qualified Name' attribute feature. + * + * + * + * @generated + */ + EAttribute SPECIFIC_NODE_PLATE__NODE_PLATE_QUALIFIED_NAME = eINSTANCE.getSpecificNodePlate_NodePlateQualifiedName(); + } } // PapyrusgmfgenextensionPackage diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/SpecificNodePlate.java b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/SpecificNodePlate.java new file mode 100644 index 00000000000..672529582bf --- /dev/null +++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/SpecificNodePlate.java @@ -0,0 +1,108 @@ +/** + */ +package org.eclipse.papyrus.papyrusgmfgenextension; + +import org.eclipse.emf.common.util.EList; + +import org.eclipse.gmf.codegen.gmfgen.GenNode; + +/** + * + * A representation of the model object 'Specific Node Plate'. + * + * + * + * This element is always linked to a genView (topLevel, or child) + * Used set if an editPart is abstract. + * SuperGenViews is a list of all superEditPart. + * + * Thanks to this, it is possible to factorize code and to decrease the number of generated classes. + * + * + *

+ * The following features are supported: + *

    + *
  • {@link org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate#getEditParts Edit Parts}
  • + *
  • {@link org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate#getName Name}
  • + *
  • {@link org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate#getNodePlateQualifiedName Node Plate Qualified Name}
  • + *
+ *

+ * + * @see org.eclipse.papyrus.papyrusgmfgenextension.PapyrusgmfgenextensionPackage#getSpecificNodePlate() + * @model + * @generated + */ +public interface SpecificNodePlate extends CommentedElement { + /** + * Returns the value of the 'Edit Parts' reference list. + * The list contents are of type {@link org.eclipse.gmf.codegen.gmfgen.GenNode}. + * + *

+ * If the meaning of the 'Edit Parts' reference list isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Edit Parts' reference list. + * @see org.eclipse.papyrus.papyrusgmfgenextension.PapyrusgmfgenextensionPackage#getSpecificNodePlate_EditParts() + * @model required="true" ordered="false" + * @generated + */ + EList getEditParts(); + + /** + * Returns the value of the 'Name' attribute. + * + *

+ * If the meaning of the 'Name' attribute isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Name' attribute. + * @see #setName(String) + * @see org.eclipse.papyrus.papyrusgmfgenextension.PapyrusgmfgenextensionPackage#getSpecificNodePlate_Name() + * @model + * @generated + */ + String getName(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate#getName Name}' attribute. + * + * + * + * @param value + * the new value of the 'Name' attribute. + * @see #getName() + * @generated + */ + void setName(String value); + + /** + * Returns the value of the 'Node Plate Qualified Name' attribute. + * + *

+ * If the meaning of the 'Node Plate Qualified Name' attribute isn't clear, there really should be more of a description here... + *

+ * + * + * @return the value of the 'Node Plate Qualified Name' attribute. + * @see #setNodePlateQualifiedName(String) + * @see org.eclipse.papyrus.papyrusgmfgenextension.PapyrusgmfgenextensionPackage#getSpecificNodePlate_NodePlateQualifiedName() + * @model + * @generated + */ + String getNodePlateQualifiedName(); + + /** + * Sets the value of the '{@link org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate#getNodePlateQualifiedName Node Plate Qualified Name}' attribute. + * + * + * + * @param value + * the new value of the 'Node Plate Qualified Name' attribute. + * @see #getNodePlateQualifiedName() + * @generated + */ + void setNodePlateQualifiedName(String value); + +} // SpecificNodePlate diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/impl/PapyrusgmfgenextensionFactoryImpl.java b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/impl/PapyrusgmfgenextensionFactoryImpl.java index b1844c1f221..86acbe040e5 100644 --- a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/impl/PapyrusgmfgenextensionFactoryImpl.java +++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/impl/PapyrusgmfgenextensionFactoryImpl.java @@ -11,6 +11,7 @@ import org.eclipse.emf.ecore.EObject; import org.eclipse.emf.ecore.EPackage; import org.eclipse.emf.ecore.impl.EFactoryImpl; import org.eclipse.emf.ecore.plugin.EcorePlugin; +import org.eclipse.papyrus.papyrusgmfgenextension.*; import org.eclipse.papyrus.papyrusgmfgenextension.AdditionalEditPartCandies; import org.eclipse.papyrus.papyrusgmfgenextension.AlternateCanvas; import org.eclipse.papyrus.papyrusgmfgenextension.AlternateGenLink; @@ -137,6 +138,8 @@ public class PapyrusgmfgenextensionFactoryImpl extends EFactoryImpl implements P return createGenerateUsingElementTypeCreationCommand(); case PapyrusgmfgenextensionPackage.CUSTOM_DIAGRAM_UPDATER_SINGLETON: return createCustomDiagramUpdaterSingleton(); + case PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE: + return createSpecificNodePlate(); default: throw new IllegalArgumentException("The class '" + eClass.getName() + "' is not a valid classifier"); } @@ -442,6 +445,18 @@ public class PapyrusgmfgenextensionFactoryImpl extends EFactoryImpl implements P return customDiagramUpdaterSingleton; } + /** + * + * + * + * @generated + */ + @Override + public SpecificNodePlate createSpecificNodePlate() { + SpecificNodePlateImpl specificNodePlate = new SpecificNodePlateImpl(); + return specificNodePlate; + } + /** * * diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/impl/PapyrusgmfgenextensionPackageImpl.java b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/impl/PapyrusgmfgenextensionPackageImpl.java index 16c8cef05e5..caa96baae62 100644 --- a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/impl/PapyrusgmfgenextensionPackageImpl.java +++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/impl/PapyrusgmfgenextensionPackageImpl.java @@ -42,6 +42,7 @@ import org.eclipse.papyrus.papyrusgmfgenextension.PropertyRefreshHook; import org.eclipse.papyrus.papyrusgmfgenextension.SpecificDiagramUpdater; import org.eclipse.papyrus.papyrusgmfgenextension.SpecificLocator; import org.eclipse.papyrus.papyrusgmfgenextension.SpecificLocatorExternalLabel; +import org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate; /** * An implementation of the model Package. @@ -239,6 +240,14 @@ public class PapyrusgmfgenextensionPackageImpl extends EPackageImpl implements P */ private EClass customDiagramUpdaterSingletonEClass = null; + /** + * + * + * + * @generated + */ + private EClass specificNodePlateEClass = null; + /** * Creates an instance of the model Package, registered with {@link org.eclipse.emf.ecore.EPackage.Registry EPackage.Registry} by the package * package URI value. @@ -1018,6 +1027,50 @@ public class PapyrusgmfgenextensionPackageImpl extends EPackageImpl implements P return (EAttribute) customDiagramUpdaterSingletonEClass.getEStructuralFeatures().get(0); } + /** + * + * + * + * @generated + */ + @Override + public EClass getSpecificNodePlate() { + return specificNodePlateEClass; + } + + /** + * + * + * + * @generated + */ + @Override + public EReference getSpecificNodePlate_EditParts() { + return (EReference) specificNodePlateEClass.getEStructuralFeatures().get(0); + } + + /** + * + * + * + * @generated + */ + @Override + public EAttribute getSpecificNodePlate_Name() { + return (EAttribute) specificNodePlateEClass.getEStructuralFeatures().get(1); + } + + /** + * + * + * + * @generated + */ + @Override + public EAttribute getSpecificNodePlate_NodePlateQualifiedName() { + return (EAttribute) specificNodePlateEClass.getEStructuralFeatures().get(2); + } + /** * * @@ -1141,6 +1194,11 @@ public class PapyrusgmfgenextensionPackageImpl extends EPackageImpl implements P customDiagramUpdaterSingletonEClass = createEClass(CUSTOM_DIAGRAM_UPDATER_SINGLETON); createEAttribute(customDiagramUpdaterSingletonEClass, CUSTOM_DIAGRAM_UPDATER_SINGLETON__SINGLETON_PATH); + + specificNodePlateEClass = createEClass(SPECIFIC_NODE_PLATE); + createEReference(specificNodePlateEClass, SPECIFIC_NODE_PLATE__EDIT_PARTS); + createEAttribute(specificNodePlateEClass, SPECIFIC_NODE_PLATE__NAME); + createEAttribute(specificNodePlateEClass, SPECIFIC_NODE_PLATE__NODE_PLATE_QUALIFIED_NAME); } /** @@ -1204,6 +1262,7 @@ public class PapyrusgmfgenextensionPackageImpl extends EPackageImpl implements P externalMetamodelTypeEClass.getESuperTypes().add(theGMFGenPackage.getMetamodelType()); generateUsingElementTypeCreationCommandEClass.getESuperTypes().add(this.getCommentedElement()); customDiagramUpdaterSingletonEClass.getESuperTypes().add(this.getCommentedElement()); + specificNodePlateEClass.getESuperTypes().add(this.getCommentedElement()); // Initialize classes and features; add operations and parameters initEClass(extendedGenViewEClass, ExtendedGenView.class, "ExtendedGenView", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); @@ -1332,6 +1391,13 @@ public class PapyrusgmfgenextensionPackageImpl extends EPackageImpl implements P initEAttribute(getCustomDiagramUpdaterSingleton_SingletonPath(), ecorePackage.getEString(), "singletonPath", null, 1, 1, CustomDiagramUpdaterSingleton.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEClass(specificNodePlateEClass, SpecificNodePlate.class, "SpecificNodePlate", !IS_ABSTRACT, !IS_INTERFACE, IS_GENERATED_INSTANCE_CLASS); + initEReference(getSpecificNodePlate_EditParts(), theGMFGenPackage.getGenNode(), null, "editParts", null, 1, -1, SpecificNodePlate.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_COMPOSITE, IS_RESOLVE_PROXIES, !IS_UNSETTABLE, !IS_UNIQUE, + !IS_DERIVED, !IS_ORDERED); + initEAttribute(getSpecificNodePlate_Name(), theEcorePackage.getEString(), "name", null, 0, 1, SpecificNodePlate.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getSpecificNodePlate_NodePlateQualifiedName(), theEcorePackage.getEString(), "nodePlateQualifiedName", null, 0, 1, SpecificNodePlate.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, + IS_ORDERED); + // Create resource createResource(eNS_URI); } diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/impl/SpecificNodePlateImpl.java b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/impl/SpecificNodePlateImpl.java new file mode 100644 index 00000000000..4b9ce6ccf7e --- /dev/null +++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/impl/SpecificNodePlateImpl.java @@ -0,0 +1,282 @@ +/** + */ +package org.eclipse.papyrus.papyrusgmfgenextension.impl; + +import java.util.Collection; + +import org.eclipse.emf.common.notify.Notification; +import org.eclipse.emf.common.util.EList; + +import org.eclipse.emf.ecore.EClass; +import org.eclipse.emf.ecore.impl.ENotificationImpl; + +import org.eclipse.emf.ecore.util.EObjectResolvingEList; + +import org.eclipse.gmf.codegen.gmfgen.GenNode; +import org.eclipse.papyrus.papyrusgmfgenextension.PapyrusgmfgenextensionPackage; +import org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate; + +/** + * + * An implementation of the model object 'Specific Node Plate'. + * + *

+ * The following features are implemented: + *

    + *
  • {@link org.eclipse.papyrus.papyrusgmfgenextension.impl.SpecificNodePlateImpl#getEditParts Edit Parts}
  • + *
  • {@link org.eclipse.papyrus.papyrusgmfgenextension.impl.SpecificNodePlateImpl#getName Name}
  • + *
  • {@link org.eclipse.papyrus.papyrusgmfgenextension.impl.SpecificNodePlateImpl#getNodePlateQualifiedName Node Plate Qualified Name}
  • + *
+ *

+ * + * @generated + */ +public class SpecificNodePlateImpl extends CommentedElementImpl implements SpecificNodePlate { + /** + * The cached value of the '{@link #getEditParts() Edit Parts}' reference list. + * + * + * + * @see #getEditParts() + * @generated + * @ordered + */ + protected EList editParts; + + /** + * The default value of the '{@link #getName() Name}' attribute. + * + * + * + * @see #getName() + * @generated + * @ordered + */ + protected static final String NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getName() Name}' attribute. + * + * + * + * @see #getName() + * @generated + * @ordered + */ + protected String name = NAME_EDEFAULT; + + /** + * The default value of the '{@link #getNodePlateQualifiedName() Node Plate Qualified Name}' attribute. + * + * + * + * @see #getNodePlateQualifiedName() + * @generated + * @ordered + */ + protected static final String NODE_PLATE_QUALIFIED_NAME_EDEFAULT = null; + + /** + * The cached value of the '{@link #getNodePlateQualifiedName() Node Plate Qualified Name}' attribute. + * + * + * + * @see #getNodePlateQualifiedName() + * @generated + * @ordered + */ + protected String nodePlateQualifiedName = NODE_PLATE_QUALIFIED_NAME_EDEFAULT; + + /** + * + * + * + * @generated + */ + protected SpecificNodePlateImpl() { + super(); + } + + /** + * + * + * + * @generated + */ + @Override + protected EClass eStaticClass() { + return PapyrusgmfgenextensionPackage.Literals.SPECIFIC_NODE_PLATE; + } + + /** + * + * + * + * @generated + */ + @Override + public EList getEditParts() { + if (editParts == null) { + editParts = new EObjectResolvingEList(GenNode.class, this, PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE__EDIT_PARTS); + } + return editParts; + } + + /** + * + * + * + * @generated + */ + @Override + public String getName() { + return name; + } + + /** + * + * + * + * @generated + */ + @Override + public void setName(String newName) { + String oldName = name; + name = newName; + if (eNotificationRequired()) { + eNotify(new ENotificationImpl(this, Notification.SET, PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE__NAME, oldName, name)); + } + } + + /** + * + * + * + * @generated + */ + @Override + public String getNodePlateQualifiedName() { + return nodePlateQualifiedName; + } + + /** + * + * + * + * @generated + */ + @Override + public void setNodePlateQualifiedName(String newNodePlateQualifiedName) { + String oldNodePlateQualifiedName = nodePlateQualifiedName; + nodePlateQualifiedName = newNodePlateQualifiedName; + if (eNotificationRequired()) { + eNotify(new ENotificationImpl(this, Notification.SET, PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE__NODE_PLATE_QUALIFIED_NAME, oldNodePlateQualifiedName, nodePlateQualifiedName)); + } + } + + /** + * + * + * + * @generated + */ + @Override + public Object eGet(int featureID, boolean resolve, boolean coreType) { + switch (featureID) { + case PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE__EDIT_PARTS: + return getEditParts(); + case PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE__NAME: + return getName(); + case PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE__NODE_PLATE_QUALIFIED_NAME: + return getNodePlateQualifiedName(); + } + return super.eGet(featureID, resolve, coreType); + } + + /** + * + * + * + * @generated + */ + @SuppressWarnings("unchecked") + @Override + public void eSet(int featureID, Object newValue) { + switch (featureID) { + case PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE__EDIT_PARTS: + getEditParts().clear(); + getEditParts().addAll((Collection) newValue); + return; + case PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE__NAME: + setName((String) newValue); + return; + case PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE__NODE_PLATE_QUALIFIED_NAME: + setNodePlateQualifiedName((String) newValue); + return; + } + super.eSet(featureID, newValue); + } + + /** + * + * + * + * @generated + */ + @Override + public void eUnset(int featureID) { + switch (featureID) { + case PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE__EDIT_PARTS: + getEditParts().clear(); + return; + case PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE__NAME: + setName(NAME_EDEFAULT); + return; + case PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE__NODE_PLATE_QUALIFIED_NAME: + setNodePlateQualifiedName(NODE_PLATE_QUALIFIED_NAME_EDEFAULT); + return; + } + super.eUnset(featureID); + } + + /** + * + * + * + * @generated + */ + @Override + public boolean eIsSet(int featureID) { + switch (featureID) { + case PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE__EDIT_PARTS: + return editParts != null && !editParts.isEmpty(); + case PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE__NAME: + return NAME_EDEFAULT == null ? name != null : !NAME_EDEFAULT.equals(name); + case PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE__NODE_PLATE_QUALIFIED_NAME: + return NODE_PLATE_QUALIFIED_NAME_EDEFAULT == null ? nodePlateQualifiedName != null : !NODE_PLATE_QUALIFIED_NAME_EDEFAULT.equals(nodePlateQualifiedName); + } + return super.eIsSet(featureID); + } + + /** + * + * + * + * @generated + */ + @Override + public String toString() { + if (eIsProxy()) { + return super.toString(); + } + + StringBuffer result = new StringBuffer(super.toString()); + result.append(" (name: "); + result.append(name); + result.append(", nodePlateQualifiedName: "); + result.append(nodePlateQualifiedName); + result.append(')'); + return result.toString(); + } + +} // SpecificNodePlateImpl diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddExternalNodeFloatingLabelDisplayBehavior.java b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddExternalNodeFloatingLabelDisplayBehavior.java new file mode 100644 index 00000000000..afeb2c93985 --- /dev/null +++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddExternalNodeFloatingLabelDisplayBehavior.java @@ -0,0 +1,223 @@ +/***************************************************************************** + * Copyright (c) 2009, 2014 CEA LIST and others. + * + * 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: + * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation + * + *****************************************************************************/ + +package org.eclipse.papyrus.papyrusgmfgenextension.popupaction; + +import java.util.Iterator; + +import org.eclipse.emf.common.util.EList; +import org.eclipse.emf.common.util.URI; +import org.eclipse.emf.ecore.EObject; +import org.eclipse.emf.ecore.resource.Resource; +import org.eclipse.gmf.codegen.gmfgen.FeatureLabelModelFacet; +import org.eclipse.gmf.codegen.gmfgen.FigureViewmap; +import org.eclipse.gmf.codegen.gmfgen.GMFGenFactory; +import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator; +import org.eclipse.gmf.codegen.gmfgen.GenExternalNodeLabel; +import org.eclipse.gmf.codegen.gmfgen.GenLinkLabel; +import org.eclipse.gmf.codegen.gmfgen.GenNode; +import org.eclipse.gmf.codegen.gmfgen.GenNodeLabel; +import org.eclipse.gmf.codegen.gmfgen.GenParsers; +import org.eclipse.gmf.codegen.gmfgen.PredefinedParser; +import org.eclipse.jface.action.IAction; +import org.eclipse.ui.IViewPart; + +/** + * this class is used to add a label to display name from external node + */ +public class AddExternalNodeFloatingLabelDisplayBehavior extends Action { + + public static final String FIGURE_VIEWMAP_PATH = "org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel";//"org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"; //$NON-NLS-1$ + + public static final String LABEL_POLICY_CLASS = "org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimaryDragRoleEditPolicy"; //$NON-NLS-1$ + + public static final String LABEL_POLICY_KEY = "org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE"; //$NON-NLS-1$ + + public static final String DEFAULT_GETTER_NAME = "getFloatingNameLabel"; //$NON-NLS-1$ + + public static final String DEFAULT_EDITPART_NAME_SUFFIX = "FloatingLabelEditPart"; //$NON-NLS-1$ + + public static final String DEFAULT_EDITPOLICY_NAME_SUFFIX = "FloatingLabelItemSemanticEditPolicy"; //$NON-NLS-1$ + + // public static final String DEFAULT_WRAPPING_LABEL_CLASS = "org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"; //$NON-NLS-1$ + + public static final String DEFAULT_PARSER_PATTERN = ""; //$NON-NLS-1$ + + public static final String GEN_CLASS_RT_CLASS = "Node"; //$NON-NLS-1$ + + public static final String GEN_CLASS_FACET_META_FEATURE = "NamedElement"; //$NON-NLS-1$ + + public static final String GEN_FEATURE_FACET_META_FEATURE = "name"; //$NON-NLS-1$ + + public static final String URI_NOTATION_GENMODEL = "org.eclipse.gmf.runtime.notation/model/notation.genmodel"; //$NON-NLS-1$ + + public static final String URI_UML_GENMODEL = "org.eclipse.uml2.uml/model/UML.genmodel"; //$NON-NLS-1$ + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) + */ + public void init(IViewPart view) { + // NO OP + } + + /* + * (non-Javadoc) + * + * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) + */ + @Override + public void run(IAction action) { + // Parse selected GenLink(s) and add the desired CustomBehavior + Iterator it = getSelectedEObject().iterator(); + while (it.hasNext()) { + EObject eObject = it.next(); + if (eObject instanceof GenNode) { + // test if it has got a external node to display floating name + if (!hasAnFloatingNameExternalNode((GenNode) eObject)) { + createAnFloatingNameExternalNode((GenNode) eObject); + } + } + } + } + + /** + * creation an external node floating name + * + * @param genNode + * the parent genNode + */ + private void createAnFloatingNameExternalNode(GenNode genNode) { + // Create une external node label + GenExternalNodeLabel label = GMFGenFactory.eINSTANCE.createGenExternalNodeLabel(); + + // Set Name of the edit part + // label.setEditPartClassName(genNode.getClassNamePrefix() + DEFAULT_EDITPART_NAME_SUFFIX); + + String editPartClassName = genNode.getEditPartClassName(); + int index = editPartClassName.indexOf("EditPart"); + String name = editPartClassName.substring(0, index) + DEFAULT_EDITPART_NAME_SUFFIX + editPartClassName.substring(index + "EditPart".length()); + label.setEditPartClassName(name); + // Set item semantic edit policy + label.setItemSemanticEditPolicyClassName(genNode.getClassNamePrefix() + DEFAULT_EDITPOLICY_NAME_SUFFIX); + // Set the Read only + label.setReadOnly(false); + + // Set GenLinkLabel VisualID with new unique ID + int visualID = SetVisualIDWithUnusedValue.getNewVisualID(genNode.eResource(), GenLinkLabel.class); + label.setVisualID(visualID); + + // Retrieve DiagramRunTimeClass in notation.genmodel (Node -> View) + URI uri_notation = URI.createPlatformPluginURI(URI_NOTATION_GENMODEL, false); + Resource notation = genNode.eResource().getResourceSet().getResource(uri_notation, true); + label.setDiagramRunTimeClass(findGenClass(notation, GEN_CLASS_RT_CLASS)); + + // Create Viewmap + FigureViewmap viewmap = GMFGenFactory.eINSTANCE.createFigureViewmap(); + viewmap.setFigureQualifiedClassName(FIGURE_VIEWMAP_PATH); + + // Create FeatureLabelModelFacet + FeatureLabelModelFacet facet = GMFGenFactory.eINSTANCE.createFeatureLabelModelFacet(); + facet.setEditPattern(DEFAULT_PARSER_PATTERN); + facet.setEditorPattern(DEFAULT_PARSER_PATTERN); + facet.setViewPattern(DEFAULT_PARSER_PATTERN); + + // Select NamedElement::name property in UML.genmodel for MetaFeatures + URI uri_uml = URI.createPlatformPluginURI(URI_UML_GENMODEL, false); + Resource uml = genNode.eResource().getResourceSet().getResource(uri_uml, true); + facet.getMetaFeatures().add(findGenFeature(uml, GEN_CLASS_FACET_META_FEATURE, GEN_FEATURE_FACET_META_FEATURE)); + // Attach Predefined Parser MessageFormatParser + // not good must find the predifined parser of the model... + + // Get the predefined parser. + PredefinedParser parser = getPredefinedParser(genNode); + facet.setParser(parser); + + // Attach created element one to another in the model + label.setViewmap(viewmap); + label.setModelFacet(facet); + + // Add custom Policy to have feedback + // addCustomBehavior(label, LABEL_POLICY_KEY, LABEL_POLICY_CLASS); + + // edit policy which permit to take into account of specific locator of external label + addCustomBehavior(genNode, "org.eclipse.gef.EditPolicy.LAYOUT_ROLE", "org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.GetChildLayoutEditPolicy"); + + genNode.getLabels().add(label); + } + + /** + * Gets the predefined parser. + * + * @param eObject + * the e object + * @return the predefined parser + */ + private PredefinedParser getPredefinedParser(GenNode eObject) { + PredefinedParser parser = null; + // /get the ressource contents + EList ressourceContents = eObject.eResource().getContents(); + for (EObject ressourceContent : ressourceContents) { + // get the Gen Editor Node + if (ressourceContent instanceof GenEditorGenerator) { + // Get Parsers node + GenParsers genParsers = ((GenEditorGenerator) ressourceContent).getLabelParsers(); + for (EObject GenParsersContent : genParsers.eContents()) { + // Get the predefined parser + if (GenParsersContent instanceof PredefinedParser) { + parser = (PredefinedParser) GenParsersContent; + } + } + } + } + return parser; + } + + /** + * Checks for a floating name external node. + * + * @param node + * the node + * @return true, if successful + */ + public boolean hasAnFloatingNameExternalNode(GenNode node) { + Iterator iterator = node.getLabels().iterator(); + while (iterator.hasNext()) { + GenNodeLabel currentGenNodeLabel = iterator.next(); + // check each child node + if (currentGenNodeLabel instanceof GenExternalNodeLabel) { + if (isAnFloatingNameExternalNode((GenExternalNodeLabel) currentGenNodeLabel)) { + return true; + } + } + } + return false; + } + + /** + * Checks if is an floating name external node. + * + * @param node + * the node + * @return true, if is an floating name external node + */ + public boolean isAnFloatingNameExternalNode(GenExternalNodeLabel node) { + // Look if the edit part name contains the default edit part name suffix + if (node.getEditPartClassName().contains(DEFAULT_EDITPART_NAME_SUFFIX)) { + return true; + } else { + return false; + } + } +} diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddExternalNodeFloatingNameDisplayBehavior.java b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddExternalNodeFloatingNameDisplayBehavior.java deleted file mode 100644 index b9c1914045e..00000000000 --- a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddExternalNodeFloatingNameDisplayBehavior.java +++ /dev/null @@ -1,214 +0,0 @@ -/***************************************************************************** - * Copyright (c) 2009, 2014 CEA LIST and others. - * - * 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: - * Mickael ADAM (ALL4TEC) mickael.adam@all4tec.net - Initial API and implementation - * - *****************************************************************************/ - -package org.eclipse.papyrus.papyrusgmfgenextension.popupaction; - -import java.util.Iterator; - -import org.eclipse.emf.common.util.EList; -import org.eclipse.emf.common.util.URI; -import org.eclipse.emf.ecore.EObject; -import org.eclipse.emf.ecore.resource.Resource; -import org.eclipse.gmf.codegen.gmfgen.FeatureLabelModelFacet; -import org.eclipse.gmf.codegen.gmfgen.FigureViewmap; -import org.eclipse.gmf.codegen.gmfgen.GMFGenFactory; -import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator; -import org.eclipse.gmf.codegen.gmfgen.GenExternalNodeLabel; -import org.eclipse.gmf.codegen.gmfgen.GenLinkLabel; -import org.eclipse.gmf.codegen.gmfgen.GenNode; -import org.eclipse.gmf.codegen.gmfgen.GenNodeLabel; -import org.eclipse.gmf.codegen.gmfgen.GenParsers; -import org.eclipse.gmf.codegen.gmfgen.PredefinedParser; -import org.eclipse.jface.action.IAction; -import org.eclipse.ui.IViewPart; - -/** - * this class is used to add a label to display name from external node - */ -public class AddExternalNodeFloatingNameDisplayBehavior extends Action { - - public static final String FIGURE_VIEWMAP_PATH = "org.eclipse.papyrus.infra.gmfdiag.common.figure.node.PapyrusWrappingLabel";//"org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"; //$NON-NLS-1$ - - public static final String LABEL_POLICY_CLASS = "org.eclipse.papyrus.infra.gmfdiag.common.editpolicies.ExternalLabelPrimaryDragRoleEditPolicy"; //$NON-NLS-1$ - - public static final String LABEL_POLICY_KEY = "org.eclipse.gef.EditPolicy.PRIMARY_DRAG_ROLE"; //$NON-NLS-1$ - - public static final String DEFAULT_GETTER_NAME = "getFloatingNameLabel"; //$NON-NLS-1$ - - public static final String DEFAULT_EDITPART_NAME_SUFFIX = "FloatingNameEditPart"; //$NON-NLS-1$ - - public static final String DEFAULT_EDITPOLICY_NAME_SUFFIX = "FloatingNameItemSemanticEditPolicy"; //$NON-NLS-1$ - - // public static final String DEFAULT_WRAPPING_LABEL_CLASS = "org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"; //$NON-NLS-1$ - - public static final String DEFAULT_PARSER_PATTERN = ""; //$NON-NLS-1$ - - public static final String GEN_CLASS_RT_CLASS = "Node"; //$NON-NLS-1$ - - public static final String GEN_CLASS_FACET_META_FEATURE = "NamedElement"; //$NON-NLS-1$ - - public static final String GEN_FEATURE_FACET_META_FEATURE = "name"; //$NON-NLS-1$ - - public static final String URI_NOTATION_GENMODEL = "org.eclipse.gmf.runtime.notation/model/notation.genmodel"; //$NON-NLS-1$ - - public static final String URI_UML_GENMODEL = "org.eclipse.uml2.uml/model/UML.genmodel"; //$NON-NLS-1$ - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart) - */ - public void init(IViewPart view) { - // NO OP - } - - /* - * (non-Javadoc) - * - * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction) - */ - public void run(IAction action) { - // Parse selected GenLink(s) and add the desired CustomBehavior - Iterator it = getSelectedEObject().iterator(); - while (it.hasNext()) { - EObject eObject = it.next(); - if (eObject instanceof GenNode) { - // test if it has got a external node to display floating name - if (!hasAnFloatingNameExternalNode((GenNode) eObject)) { - createAnFloatingNameExternalNode((GenNode) eObject); - } - } - } - } - - /** - * creation an external node floating name - * - * @param eObject - * the parent genNode - */ - private void createAnFloatingNameExternalNode(GenNode eObject) { - // Create une external node label - GenExternalNodeLabel label = GMFGenFactory.eINSTANCE.createGenExternalNodeLabel(); - - // Set Name of the edit part - label.setEditPartClassName(eObject.getClassNamePrefix() + DEFAULT_EDITPART_NAME_SUFFIX); - // Set item semantic edit policy - label.setItemSemanticEditPolicyClassName(eObject.getClassNamePrefix() + DEFAULT_EDITPOLICY_NAME_SUFFIX); - // Set the Read only - label.setReadOnly(false); - - // Set GenLinkLabel VisualID with new unique ID - int visualID = SetVisualIDWithUnusedValue.getNewVisualID(eObject.eResource(), GenLinkLabel.class); - label.setVisualID(visualID); - - // Retrieve DiagramRunTimeClass in notation.genmodel (Node -> View) - URI uri_notation = URI.createPlatformPluginURI(URI_NOTATION_GENMODEL, false); - Resource notation = eObject.eResource().getResourceSet().getResource(uri_notation, true); - label.setDiagramRunTimeClass(findGenClass(notation, GEN_CLASS_RT_CLASS)); - - // Create Viewmap - FigureViewmap viewmap = GMFGenFactory.eINSTANCE.createFigureViewmap(); - viewmap.setFigureQualifiedClassName(FIGURE_VIEWMAP_PATH); - - // Create FeatureLabelModelFacet - FeatureLabelModelFacet facet = GMFGenFactory.eINSTANCE.createFeatureLabelModelFacet(); - facet.setEditPattern(DEFAULT_PARSER_PATTERN); - facet.setEditorPattern(DEFAULT_PARSER_PATTERN); - facet.setViewPattern(DEFAULT_PARSER_PATTERN); - - // Select NamedElement::name property in UML.genmodel for MetaFeatures - URI uri_uml = URI.createPlatformPluginURI(URI_UML_GENMODEL, false); - Resource uml = eObject.eResource().getResourceSet().getResource(uri_uml, true); - facet.getMetaFeatures().add(findGenFeature(uml, GEN_CLASS_FACET_META_FEATURE, GEN_FEATURE_FACET_META_FEATURE)); - // Attach Predefined Parser MessageFormatParser - // not good must find the predifined parser of the model... - - // Get the predefined parser. - PredefinedParser parser = getPredefinedParser(eObject); - facet.setParser(parser); - - // Attach created element one to another in the model - label.setViewmap(viewmap); - label.setModelFacet(facet); - - // Add custom Policy to have feedback - addCustomBehavior(label, LABEL_POLICY_KEY, LABEL_POLICY_CLASS); - - eObject.getLabels().add(label); - } - - /** - * Gets the predefined parser. - * - * @param eObject - * the e object - * @return the predefined parser - */ - private PredefinedParser getPredefinedParser(GenNode eObject) { - PredefinedParser parser = null; - // /get the ressource contents - EList ressourceContents = eObject.eResource().getContents(); - for (EObject ressourceContent : ressourceContents) { - // get the Gen Editor Node - if (ressourceContent instanceof GenEditorGenerator) { - // Get Parsers node - GenParsers genParsers = ((GenEditorGenerator) ressourceContent).getLabelParsers(); - for (EObject GenParsersContent : genParsers.eContents()) { - // Get the predefined parser - if (GenParsersContent instanceof PredefinedParser) { - parser = (PredefinedParser) GenParsersContent; - } - } - } - } - return parser; - } - - /** - * Checks for a floating name external node. - * - * @param node - * the node - * @return true, if successful - */ - public boolean hasAnFloatingNameExternalNode(GenNode node) { - Iterator iterator = node.getLabels().iterator(); - while (iterator.hasNext()) { - GenNodeLabel currentGenNodeLabel = iterator.next(); - // check each child node - if (currentGenNodeLabel instanceof GenExternalNodeLabel) { - if (isAnFloatingNameExternalNode((GenExternalNodeLabel) currentGenNodeLabel)) { - return true; - } - } - } - return false; - } - - /** - * Checks if is an floating name external node. - * - * @param node - * the node - * @return true, if is an floating name external node - */ - public boolean isAnFloatingNameExternalNode(GenExternalNodeLabel node) { - // Look if the edit part name contains the default edit part name suffix - if (node.getEditPartClassName().contains(DEFAULT_EDITPART_NAME_SUFFIX)) { - return true; - } else { - return false; - } - } -} diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/util/PapyrusgmfgenextensionAdapterFactory.java b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/util/PapyrusgmfgenextensionAdapterFactory.java index b69d3ed3c1c..59cc8fe2035 100644 --- a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/util/PapyrusgmfgenextensionAdapterFactory.java +++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/util/PapyrusgmfgenextensionAdapterFactory.java @@ -17,6 +17,7 @@ import org.eclipse.gmf.codegen.gmfgen.GenContainerBase; import org.eclipse.gmf.codegen.gmfgen.GenLinkEnd; import org.eclipse.gmf.codegen.gmfgen.GenNode; import org.eclipse.gmf.codegen.gmfgen.MetamodelType; +import org.eclipse.papyrus.papyrusgmfgenextension.*; import org.eclipse.papyrus.papyrusgmfgenextension.AdditionalEditPartCandies; import org.eclipse.papyrus.papyrusgmfgenextension.AlternateCanvas; import org.eclipse.papyrus.papyrusgmfgenextension.AlternateGenLink; @@ -230,6 +231,11 @@ public class PapyrusgmfgenextensionAdapterFactory extends AdapterFactoryImpl { return createCustomDiagramUpdaterSingletonAdapter(); } + @Override + public Adapter caseSpecificNodePlate(SpecificNodePlate object) { + return createSpecificNodePlateAdapter(); + } + @Override public Adapter caseGenCommonBase(GenCommonBase object) { return createGenCommonBaseAdapter(); @@ -662,6 +668,21 @@ public class PapyrusgmfgenextensionAdapterFactory extends AdapterFactoryImpl { return null; } + /** + * Creates a new adapter for an object of class '{@link org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate Specific Node Plate}'. + * + * This default implementation returns null so that we can easily ignore cases; + * it's useful to ignore a case when inheritance will catch all the cases anyway. + * + * + * @return the new adapter. + * @see org.eclipse.papyrus.papyrusgmfgenextension.SpecificNodePlate + * @generated + */ + public Adapter createSpecificNodePlateAdapter() { + return null; + } + /** * Creates a new adapter for an object of class '{@link org.eclipse.gmf.codegen.gmfgen.GenCommonBase Gen Common Base}'. * diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/util/PapyrusgmfgenextensionSwitch.java b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/util/PapyrusgmfgenextensionSwitch.java index 0f0206b2061..1c9e0a43873 100644 --- a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/util/PapyrusgmfgenextensionSwitch.java +++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/util/PapyrusgmfgenextensionSwitch.java @@ -16,6 +16,7 @@ import org.eclipse.gmf.codegen.gmfgen.GenContainerBase; import org.eclipse.gmf.codegen.gmfgen.GenLinkEnd; import org.eclipse.gmf.codegen.gmfgen.GenNode; import org.eclipse.gmf.codegen.gmfgen.MetamodelType; +import org.eclipse.papyrus.papyrusgmfgenextension.*; import org.eclipse.papyrus.papyrusgmfgenextension.AdditionalEditPartCandies; import org.eclipse.papyrus.papyrusgmfgenextension.AlternateCanvas; import org.eclipse.papyrus.papyrusgmfgenextension.AlternateGenLink; @@ -410,6 +411,17 @@ public class PapyrusgmfgenextensionSwitch extends Switch { } return result; } + case PapyrusgmfgenextensionPackage.SPECIFIC_NODE_PLATE: { + SpecificNodePlate specificNodePlate = (SpecificNodePlate) theEObject; + T result = caseSpecificNodePlate(specificNodePlate); + if (result == null) { + result = caseCommentedElement(specificNodePlate); + } + if (result == null) { + result = defaultCase(theEObject); + } + return result; + } default: return defaultCase(theEObject); } @@ -840,6 +852,23 @@ public class PapyrusgmfgenextensionSwitch extends Switch { return null; } + /** + * Returns the result of interpreting the object as an instance of 'Specific Node Plate'. + * + * This implementation returns null; + * returning a non-null result will terminate the switch. + * + * + * @param object + * the target of the switch. + * @return the result of interpreting the object as an instance of 'Specific Node Plate'. + * @see #doSwitch(org.eclipse.emf.ecore.EObject) doSwitch(EObject) + * @generated + */ + public T caseSpecificNodePlate(SpecificNodePlate object) { + return null; + } + /** * Returns the result of interpreting the object as an instance of 'Gen Common Base'. * -- cgit v1.2.3