Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorptessier2010-06-08 17:40:21 +0000
committerptessier2010-06-08 17:40:21 +0000
commit2ebb0e6e1ae7e2bef95f29a59e6e6174e74c79f3 (patch)
tree4849374cf6d3f772d8bf96cca9b83b0fbecc29bb /plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction
parent9f12de49df83a00f3c12adfc183dd01cb6e00740 (diff)
downloadorg.eclipse.papyrus-2ebb0e6e1ae7e2bef95f29a59e6e6174e74c79f3.tar.gz
org.eclipse.papyrus-2ebb0e6e1ae7e2bef95f29a59e6e6174e74c79f3.tar.xz
org.eclipse.papyrus-2ebb0e6e1ae7e2bef95f29a59e6e6174e74c79f3.zip
NEW - bug 315994: [Tool development] add tool in order to create a default representation of a named Element
https://bugs.eclipse.org/bugs/show_bug.cgi?id=315994
Diffstat (limited to 'plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction')
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddDefaultNamedElementAction.java172
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddShapeNamedElementAction.java182
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/EditpartGenHelper.java239
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/Messages.java51
-rw-r--r--plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/messages.properties5
5 files changed, 649 insertions, 0 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddDefaultNamedElementAction.java b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddDefaultNamedElementAction.java
new file mode 100644
index 00000000000..521a657faa0
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddDefaultNamedElementAction.java
@@ -0,0 +1,172 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.papyrusgmfgenextension.popupaction;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.codegen.ecore.genmodel.GenModelFactory;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage;
+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.CustomBehaviour;
+import org.eclipse.gmf.codegen.gmfgen.DefaultSizeAttributes;
+import org.eclipse.gmf.codegen.gmfgen.FigureViewmap;
+import org.eclipse.gmf.codegen.gmfgen.GMFGenFactory;
+import org.eclipse.gmf.codegen.gmfgen.GenDiagram;
+import org.eclipse.gmf.codegen.gmfgen.GenLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenTopLevelNode;
+import org.eclipse.gmf.codegen.gmfgen.MetamodelType;
+import org.eclipse.gmf.codegen.gmfgen.TypeModelFacet;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.resource.UML22UMLResource;
+
+
+/**
+ * The Class AddDefaultNamedElementAction it create an edti part to show a named element in the diagram
+ */
+public class AddDefaultNamedElementAction extends Action {
+
+
+ /** The Constant PACKAGED_ELEMENT_ATTRIBUTE. */
+ protected static final String PACKAGED_ELEMENT_ATTRIBUTE = "packagedElement"; //$NON-NLS-1$
+
+ /** The Constant PACKAGE_NAME. */
+ protected static final String PACKAGE_NAME = "Package"; //$NON-NLS-1$
+
+ /** The Constant UNKNOW_EDITPOLICY. */
+ protected static final String UNKNOW_EDITPOLICY = "YOUR OWN CHANGE SHAPE EDIT POLICY"; //$NON-NLS-1$
+
+ /** The Constant QUALIFIED_NAME_DISPLAY_EDIT_POLICY_VALUE. */
+ protected static final String QUALIFIED_NAME_DISPLAY_EDIT_POLICY_VALUE = "org.eclipse.papyrus.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy"; //$NON-NLS-1$
+
+ /** The Constant NODE_LABEL_DISPLAY_EDIT_POLICY_VALUE. */
+ protected static final String NODE_LABEL_DISPLAY_EDIT_POLICY_VALUE = "org.eclipse.papyrus.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy"; //$NON-NLS-1$
+
+ /** The Constant POPUP_BAR_EDIT_POLICY_VALUE. */
+ protected static final String POPUP_BAR_EDIT_POLICY_VALUE = "org.eclipse.papyrus.diagram.common.editpolicies.HyperLinkPopupBarEditPolicy"; //$NON-NLS-1$
+
+ /** The Constant CHANGE_SHAPE_POLICY_KEY. */
+ protected static final String CHANGE_SHAPE_POLICY_KEY = "org.eclipse.papyrus.diagram.common.editpolicies.ChangeStereotypedShapeEditPolicy.CHANGE_SHAPE_POLICY"; //$NON-NLS-1$
+
+ /** The Constant POLICY_QUALIFIED_NAME_POLICY_KEY. */
+ protected static final String POLICY_QUALIFIED_NAME_POLICY_KEY = "org.eclipse.papyrus.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY"; //$NON-NLS-1$
+
+ /** The Constant STEREOTYPE_LABEL_POLICY_KEY. */
+ protected static final String STEREOTYPE_LABEL_POLICY_KEY = "org.eclipse.papyrus.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY"; //$NON-NLS-1$
+
+ /** The Constant POPUPBAR_ROLE_KEY. */
+ protected static final String POPUPBAR_ROLE_KEY = "org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE"; //$NON-NLS-1$
+
+ /** The Constant NAME_ATTRIBUTE. */
+ protected static final String NAME_ATTRIBUTE = "name"; //$NON-NLS-1$
+
+ /** The Constant NAMED_ELEMENT_NAME. */
+ protected static final String NAMED_ELEMENT_NAME = "NamedElement"; //$NON-NLS-1$
+
+ /** The Constant NODE_NAMED_ELEMENT_FIGURE. */
+ protected static final String NODE_NAMED_ELEMENT_FIGURE = "org.eclipse.papyrus.diagram.common.figure.node.NodeNamedElementFigure"; //$NON-NLS-1$
+
+ /** The Constant GMF_NODE. */
+ protected static final String GMF_NODE = "Node"; //$NON-NLS-1$
+
+ /** The Constant WRAPPING_LABEL. */
+ protected static final String WRAPPING_LABEL = "org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"; //$NON-NLS-1$
+
+ /** The Constant DEFAULT_NAMED_ELEMENT_NAME. */
+ protected static final String DEFAULT_NAMED_ELEMENT_NAME = "DefaultNamedElementName"; //$NON-NLS-1$
+
+ /** The Constant URI_UML_GENMODEL. */
+ protected static final String URI_UML_GENMODEL = "org.eclipse.uml2.uml/model/UML.genmodel"; //$NON-NLS-1$
+
+ /** The Constant URI_NOTATION_GENMODEL. */
+ protected static final String URI_NOTATION_GENMODEL = "org.eclipse.gmf.runtime.notation/model/notation.genmodel"; //$NON-NLS-1$
+
+ /** The Constant DEFAULT_NAMED_ELEMENT. */
+ private static final String DEFAULT_NAMED_ELEMENT = "DefaultNamedElement"; //$NON-NLS-1$
+
+ /**
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ *
+ * @param action
+ */
+
+ @Override
+ public void run(IAction action) {
+ Iterator<EObject> it = getSelectedEObject().iterator();
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+ if(eObject instanceof GenDiagram){
+ GenDiagram genDiagram= ((GenDiagram)eObject);
+ createTopNode(genDiagram);
+ }
+ }
+ }
+
+ /**
+ * Creates the top node.
+ *
+ * @param genDiagram the gen diagram
+ */
+ public void createTopNode(GenDiagram genDiagram){
+ URI uri_notation = URI.createPlatformPluginURI(URI_NOTATION_GENMODEL, false);
+
+ Resource notation = genDiagram.eResource().getResourceSet().getResource(uri_notation, true);
+
+ GenTopLevelNode topNode=EditpartGenHelper.createTopNode(genDiagram, DEFAULT_NAMED_ELEMENT,findGenClass(notation, GMF_NODE));
+ genDiagram.getTopLevelNodes().add(topNode);
+ EditpartGenHelper.createMetaModelType(topNode, DEFAULT_NAMED_ELEMENT);
+ addBehavior(topNode);
+ addModelFacet(topNode);
+ GenLabel label=EditpartGenHelper.createGenNodeLabel(topNode, DEFAULT_NAMED_ELEMENT_NAME, findGenClass(notation, GMF_NODE));
+ EditpartGenHelper.createLabelViewMap(label, WRAPPING_LABEL);
+ findGenClass(notation, GMF_NODE);
+ EditpartGenHelper.createFigureViewMap(topNode, NODE_NAMED_ELEMENT_FIGURE, 100, 50);
+ URI uri_uml = URI.createPlatformPluginURI(URI_UML_GENMODEL, false);
+ Resource uml = topNode.eResource().getResourceSet().getResource(uri_uml, true);
+ EditpartGenHelper.createLabelModelFacet(label,findGenFeature(uml,NAMED_ELEMENT_NAME, NAME_ATTRIBUTE) ,EditpartGenHelper.getFirstPredefinedParse(genDiagram.getEditorGen()));
+ MessageDialog.open(MessageDialog.INFORMATION, new Shell(), Messages.generalInformation, Messages.message_Intro+Messages.rulesAboutNamedElement+Messages.ruleAboutChangeEditPolicy, MessageDialog.NONE);
+
+ }
+
+ /**
+ * Adds behaviors.
+ *
+ * @param topNode the top node
+ */
+ public void addBehavior(GenTopLevelNode topNode){
+ // add behavior
+ EditpartGenHelper.addBehavior(topNode, POPUPBAR_ROLE_KEY, POPUP_BAR_EDIT_POLICY_VALUE);
+ EditpartGenHelper.addBehavior(topNode, STEREOTYPE_LABEL_POLICY_KEY,NODE_LABEL_DISPLAY_EDIT_POLICY_VALUE);
+ EditpartGenHelper.addBehavior(topNode, POLICY_QUALIFIED_NAME_POLICY_KEY,QUALIFIED_NAME_DISPLAY_EDIT_POLICY_VALUE);
+ EditpartGenHelper.addBehavior(topNode, CHANGE_SHAPE_POLICY_KEY,UNKNOW_EDITPOLICY);
+ }
+
+ /**
+ * Adds the model facet.
+ *
+ * @param topNode the top node
+ */
+ public void addModelFacet(GenTopLevelNode topNode){
+ URI uri_uml = URI.createPlatformPluginURI(URI_UML_GENMODEL, false);
+ Resource uml = topNode.eResource().getResourceSet().getResource(uri_uml, true);
+ EditpartGenHelper.createModelFacet(topNode, findGenFeature(uml,PACKAGE_NAME, PACKAGED_ELEMENT_ATTRIBUTE), findGenClass(uml, NAMED_ELEMENT_NAME));
+
+ }
+
+}
+
diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddShapeNamedElementAction.java b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddShapeNamedElementAction.java
new file mode 100644
index 00000000000..aeda9382723
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/AddShapeNamedElementAction.java
@@ -0,0 +1,182 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.papyrusgmfgenextension.popupaction;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.codegen.ecore.genmodel.GenModelFactory;
+import org.eclipse.emf.codegen.ecore.genmodel.GenModelPackage;
+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.CustomBehaviour;
+import org.eclipse.gmf.codegen.gmfgen.DefaultSizeAttributes;
+import org.eclipse.gmf.codegen.gmfgen.FigureViewmap;
+import org.eclipse.gmf.codegen.gmfgen.GMFGenFactory;
+import org.eclipse.gmf.codegen.gmfgen.GenDiagram;
+import org.eclipse.gmf.codegen.gmfgen.GenLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenTopLevelNode;
+import org.eclipse.gmf.codegen.gmfgen.MetamodelType;
+import org.eclipse.gmf.codegen.gmfgen.TypeModelFacet;
+import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.dialogs.MessageDialog;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.uml2.uml.UMLPackage;
+import org.eclipse.uml2.uml.resource.UML22UMLResource;
+
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class AddShapeNamedElementAction: create an edit part to display an element as the shape that comes from applied stereotypes.
+ */
+public class AddShapeNamedElementAction extends Action {
+
+
+ /** The Constant MESSAGE_INTRO. */
+ protected static final String MESSAGE_INTRO = Messages.message_Intro;
+
+ /** The Constant MESSAGE_INFO_1. */
+ protected static final String MESSAGE_INFO_1 =Messages.rulesAboutShapeEditPart;
+
+ /** The Constant MESSAGE_INFO_2. */
+ protected static final String MESSAGE_INFO_2 =Messages.ruleAboutChangeEditPolicy;
+
+ /** The Constant PACKAGED_ELEMENT_ATTRIBUTE. */
+ protected static final String PACKAGED_ELEMENT_ATTRIBUTE = "packagedElement"; //$NON-NLS-1$
+
+ /** The Constant PACKAGE_NAME. */
+ protected static final String PACKAGE_NAME = "Package"; //$NON-NLS-1$
+
+ /** The Constant UNKNOW_EDITPOLICY. */
+ protected static final String UNKNOW_EDITPOLICY = "YOUR OWN CHANGE SHAPE EDIT POLICY"; //$NON-NLS-1$
+
+ /** The Constant QUALIFIED_NAME_DISPLAY_EDIT_POLICY_VALUE. */
+ protected static final String QUALIFIED_NAME_DISPLAY_EDIT_POLICY_VALUE = "org.eclipse.papyrus.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy"; //$NON-NLS-1$
+
+ /** The Constant NODE_LABEL_DISPLAY_EDIT_POLICY_VALUE. */
+ protected static final String NODE_LABEL_DISPLAY_EDIT_POLICY_VALUE = "org.eclipse.papyrus.diagram.common.editpolicies.AppliedStereotypeNodeLabelDisplayEditPolicy"; //$NON-NLS-1$
+
+ /** The Constant POPUP_BAR_EDIT_POLICY_VALUE. */
+ protected static final String POPUP_BAR_EDIT_POLICY_VALUE = "org.eclipse.papyrus.diagram.common.editpolicies.HyperLinkPopupBarEditPolicy"; //$NON-NLS-1$
+
+ /** The Constant CHANGE_SHAPE_POLICY_KEY. */
+ protected static final String CHANGE_SHAPE_POLICY_KEY = "org.eclipse.papyrus.diagram.common.editpolicies.ChangeStereotypedShapeEditPolicy.CHANGE_SHAPE_POLICY"; //$NON-NLS-1$
+
+ /** The Constant POLICY_QUALIFIED_NAME_POLICY_KEY. */
+ protected static final String POLICY_QUALIFIED_NAME_POLICY_KEY = "org.eclipse.papyrus.diagram.common.editpolicies.QualifiedNameDisplayEditPolicy.QUALIFIED_NAME_POLICY"; //$NON-NLS-1$
+
+ /** The Constant STEREOTYPE_LABEL_POLICY_KEY. */
+ protected static final String STEREOTYPE_LABEL_POLICY_KEY = "org.eclipse.papyrus.diagram.common.editpolicies.AppliedStereotypeLabelDisplayEditPolicy.STEREOTYPE_LABEL_POLICY"; //$NON-NLS-1$
+
+ /** The Constant POPUPBAR_ROLE_KEY. */
+ protected static final String POPUPBAR_ROLE_KEY = "org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.POPUPBAR_ROLE"; //$NON-NLS-1$
+
+ /** The Constant NAME_ATTRIBUTE. */
+ protected static final String NAME_ATTRIBUTE = "name"; //$NON-NLS-1$
+
+ /** The Constant NAMED_ELEMENT_NAME. */
+ protected static final String NAMED_ELEMENT_NAME = "NamedElement"; //$NON-NLS-1$
+
+ /** The Constant NODE_NAMED_ELEMENT_FIGURE. */
+ protected static final String NODE_NAMED_ELEMENT_FIGURE = "org.eclipse.papyrus.diagram.common.figure.node.ShapeNamedElementFigure"; //$NON-NLS-1$
+
+ /** The Constant GMF_NODE. */
+ protected static final String GMF_NODE = "Node"; //$NON-NLS-1$
+
+ /** The Constant WRAPPING_LABEL. */
+ protected static final String WRAPPING_LABEL = "org.eclipse.gmf.runtime.draw2d.ui.figures.WrappingLabel"; //$NON-NLS-1$
+
+ /** The Constant DEFAULT_NAMED_ELEMENT_NAME. */
+ protected static final String DEFAULT_NAMED_ELEMENT_NAME = "ShapeNamedElementName"; //$NON-NLS-1$
+
+ /** The Constant URI_UML_GENMODEL. */
+ protected static final String URI_UML_GENMODEL = "org.eclipse.uml2.uml/model/UML.genmodel"; //$NON-NLS-1$
+
+ /** The Constant URI_NOTATION_GENMODEL. */
+ protected static final String URI_NOTATION_GENMODEL = "org.eclipse.gmf.runtime.notation/model/notation.genmodel"; //$NON-NLS-1$
+
+ /** The Constant DEFAULT_NAMED_ELEMENT. */
+ private static final String DEFAULT_NAMED_ELEMENT = "ShapeNamedElement"; //$NON-NLS-1$
+
+ /**
+ * @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
+ *
+ * @param action
+ */
+
+ @Override
+ public void run(IAction action) {
+ Iterator<EObject> it = getSelectedEObject().iterator();
+ while(it.hasNext()) {
+ EObject eObject = it.next();
+ if(eObject instanceof GenDiagram){
+ GenDiagram genDiagram= ((GenDiagram)eObject);
+ createTopNode(genDiagram);
+ }
+ }
+ }
+
+ /**
+ * Creates the top node.
+ *
+ * @param genDiagram the gen diagram
+ */
+ public void createTopNode(GenDiagram genDiagram){
+ URI uri_notation = URI.createPlatformPluginURI(URI_NOTATION_GENMODEL, false);
+
+ Resource notation = genDiagram.eResource().getResourceSet().getResource(uri_notation, true);
+
+ GenTopLevelNode topNode=EditpartGenHelper.createTopNode(genDiagram, DEFAULT_NAMED_ELEMENT,findGenClass(notation, GMF_NODE));
+ genDiagram.getTopLevelNodes().add(topNode);
+ EditpartGenHelper.createMetaModelType(topNode, DEFAULT_NAMED_ELEMENT);
+ addBehavior(topNode);
+ addModelFacet(topNode);
+ GenLabel label=EditpartGenHelper.createExternalGenNodeLabel(topNode, DEFAULT_NAMED_ELEMENT_NAME, findGenClass(notation, GMF_NODE));
+ EditpartGenHelper.createLabelViewMap(label, WRAPPING_LABEL);
+ findGenClass(notation, GMF_NODE);
+ EditpartGenHelper.createFigureViewMap(topNode, NODE_NAMED_ELEMENT_FIGURE, 100, 50);
+ URI uri_uml = URI.createPlatformPluginURI(URI_UML_GENMODEL, false);
+ Resource uml = topNode.eResource().getResourceSet().getResource(uri_uml, true);
+ EditpartGenHelper.createLabelModelFacet(label,findGenFeature(uml,NAMED_ELEMENT_NAME, NAME_ATTRIBUTE) ,EditpartGenHelper.getFirstPredefinedParse(genDiagram.getEditorGen()));
+ MessageDialog.open(MessageDialog.INFORMATION, new Shell(), Messages.generalInformation, MESSAGE_INTRO+MESSAGE_INFO_1+MESSAGE_INFO_2, MessageDialog.NONE);
+
+ }
+
+ /**
+ * Adds the behavior.
+ *
+ * @param topNode the top node
+ */
+ public void addBehavior(GenTopLevelNode topNode){
+ // add behavior
+ EditpartGenHelper.addBehavior(topNode, POPUPBAR_ROLE_KEY, POPUP_BAR_EDIT_POLICY_VALUE);
+ EditpartGenHelper.addBehavior(topNode, STEREOTYPE_LABEL_POLICY_KEY,NODE_LABEL_DISPLAY_EDIT_POLICY_VALUE);
+ EditpartGenHelper.addBehavior(topNode, POLICY_QUALIFIED_NAME_POLICY_KEY,QUALIFIED_NAME_DISPLAY_EDIT_POLICY_VALUE);
+ EditpartGenHelper.addBehavior(topNode, CHANGE_SHAPE_POLICY_KEY,UNKNOW_EDITPOLICY);
+ }
+
+ /**
+ * Adds the model facet.
+ *
+ * @param topNode the top node
+ */
+ public void addModelFacet(GenTopLevelNode topNode){
+ URI uri_uml = URI.createPlatformPluginURI(URI_UML_GENMODEL, false);
+ Resource uml = topNode.eResource().getResourceSet().getResource(uri_uml, true);
+ EditpartGenHelper.createModelFacet(topNode, findGenFeature(uml,PACKAGE_NAME, PACKAGED_ELEMENT_ATTRIBUTE), findGenClass(uml, NAMED_ELEMENT_NAME));
+
+ }
+
+}
+
diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/EditpartGenHelper.java b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/EditpartGenHelper.java
new file mode 100644
index 00000000000..8c122b2c2f3
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/EditpartGenHelper.java
@@ -0,0 +1,239 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.papyrusgmfgenextension.popupaction;
+
+import java.util.Iterator;
+
+import org.eclipse.emf.codegen.ecore.genmodel.GenClass;
+import org.eclipse.emf.codegen.ecore.genmodel.GenFeature;
+import org.eclipse.emf.common.util.EList;
+import org.eclipse.emf.common.util.URI;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.gmf.codegen.gmfgen.CustomBehaviour;
+import org.eclipse.gmf.codegen.gmfgen.DefaultSizeAttributes;
+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.GenCommonBase;
+import org.eclipse.gmf.codegen.gmfgen.GenDiagram;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorGenerator;
+import org.eclipse.gmf.codegen.gmfgen.GenEditorView;
+import org.eclipse.gmf.codegen.gmfgen.GenExpressionProviderBase;
+import org.eclipse.gmf.codegen.gmfgen.GenExternalNodeLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenNode;
+import org.eclipse.gmf.codegen.gmfgen.GenNodeLabel;
+import org.eclipse.gmf.codegen.gmfgen.GenParserImplementation;
+import org.eclipse.gmf.codegen.gmfgen.GenTopLevelNode;
+import org.eclipse.gmf.codegen.gmfgen.LabelModelFacet;
+import org.eclipse.gmf.codegen.gmfgen.MetamodelType;
+import org.eclipse.gmf.codegen.gmfgen.ParentAssignedViewmap;
+import org.eclipse.gmf.codegen.gmfgen.PredefinedParser;
+import org.eclipse.gmf.codegen.gmfgen.StyleAttributes;
+import org.eclipse.gmf.codegen.gmfgen.TypeModelFacet;
+
+
+
+/**
+ * The Class EditpartGenHelper tha contains a lot of useful method to create gennodes etc..
+ */
+public class EditpartGenHelper {
+
+ /** The Constant EDIT_HELPER. */
+ public static final String EDIT_HELPER = "EditHelper";
+
+ /** The Constant CANONICAL_EDIT_POLICY. */
+ protected static final String CANONICAL_EDIT_POLICY = "CanonicalEditPolicy"; //$NON-NLS-1$
+
+ /** The Constant EDIT_PART. */
+ private static final String EDIT_PART = "EditPart"; //$NON-NLS-1$
+
+ /**
+ * Adds the behavior.
+ *
+ * @param base the base where we want to add a behvior
+ * @param key the key
+ * @param value the value
+ */
+ public static void addBehavior(GenCommonBase base, String key,String value){
+ CustomBehaviour behaviour =GMFGenFactory.eINSTANCE.createCustomBehaviour();
+ behaviour.setKey(key);
+ behaviour.setEditPolicyQualifiedClassName(value);
+ base.getBehaviour().add(behaviour);
+ }
+
+ /**
+ * Creates the top node.
+ *
+ * @param genDiagram the gen diagram
+ * @param name the name
+ * @param visualClass the visual class node etc..
+ * @return the gen top level node
+ */
+ public static GenTopLevelNode createTopNode(GenDiagram genDiagram, String name, GenClass visualClass){
+ GenTopLevelNode topNode=GMFGenFactory.eINSTANCE.createGenTopLevelNode();
+ topNode.setEditPartClassName(name+EDIT_PART);
+ topNode.setCanonicalEditPolicyClassName(name+CANONICAL_EDIT_POLICY);
+ topNode.setCreateCommandClassName(name+"CreateCommand"); //$NON-NLS-1$
+ topNode.setGraphicalNodeEditPolicyClassName(name+"GraphicalNodeEditPolicy"); //$NON-NLS-1$
+ topNode.setItemSemanticEditPolicyClassName(name+"ItemSemanticEditPolicy"); //$NON-NLS-1$
+ topNode.setDiagramRunTimeClass(visualClass);
+ genDiagram.getTopLevelNodes().add(topNode);
+ topNode.setVisualID(SetVisualIDWithUnusedValue.getNewVisualID(topNode.eResource(), topNode.getClass()));
+
+
+ return topNode;
+
+ }
+
+ /**
+ * Creates the gen node label.
+ *
+ * @param genNode the gen node
+ * @param name the name
+ * @param visualClass the visual class node etc...
+ * @return the gen node label
+ */
+ public static GenNodeLabel createGenNodeLabel(GenNode genNode, String name, GenClass visualClass){
+ GenNodeLabel nodeLabel=GMFGenFactory.eINSTANCE.createGenNodeLabel();
+ nodeLabel.setEditPartClassName(name+EDIT_PART);
+ nodeLabel.setItemSemanticEditPolicyClassName(name+"ItemSemanticEditPolicy"); //$NON-NLS-1$
+ nodeLabel.setDiagramRunTimeClass(visualClass);
+ genNode.getLabels().add(nodeLabel);
+ nodeLabel.setVisualID(SetVisualIDWithUnusedValue.getNewVisualID(genNode.eResource(), GenCommonBase.class));
+
+ return nodeLabel;
+
+ }
+
+ /**
+ * Creates the external gen node label.
+ *
+ * @param genNode the gen node
+ * @param name the name
+ * @param visualClass the visual class node etc ...
+ * @return the gen node label
+ */
+ public static GenNodeLabel createExternalGenNodeLabel(GenNode genNode, String name, GenClass visualClass){
+ GenNodeLabel nodeLabel=GMFGenFactory.eINSTANCE.createGenExternalNodeLabel();
+ nodeLabel.setEditPartClassName(name+EDIT_PART);
+ nodeLabel.setItemSemanticEditPolicyClassName(name+"ItemSemanticEditPolicy"); //$NON-NLS-1$
+ nodeLabel.setDiagramRunTimeClass(visualClass);
+ genNode.getLabels().add(nodeLabel);
+ nodeLabel.setVisualID(SetVisualIDWithUnusedValue.getNewVisualID(genNode.eResource(), GenCommonBase.class));
+
+ return nodeLabel;
+
+ }
+
+ /**
+ * Creates the meta model type.
+ *
+ * @param base the base that will contains the metamodel type
+ * @param name the name of the edit class helper
+ */
+ public static void createMetaModelType(GenCommonBase base,String name){
+ MetamodelType metamodelType=GMFGenFactory.eINSTANCE.createMetamodelType();
+ metamodelType.setDefinedExternally(false);
+ metamodelType.setDisplayName(name);
+ metamodelType.setEditHelperClassName(name+EDIT_HELPER); //$NON-NLS-1$
+ metamodelType.setDiagramElement(base);
+ }
+
+
+ /**
+ * Creates the label view map.
+ *
+ * @param base the base that will contains the labelview map
+ * @param qualifiedNameFigure the qualified name figure
+ */
+ public static void createLabelViewMap(GenCommonBase base, String qualifiedNameFigure){
+ ParentAssignedViewmap figureViewmap=GMFGenFactory.eINSTANCE.createParentAssignedViewmap();
+ figureViewmap.setFigureQualifiedClassName(qualifiedNameFigure);
+ figureViewmap.setGetterName("getNameLabel");
+ StyleAttributes styleAttributes= GMFGenFactory.eINSTANCE.createStyleAttributes();
+ styleAttributes.setFixedBackground(false);
+ styleAttributes.setFixedFont(true);
+ styleAttributes.setFixedForeground(false);
+
+ figureViewmap.getAttributes().add(styleAttributes);
+ base.setViewmap(figureViewmap);
+ }
+
+ /**
+ * Creates the figure view map.
+ *
+ * @param base the base that will contains the labelview map
+ * @param qualifiedNameFigure the qualified name figure
+ * @param width the width of the default figure
+ * @param height the height of the default figure
+ */
+ public static void createFigureViewMap(GenCommonBase base, String qualifiedNameFigure,int width ,int height){
+ FigureViewmap figureViewmap=GMFGenFactory.eINSTANCE.createFigureViewmap();
+ figureViewmap.setFigureQualifiedClassName(qualifiedNameFigure);
+ DefaultSizeAttributes defaultSizeAttributes= GMFGenFactory.eINSTANCE.createDefaultSizeAttributes();
+ defaultSizeAttributes.setWidth(width);
+ defaultSizeAttributes.setHeight(height);
+ figureViewmap.getAttributes().add(defaultSizeAttributes);
+ base.setViewmap(figureViewmap);
+ }
+
+ /**
+ * Creates the model facet.
+ *
+ * @param base the base that will contains the model facet
+ * @param genFeature the gen feature
+ * @param genclass the genclass
+ */
+ public static void createModelFacet(GenNode base, GenFeature genFeature,GenClass genclass){
+ TypeModelFacet facet = GMFGenFactory.eINSTANCE.createTypeModelFacet();
+ facet.setMetaClass(genclass);
+ facet.setContainmentMetaFeature(genFeature);
+ base.setModelFacet(facet);
+
+ }
+
+ /**
+ * Creates the label model facet.
+ *
+ * @param label the label that will contains the label model facet
+ * @param genFeature the gen feature
+ * @param value the value
+ */
+ public static void createLabelModelFacet(GenLabel label, GenFeature genFeature, GenParserImplementation value){
+ FeatureLabelModelFacet facet = GMFGenFactory.eINSTANCE.createFeatureLabelModelFacet();
+ facet.getMetaFeatures().add(genFeature);
+ facet.setParser(value);
+ label.setModelFacet(facet);
+
+ }
+
+ /**
+ * Gets the first predefined parse.
+ *
+ * @param editorView the editor view
+ * @return the first predefined parse
+ */
+ public static PredefinedParser getFirstPredefinedParse(GenEditorGenerator editorView){
+ Iterator<GenParserImplementation>iter=editorView.getLabelParsers().getImplementations().iterator();
+ while(iter.hasNext()){
+ GenParserImplementation base= iter.next();
+ if(base instanceof PredefinedParser){
+ return (PredefinedParser)base;
+ }
+
+ }
+ return null;
+ }
+}
diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/Messages.java b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/Messages.java
new file mode 100644
index 00000000000..99cf4e9943f
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/Messages.java
@@ -0,0 +1,51 @@
+/*****************************************************************************
+ * Copyright (c) 2010 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:
+ * Patrick Tessier (CEA LIST) Patrick.tessier@cea.fr - Initial API and implementation
+ *
+ *****************************************************************************/
+package org.eclipse.papyrus.papyrusgmfgenextension.popupaction;
+
+import org.eclipse.osgi.util.NLS;
+
+// TODO: Auto-generated Javadoc
+/**
+ * The Class Messages.
+ */
+public class Messages extends NLS {
+
+ /** The Constant BUNDLE_NAME. */
+ private static final String BUNDLE_NAME = "org.eclipse.papyrus.papyrusgmfgenextension.popupaction.messages"; //$NON-NLS-1$
+
+ /** The rules about named element. */
+ public static String rulesAboutNamedElement;
+
+ /** The message_ intro. */
+ public static String message_Intro;
+
+ /** The rules about shape edit part. */
+ public static String rulesAboutShapeEditPart;
+
+ /** The rule about change edit policy. */
+ public static String ruleAboutChangeEditPolicy;
+
+ /** The general information. */
+ public static String generalInformation;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ /**
+ * Instantiates a new messages.
+ */
+ private Messages() {
+ }
+}
diff --git a/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/messages.properties b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/messages.properties
new file mode 100644
index 00000000000..ed1008e119c
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.gmfgenextension/src/org/eclipse/papyrus/papyrusgmfgenextension/popupaction/messages.properties
@@ -0,0 +1,5 @@
+rulesAboutNamedElement=set in the gmf extension that this edit part must inherits from org.eclipse.papyrus.diagram.common.editparts.NamedElementEditPart
+message_Intro=Do not forget :\n
+rulesAboutShapeEditPart=- set the abstract editpart in the gmf extension: org.eclipse.papyrus.diagram.common.editparts.AbstractShapeEditPart\n
+ruleAboutChangeEditPolicy=- Fill the editpolicy CHANGE_SHAPE_POLICY that have to inherit from org.eclipse.papyrus.diagram.common.editpolicies.ChangeStereotypedShapeEditPolicy
+generalInformation=Generation Information

Back to the top