Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoratikhomirov2009-02-18 12:31:17 -0500
committeratikhomirov2009-02-18 12:31:17 -0500
commit3f4b1fe632b642b3a3120b138dfd6d6793b3b0e5 (patch)
tree324662097bd9631035bde96eedb308d95835fc05
parent520bd960699ef0ded46b47d0cb1f22ce949feee7 (diff)
downloadorg.eclipse.gmf-tooling-3f4b1fe632b642b3a3120b138dfd6d6793b3b0e5.tar.gz
org.eclipse.gmf-tooling-3f4b1fe632b642b3a3120b138dfd6d6793b3b0e5.tar.xz
org.eclipse.gmf-tooling-3f4b1fe632b642b3a3120b138dfd6d6793b3b0e5.zip
[257632] NPE on element selection if there are hidden elements on a diagram
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/commands/DeleteLinkCommand.xpt62
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt40
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt32
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xpt103
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto13
5 files changed, 161 insertions, 89 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/commands/DeleteLinkCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/commands/DeleteLinkCommand.xpt
new file mode 100644
index 000000000..7e453c47f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/impl/diagram/commands/DeleteLinkCommand.xpt
@@ -0,0 +1,62 @@
+/*
+ * Copyright (c) 2009 Borland Software Corporation
+ *
+ * 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:
+ * Artem Tikhomirov (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE newInstance(String requestVar) FOR gmfgen::GenLink»«EXPAND newDeleteLinkCommand(self, requestVar) FOR modelFacet»«ENDDEFINE»
+
+«DEFINE newRequest(String requestVar, String edgeVar) FOR gmfgen::GenLink»«EXPAND newDestroyRequest(self, requestVar, edgeVar) FOR modelFacet»«ENDDEFINE»
+
+«DEFINE newDeleteLinkCommand(gmfgen::GenLink genLink, String requestVar) FOR gmfgen::LinkModelFacet»
+«ERROR 'Unsupported model facet: ' + self.repr()-»
+«ENDDEFINE»
+
+«DEFINE newDeleteLinkCommand(gmfgen::GenLink genLink, String requestVar) FOR gmfgen::TypeLinkModelFacet-»
+«EXPAND newDeleteLinkWithClassCommand(genLink, requestVar)-»
+«ENDDEFINE»
+
+«DEFINE newDeleteLinkCommand(gmfgen::GenLink genLink, String requestVar) FOR gmfgen::FeatureLinkModelFacet-»
+«EXPAND newDeleteReferenceLinkCommand(genLink, requestVar)-»
+«ENDDEFINE»
+
+«DEFINE newDeleteReferenceLinkCommand(GenLink genLink, String destroyReferenceRequest) FOR gmfgen::FeatureLinkModelFacet-»
+new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand(«destroyReferenceRequest»)«IF isContains(metaFeature)» {
+ protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor progressMonitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
+ org.eclipse.emf.ecore.EObject referencedObject = getReferencedObject();
+ org.eclipse.emf.ecore.resource.Resource resource = referencedObject.eResource();
+ org.eclipse.gmf.runtime.common.core.command.CommandResult result = super.doExecuteWithResult(progressMonitor, info);
+ resource.getContents().add(referencedObject);
+ return result;
+ }
+}«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE newDeleteLinkWithClassCommand(GenLink genLink, String destroyElementRequest) FOR gmfgen::TypeLinkModelFacet-»
+new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(«destroyElementRequest»)«-»
+«ENDDEFINE»
+
+«DEFINE newDestroyRequest(gmfgen::GenLink genLink, String requestVar, String edgeVar) FOR gmfgen::LinkModelFacet»
+«ERROR 'Unsupported model facet: ' + self.repr()-»
+«ENDDEFINE»
+
+«DEFINE newDestroyRequest(gmfgen::GenLink genLink, String requestVar, String edgeVar) FOR gmfgen::TypeLinkModelFacet-»
+org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest «requestVar» = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest(«edgeVar».getElement(), false);
+«ENDDEFINE»
+
+«DEFINE newDestroyRequest(gmfgen::GenLink genLink, String requestVar, String edgeVar) FOR gmfgen::FeatureLinkModelFacet-»
+«REM»FIXME source not always container, target is not always referenced object. And containerReference is known at generation time«ENDREM-»
+org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest «requestVar» = new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest(«edgeVar».getSource().getElement(), null, «edgeVar».getTarget().getElement(), false);
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
index 1066db193..9d44048a1 100644
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/BaseItemSemanticEditPolicy.xpt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008 Borland Software Corporation
+ * Copyright (c) 2007, 2009 Borland Software Corporation
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -75,20 +75,6 @@ element kind from domain element.
new org.eclipse.gmf.runtime.diagram.ui.requests.EditCommandRequestWrapper(request, java.util.Collections.EMPTY_MAP));
}
- «EXPAND xpt::Common::generatedMemberComment('Creates commands to destroy all host incoming and outgoing links.
-')»
- protected org.eclipse.gef.commands.CompoundCommand getDestroyEdgesCommand() {
- org.eclipse.gef.commands.CompoundCommand cmd = new org.eclipse.gef.commands.CompoundCommand();
- org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
- for (java.util.Iterator it = view.getSourceEdges().iterator(); it.hasNext();) {
- cmd.add(getDestroyElementCommand((org.eclipse.gmf.runtime.notation.Edge) it.next()));
- }
- for (java.util.Iterator it = view.getTargetEdges().iterator(); it.hasNext();) {
- cmd.add(getDestroyElementCommand((org.eclipse.gmf.runtime.notation.Edge) it.next()));
- }
- return cmd;
- }
-
«EXPAND addDestroyShortcutsCommand-»
«EXPAND linkConstraints-»
@@ -98,8 +84,7 @@ element kind from domain element.
«ENDDEFINE»
«DEFINE attributes FOR gmfgen::GenDiagram-»
- «EXPAND xpt::Common::generatedMemberComment('Extended request data key to hold editpart visual id.
-')»
+ «EXPAND xpt::Common::generatedMemberComment('Extended request data key to hold editpart visual id.')»
public static final String VISUAL_ID_KEY = "visual_id"; «EXPAND xpt::Common::nonNLS»
«EXPAND xpt::Common::generatedMemberComment»
@@ -114,20 +99,17 @@ element kind from domain element.
«ENDDEFINE»
«DEFINE addDestroyShortcutsCommand FOR gmfgen::GenDiagram-»
- «EXPAND xpt::Common::generatedMemberComment»
-protected void addDestroyShortcutsCommand(org.eclipse.gef.commands.CompoundCommand command) {
- org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
- if (view.getEAnnotation("Shortcut") != null) { «EXPAND xpt::Common::nonNLS»
- return;
- }
- for (java.util.Iterator it = view.getDiagram().getChildren().iterator(); it.hasNext();) {
- org.eclipse.gmf.runtime.notation.View nextView = (org.eclipse.gmf.runtime.notation.View) it.next();
- if (nextView.getEAnnotation("Shortcut") == null || !nextView.isSetElement() || nextView.getElement() != view.getElement()) { «EXPAND xpt::Common::nonNLS»
- continue;
+ «EXPAND xpt::Common::generatedMemberComment('Clean all shortcuts to the host element from the same diagram')»
+ protected void addDestroyShortcutsCommand(org.eclipse.gmf.runtime.common.core.command.CompositeCommand cmd, org.eclipse.gmf.runtime.notation.View view) {
+ «EXPAND xpt::Common::_assert('view.getEAnnotation("Shortcut") == null')-»
+ for (java.util.Iterator it = view.getDiagram().getChildren().iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.View nextView = (org.eclipse.gmf.runtime.notation.View) it.next();
+ if (nextView.getEAnnotation("Shortcut") == null || !nextView.isSetElement() || nextView.getElement() != view.getElement()) { «EXPAND xpt::Common::nonNLS»
+ continue;
+ }
+ cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), nextView));
}
- command.add(getDestroyElementCommand(nextView));
}
-}
«ENDDEFINE»
«DEFINE semanticPart FOR gmfgen::GenDiagram-»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt
index 764aace1f..cd6ae4aec 100644
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/LinkItemSemanticEditPolicy.xpt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008 Borland Software Corporation
+ * Copyright (c) 2007, 2009 Borland Software Corporation
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -31,38 +31,28 @@ public class «itemSemanticEditPolicyClassName» extends «diagram.getBaseItemSeman
«ENDDEFINE»
«DEFINE classBody FOR gmfgen::GenLink-»
- «EXPAND getDestroySemanticCommand FOR modelFacet -»
+ «EXPAND getDestroySemanticCommand(self) FOR modelFacet -»
«IF isTypeLink(self)-»
«EXPAND xpt::diagram::editpolicies::linkCommands::linkCommands -»
«ENDIF-»
«ENDDEFINE»
-«DEFINE getDestroySemanticCommand FOR gmfgen::LinkModelFacet-»
+«DEFINE getDestroySemanticCommand(gmfgen::GenLink genLink) FOR gmfgen::LinkModelFacet-»
«ERROR 'Unsupported model facet: ' + self.repr()-»
«ENDDEFINE»
-«DEFINE getDestroySemanticCommand FOR gmfgen::FeatureLinkModelFacet-»
+«DEFINE getDestroySemanticCommand(gmfgen::GenLink genLink) FOR gmfgen::FeatureLinkModelFacet-»
«EXPAND xpt::Common::generatedMemberComment»
-protected org.eclipse.gef.commands.Command getDestroyReferenceCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest req) {
- return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyReferenceCommand(req)«IF isContains(metaFeature)» {
-
- protected org.eclipse.gmf.runtime.common.core.command.CommandResult doExecuteWithResult(org.eclipse.core.runtime.IProgressMonitor progressMonitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
- org.eclipse.emf.ecore.EObject referencedObject = getReferencedObject();
- org.eclipse.emf.ecore.resource.Resource resource = referencedObject.eResource();
- org.eclipse.gmf.runtime.common.core.command.CommandResult result = super.doExecuteWithResult(progressMonitor, info);
- resource.getContents().add(referencedObject);
- return result;
- }
-
- }«ENDIF»);
-}
+ protected org.eclipse.gef.commands.Command getDestroyReferenceCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyReferenceRequest req) {
+ return getGEFWrapper(«EXPAND impl::diagram::commands::DeleteLinkCommand::newDeleteReferenceLinkCommand(genLink, 'req')»);
+ }
«ENDDEFINE»
-«DEFINE getDestroySemanticCommand FOR gmfgen::TypeLinkModelFacet-»
+«DEFINE getDestroySemanticCommand(gmfgen::GenLink genLink) FOR gmfgen::TypeLinkModelFacet-»
«EXPAND xpt::Common::generatedMemberComment»
-protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
- return getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
-}
+ protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
+ return getGEFWrapper(«EXPAND impl::diagram::commands::DeleteLinkCommand::newDeleteLinkWithClassCommand(genLink, 'req')»);
+ }
«ENDDEFINE»
«DEFINE additions FOR gmfgen::GenLink»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xpt
index 50c775256..708222dff 100644
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xpt
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/NodeItemSemanticEditPolicy.xpt
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008 Borland Software Corporation
+ * Copyright (c) 2007, 2009 Borland Software Corporation
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -8,6 +8,7 @@
*
* Contributors:
* Alexander Shatalin (Borland) - initial API and implementation
+ * Artem Tikhomirov (Borland) - [257632] do not rely on EditPart presence for element deletion
*/
«REM»
@@ -45,68 +46,94 @@ public class «itemSemanticEditPolicyClassName» extends «getDiagram().getBaseItem
«DEFINE getDestroyElementCommand FOR gmfgen::GenNode-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.gef.commands.Command getDestroyElementCommand(org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest req) {
- org.eclipse.gef.commands.CompoundCommand cc = getDestroyEdgesCommand();
- «IF hasChildrenOrCompartments(self)-»
- addDestroyChildNodesCommand(cc);
- «ENDIF-»
- addDestroyShortcutsCommand(cc);
- «EXPAND destroySemanticElement-»
- return cc.unwrap();
+ org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
+ org.eclipse.gmf.runtime.common.core.command.CompositeCommand cc = new org.eclipse.gmf.runtime.common.core.command.CompositeCommand(null);
+ «EXPAND destroyEdges('view')-»
+ org.eclipse.emf.ecore.EAnnotation annotation = view.getEAnnotation("Shortcut");«EXPAND xpt::Common::nonNLS»
+ if (annotation == null) {
+ // there are indirectly referenced children, need extra commands: «childNodes->union(compartments.childNodes->asBag())->exists(not isDirectlyOwned(self))»
+«IF hasChildrenOrCompartments(self)-»
+ addDestroyChildNodesCommand(cc);
+«ENDIF-»
+ addDestroyShortcutsCommand(cc, view);
+ // delete host element
+ cc.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req));
+ } else {«REM»Here, we may play smart and don't generate else for non-toplevel nodes(which can't be shortcuts). Is it worth doing?«ENDREM»
+ cc.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), view));
+ }
+ return getGEFWrapper(cc.reduce());
}
«ENDDEFINE»
-«DEFINE destroySemanticElement FOR gmfgen::GenNode-»
- «EXPAND fixElementToDeleteIfShortcut-»
-cc.add(getGEFWrapper(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(req)));
-«ENDDEFINE»
-
«DEFINE addDestroyChildNodesCommand FOR gmfgen::GenNode-»
«EXPAND xpt::Common::generatedMemberComment»
- protected void addDestroyChildNodesCommand(org.eclipse.gef.commands.CompoundCommand cmd) {
+ private void addDestroyChildNodesCommand(org.eclipse.gmf.runtime.common.core.command.CompositeCommand cmd) {
org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
- org.eclipse.emf.ecore.EAnnotation annotation = view.getEAnnotation("Shortcut"); «EXPAND xpt::Common::nonNLS»
- if (annotation != null) {
- return;
- }
for (java.util.Iterator it = view.getChildren().iterator(); it.hasNext();) {
org.eclipse.gmf.runtime.notation.Node node = (org.eclipse.gmf.runtime.notation.Node) it.next();
switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(node)) {
- «EXPAND destroyChildNodes('node')-»
- «IF not compartments->isEmpty()-»
- «FOREACH compartments->asSequence() AS compartment-»
+ «EXPAND destroyChildNodes('node', self) FOREACH childNodes-»
+ «IF compartments->notEmpty()»«FOREACH compartments AS compartment-»
«EXPAND xpt::Common::caseVisualID FOR 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 («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(cnode)) {
- «EXPAND destroyChildNodes('cnode') FOR compartment-»
+ «EXPAND destroyChildNodes('cnode', self) FOREACH compartment.childNodes-»
}
}
break;
- «ENDFOREACH-»
- «ENDIF-»
+ «ENDFOREACH»«ENDIF-»
}
}
}
«ENDDEFINE»
-«DEFINE destroyChildNodes(nodeVar : String) FOR gmfgen::GenChildContainer-»
- «FOREACH childNodes->asSequence() AS childNode-»
- «EXPAND xpt::Common::caseVisualID FOR childNode»
- cmd.add(getDestroyElementCommand(«nodeVar»));
- break;
- «ENDFOREACH-»
+«DEFINE destroyChildNodes(nodeVar : String, gmfgen::GenNode genNode) FOR gmfgen::GenChildNode-»
+«EXPAND xpt::Common::caseVisualID»
+ «EXPAND destroyEdges(nodeVar)-»
+ cmd.add(new org.eclipse.gmf.runtime.emf.type.core.commands.DestroyElementCommand(new org.eclipse.gmf.runtime.emf.type.core.requests.DestroyElementRequest(getEditingDomain(), «nodeVar».getElement(), false))); // directlyOwned: «self.isDirectlyOwned(genNode)»
+ // don't need explicit deletion of «nodeVar» as parent's view deletion would clean child views as well
+ // cmd.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), «nodeVar»));
+ break;
«ENDDEFINE»
-
-«DEFINE fixElementToDeleteIfShortcut FOR gmfgen::GenTopLevelNode-»
- org.eclipse.gmf.runtime.notation.View view = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
- if (view.getEAnnotation("Shortcut") != null) { «EXPAND xpt::Common::nonNLS»
- req.setElementToDestroy(view);
+// @param view - Notation element for the passed node
+«DEFINE destroyEdges(String view) FOR gmfgen::GenNode-»
+«REM»
+ XXX: Though semantic editpolicy is supposed to create commands that operate with semantic elements only,
+ old code used to delegate child/link deletion to respective editparts, which in turn led to semantic commands
+ being combined with notational commands (BaseItemSemanticEditPolicy#addDeleteViewCommand()).
+ ---
+ Use DiagramUpdater.get[Incoming|Outgoing]View instead, to clean links that are not present on a diagram
+ (but don't forget to clean corresponding Edge, if any)
+«ENDREM-»
+«IF genIncomingLinks->notEmpty()-»
+ for (Iterator it = «view».getTargetEdges().iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.Edge incomingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next();
+«FOREACH genIncomingLinks AS il-»
+ if («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(incomingLink) == «EXPAND xpt::editor::VisualIDRegistry::visualID FOR il») {
+ «EXPAND impl::diagram::commands::DeleteLinkCommand::newRequest('r', 'incomingLink') FOR il-»
+ cc.add(«EXPAND impl::diagram::commands::DeleteLinkCommand::newInstance('r') FOR il»);
+ cc.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), incomingLink));
+ continue;
+ }
+«ENDFOREACH-»
}
+«ENDIF-»
+«IF genOutgoingLinks->notEmpty()-»
+ for (Iterator it = «view».getSourceEdges().iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.notation.Edge outgoingLink = (org.eclipse.gmf.runtime.notation.Edge) it.next();
+«FOREACH genOutgoingLinks AS ol-»
+ if («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(outgoingLink) == «EXPAND xpt::editor::VisualIDRegistry::visualID FOR ol») {
+ «EXPAND impl::diagram::commands::DeleteLinkCommand::newRequest('r', 'outgoingLink') FOR ol-»
+ cc.add(«EXPAND impl::diagram::commands::DeleteLinkCommand::newInstance('r') FOR ol»);
+ cc.add(new org.eclipse.gmf.runtime.diagram.core.commands.DeleteCommand(getEditingDomain(), outgoingLink));
+ continue;
+ }
+«ENDFOREACH-»
+ }
+«ENDIF-»
«ENDDEFINE»
-«REM»Shortcuts supported only for top-level elements«ENDREM»
-«DEFINE fixElementToDeleteIfShortcut FOR gmfgen::GenNode»«ENDDEFINE»
-
«DEFINE additions FOR gmfgen::GenNode»«ENDDEFINE»
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto
index 28e1f57ae..85b86ffda 100644
--- a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/editpolicies/Utils.qvto
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2007, 2008 Borland Software Corporation
+ * Copyright (c) 2007, 2009 Borland Software Corporation
*
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@@ -43,14 +43,17 @@ helper getReroutableRefLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel
--XXX[MG]: again, it would be better to use linkEnd.incomingLinks.union(linkEnd.outgoingLinks).toList()
--but it will change the ordering and produce meaningless diff in the generated code
+-- MODIFIERS: private cached
helper getAllRelatedLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
return linkEnd.getDiagram().links->select(link | canBeSource(link, linkEnd) or canBeTarget(link, linkEnd))->asSequence()
}
+-- MODIFIERS: private cached
helper getAllRelatedReroutableLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
return linkEnd.getDiagram().links->select(link | canBeSource(link, linkEnd) and link.sourceReorientingAllowed or (canBeTarget(link, linkEnd) and link.targetReorientingAllowed))->asSequence()
}
+-- MODIFIERS: private
helper isCreationAllowed(link : genModel::GenLink) : Boolean {
return null <> link.modelFacet and (link.outgoingCreationAllowed or link.incomingCreationAllowed)
}
@@ -87,14 +90,17 @@ helper checkTarget(reversedRequest : Boolean, isCompleteCommand : Boolean) : Boo
return reversedRequest or isCompleteCommand
}
+-- MODIFIERS: private
helper isSelf(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
return canBeSource(link, linkEnd) and canBeTarget(link, linkEnd)
}
+-- MODIFIERS: private
helper isOutgoing(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
return canBeSource(link, linkEnd) and not canBeTarget(link, linkEnd)
}
+-- MODIFIERS: private
helper isIncoming(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Boolean {
return canBeTarget(link, linkEnd) and not canBeSource(link, linkEnd)
}
@@ -102,3 +108,8 @@ helper isIncoming(link : genModel::GenLink, linkEnd : genModel::GenLinkEnd) : Bo
helper i18nKeyForOpenCommandName() : String {
return 'CommandName.OpenDiagram'
}
+-- if child's containment feature comes from the node, assume deletion of the parent would delete the child.
+helper GenChildNode::isDirectlyOwned(genNode : GenNode) : Boolean {
+ if self.modelFacet.oclIsUndefined() or genNode.modelFacet.oclIsUndefined() then return false endif; -- can't assume anything
+ return self.modelFacet.containmentMetaFeature.ecoreFeature.eContainingClass.isSuperTypeOf(genNode.modelFacet.metaClass.ecoreClass)
+}

Back to the top