Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFlorian Noyrit2016-01-14 11:20:03 +0000
committerFlorian Noyrit2016-01-16 22:05:25 +0000
commitee643f15fbc35c66669deb860b1c86e025a9f177 (patch)
tree75296c779e3234ffdae44e7fbded8642ca3e71f3 /plugins/developer
parent05e99c8bdfa2d44588e9e4ea19a24c69e7146469 (diff)
downloadorg.eclipse.papyrus-ee643f15fbc35c66669deb860b1c86e025a9f177.tar.gz
org.eclipse.papyrus-ee643f15fbc35c66669deb860b1c86e025a9f177.tar.xz
org.eclipse.papyrus-ee643f15fbc35c66669deb860b1c86e025a9f177.zip
Refactored the generated code to handle visualID as a String instead of
an int and refactoed the API to comply. Change-Id: Ie459e27d5c80dd18743aeac9e2d745b2f95a4fe0
Diffstat (limited to 'plugins/developer')
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/META-INF/MANIFEST.MF3
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/impl/diagram/editparts/NodeEditPart.xtend35
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/impl/diagram/update/CanonicalUpdate.xtend11
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/impl/parsers/ParserProvider.xtend19
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editparts/Common.xtend6
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xtend7
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend84
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/linkCommands.xtend19
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/DiagramUpdater.xtend55
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/LinkDescriptor.xtend41
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/NodeDescriptor.xtend34
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/DiagramContentInitializer.xtend27
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/NewDiagramFileWizard.xtend4
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/VisualIDRegistry.xtend184
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/navigator/NavigatorContentProvider.xtend17
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/navigator/NavigatorSorter.xtend42
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/propsheet/LabelProvider.xtend66
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/EditPartProvider.xtend26
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ElementTypes.xtend75
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/IconProvider.xtend26
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ValidationProvider.xtend101
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ViewProvider.xtend81
-rw-r--r--plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/VisualTypeProvider.xtend8
-rw-r--r--plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/xtend-gen/org/eclipse/papyrus/elementtypesconfigurations/developer/generator/ElementTypeRegistryGenerator.java232
24 files changed, 926 insertions, 277 deletions
diff --git a/plugins/developer/org.eclipse.papyrus.def/META-INF/MANIFEST.MF b/plugins/developer/org.eclipse.papyrus.def/META-INF/MANIFEST.MF
index 7841b77e423..b5120a970b4 100644
--- a/plugins/developer/org.eclipse.papyrus.def/META-INF/MANIFEST.MF
+++ b/plugins/developer/org.eclipse.papyrus.def/META-INF/MANIFEST.MF
@@ -18,8 +18,7 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.2.0,4.0.0)",
org.eclipse.gmf.codegen.xtend;bundle-version="1.0.0",
org.eclipse.papyrus.gmfgenextension;bundle-version="1.2.0"
Bundle-Vendor: %providerName
-Bundle-ClassPath: .,
- bin/
+Bundle-ClassPath: ., bin/
Bundle-Version: 1.2.0.qualifier
Bundle-Name: %pluginName
Bundle-Localization: plugin
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/impl/diagram/editparts/NodeEditPart.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/impl/diagram/editparts/NodeEditPart.xtend
index 81aac98f260..78cc989408a 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/impl/diagram/editparts/NodeEditPart.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/impl/diagram/editparts/NodeEditPart.xtend
@@ -215,22 +215,25 @@ override addFixedChild (GenNode it)'''
override borderItemSelectionEditPolicy(GenNode it)'''
«IF hasBorderItems(it)»
org.eclipse.gmf.runtime.notation.View childView = (org.eclipse.gmf.runtime.notation.View) child.getModel();
- switch («getVisualIDMethodCall(getDiagram())»(childView)) {
- «IF getExternalLabels(it).size > 0»
- «FOR nextLabel : getExternalLabels(it) »
- «caseVisualID(nextLabel)»
- «ENDFOR»
- return «borderItemSelectionEP(it)»;
- «ENDIF»
- «IF getSideAffixedChildren(it).size > 0»
- «FOR nextBorderItem : getSideAffixedChildren(it)»
- «caseVisualID(nextBorderItem)»
- «ENDFOR»
- ««« BEGIN PapyrusGenCode
- ««« The purprose is to add replace GMF edit prolicy by an new editPolicy that allows to resize BorderItem
- return new org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy();
- ««« END PapyrusGenCode
- «ENDIF»
+ String vid = «getVisualIDMethodCall(getDiagram())»(childView);
+ if (vid != null) {
+ switch (vid) {
+ «IF getExternalLabels(it).size > 0»
+ «FOR nextLabel : getExternalLabels(it) »
+ «caseVisualID(nextLabel)»
+ «ENDFOR»
+ return «borderItemSelectionEP(it)»;
+ «ENDIF»
+ «IF getSideAffixedChildren(it).size > 0»
+ «FOR nextBorderItem : getSideAffixedChildren(it)»
+ «caseVisualID(nextBorderItem)»
+ «ENDFOR»
+ ««« BEGIN PapyrusGenCode
+ ««« The purprose is to add replace GMF edit prolicy by an new editPolicy that allows to resize BorderItem
+ return new org.eclipse.papyrus.uml.diagram.common.editpolicies.BorderItemResizableEditPolicy();
+ ««« END PapyrusGenCode
+ «ENDIF»
+ }
}
«ENDIF»
'''
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/impl/diagram/update/CanonicalUpdate.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/impl/diagram/update/CanonicalUpdate.xtend
index 0206e2b54cc..ee25e102f69 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/impl/diagram/update/CanonicalUpdate.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/impl/diagram/update/CanonicalUpdate.xtend
@@ -121,10 +121,13 @@ import xpt.editor.VisualIDRegistry
}
java.util.LinkedList<«linkDescriptor.qualifiedClassName(it.editorGen.diagramUpdater)»> result = new java.util.LinkedList<«linkDescriptor.
qualifiedClassName(it.editorGen.diagramUpdater)»>();
- switch («xptVisualIDRegistry.getVisualIDMethodCall(it)»(view)) {
- «FOR se : it.allSemanticElements»
- «caseSemanticElement(se)»
- «ENDFOR»
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(it)»(view);
+ if (vid != null) {
+ switch (vid) {
+ «FOR se : it.allSemanticElements»
+ «caseSemanticElement(se)»
+ «ENDFOR»
+ }
}
for (java.util.Iterator<?> children = view.getChildren().iterator(); children.hasNext();) {
result.addAll(collectAllLinks((org.eclipse.gmf.runtime.notation.View) children.next(), domain2NotationMap));
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/impl/parsers/ParserProvider.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/impl/parsers/ParserProvider.xtend
index 03dc1d64c19..927e0195a6b 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/impl/parsers/ParserProvider.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/impl/parsers/ParserProvider.xtend
@@ -131,4 +131,23 @@ import xpt.providers.ParserUtils_qvto
«ENDIF»
'''
+ override def getParserByVisualIdMethod(GenParsers it) '''
+ «generatedMemberComment()»
+ protected org.eclipse.gmf.runtime.common.ui.services.parser.IParser getParser(String visualID) {
+ if (visualID != null) {
+ switch (visualID) {
+ «FOR node : editorGen.diagram.topLevelNodes»
+ «dispatch_getParsers(node)»
+ «ENDFOR»
+ «FOR node : editorGen.diagram.childNodes»
+ «dispatch_getParsers(node)»
+ «ENDFOR»
+ «FOR link : editorGen.diagram.links»
+ «dispatch_getParsers(link)»
+ «ENDFOR»
+ }
+ }
+ return null;
+ }
+ '''
}
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editparts/Common.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editparts/Common.xtend
index e684003f814..7f4538d4f87 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editparts/Common.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editparts/Common.xtend
@@ -23,6 +23,7 @@ import com.google.inject.Inject
//This template has been modified in order to remove canonical ediPolicies
@Singleton class Common extends xpt.diagram.editparts.Common {
+ @Inject extension xpt.Common;
@Inject QualifiedClassNameProvider qualifiedClassNameProvider;
@@ -48,4 +49,9 @@ import com.google.inject.Inject
installEditPolicy(org.eclipse.gmf.runtime.diagram.ui.editpolicies.EditPolicyRoles.SEMANTIC_ROLE, new «qualifiedClassNameProvider.getItemSemanticEditPolicyQualifiedClassName(it)»());
«ENDIF»
'''
+
+ override def visualIDConstant(GenCommonBase it) '''
+ «generatedMemberComment»
+ public static final String VISUAL_ID = "«visualID»";
+ '''
} \ No newline at end of file
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xtend
index 7eddd06d17f..eac67c43c73 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xtend
@@ -60,7 +60,7 @@ public class «className(it)» extends org.eclipse.gmf.runtime.diagram.ui.editpoli
if (request instanceof org.eclipse.gef.requests.ReconnectRequest) {
Object view = ((org.eclipse.gef.requests.ReconnectRequest) request).getConnectionEditPart().getModel();
if (view instanceof org.eclipse.gmf.runtime.notation.View) {
- Integer id = new Integer(«getVisualIDMethodCall(it)»((org.eclipse.gmf.runtime.notation.View) view));
+ String id = «getVisualIDMethodCall(it)»((org.eclipse.gmf.runtime.notation.View) view);
request.getExtendedData().put(VISUAL_ID_KEY, id);
request.getExtendedData().put(GRAPHICAL_RECONNECTED_EDGE, view);
}
@@ -69,9 +69,8 @@ public class «className(it)» extends org.eclipse.gmf.runtime.diagram.ui.editpoli
}
«generatedMemberComment('Returns visual id from request parameters.')»
- protected int getVisualID(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest request) {
- Object id = request.getParameter(VISUAL_ID_KEY);
- return id instanceof Integer ? ((Integer) id).intValue() : -1;
+ protected String getVisualID(org.eclipse.gmf.runtime.emf.type.core.requests.IEditCommandRequest request) {
+ return (String) request.getParameter(VISUAL_ID_KEY);
}
«semanticPart(it)»
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend
index 9c54424d319..cad9fffee3d 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xtend
@@ -107,22 +107,28 @@ protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.
org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
for (java.util.Iterator<?> nit = view.getChildren().iterator(); nit.hasNext();) {
org.eclipse.gmf.runtime.notation.Node node = (org.eclipse.gmf.runtime.notation.Node) nit.next();
- switch («xptVisualIDRegistry.getVisualIDMethodCall(it.diagram)»(node)) {
- «FOR cn : it.childNodes»
- «destroyChildNodes(cn, 'node', it)»
- «ENDFOR»
- «FOR compartment : it.compartments»
- «xptVisualIDRegistry.caseVisualID(compartment)»
- for (java.util.Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
- org.eclipse.gmf.runtime.notation.Node cnode = (org.eclipse.gmf.runtime.notation.Node) cit.next();
- switch («xptVisualIDRegistry.getVisualIDMethodCall(it.diagram)»(cnode)) {
- «FOR cn : compartment.childNodes»
- «destroyChildNodes(cn, 'cnode', it)»
- «ENDFOR»
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(it.diagram)»(node);
+ if (vid != null) {
+ switch (vid) {
+ «FOR cn : it.childNodes»
+ «destroyChildNodes(cn, 'node', it)»
+ «ENDFOR»
+ «FOR compartment : it.compartments»
+ «xptVisualIDRegistry.caseVisualID(compartment)»
+ for (java.util.Iterator<?> cit = node.getChildren().iterator(); cit.hasNext();) {
+ org.eclipse.gmf.runtime.notation.Node cnode = (org.eclipse.gmf.runtime.notation.Node) cit.next();
+ String cvid = «xptVisualIDRegistry.getVisualIDMethodCall(it.diagram)»(cnode);
+ if (cvid != null) {
+ switch (cvid) {
+ «FOR cn : compartment.childNodes»
+ «destroyChildNodes(cn, 'cnode', it)»
+ «ENDFOR»
+ }
+ }
}
+ break;
+ «ENDFOR»
}
- break;
- «ENDFOR»
}
}
}
@@ -179,25 +185,28 @@ protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.
«IF !genIncomingLinks.isEmpty()»
for (java.util.Iterator<?> it = «view».getTargetEdges().iterator(); it.hasNext();) {
org.eclipse.gmf.runtime.notation.Edge incomingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next();
- switch(«xptVisualIDRegistry.getVisualIDMethodCall(getDiagram())»(incomingLink)) {
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(getDiagram())»(incomingLink);
+ if (vid != null) {
+ switch(vid) {
«IF !genIncomingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet].empty»
«FOR il : genIncomingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet]»
- case «VisualIDRegistry.visualID(il)»:
+ case «VisualIDRegistry.visualID(il)»:
«ENDFOR»
- org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest destroyRefReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
- cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
+ org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest destroyRefReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest(incomingLink.getSource().getElement(), null, incomingLink.getTarget().getElement(), false);
+ cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
«ENDIF»
«IF !genIncomingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet].empty»
«FOR il : genIncomingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet]»
- case «VisualIDRegistry.visualID(il)»:
+ case «VisualIDRegistry.visualID(il)»:
«ENDFOR»
- org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest destroyEltReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest(incomingLink.getElement(), false);
- cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
- break;
+ org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest destroyEltReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest(incomingLink.getElement(), false);
+ cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ break;
«ENDIF»
+ }
}
}
«ENDIF»
@@ -205,25 +214,28 @@ protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.
«IF genOutgoingLinks.isEmpty()»
for (java.util.Iterator<?> it = «view».getSourceEdges().iterator(); it.hasNext();) {
org.eclipse.gmf.runtime.notation.Edge outgoingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next();
- switch(«xptVisualIDRegistry.getVisualIDMethodCall(getDiagram())»(outgoingLink)) {
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(getDiagram())»(outgoingLink);
+ if (vid != null) {
+ switch(vid) {
«IF !genOutgoingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet].empty»
«FOR ol : genOutgoingLinks.filter[l | l.modelFacet instanceof FeatureLinkModelFacet]»
- case «VisualIDRegistry.visualID(ol)»:
+ case «VisualIDRegistry.visualID(ol)»:
«ENDFOR»
- org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest destroyRefReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest(outgoingLink.getSource().getElement(), null, outgoingLink.getTarget().getElement(), false);
- cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand(destroyRefReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), outgoingLink));
- break;
+ org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest destroyRefReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest(outgoingLink.getSource().getElement(), null, outgoingLink.getTarget().getElement(), false);
+ cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand(destroyRefReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), outgoingLink));
+ break;
«ENDIF»
«IF !genOutgoingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet].empty»
«FOR ol : genOutgoingLinks.filter[l | l.modelFacet instanceof TypeLinkModelFacet]»
- case «VisualIDRegistry.visualID(ol)»:
+ case «VisualIDRegistry.visualID(ol)»:
«ENDFOR»
- org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest destroyEltReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest(outgoingLink.getElement(), false);
- cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(destroyEltReq));
- cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), outgoingLink));
- break;
+ org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest destroyEltReq = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest(outgoingLink.getElement(), false);
+ cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(destroyEltReq));
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), outgoingLink));
+ break;
«ENDIF»
+ }
}
}
«ENDIF»
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/linkCommands.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/linkCommands.xtend
index f8dc70c6a14..f4895b3a4d6 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/linkCommands.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/editpolicies/linkCommands.xtend
@@ -153,14 +153,17 @@ import xpt.providers.ElementTypes
protected org.eclipse.gef.commands.Command getReorientRelationshipCommand(
org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest req) {
- switch (getVisualID(req)) {
- «FOR link : getReroutableTypeLinks(it)»
- «reorientLinkCommandWithService(link) »
- «ENDFOR»
- «callReorientCommand(it)»
- «FOR link : getReroutableTypeLinks(it)»
- «reorientLinkCommandWithoutService(link) »
- «ENDFOR»
+ String vid = getVisualID(req);
+ if (vid != null) {
+ switch (vid) {
+ «FOR link : getReroutableTypeLinks(it)»
+ «reorientLinkCommandWithService(link) »
+ «ENDFOR»
+ «callReorientCommand(it)»
+ «FOR link : getReroutableTypeLinks(it)»
+ «reorientLinkCommandWithoutService(link) »
+ «ENDFOR»
+ }
}
return super.getReorientRelationshipCommand(req);
}
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/DiagramUpdater.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/DiagramUpdater.xtend
index 13adcc7b058..a2888d120d6 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/DiagramUpdater.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/DiagramUpdater.xtend
@@ -22,18 +22,17 @@ import org.eclipse.gmf.codegen.gmfgen.FeatureLinkModelFacet
import org.eclipse.gmf.codegen.gmfgen.GenCommonBase
import org.eclipse.gmf.codegen.gmfgen.GenContainerBase
import org.eclipse.gmf.codegen.gmfgen.GenDiagram
+import org.eclipse.gmf.codegen.gmfgen.GenDiagramUpdater
import org.eclipse.gmf.codegen.gmfgen.GenLink
+import org.eclipse.gmf.codegen.gmfgen.GenNode
import org.eclipse.gmf.codegen.gmfgen.TypeLinkModelFacet
+import org.eclipse.papyrus.papyrusgmfgenextension.CustomDiagramUpdaterSingleton
import org.eclipse.papyrus.papyrusgmfgenextension.SpecificDiagramUpdater
import xpt.Common
import xpt.Common_qvto
import xpt.GenModelUtils_qvto
-import xpt.diagram.updater.LinkDescriptor
-import xpt.diagram.updater.NodeDescriptor
import xpt.diagram.updater.UpdaterLinkType
import xpt.diagram.updater.Utils_qvto
-import org.eclipse.gmf.codegen.gmfgen.GenDiagramUpdater
-import org.eclipse.papyrus.papyrusgmfgenextension.CustomDiagramUpdaterSingleton
// we removed all static modifiers and all private methods becames protected to allow to override method.
//see bug421212: [Diagram] Papyrus should provide actions for Show/Hide related links in all diagrams
@@ -42,9 +41,9 @@ import org.eclipse.papyrus.papyrusgmfgenextension.CustomDiagramUpdaterSingleton
@Inject extension Common_qvto;
@Inject extension Utils_qvto;
@Inject extension GenModelUtils_qvto;
- @Inject LinkDescriptor linkDescriptor;
+ @Inject xpt.diagram.updater.LinkDescriptor linkDescriptor;
@Inject VisualIDRegistry xptVisualIDRegistry;
- @Inject NodeDescriptor nodeDescriptor;
+ @Inject xpt.diagram.updater.NodeDescriptor nodeDescriptor;
@Inject MetaModel xptMetaModel;
@@ -91,7 +90,7 @@ import org.eclipse.papyrus.papyrusgmfgenextension.CustomDiagramUpdaterSingleton
package «packageName(it)»;
«generatedClassComment»
- public class «className(it)» implements org.eclipse.gmf.tooling.runtime.update.DiagramUpdater {
+ public class «className(it)» implements org.eclipse.papyrus.infra.gmfdiag.common.updater.DiagramUpdater {
«classSingleton(it)»
«_constructor(it)»
«isShortcutOrphaned(it)»
@@ -216,7 +215,7 @@ import org.eclipse.papyrus.papyrusgmfgenextension.CustomDiagramUpdaterSingleton
{ «xptMetaModel.DeclareAndAssign(childMetaFeature.typeGenClass, 'childElement', 'modelElement',
it.getModelElementType(), childMetaFeature)»
«ENDIF»
- int visualID = «xptVisualIDRegistry.getNodeVisualIDMethodCall(it.diagram)»(view, «xptMetaModel.
+ String visualID = «xptVisualIDRegistry.getNodeVisualIDMethodCall(it.diagram)»(view, «xptMetaModel.
DowncastToEObject(childMetaFeature.typeGenClass, 'childElement')»);
«FOR next : getSemanticChildren(it, childMetaFeature)»
«checkChildElementVisualID(next, null != childMetaFeature && childMetaFeature.listType)»
@@ -282,10 +281,13 @@ import org.eclipse.papyrus.papyrusgmfgenextension.CustomDiagramUpdaterSingleton
««« remove static modifier
public «listOfNodeDescriptors» getSemanticChildren(org.eclipse.gmf.runtime.notation.View view) {
«IF semanticContainers.notEmpty»
- switch («xptVisualIDRegistry.getVisualIDMethodCall(editorGen.diagram)»(view)) {
- «FOR next : semanticContainers»
- «getSemanticChildrenCase(next)»
- «ENDFOR»
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(editorGen.diagram)»(view);
+ if (vid != null) {
+ switch (vid) {
+ «FOR next : semanticContainers»
+ «getSemanticChildrenCase(next)»
+ «ENDFOR»
+ }
}
«ENDIF»
return «newEmptyList()»;
@@ -309,10 +311,13 @@ import org.eclipse.papyrus.papyrusgmfgenextension.CustomDiagramUpdaterSingleton
««« remove static modifier
public «listOfLinkDescriptors» get«linkType.linkMethodSuffix»Links(org.eclipse.gmf.runtime.notation.View view) {
«IF linkContainers.notEmpty»
- switch («xptVisualIDRegistry.getVisualIDMethodCall(it.editorGen.diagram)»(view)) {
- «FOR next : linkContainers»
- «getContainedLinksCase(next, linkType)»
- «ENDFOR»
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(it.editorGen.diagram)»(view);
+ if (vid != null) {
+ switch (vid) {
+ «FOR next : linkContainers»
+ «getContainedLinksCase(next, linkType)»
+ «ENDFOR»
+ }
}
«ENDIF»
return «newEmptyList»;
@@ -322,4 +327,22 @@ import org.eclipse.papyrus.papyrusgmfgenextension.CustomDiagramUpdaterSingleton
override runtimeTypedInstance(GenDiagramUpdater it) '''
'''
+ /**
+ * XXX: [MG] suspicious code inside, EVEN after I moved ", " into the IF, there still may be problem if inner IF condition is not met.
+ * Need to check with case when it.modelFacet.childMetaFeature == null
+ */
+ override def checkChildElementVisualID(GenNode it, Boolean inLoop) '''
+ if («VisualIDRegistry::visualID(it)».equals(visualID)) {
+ result.add(new «nodeDescriptor.qualifiedClassName(it.getDiagram().diagramUpdater)»(«IF null != modelFacet.childMetaFeature»«xptMetaModel.DowncastToEObject(modelFacet.childMetaFeature.typeGenClass, 'childElement')», «ENDIF»visualID));
+ «IF inLoop»
+ continue;
+ «ENDIF»
+ }
+ '''
+
+ override def checkLinkVisualID(TypeLinkModelFacet it, GenLink genLink, boolean inLoop) '''
+ if (!«VisualIDRegistry::visualID(genLink)».equals(«xptVisualIDRegistry.getLinkWithClassVisualIDMethodCall(genLink.diagram)»(«xptMetaModel.DowncastToEObject(metaClass, 'link')»))) {
+ «stopLinkProcessing(inLoop)»
+ }
+ '''
} \ No newline at end of file
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/LinkDescriptor.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/LinkDescriptor.xtend
new file mode 100644
index 00000000000..d5ebb0ee871
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/LinkDescriptor.xtend
@@ -0,0 +1,41 @@
+/**
+ * Copyright (c) 2007, 2010, 2014 Borland Software Corporation, CEA, 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Borland) - [243151] explicit source/target for links
+ * Michael Golubev (Montages) - API extracted to gmf.tooling.runtime, template migrated to Xtend2
+ * Christian W. Damus (CEA) - bug 426732: override the cross-reference searches for views to use the CrossReferenceAdapter
+ */
+package aspects.xpt.diagram.updater
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.gmf.codegen.gmfgen.GenDiagramUpdater
+import xpt.Common
+
+@Singleton class LinkDescriptor extends xpt.diagram.updater.LinkDescriptor {
+ @Inject extension Common;
+
+ override def extendsList(GenDiagramUpdater it) '''extends org.eclipse.papyrus.infra.gmfdiag.common.updater.UpdaterLinkDescriptor'''
+
+ override def refOnlyLinkConstructor(GenDiagramUpdater it) '''
+ «generatedMemberComment»
+ public «className(it)»(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject destination, org.eclipse.gmf.runtime.emf.type.core.IElementType elementType, String linkVID) {
+ super(source, destination, elementType, linkVID);
+ }
+ '''
+
+ override def typeLinkConstructor(GenDiagramUpdater it) '''
+ «generatedMemberComment»
+ public «className(it)»(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject destination, org.eclipse.emf.ecore.EObject linkElement, org.eclipse.gmf.runtime.emf.type.core.IElementType elementType, String linkVID) {
+ super(source, destination, linkElement, elementType, linkVID);
+ }
+ '''
+
+} \ No newline at end of file
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/NodeDescriptor.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/NodeDescriptor.xtend
new file mode 100644
index 00000000000..5dbb3e1e4ae
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/diagram/updater/NodeDescriptor.xtend
@@ -0,0 +1,34 @@
+/**
+ * Copyright (c) 2007, 2010, 2014 Borland Software Corporation, CEA, 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Borland) - [243151] explicit source/target for links
+ * Michael Golubev (Montages) - API extracted to gmf.tooling.runtime, template migrated to Xtend2
+ * Christian W. Damus (CEA) - bug 426732: override the cross-reference searches for views to use the CrossReferenceAdapter
+ */
+package aspects.xpt.diagram.updater
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.gmf.codegen.gmfgen.GenDiagramUpdater
+import xpt.Common
+
+@Singleton class NodeDescriptor extends xpt.diagram.updater.NodeDescriptor {
+ @Inject extension Common;
+
+ override def extendsList(GenDiagramUpdater it) '''extends org.eclipse.papyrus.infra.gmfdiag.common.updater.UpdaterNodeDescriptor'''
+
+ override def constructor(GenDiagramUpdater it) '''
+ «generatedMemberComment»
+ public «className(it)»(org.eclipse.emf.ecore.EObject modelElement, String visualID) {
+ super(modelElement, visualID);
+ }
+ '''
+
+} \ No newline at end of file
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/DiagramContentInitializer.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/DiagramContentInitializer.xtend
new file mode 100644
index 00000000000..b57b883619e
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/DiagramContentInitializer.xtend
@@ -0,0 +1,27 @@
+package aspects.xpt.editor
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.gmf.codegen.gmfgen.GenDiagram
+import xpt.Common
+
+@Singleton class DiagramContentInitializer extends xpt.editor.DiagramContentInitializer {
+ @Inject extension Common;
+
+ @Inject VisualIDRegistry xptVisualIDRegistry;
+
+ override def getCompartment(GenDiagram it) '''
+ «generatedMemberComment»
+ private org.eclipse.gmf.runtime.notation.Node getCompartment(org.eclipse.gmf.runtime.notation.View node, String visualID) {
+ String type = «xptVisualIDRegistry.typeMethodCall(it, 'visualID')»;
+ for (java.util.Iterator it = node.getChildren().iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.View nextView = (org.eclipse.gmf.runtime.notation.View) it.next();
+ if (nextView instanceof org.eclipse.gmf.runtime.notation.Node && type.equals(nextView.getType())) {
+ return (org.eclipse.gmf.runtime.notation.Node) nextView;
+ }
+ }
+ return null;
+ }
+ '''
+
+} \ No newline at end of file
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/NewDiagramFileWizard.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/NewDiagramFileWizard.xtend
index c6ba5db9b2e..3e836230ef3 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/NewDiagramFileWizard.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/NewDiagramFileWizard.xtend
@@ -141,8 +141,8 @@ import xpt.CodeStyle
protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(
org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info)
throws org.eclipse.core.commands.ExecutionException {
- int diagramVID = «xptVisualIDRegistry.getDiagramVisualIDMethodCall(it)»(diagramRootElementSelectionPage.getModelElement());
- if (diagramVID != «VisualIDRegistry::visualID(it)») {
+ String diagramVID = «xptVisualIDRegistry.getDiagramVisualIDMethodCall(it)»(diagramRootElementSelectionPage.getModelElement());
+ if (diagramVID.equals(«VisualIDRegistry::visualID(it)»)) {
return org.eclipse.gmf.runtime.common.core.command.CommandResult.newErrorCommandResult(
«xptExternalizer.accessorCall(editorGen, i18nKeyForNewDiagramFileWizardIncorrectRootError(it))»);
}
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/VisualIDRegistry.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/VisualIDRegistry.xtend
index b799fa7b3c3..0678d9c5410 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/VisualIDRegistry.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/editor/VisualIDRegistry.xtend
@@ -18,31 +18,33 @@ import metamodel.MetaModel
import org.eclipse.emf.codegen.ecore.genmodel.GenClass
import org.eclipse.gmf.codegen.gmfgen.GenCommonBase
import org.eclipse.gmf.codegen.gmfgen.GenDiagram
-import org.eclipse.gmf.codegen.gmfgen.GenExpressionInterpreter
import org.eclipse.gmf.codegen.gmfgen.GenJavaExpressionProvider
import org.eclipse.gmf.codegen.gmfgen.GenLink
import org.eclipse.gmf.codegen.gmfgen.TypeModelFacet
import org.eclipse.gmf.codegen.gmfgen.ValueExpression
import xpt.CodeStyle
import xpt.Common
-import xpt.expressions.getExpression
-import org.eclipse.gmf.codegen.gmfgen.GenConstraint
+import xpt.Common_qvto
+import xpt.diagram.editpolicies.LinkUtils_qvto
+import xpt.diagram.updater.Utils_qvto
//XXX: [MG] decide what to do with @MetaDef methods
@Singleton class VisualIDRegistry extends xpt.editor.VisualIDRegistry {
-
@Inject extension MetaModel
@Inject extension Common
+ @Inject extension Common_qvto;
+ @Inject extension LinkUtils_qvto;
+ @Inject extension Utils_qvto;
+
@Inject CodeStyle xptCodeStyle;
- @Inject getExpression xptGetExpression;
override getDiagramVisualID(GenDiagram it) '''
«generatedMemberComment()»
- public static int «getDiagramVisualIDMethodName(it)»(org.eclipse.emf.ecore.EObject domainElement) {
+ public static String «getDiagramVisualIDMethodName(it)»(org.eclipse.emf.ecore.EObject domainElement) {
if (domainElement == null) {
«unrecognizedVID(it)»
}
- return «visualID»;
+ return «visualID(it)»;
}
'''
@@ -124,10 +126,10 @@ import org.eclipse.gmf.codegen.gmfgen.GenConstraint
override runtimeTypedInstance(GenDiagram it) '''
«generatedClassComment()»
- public static final org.eclipse.gmf.tooling.runtime.structure.DiagramStructure «runtimeTypedInstanceName(it)» = new org.eclipse.gmf.tooling.runtime.structure.DiagramStructure() {
+ public static final org.eclipse.papyrus.infra.gmfdiag.common.structure.DiagramStructure «runtimeTypedInstanceName(it)» = new org.eclipse.papyrus.infra.gmfdiag.common.structure.DiagramStructure() {
«generatedMemberComment()»
«xptCodeStyle.overrideC(it)»
- public int «getVisualIdMethodName(it)»(org.eclipse.gmf.runtime.notation.View view) {
+ public String «getVisualIdMethodName(it)»(org.eclipse.gmf.runtime.notation.View view) {
return «getVisualIDMethodCall(it)»(view);
}
@@ -139,25 +141,25 @@ import org.eclipse.gmf.codegen.gmfgen.GenConstraint
«generatedMemberComment()»
«xptCodeStyle.overrideC(it)»
- public int «getNodeVisualIDMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement) {
+ public String «getNodeVisualIDMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement) {
return «getNodeVisualIDMethodCall(it)»(containerView, domainElement);
}
«generatedMemberComment()»
«xptCodeStyle.overrideC(it)»
- public boolean «checkNodeVisualIDMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement, int candidate) {
+ public boolean «checkNodeVisualIDMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement, String candidate) {
return «checkNodeVisualIDMethodCall(it)»(containerView, domainElement, candidate);
}
«generatedMemberComment()»
«xptCodeStyle.overrideC(it)»
- public boolean «isCompartmentVisualIDMethodName(it)»(int visualID) {
+ public boolean «isCompartmentVisualIDMethodName(it)»(String visualID) {
return «isCompartmentVisualIDMethodCall(it)»(visualID);
}
«generatedMemberComment()»
«xptCodeStyle.overrideC(it)»
- public boolean «isSemanticLeafVisualIDMethodName(it)»(int visualID) {
+ public boolean «isSemanticLeafVisualIDMethodName(it)»(String visualID) {
return «isSemanticLeafVisualIDMethodCall(it)»(visualID);
}
};
@@ -177,4 +179,160 @@ import org.eclipse.gmf.codegen.gmfgen.GenConstraint
return diagram != null ? diagram.getType() : null;
}
'''
+
+ override def getType(GenDiagram it) '''
+ «generatedMemberComment()»
+ public static String «getTypeMethodName(it)»(String visualID) {
+ return visualID;
+ }
+ '''
+
+ override def getViewVisualID(GenDiagram it) '''
+ «generatedMemberComment()»
+ public static String «getVisualIdMethodName(it)»(org.eclipse.gmf.runtime.notation.View view) {
+ if (view instanceof org.eclipse.gmf.runtime.notation.Diagram) {
+ if («modelID(it)».equals(view.getType())) {
+ return «visualID(it)»;
+ } else {
+ «unrecognizedVID(it)»
+ }
+ }
+ return «getVisualIDMethodCall(it)»(view.getType());
+ }
+ '''
+
+ override def unrecognizedVID(GenDiagram it) '''
+ return null;
+ '''
+
+ override def getVisualID(GenDiagram it) '''
+ «generatedMemberComment()»
+ public static String «getVisualIdMethodName(it)»(String type) {
+ return type;
+ }
+ '''
+
+ override def getNodeVisualID(GenDiagram it) '''
+ «generatedMemberComment()»
+ public static String «getNodeVisualIDMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement) {
+ if (domainElement == null) {
+ «unrecognizedVID(it)»
+ }
+ String containerModelID = «getModelIDMethodCall(it)»(containerView);
+ if (!«modelID(it)».equals(containerModelID)«FOR spf : shortcutsProvidedFor»«checkContainerModelID(spf)»«ENDFOR») { «nonNLS_All(shortcutsProvidedFor)»
+ «unrecognizedVID(it)»
+ }
+ String containerVisualID;
+ if («modelID(it)».equals(containerModelID)) {
+ containerVisualID = «getVisualIDMethodCall(it)»(containerView);
+ } else {
+ if (containerView instanceof org.eclipse.gmf.runtime.notation.Diagram) {
+ containerVisualID = «visualID(it)»;
+ } else {
+ «unrecognizedVID(it)»
+ }
+ }
+ if (containerVisualID != null) {
+ switch (containerVisualID) {
+ «FOR container : allContainers»
+ «caseDomainContainerVisualID(container)»
+ «ENDFOR»
+ }
+ }
+ «unrecognizedVID(it)»
+ }
+ '''
+
+ override def getLinkWithClassVisualID(GenDiagram it) '''
+ «generatedMemberComment()»
+ public static String «getLinkWithClassVisualIDMethodName(it)»(org.eclipse.emf.ecore.EObject domainElement) {
+ if (domainElement == null) {
+ «unrecognizedVID(it)»
+ }
+ «FOR typeLink : links.filter[l|isTypeLink(l)]»«returnVisualID(typeLink)»«ENDFOR»
+ «unrecognizedVID(it)»
+ }
+ '''
+
+ override def canCreateNode(GenDiagram it) '''
+ «generatedMemberComment()»
+ public static boolean «canCreateNodeMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, String nodeVisualID) {
+ String containerModelID = «getModelIDMethodCall(it)»(containerView);
+ if (!«modelID(it)».equals(containerModelID)«FOR spf : shortcutsProvidedFor»«checkContainerModelID(spf)»«ENDFOR») { «nonNLS_All(shortcutsProvidedFor)»
+ return false;
+ }
+ String containerVisualID;
+ if («modelID(it)».equals(containerModelID)) {
+ containerVisualID = «getVisualIDMethodCall(it)»(containerView);
+ } else {
+ if (containerView instanceof org.eclipse.gmf.runtime.notation.Diagram) {
+ containerVisualID = «visualID(it)»;
+ } else {
+ return false;
+ }
+ }
+ if (containerVisualID != null) {
+ switch (containerVisualID) {
+ «FOR container : allContainers.filter[e|getEssentialVisualChildren(e).notEmpty]»«checkEssentialChildren(container)»«ENDFOR»
+ «FOR link : links.filter[l|getEssentialVisualChildren(l).notEmpty]»«checkEssentialChildren(link)»«ENDFOR»
+ }
+ }
+ return false;
+ }
+ '''
+
+ override def checkEssentialChild(GenCommonBase it) '''
+ if («visualID(it)».equals(nodeVisualID)) {
+ return true;
+ }
+ '''
+
+ override def isCompartmentVisualID(GenDiagram it) '''
+ «generatedMemberComment()»
+ public static boolean «isCompartmentVisualIDMethodName(it)»(String visualID) {
+ «IF compartments.notEmpty»
+ if (visualID != null) {
+ switch (visualID) {
+ «FOR compartment : compartments»«caseVisualID(compartment)»«ENDFOR»
+ return true;
+ }
+ }
+ «ENDIF»
+ return false;
+ }
+ '''
+
+ override def isSemanticLeafVisualID(GenDiagram it) {
+ var leafs = it.allNodes.filter[n | getSemanticChildren(n).empty && n.compartments.forall[c | getSemanticChildren(c).empty]].sortBy[n|n.visualID]
+ return '''
+ «generatedMemberComment()»
+ public static boolean «isSemanticLeafVisualIDMethodName(it)»(String visualID) {
+ if (visualID != null) {
+ switch (visualID) {
+ «/*We need to ensure at last one case, this is legitimate way*/
+ caseVisualID(it)»
+ return false;
+ «IF leafs.notEmpty»
+ «FOR leaf : leafs»«caseVisualID(leaf)»«ENDFOR»
+ return true;
+ «ENDIF»
+ }
+ }
+ return false;
+ }
+ '''
+ }
+
+ override def checkNodeVisualID(GenDiagram it) '''
+ «generatedMemberComment()»
+ public static boolean «checkNodeVisualIDMethodName(it)»(org.eclipse.gmf.runtime.notation.View containerView, org.eclipse.emf.ecore.EObject domainElement, String candidate) {
+ if (candidate == null){
+ //unrecognized id is always bad
+ return false;
+ }
+ String basic = «getNodeVisualIDMethodName(it)»(containerView, domainElement);
+ return candidate.equals(basic);
+ }
+ '''
+
}
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/navigator/NavigatorContentProvider.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/navigator/NavigatorContentProvider.xtend
index 7ffd0a151d7..ddcff335340 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/navigator/NavigatorContentProvider.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/navigator/NavigatorContentProvider.xtend
@@ -175,13 +175,16 @@ import xpt.navigator.Utils_qvto import xpt.CodeStyle
override getViewChildren(GenNavigator it) '''
«generatedMemberComment()»
private Object[] getViewChildren(org.eclipse.gmf.runtime.notation.View view, Object parentElement) {
- switch («xptVisualIDRegistry.getVisualIDMethodCall(it.editorGen.diagram)»(view)) {
- ««« BEGIN: PapyrusGenCode
- ««« Restructuration of the case
- «FOR node : getNavigatorContainerNodes(it)»
- «caseNavigatorNode(node, it)»
- «ENDFOR»
- «««BEGIN: PapyrusGenCode
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(it.editorGen.diagram)»(view);
+ if (vid != null) {
+ switch (vid) {
+ ««« BEGIN: PapyrusGenCode
+ ««« Restructuration of the case
+ «FOR node : getNavigatorContainerNodes(it)»
+ «caseNavigatorNode(node, it)»
+ «ENDFOR»
+ «««BEGIN: PapyrusGenCode
+ }
}
return EMPTY_ARRAY;
}
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/navigator/NavigatorSorter.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/navigator/NavigatorSorter.xtend
new file mode 100644
index 00000000000..1bb05d61ecc
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/navigator/NavigatorSorter.xtend
@@ -0,0 +1,42 @@
+/**
+ * Copyright (c) 2007, 2010, 2013 Borland Software Corporation 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ */
+package aspects.xpt.navigator
+
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.gmf.codegen.gmfgen.GenNavigator
+import xpt.Common
+import xpt.editor.VisualIDRegistry
+
+@Singleton class NavigatorSorter extends xpt.navigator.NavigatorSorter {
+ @Inject extension Common;
+
+ @Inject VisualIDRegistry xptVisualIDRegistry;
+ @Inject NavigatorItem xptNavigatorItem;
+
+ override def category(GenNavigator it) '''
+ «generatedMemberComment()»
+ public int category(Object element) {
+ if (element instanceof «xptNavigatorItem.qualifiedClassName(it)») {
+ «xptNavigatorItem.qualifiedClassName(it)» item = («xptNavigatorItem.qualifiedClassName(it)») element;
+ «IF editorGen.diagram.generateCreateShortcutAction()»
+ if (item.getView().getEAnnotation("Shortcut") != null) { «nonNLS(1)»
+ return SHORTCUTS_CATEGORY;
+ }
+ «ENDIF»
+ return «xptVisualIDRegistry.getVisualIDMethodCall(editorGen.diagram)»(item.getView()).hashCode();
+ }
+ return GROUP_CATEGORY;
+ }
+ '''
+}
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/propsheet/LabelProvider.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/propsheet/LabelProvider.xtend
new file mode 100644
index 00000000000..4a89c0aa92c
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/propsheet/LabelProvider.xtend
@@ -0,0 +1,66 @@
+/**
+ * Copyright (c) 2007, 2010, 2013 Borland Software Corporation 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ */
+package aspects.xpt.propsheet
+
+import aspects.xpt.Common
+import aspects.xpt.editor.VisualIDRegistry
+import aspects.xpt.providers.ElementTypes
+import com.google.inject.Inject
+import com.google.inject.Singleton
+import org.eclipse.gmf.codegen.gmfgen.GenPropertySheet
+
+@Singleton class LabelProvider extends xpt.propsheet.LabelProvider {
+ @Inject extension Common;
+
+ @Inject ElementTypes xptElementTypes;
+ @Inject VisualIDRegistry visualId;
+
+ override def unwrapMethods(GenPropertySheet it) '''
+ «generatedMemberComment»
+ private Object unwrap(Object element) {
+ if (element instanceof org.eclipse.jface.viewers.IStructuredSelection) {
+ return ((org.eclipse.jface.viewers.IStructuredSelection) element).getFirstElement();
+ }
+ return element;
+ }
+
+ «generatedMemberComment»
+ private org.eclipse.gmf.runtime.notation.View getView(Object element) {
+ if (element instanceof org.eclipse.gmf.runtime.notation.View) {
+ return (org.eclipse.gmf.runtime.notation.View) element;
+ }
+ if (element instanceof org.eclipse.core.runtime.IAdaptable) {
+ return (org.eclipse.gmf.runtime.notation.View)
+ ((org.eclipse.core.runtime.IAdaptable) element).getAdapter(org.eclipse.gmf.runtime.notation.View.class);
+ }
+ return null;
+ }
+
+ «generatedMemberComment»
+ private org.eclipse.gmf.runtime.emf.type.core.IElementType getElementType(org.eclipse.gmf.runtime.notation.View view) {
+ // For intermediate views climb up the containment hierarchy to find the one associated with an element type.
+ while (view != null) {
+ String vid = «visualId.qualifiedClassName(editorGen.diagram)».getVisualID(view);
+ org.eclipse.gmf.runtime.emf.type.core.IElementType etype =
+ «xptElementTypes.qualifiedClassName(editorGen.diagram)».getElementType(vid);
+ if (etype != null) {
+ return etype;
+ }
+ view = view.eContainer() instanceof org.eclipse.gmf.runtime.notation.View ?
+ (org.eclipse.gmf.runtime.notation.View) view.eContainer() : null;
+ }
+ return null;
+ }
+ '''
+
+}
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/EditPartProvider.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/EditPartProvider.xtend
new file mode 100644
index 00000000000..e09576f2734
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/EditPartProvider.xtend
@@ -0,0 +1,26 @@
+/**
+ * Copyright (c) 2007, 2010, 2013 Borland Software Corporation 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Artem Tikhomirov (Borland) - [257119] Create views directly, not through ViewFactories
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Thibault Landre (Atos Origin) - initial API and implementation
+ * Vincent Lorenzo (CEA-LIST) Add a line to initialize the display of the compartments to true
+ * Vincent Lorenzo (CEA-LIST) - Add lines to initialize the display of the labels - Bug 335987 [General][Enhancement] Show/Hide Connectors Labels and External Nodes Labels
+ */
+package aspects.xpt.providers
+
+import com.google.inject.Singleton
+import org.eclipse.gmf.codegen.gmfgen.GenDiagram
+
+@Singleton class EditPartProvider extends xpt.providers.EditPartProvider {
+
+ override def extendsList(GenDiagram it) '''extends org.eclipse.papyrus.infra.gmfdiag.common.providers.DefaultEditPartProvider'''
+
+}
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ElementTypes.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ElementTypes.xtend
index 5b0ee5b1422..6e28d18da21 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ElementTypes.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ElementTypes.xtend
@@ -11,19 +11,22 @@
* Michael Golubev (Montages) - #386838 - migrate to Xtend2
* Christian W. Damus - bug 451230
*/
-package aspects.xpt.providers
-
+package aspects.xpt.providers
+
+import aspects.xpt.CodeStyle
import com.google.inject.Inject
-import xpt.diagram.Utils_qvto
-import com.google.inject.Singleton
-import org.eclipse.gmf.codegen.gmfgen.GenDiagram
-import xpt.Common
-
-@Singleton class ElementTypes extends xpt.providers.ElementTypes {
+import com.google.inject.Singleton
+import org.eclipse.gmf.codegen.gmfgen.GenCommonBase
+import org.eclipse.gmf.codegen.gmfgen.GenDiagram
+import xpt.Common
+import xpt.diagram.Utils_qvto
+@Singleton class ElementTypes extends xpt.providers.ElementTypes {
@Inject extension Common;
@Inject extension Utils_qvto;
+ @Inject CodeStyle xptCodeStyle;
+
override def getElement(GenDiagram it) '''
«generatedMemberComment('Returns \'type\' of the ecore object associated with the hint.\n')»
public static synchronized org.eclipse.emf.ecore.ENamedElement getElement(org.eclipse.core.runtime.IAdaptable hint) {
@@ -82,4 +85,58 @@ import xpt.Common
return result;
}
'''
-}
+
+ override def getElementTypeByVisualID(GenDiagram it) '''
+ «generatedMemberComment»
+ public static org.eclipse.gmf.runtime.emf.type.core.IElementType getElementType(String visualID) {
+ if (visualID != null) {
+ switch (visualID) {
+ «FOR e : it.getAllTypedElements().filter[el|el.elementType != null]»
+ «caseElementType(e)»
+ «ENDFOR»
+ }
+ }
+ return null;
+ }
+ '''
+
+ override def getElementType(GenDiagram it) '''
+ «generatedMemberComment»
+ private static org.eclipse.gmf.runtime.emf.type.core.IElementType getElementTypeByUniqueId(String id) {
+ return org.eclipse.gmf.runtime.emf.type.core.ElementTypeRegistry.getInstance().getType(id);
+ }
+ '''
+
+ override def elementTypeField(GenCommonBase it) '''
+ «IF null != elementType»
+ «generatedMemberComment»
+ public static final org.eclipse.gmf.runtime.emf.type.core.IElementType «getUniqueIdentifier()» = getElementTypeByUniqueId("«elementType.
+ uniqueIdentifier»"); «nonNLS(1)»
+ «ENDIF»
+ '''
+
+ override def typedInstance(GenDiagram it) '''
+ «generatedClassComment»
+ public static final org.eclipse.papyrus.infra.gmfdiag.common.providers.DiagramElementTypes TYPED_INSTANCE
+ = new org.eclipse.papyrus.infra.gmfdiag.common.providers.DiagramElementTypes(elementTypeImages) {
+
+ «generatedMemberComment»
+ «xptCodeStyle.overrideC(it)»
+ public boolean isKnownElementType(org.eclipse.gmf.runtime.emf.type.core.IElementType elementType) {
+ return «qualifiedClassName(it)».isKnownElementType(elementType);
+ }
+
+ «generatedMemberComment»
+ «xptCodeStyle.overrideC(it)»
+ public org.eclipse.gmf.runtime.emf.type.core.IElementType getElementTypeForVisualId(String visualID) {
+ return «qualifiedClassName(it)».getElementType(visualID);
+ }
+
+ «generatedMemberComment»
+ «xptCodeStyle.overrideC(it)»
+ public org.eclipse.emf.ecore.ENamedElement getDefiningNamedElement(org.eclipse.core.runtime.IAdaptable elementTypeAdapter) {
+ return «qualifiedClassName(it)».getElement(elementTypeAdapter);
+ }
+ };
+ '''
+} \ No newline at end of file
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/IconProvider.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/IconProvider.xtend
new file mode 100644
index 00000000000..3117626b436
--- /dev/null
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/IconProvider.xtend
@@ -0,0 +1,26 @@
+/**
+ * Copyright (c) 2007, 2014 Borland Software Corporation, CEA, 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:
+ * Dmitry Stadnik (Borland) - initial API and implementation
+ * Artem Tikhomirov (Borland) - refactored javaInitilizers not to use methods from GMFGen model
+ * [221347] Got rid of generated interfaces
+ * (IObjectInitializer, IFeatureInitializer) and implementation thereof
+ * Michael Golubev (Montages) - #386838 - migrate to Xtend2
+ * Christian W. Damus (CEA) - bug 440263
+ */
+package aspects.xpt.providers
+
+import com.google.inject.Singleton
+import org.eclipse.gmf.codegen.gmfgen.GenDiagram
+
+@Singleton class IconProvider extends xpt.providers.IconProvider {
+
+ override def extendsList(GenDiagram it) '''extends org.eclipse.papyrus.infra.gmfdiag.common.providers.DefaultElementTypeIconProvider'''
+
+}
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ValidationProvider.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ValidationProvider.xtend
index d731bc26480..88db7f9eeed 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ValidationProvider.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ValidationProvider.xtend
@@ -47,10 +47,10 @@ import xpt.CodeStyle
public boolean selects(Object object) {
«IF ctx.ruleTargets.filter(typeof(GenDiagramElementTarget)).notEmpty»
if (isInDefaultEditorContext(object) && object instanceof org.eclipse.gmf.runtime.notation.View) {
- final int id = «xptVisualIDRegistry.getVisualIDMethodCall(editorGen.diagram)»((org.eclipse.gmf.runtime.notation.View) object);
+ final String id = «xptVisualIDRegistry.getVisualIDMethodCall(editorGen.diagram)»((org.eclipse.gmf.runtime.notation.View) object);
boolean result = false;
«FOR e : getTargetDiagramElements(ctx)»
- result = result || id == «VisualIDRegistry::visualID(e)»;
+ result = result || «VisualIDRegistry::visualID(e)».equals(id);
«ENDFOR»
return result;
}
@@ -105,4 +105,101 @@ import xpt.CodeStyle
}
}
'''
+
+ override def strategy_support(GenDiagram it) '''
+ «IF hasDiagramElementTargetRule(editorGen.audits)»
+ «generatedMemberComment»
+ public static org.eclipse.emf.validation.service.ITraversalStrategy getNotationTraversalStrategy(
+ org.eclipse.emf.validation.service.IBatchValidator validator) {
+ return new CtxSwitchStrategy(validator);
+ }
+
+ «generatedMemberComment»
+ private static class CtxSwitchStrategy implements org.eclipse.emf.validation.service.ITraversalStrategy {
+
+ «generatedMemberComment»
+ private org.eclipse.emf.validation.service.ITraversalStrategy defaultStrategy;
+
+ «generatedMemberComment»
+ private String currentSemanticCtxId;
+
+ «generatedMemberComment»
+ private boolean ctxChanged = true;
+
+ «generatedMemberComment»
+ private org.eclipse.emf.ecore.EObject currentTarget;
+
+ «generatedMemberComment»
+ private org.eclipse.emf.ecore.EObject preFetchedNextTarget;
+
+ «generatedMemberComment»
+ private final String[] contextSwitchingIdentifiers;
+
+ «generatedMemberComment»
+ CtxSwitchStrategy(org.eclipse.emf.validation.service.IBatchValidator validator) {
+ this.defaultStrategy = validator.getDefaultTraversalStrategy();
+ this.contextSwitchingIdentifiers = new String[] {
+ «FOR e : getAllTargetDiagramElements(editorGen.audits) SEPARATOR ','»«VisualIDRegistry::visualID(e)»«ENDFOR»
+ };
+ java.util.Arrays.sort(this.contextSwitchingIdentifiers);
+ }
+
+ «generatedMemberComment»
+ public void elementValidated(org.eclipse.emf.ecore.EObject element,
+ org.eclipse.core.runtime.IStatus status) {
+ defaultStrategy.elementValidated(element, status);
+ }
+
+ «generatedMemberComment»
+ public boolean hasNext() {
+ return defaultStrategy.hasNext();
+ }
+
+ «generatedMemberComment»
+ public boolean isClientContextChanged() {
+ if (preFetchedNextTarget == null) {
+ preFetchedNextTarget = next();
+ prepareNextClientContext(preFetchedNextTarget);
+ }
+ return ctxChanged;
+ }
+
+ «generatedMemberComment»
+ public org.eclipse.emf.ecore.EObject next() {
+ org.eclipse.emf.ecore.EObject nextTarget = preFetchedNextTarget;
+ if (nextTarget == null) {
+ nextTarget = defaultStrategy.next();
+ }
+ this.preFetchedNextTarget = null;
+ return this.currentTarget = nextTarget;
+ }
+
+ «generatedMemberComment»
+ public void startTraversal(java.util.Collection traversalRoots, org.eclipse.core.runtime.IProgressMonitor monitor) {
+ defaultStrategy.startTraversal(traversalRoots, monitor);
+ }
+
+ «generatedMemberComment»
+ private void prepareNextClientContext(org.eclipse.emf.ecore.EObject nextTarget) {
+ if (nextTarget != null && currentTarget != null) {
+ if (nextTarget instanceof org.eclipse.gmf.runtime.notation.View) {
+ final String id = «xptVisualIDRegistry.getVisualIDMethodCall(editorGen.diagram)»((org.eclipse.gmf.runtime.notation.View) nextTarget);
+ String nextSemanticId = (id != null && java.util.Arrays.binarySearch(contextSwitchingIdentifiers, id) >= 0) ? id : null;
+ if ((currentSemanticCtxId != null && currentSemanticCtxId != nextSemanticId)
+ || (nextSemanticId != null && nextSemanticId != currentSemanticCtxId)) {
+ this.ctxChanged = true;
+ }«/*[artem] not sure why not ctxChanged = <expr>, is it intentional not to reset ctxChanged if condition did not match? I doubt. FIXME?*/»
+ currentSemanticCtxId = nextSemanticId;
+ } else {
+ // context of domain model
+ this.ctxChanged = currentSemanticCtxId != null;
+ currentSemanticCtxId = null;
+ }
+ } else {
+ this.ctxChanged = false;
+ }
+ }
+ }
+ «ENDIF»
+ '''
}
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ViewProvider.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ViewProvider.xtend
index c1792cad297..3c3dc43c983 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ViewProvider.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/ViewProvider.xtend
@@ -90,7 +90,7 @@ import xpt.editor.VisualIDRegistry
return false;
}
- int visualID = «getVisualIDMethodCall(it)»(op.getSemanticHint());
+ String visualID = «getVisualIDMethodCall(it)»(op.getSemanticHint());
if(org.eclipse.gmf.runtime.notation.Node.class.isAssignableFrom(op.getViewKind())) {
return «canCreateNodeMethodCall(it)»(op.getContainerView(), visualID);
}
@@ -113,7 +113,7 @@ import xpt.editor.VisualIDRegistry
«generatedMemberComment»«/* When diagram domain element is null only diagram kind is checked */»
protected boolean provides(org.eclipse.gmf.runtime.diagram.core.services.view.CreateDiagramViewOperation op) {
- return «VisualIDRegistry::modelID(it)».equals(op.getSemanticHint())«IF domainDiagramElement != null» && «xptVisualIDRegistry.getDiagramVisualIDMethodCall(it)»(getSemanticElement(op.getSemanticAdapter())) != -1«ENDIF»;
+ return «VisualIDRegistry::modelID(it)».equals(op.getSemanticHint())«IF domainDiagramElement != null» && «xptVisualIDRegistry.getDiagramVisualIDMethodCall(it)»(getSemanticElement(op.getSemanticAdapter())) != null«ENDIF»;
}
«generatedMemberComment»
@@ -123,7 +123,7 @@ import xpt.editor.VisualIDRegistry
}
org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = getSemanticElementType(op.getSemanticAdapter());
org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(op.getSemanticAdapter());
- int visualID;
+ String visualID;
if (op.getSemanticHint() == null) {
// Semantic hint is not specified. Can be a result of call from CanonicalEditPolicy.
// In this situation there should be NO elementType, visualID will be determined
@@ -148,7 +148,7 @@ import xpt.editor.VisualIDRegistry
if (!op.getSemanticHint().equals(elementTypeHint)) {
return false; // if semantic hint is specified it should be the same as in element type
}
- //if (domainElement != null && visualID != «getNodeVisualIDMethodCall(it)»(op.getContainerView(), domainElement)) {
+ //if (domainElement != null && !visualID.equals(«getNodeVisualIDMethodCall(it)»(op.getContainerView(), domainElement))) {
// return false; // visual id for node EClass should match visual id from element type
//}
} else {«/*
@@ -160,27 +160,29 @@ import xpt.editor.VisualIDRegistry
if (!«VisualIDRegistry::modelID(it)».equals(«xptVisualIDRegistry.getModelIDMethodCall(it)»(op.getContainerView()))) {
return false; // foreign diagram
}
- switch (visualID) {
- «IF getAllNodes().exists[e|e.elementType instanceof NotationType]»
- «FOR e : getAllNodes().map[e|e.elementType].filter(typeof(NotationType))»
- «localCaseVisualID(e)»
- «ENDFOR»
- break; // pure design element
- «ENDIF»
- «IF getAllNodes().exists[e|e.elementType instanceof MetamodelType || e.elementType instanceof SpecializationType]»
- «FOR e : getAllNodes().map[e|e.elementType].filter(typeof(MetamodelType))»
- «localCaseVisualID(e)»
- «ENDFOR»
- «FOR e : getAllNodes().map[e|e.elementType].filter(typeof(SpecializationType))»
- «localCaseVisualID(e)»
- «ENDFOR»
- if (domainElement == null || visualID != «xptVisualIDRegistry.getNodeVisualIDMethodCall(it)»(op.getContainerView(), domainElement)) {
- return false; // visual id in semantic hint should match visual id for domain element
+ if (visualID != null) {
+ switch (visualID) {
+ «IF getAllNodes().exists[e|e.elementType instanceof NotationType]»
+ «FOR e : getAllNodes().map[e|e.elementType].filter(typeof(NotationType))»
+ «localCaseVisualID(e)»
+ «ENDFOR»
+ break; // pure design element
+ «ENDIF»
+ «IF getAllNodes().exists[e|e.elementType instanceof MetamodelType || e.elementType instanceof SpecializationType]»
+ «FOR e : getAllNodes().map[e|e.elementType].filter(typeof(MetamodelType))»
+ «localCaseVisualID(e)»
+ «ENDFOR»
+ «FOR e : getAllNodes().map[e|e.elementType].filter(typeof(SpecializationType))»
+ «localCaseVisualID(e)»
+ «ENDFOR»
+ if (domainElement == null || !visualID.equals(«xptVisualIDRegistry.getNodeVisualIDMethodCall(it)»(op.getContainerView(), domainElement))) {
+ return false; // visual id in semantic hint should match visual id for domain element
+ }
+ break;«/*FIXME: Perhaps, can return true or false right away, without any further check?*/»
+ «ENDIF»
+ default:
+ return false;
}
- break;«/*FIXME: Perhaps, can return true or false right away, without any further check?*/»
- «ENDIF»
- default:
- return false;
}
«ELSE»
return false;
@@ -213,9 +215,9 @@ import xpt.editor.VisualIDRegistry
if (elementTypeHint == null || (op.getSemanticHint() != null && !elementTypeHint.equals(op.getSemanticHint()))) {
return false; // our hint is visual id and must be specified, and it should be the same as in element type
}
- //int visualID = «getVisualIDMethodCall(it)»(elementTypeHint);
+ //String visualID = «getVisualIDMethodCall(it)»(elementTypeHint);
//org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(op.getSemanticAdapter());
- //if (domainElement != null && visualID != «getLinkWithClassVisualIDMethodCall(it)»(domainElement)) {
+ //if (domainElement != null && !visualID.equals(«getLinkWithClassVisualIDMethodCall(it)»(domainElement))) {
// return false; // visual id for link EClass should match visual id from element type
//}
return true; «««Does it make sense to check visualID here, like we did for nodes?
@@ -245,17 +247,19 @@ import xpt.editor.VisualIDRegistry
«generatedMemberComment»
public org.eclipse.gmf.runtime.notation.Node createNode(org.eclipse.core.runtime.IAdaptable semanticAdapter, org.eclipse.gmf.runtime.notation.View containerView, String semanticHint, int index, boolean persisted, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
final org.eclipse.emf.ecore.EObject domainElement = getSemanticElement(semanticAdapter);
- final int visualID;
+ final String visualID;
if (semanticHint == null) {
visualID = «xptVisualIDRegistry.getNodeVisualIDMethodCall(it)»(containerView, domainElement);
} else {
visualID = «xptVisualIDRegistry.getVisualIDMethodCall(it)»(semanticHint);
}
- switch(visualID) {
- «FOR n : getAllNodes()»
- «xptVisualIDRegistry.caseVisualID(n)»
- return create«n.uniqueIdentifier»(domainElement, containerView, index, persisted, preferencesHint);
- «ENDFOR»
+ if (visualID != null) {
+ switch(visualID) {
+ «FOR n : getAllNodes()»
+ «xptVisualIDRegistry.caseVisualID(n)»
+ return create«n.uniqueIdentifier»(domainElement, containerView, index, persisted, preferencesHint);
+ «ENDFOR»
+ }
}
// can't happen, provided #provides(CreateNodeViewOperation) is correct
return null;
@@ -265,11 +269,14 @@ import xpt.editor.VisualIDRegistry
public org.eclipse.gmf.runtime.notation.Edge createEdge(org.eclipse.core.runtime.IAdaptable semanticAdapter, org.eclipse.gmf.runtime.notation.View containerView, String semanticHint, int index, boolean persisted, org.eclipse.gmf.runtime.diagram.core.preferences.PreferencesHint preferencesHint) {
org.eclipse.gmf.runtime.emf.type.core.IElementType elementType = getSemanticElementType(semanticAdapter);
String elementTypeHint = ((org.eclipse.gmf.runtime.emf.type.core.IHintedType) elementType).getSemanticHint();
- switch («xptVisualIDRegistry.getVisualIDMethodCall(it)»(elementTypeHint)) {
- «FOR link : links»
- «xptVisualIDRegistry.caseVisualID(link)»
- return create«link.uniqueIdentifier»(«IF isTypeLink(link)» getSemanticElement(semanticAdapter), «ENDIF»containerView, index, persisted, preferencesHint);
- «ENDFOR»
+ String vid = «xptVisualIDRegistry.getVisualIDMethodCall(it)»(elementTypeHint);
+ if (vid != null) {
+ switch (vid) {
+ «FOR link : links»
+ «xptVisualIDRegistry.caseVisualID(link)»
+ return create«link.uniqueIdentifier»(«IF isTypeLink(link)» getSemanticElement(semanticAdapter), «ENDIF»containerView, index, persisted, preferencesHint);
+ «ENDFOR»
+ }
}
// can never happen, provided #provides(CreateEdgeViewOperation) is correct
return null;
diff --git a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/VisualTypeProvider.xtend b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/VisualTypeProvider.xtend
index 28a4a965ccd..594db96b084 100644
--- a/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/VisualTypeProvider.xtend
+++ b/plugins/developer/org.eclipse.papyrus.def/xtend/aspects/xpt/providers/VisualTypeProvider.xtend
@@ -53,7 +53,7 @@ import xpt.providers.ElementTypes
org.eclipse.gmf.runtime.emf.type.core.IElementType result = null;
try {
- result = «elementTypes.qualifiedClassName(it)».getElementType(Integer.parseInt(viewType));
+ result = «elementTypes.qualifiedClassName(it)».getElementType(viewType);
} catch (NumberFormatException e) {
// Not supported by this diagram
}
@@ -66,8 +66,7 @@ import xpt.providers.ElementTypes
«generatedMemberComment»
«overrideI»
public String getNodeType(org.eclipse.gmf.runtime.notation.View parentView, org.eclipse.emf.ecore.EObject element) {
- int result = «visualIDs.getNodeVisualIDMethodCall(it)»(parentView, element);
- return (result < 0) ? null : Integer.toString(result);
+ return «visualIDs.getNodeVisualIDMethodCall(it)»(parentView, element);
}
'''
@@ -75,8 +74,7 @@ import xpt.providers.ElementTypes
«generatedMemberComment»
«overrideI»
public String getLinkType(org.eclipse.gmf.runtime.notation.Diagram diagram, org.eclipse.emf.ecore.EObject element) {
- int result = «visualIDs.getLinkWithClassVisualIDMethodCall(it)»(element);
- return (result < 0) ? null : Integer.toString(result);
+ return «visualIDs.getLinkWithClassVisualIDMethodCall(it)»(element);
}
'''
diff --git a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/xtend-gen/org/eclipse/papyrus/elementtypesconfigurations/developer/generator/ElementTypeRegistryGenerator.java b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/xtend-gen/org/eclipse/papyrus/elementtypesconfigurations/developer/generator/ElementTypeRegistryGenerator.java
index 3b6064b7353..585e65a24e8 100644
--- a/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/xtend-gen/org/eclipse/papyrus/elementtypesconfigurations/developer/generator/ElementTypeRegistryGenerator.java
+++ b/plugins/developer/org.eclipse.papyrus.elementtypesconfigurations.developer/xtend-gen/org/eclipse/papyrus/elementtypesconfigurations/developer/generator/ElementTypeRegistryGenerator.java
@@ -1,116 +1,116 @@
-package org.eclipse.papyrus.elementtypesconfigurations.developer.generator;
-
-import com.google.common.collect.Iterables;
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.resource.Resource;
-import org.eclipse.papyrus.infra.elementtypesconfigurations.ElementTypeConfiguration;
-import org.eclipse.xtend2.lib.StringConcatenation;
-import org.eclipse.xtext.xbase.lib.IteratorExtensions;
-
-@SuppressWarnings("all")
-public class ElementTypeRegistryGenerator {
- public static Iterable<EObject> allContentsIterable(final Resource resource) {
- TreeIterator<EObject> _allContents = resource.getAllContents();
- return IteratorExtensions.<EObject>toIterable(_allContents);
- }
-
- public static String camelToUnderScore(final String in) {
- String regex = "([a-z])([A-Z])";
- String replacement = "$1_$2";
- return in.replaceAll(regex, replacement);
- }
-
- public static String safeName(final String in) {
- String result = ElementTypeRegistryGenerator.camelToUnderScore(in);
- String _replaceAll = result.replaceAll("[^A-Za-z0-9]", "_");
- result = _replaceAll;
- String _replaceAll_1 = result.replaceAll("_{2,}", "_");
- result = _replaceAll_1;
- String _upperCase = result.toUpperCase();
- result = _upperCase;
- String _replaceAll_2 = result.replaceAll("UML_", "");
- result = _replaceAll_2;
- return result;
- }
-
- public static CharSequence generateRegistry(final Resource it, final String outputType) {
- StringConcatenation _builder = new StringConcatenation();
- _builder.append("/*****************************************************************************");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Copyright (c) 2014 CEA LIST.");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* All rights reserved. This program and the accompanying materials");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* are made available under the terms of the Eclipse Public License v1.0");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* which accompanies this distribution, and is available at");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* http://www.eclipse.org/legal/epl-v10.html");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* Contributors:");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("* \t\tCEA LIST - Initial API and implementation");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*");
- _builder.newLine();
- _builder.append(" ");
- _builder.append("*****************************************************************************/");
- _builder.newLine();
- _builder.append("import org.eclipse.gmf.runtime.emf.type.core.AbstractElementTypeEnumerator;");
- _builder.newLine();
- _builder.append("import org.eclipse.gmf.runtime.emf.type.core.IHintedType;");
- _builder.newLine();
- _builder.newLine();
- _builder.append("public class ");
- _builder.append(outputType, "");
- _builder.append(" extends AbstractElementTypeEnumerator {");
- _builder.newLineIfNotEmpty();
- _builder.newLine();
- _builder.append("\t");
- _builder.append("/** Constant for UML nature */");
- _builder.newLine();
- _builder.append("\t");
- _builder.append("public static final String UML_NATURE = \"UML_Nature\";");
- _builder.newLine();
- _builder.append("\t");
- _builder.newLine();
- {
- Iterable<EObject> _allContentsIterable = ElementTypeRegistryGenerator.allContentsIterable(it);
- Iterable<ElementTypeConfiguration> _filter = Iterables.<ElementTypeConfiguration>filter(_allContentsIterable, ElementTypeConfiguration.class);
- for(final ElementTypeConfiguration elementTypeConfiguration : _filter) {
- _builder.append("\t");
- _builder.append("public static final IHintedType ");
- String _name = elementTypeConfiguration.getName();
- String _safeName = ElementTypeRegistryGenerator.safeName(_name);
- String _upperCase = _safeName.toUpperCase();
- _builder.append(_upperCase, "\t");
- _builder.append(" = (IHintedType)getElementType(\"");
- String _identifier = elementTypeConfiguration.getIdentifier();
- _builder.append(_identifier, "\t");
- _builder.append("\"); //$NON-NLS-1$");
- _builder.newLineIfNotEmpty();
- _builder.append("\t");
- _builder.newLine();
- }
- }
- _builder.newLine();
- _builder.append("}");
- _builder.newLine();
- return _builder;
- }
-}
+package org.eclipse.papyrus.elementtypesconfigurations.developer.generator;
+
+import com.google.common.collect.Iterables;
+import org.eclipse.emf.common.util.TreeIterator;
+import org.eclipse.emf.ecore.EObject;
+import org.eclipse.emf.ecore.resource.Resource;
+import org.eclipse.papyrus.infra.elementtypesconfigurations.ElementTypeConfiguration;
+import org.eclipse.xtend2.lib.StringConcatenation;
+import org.eclipse.xtext.xbase.lib.IteratorExtensions;
+
+@SuppressWarnings("all")
+public class ElementTypeRegistryGenerator {
+ public static Iterable<EObject> allContentsIterable(final Resource resource) {
+ TreeIterator<EObject> _allContents = resource.getAllContents();
+ return IteratorExtensions.<EObject>toIterable(_allContents);
+ }
+
+ public static String camelToUnderScore(final String in) {
+ String regex = "([a-z])([A-Z])";
+ String replacement = "$1_$2";
+ return in.replaceAll(regex, replacement);
+ }
+
+ public static String safeName(final String in) {
+ String result = ElementTypeRegistryGenerator.camelToUnderScore(in);
+ String _replaceAll = result.replaceAll("[^A-Za-z0-9]", "_");
+ result = _replaceAll;
+ String _replaceAll_1 = result.replaceAll("_{2,}", "_");
+ result = _replaceAll_1;
+ String _upperCase = result.toUpperCase();
+ result = _upperCase;
+ String _replaceAll_2 = result.replaceAll("UML_", "");
+ result = _replaceAll_2;
+ return result;
+ }
+
+ public static CharSequence generateRegistry(final Resource it, final String outputType) {
+ StringConcatenation _builder = new StringConcatenation();
+ _builder.append("/*****************************************************************************");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Copyright (c) 2014 CEA LIST.");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* All rights reserved. This program and the accompanying materials");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* are made available under the terms of the Eclipse Public License v1.0");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* which accompanies this distribution, and is available at");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* http://www.eclipse.org/legal/epl-v10.html");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* Contributors:");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("* \t\tCEA LIST - Initial API and implementation");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*");
+ _builder.newLine();
+ _builder.append(" ");
+ _builder.append("*****************************************************************************/");
+ _builder.newLine();
+ _builder.append("import org.eclipse.gmf.runtime.emf.type.core.AbstractElementTypeEnumerator;");
+ _builder.newLine();
+ _builder.append("import org.eclipse.gmf.runtime.emf.type.core.IHintedType;");
+ _builder.newLine();
+ _builder.newLine();
+ _builder.append("public class ");
+ _builder.append(outputType, "");
+ _builder.append(" extends AbstractElementTypeEnumerator {");
+ _builder.newLineIfNotEmpty();
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("/** Constant for UML nature */");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.append("public static final String UML_NATURE = \"UML_Nature\";");
+ _builder.newLine();
+ _builder.append("\t");
+ _builder.newLine();
+ {
+ Iterable<EObject> _allContentsIterable = ElementTypeRegistryGenerator.allContentsIterable(it);
+ Iterable<ElementTypeConfiguration> _filter = Iterables.<ElementTypeConfiguration>filter(_allContentsIterable, ElementTypeConfiguration.class);
+ for(final ElementTypeConfiguration elementTypeConfiguration : _filter) {
+ _builder.append("\t");
+ _builder.append("public static final IHintedType ");
+ String _name = elementTypeConfiguration.getName();
+ String _safeName = ElementTypeRegistryGenerator.safeName(_name);
+ String _upperCase = _safeName.toUpperCase();
+ _builder.append(_upperCase, "\t");
+ _builder.append(" = (IHintedType)getElementType(\"");
+ String _identifier = elementTypeConfiguration.getIdentifier();
+ _builder.append(_identifier, "\t");
+ _builder.append("\"); //$NON-NLS-1$");
+ _builder.newLineIfNotEmpty();
+ _builder.append("\t");
+ _builder.newLine();
+ }
+ }
+ _builder.newLine();
+ _builder.append("}");
+ _builder.newLine();
+ return _builder;
+ }
+}

Back to the top