Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorashatalin2008-12-29 07:41:38 -0500
committerashatalin2008-12-29 07:41:38 -0500
commitfc1dfb3b462e159eec1b6031bb41ab79c762474b (patch)
tree66acb7873f68640147106dcd919a5041ecbc918b /plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater
parent7f3bb1960b122d5d9c4edae8dc1c330032c9cf60 (diff)
downloadorg.eclipse.gmf-tooling-fc1dfb3b462e159eec1b6031bb41ab79c762474b.tar.gz
org.eclipse.gmf-tooling-fc1dfb3b462e159eec1b6031bb41ab79c762474b.tar.xz
org.eclipse.gmf-tooling-fc1dfb3b462e159eec1b6031bb41ab79c762474b.zip
QVTO-based xpand implementation was merged to HEAD
Diffstat (limited to 'plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater')
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/DiagramUpdater.xpt488
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/LinkDescriptor.xpt120
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/NodeDescriptor.xpt64
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/UpdateCommand.xpt93
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/Utils.qvto150
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/containerBaseCanonicalMethods.xpt166
-rw-r--r--plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/extensions.xpt34
7 files changed, 1115 insertions, 0 deletions
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/DiagramUpdater.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/DiagramUpdater.xpt
new file mode 100644
index 000000000..2bcb9cb66
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/DiagramUpdater.xpt
@@ -0,0 +1,488 @@
+/*
+ * Copyright (c) 2007, 2008 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ * Michael Golubev (Borland) - [243151] explicit source/target for links
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/Ecore'»
+
+«EXTENSION xpt::diagram::updater::Utils»
+«EXTENSION xpt::diagram::editpolicies::LinkUtils»
+«EXTENSION xpt::GenModelUtils»
+«EXTENSION xpt::NativeGenModelUtils»
+
+«DEFINE DiagramUpdater FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «diagramUpdaterClassName» {
+ «EXPAND isShortcutOrphaned-»
+«LET editorGen.diagram.getAllContainers()->select(container | hasSemanticChildren(container))->asSequence() AS semanticContainers-»
+
+ «EXPAND getGenericSemanticChildrenOfView(semanticContainers)-»
+ «EXPAND getSemanticChildrenOfView FOREACH semanticContainers-»
+ «EXPAND getPhantomNodesIterator-»
+«ENDLET-»
+
+ «EXPAND getGenericConnectedLinks(getAllSemanticElements(editorGen.diagram), getContainedLinksMethodNameSuffix())-»
+
+ «EXPAND getGenericConnectedLinks(getAllSemanticDiagramElements(editorGen.diagram), getIncomingLinksMethodNameSuffix())-»
+
+ «EXPAND getGenericConnectedLinks(getAllSemanticDiagramElements(editorGen.diagram), getOutgoingLinksMethodNameSuffix())-»
+ «EXPAND getContainedLinks FOREACH getAllSemanticElements(editorGen.diagram)-»
+ «EXPAND getIncomingLinks FOREACH getAllSemanticDiagramElements(editorGen.diagram)-»
+ «EXPAND getOutgoingLinks FOREACH getAllSemanticDiagramElements(editorGen.diagram)-»
+ «EXPAND getContainedLinksByTypeMethod FOREACH getAllContainedLinks(editorGen.diagram)-»
+ «EXPAND getIncomingLinksByTypeMethod FOREACH getAllIncomingLinks(editorGen.diagram)-»
+ «EXPAND getOutgoingLinksByTypeMethod FOREACH getAllOutgoingLinks(editorGen.diagram)-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«REM»
+ Currently shortcuts are supported only for domain-based diagram element.
+ This means, view.isSetElement() == true.
+«ENDREM»
+«DEFINE isShortcutOrphaned FOR gmfgen::GenDiagramUpdater-»
+ «IF not editorGen.diagram.containsShortcutsTo->isEmpty()-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+public static boolean isShortcutOrphaned(org.eclipse.gmf.runtime.notation.View view) {
+ return !view.isSetElement() || view.getElement() == null || view.getElement().eIsProxy();
+}
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getGenericSemanticChildrenOfView(semanticContainers : Sequence(gmfgen::GenContainerBase)) FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public static java.util.List getSemanticChildren(org.eclipse.gmf.runtime.notation.View view) {
+ «IF not semanticContainers->isEmpty()-»
+ switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR editorGen.diagram»(view)) {
+ «EXPAND getSemanticChildrenCase FOREACH semanticContainers-»
+ }
+ «ENDIF-»
+ return java.util.Collections.EMPTY_LIST;
+}
+«ENDDEFINE»
+
+«DEFINE getSemanticChildrenCase FOR gmfgen::GenContainerBase-»
+«EXPAND xpt::Common::caseVisualID»
+ return «EXPAND getSemanticChildrenMethodName»(view);
+«ENDDEFINE»
+
+«DEFINE getSemanticChildrenOfView FOR gmfgen::GenContainerBase-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+public static java.util.List «EXPAND getSemanticChildrenMethodName»(org.eclipse.gmf.runtime.notation.View view) {
+ «IF getSemanticChildrenChildFeatures(self)->size() > 0 or self.getPhantomNodes()->size() > 0-»
+ «EXPAND defineModelElement-»
+ java.util.List result = new java.util.LinkedList();
+«REM»childMetaFeature can be null here!«ENDREM»«-»
+ «FOREACH getSemanticChildrenChildFeatures(self) AS childMetaFeature-»
+ «IF null = childMetaFeature-»
+ { /*FIXME no containment/child feature found in the genmodel, toolsmith need to specify Class here manually*/ childElement = /*FIXME no containment/child feature found in the genmodel, toolsmith need to specify correct one here manually*/;
+ «ELSEIF isListType(childMetaFeature)-»
+ for (java.util.Iterator it = «EXPAND MetaModel::getFeatureValue('modelElement', self.getModelElementType()) FOR childMetaFeature».iterator(); it.hasNext();) {
+ «EXPAND MetaModel::DeclareAndAssign('childElement', 'it.next()', true) FOR getTypeGenClassX(childMetaFeature)»
+ «ELSE-»
+ { «EXPAND MetaModel::DeclareAndAssign('childElement', 'modelElement', self.getModelElementType(), childMetaFeature) FOR getTypeGenClassX(childMetaFeature)»
+ «ENDIF-»
+ int visualID = «EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall FOR getDiagram()»(view, «EXPAND MetaModel::DowncastToEObject('childElement') FOR getTypeGenClassX(childMetaFeature)»);
+ «EXPAND checkChildElementVisualID(null <> childMetaFeature and isListType(childMetaFeature)) FOREACH getSemanticChildren(self, childMetaFeature)-»
+ }
+ «ENDFOREACH-»
+ «IF not self.getPhantomNodes()->isEmpty()-»
+ org.eclipse.emf.ecore.resource.Resource resource = modelElement.eResource();
+ for (java.util.Iterator semanticIterator = getPhantomNodesIterator(resource); semanticIterator.hasNext();) {
+ org.eclipse.emf.ecore.EObject childElement = (org.eclipse.emf.ecore.EObject) semanticIterator.next();
+ if (childElement == modelElement) {
+ continue;
+ }
+ «EXPAND addNextIfPhantom FOREACH self.getPhantomNodes()-»
+ }
+ «ENDIF-»
+ return result;
+ «ELSE-»
+ return java.util.Collections.EMPTY_LIST;
+ «ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE defineModelElement FOR gmfgen::GenContainerBase-»
+if (!view.isSetElement()) {
+ return java.util.Collections.EMPTY_LIST;
+}
+«EXPAND MetaModel::DeclareAndAssign('modelElement', 'view.getElement()') FOR self.getModelElementType()»
+«ENDDEFINE»
+
+«DEFINE defineModelElement FOR gmfgen::GenCompartment-»
+if (false == view.eContainer() instanceof org.eclipse.gmf.runtime.notation.View) {
+ return java.util.Collections.EMPTY_LIST;
+}
+org.eclipse.gmf.runtime.notation.View containerView = (org.eclipse.gmf.runtime.notation.View) view.eContainer();
+if (!containerView.isSetElement()) {
+ return java.util.Collections.EMPTY_LIST;
+}
+«EXPAND MetaModel::DeclareAndAssign('modelElement', 'containerView.getElement()') FOR self.getModelElementType()»
+«ENDDEFINE»
+
+«DEFINE getSemanticChildrenMethodName FOR gmfgen::GenContainerBase»get«getUniqueIdentifier()»SemanticChildren«ENDDEFINE»
+
+«DEFINE getSemanticChildrenMethodCall FOR gmfgen::GenContainerBase»«getDiagram().editorGen.diagramUpdater.getDiagramUpdaterQualifiedClassName()».«EXPAND getSemanticChildrenMethodName»«ENDDEFINE»
+
+«DEFINE checkChildElementVisualID(inLoop : Boolean) FOR gmfgen::GenNode-»
+if (visualID == «EXPAND xpt::editor::VisualIDRegistry::visualID») {
+ result.add(new «getDiagram().editorGen.diagramUpdater.getNodeDescriptorQualifiedClassName()»(«IF null <> modelFacet.childMetaFeature»«EXPAND MetaModel::DowncastToEObject('childElement') FOR getTypeGenClassX(modelFacet.childMetaFeature)»«ENDIF», visualID));
+«IF inLoop-»
+ continue;
+«ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE addNextIfPhantom FOR gmfgen::GenNode-»
+if («EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall FOR getDiagram()»(view, childElement) == «EXPAND xpt::editor::VisualIDRegistry::visualID») {
+ result.add(new «getDiagram().editorGen.diagramUpdater.getNodeDescriptorQualifiedClassName()»(childElement, «EXPAND xpt::editor::VisualIDRegistry::visualID»));
+ continue;
+}
+«ENDDEFINE»
+
+
+«DEFINE getPhantomNodesIterator FOR gmfgen::GenDiagramUpdater-»
+ «IF not editorGen.diagram.getPhantomNodes()->isEmpty()-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private static java.util.Iterator getPhantomNodesIterator(org.eclipse.emf.ecore.resource.Resource resource) {
+ return resource.getAllContents();
+}
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getGenericConnectedLinks(linkContainers : Sequence(gmfgen::GenCommonBase), methodNameSuffix : String) FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public static java.util.List get«methodNameSuffix»Links(org.eclipse.gmf.runtime.notation.View view) {
+ «IF not linkContainers->isEmpty()-»
+ switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR editorGen.diagram»(view)) {
+ «EXPAND getContainedLinksCase(methodNameSuffix) FOREACH linkContainers-»
+ }
+ «ENDIF-»
+ return java.util.Collections.EMPTY_LIST;
+}
+«ENDDEFINE»
+
+«DEFINE getContainedLinksCase(methodNameSuffix : String) FOR gmfgen::GenCommonBase-»
+«EXPAND xpt::Common::caseVisualID»
+ return «EXPAND linkGetterName(methodNameSuffix)»(view);
+«ENDDEFINE»
+
+«REM»This DEFING can be used from other templates to inject call to the corresponding method«ENDREM»
+«DEFINE getContainedLinksMethodCall FOR gmfgen::GenCommonBase»«getDiagram().editorGen.diagramUpdater.getDiagramUpdaterQualifiedClassName()».«EXPAND linkGetterName(getContainedLinksMethodNameSuffix())»«ENDDEFINE»
+
+«REM»This DEFING can be used from other templates to inject call to the corresponding method«ENDREM»
+«DEFINE getIncomingLinksMethodCall FOR gmfgen::GenCommonBase»«getDiagram().editorGen.diagramUpdater.getDiagramUpdaterQualifiedClassName()».«EXPAND linkGetterName(getIncomingLinksMethodNameSuffix())»«ENDDEFINE»
+
+«REM»This DEFING can be used from other templates to inject call to the corresponding method«ENDREM»
+«DEFINE getOutgoingLinksMethodCall FOR gmfgen::GenCommonBase»«getDiagram().editorGen.diagramUpdater.getDiagramUpdaterQualifiedClassName()».«EXPAND linkGetterName(getOutgoingLinksMethodNameSuffix())»«ENDDEFINE»
+
+«DEFINE linkGetterName(suffix : String) FOR gmfgen::GenCommonBase»get«getUniqueIdentifier()»«suffix»Links«ENDDEFINE»
+
+«DEFINE getContainedLinks FOR gmfgen::GenCommonBase-»
+ «EXPAND getConnectedLinks(getContainedLinks(self.getMetaClass(), getDiagram()), getContainedLinksMethodNameSuffix(), false)-»
+«ENDDEFINE»
+
+«DEFINE getIncomingLinks FOR gmfgen::GenLinkEnd-»
+ «EXPAND getConnectedLinks(getIncomingLinks(self), getIncomingLinksMethodNameSuffix(), true)-»
+«ENDDEFINE»
+
+«DEFINE getOutgoingLinks FOR gmfgen::GenLinkEnd-»
+ «EXPAND getConnectedLinks(getOutgoingLinks(self), getOutgoingLinksMethodNameSuffix(), false)-»
+«ENDDEFINE»
+
+«DEFINE getConnectedLinks(genLinks : Sequence(gmfgen::GenLink), methodNameSuffix : String, needCrossReferencer : Boolean) FOR gmfgen::GenCommonBase-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+public static java.util.List «EXPAND linkGetterName(methodNameSuffix)»(org.eclipse.gmf.runtime.notation.View view) {
+ «IF not genLinks->isEmpty()-»
+ «LET self.getMetaClass() AS metaclass-»
+ «EXPAND MetaModel::DeclareAndAssign('modelElement', 'view.getElement()') FOR metaclass»
+ «IF needCrossReferencer-»
+ java.util.Map crossReferences = org.eclipse.emf.ecore.util.EcoreUtil.CrossReferencer.find(view.eResource().getResourceSet().getResources());
+ «ENDIF-»
+ java.util.List result = new java.util.LinkedList();
+ «EXPAND colectConnectedLinks(methodNameSuffix, needCrossReferencer, isExternalInterface(metaclass)) FOREACH genLinks-»
+ return result;
+ «ENDLET-»
+ «ELSE-»
+ return java.util.Collections.EMPTY_LIST;
+ «ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE colectConnectedLinks(methodNameSuffix : String, needCrossReferencer : Boolean, isExternalInterface : Boolean) FOR gmfgen::GenLink-»
+«IF isExternalInterface-»
+ if («EXPAND MetaModel::IsInstance('modelElement') FOR modelFacet.getLinkEndType(methodNameSuffix)») {
+«ENDIF-»
+ result.addAll(«EXPAND chooseConnectedLinksByTypeMethodName(methodNameSuffix, self) FOR modelFacet»(«IF isExternalInterface-»
+«EXPAND MetaModel::CastEObject('modelElement') FOR modelFacet.getLinkEndType(methodNameSuffix)»«ELSE»modelElement«ENDIF»«IF needCrossReferencer», crossReferences«ENDIF»));
+«IF isExternalInterface-»
+ }
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE chooseConnectedLinksByTypeMethodName(methodNameSuffix : String, genLink : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+ «EXPAND incorrectLinkModelFacet-»
+«ENDDEFINE»
+
+«REM»
+ For FeatureModelFacet-based links we are calling
+ getOutgoing???Links instead of getContained???Links
+«ENDREM»
+«DEFINE chooseConnectedLinksByTypeMethodName(methodNameSuffix : String, genLink : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet-»
+«IF getContainedLinksMethodNameSuffix() = methodNameSuffix»«EXPAND getConnectedLinksByTypeMethodName(getOutgoingLinksMethodNameSuffix()) FOR genLink-»
+«ELSE»«EXPAND getConnectedLinksByTypeMethodName(methodNameSuffix) FOR genLink-»
+«ENDIF-»
+«ENDDEFINE»
+
+«REM»
+ For TypeModelFacet-based links we are calling
+ getContained???Links instead of getOutgoinf???Links
+ if sourceMetaFeature was not specified
+«ENDREM»
+«DEFINE chooseConnectedLinksByTypeMethodName(methodNameSuffix : String, genLink : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+«IF getOutgoingLinksMethodNameSuffix() = methodNameSuffix and null = sourceMetaFeature»«EXPAND getConnectedLinksByTypeMethodName(getContainedLinksMethodNameSuffix()) FOR genLink-»
+«ELSE»«EXPAND getConnectedLinksByTypeMethodName(methodNameSuffix) FOR genLink-»
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getContainedLinksByTypeMethod FOR gmfgen::GenLink»«EXPAND getContainedLinksByTypeMethod(self) FOR modelFacet»«ENDDEFINE»
+
+«DEFINE getConnectedLinksByTypeMethodName(suffix : String) FOR gmfgen::GenLink»get«suffix»«EXPAND getConnectedLinksByTypeMethodFragment FOR modelFacet»_«visualID»«ENDDEFINE»
+
+«DEFINE getConnectedLinksByTypeMethodFragment FOR gmfgen::TypeLinkModelFacet»TypeModelFacetLinks_«metaClass.ecoreClass.name»«ENDDEFINE»
+
+«DEFINE getConnectedLinksByTypeMethodFragment FOR gmfgen::FeatureLinkModelFacet»FeatureModelFacetLinks_«metaFeature.genClass.ecoreClass.name»_«metaFeature.ecoreFeature.name.firstToUpper()»«ENDDEFINE»
+
+«DEFINE getConnectedLinksByTypeMethodFragment FOR gmfgen::LinkModelFacet-»
+ «EXPAND incorrectLinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE getContainedLinksByTypeMethod(genLink : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+ «EXPAND incorrectLinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE getContainedLinksByTypeMethod(genLink : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet»«ENDDEFINE»
+
+«DEFINE getContainedLinksByTypeMethod(genLink : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private static java.util.Collection «EXPAND getConnectedLinksByTypeMethodName(getContainedLinksMethodNameSuffix()) FOR genLink»(«EXPAND MetaModel::QualifiedClassName FOR childMetaFeature.genClass» container) {
+ «EXPAND getContainedLinksByTypeMethodBody(genLink, false)-»
+}
+«ENDDEFINE»
+
+«DEFINE getContainedLinksByTypeMethodBody(genLink : gmfgen::GenLink, sourceVarDefined : Boolean) FOR gmfgen::TypeLinkModelFacet-»
+java.util.Collection result = new java.util.LinkedList();
+ «LET isListType(childMetaFeature) AS inLoop-»
+«IF inLoop-»
+for (java.util.Iterator links = «EXPAND MetaModel::getFeatureValue('container', childMetaFeature.genClass) FOR childMetaFeature».iterator(); links.hasNext();) {
+ org.eclipse.emf.ecore.EObject linkObject = (org.eclipse.emf.ecore.EObject ) links.next();
+ if («EXPAND MetaModel::NotInstance('linkObject') FOR metaClass») {
+ continue;
+ }
+ «EXPAND MetaModel::DeclareAndAssign('link', 'linkObject') FOR metaClass»
+«ELSE-»
+ «IF getTypeGenClassX(childMetaFeature) = metaClass-»
+ «EXPAND MetaModel::DeclareAndAssign('link', 'container', getSourceType(), childMetaFeature) FOR metaClass»
+ «ELSE-»
+ «EXPAND MetaModel::DeclareAndAssign('linkObject', 'container', getSourceType(), childMetaFeature) FOR getTypeGenClassX(childMetaFeature)»
+ if («EXPAND MetaModel::NotInstance('linkObject') FOR metaClass») {
+ return result;
+ }
+ «EXPAND MetaModel::DeclareAndAssign('link', 'linkObject') FOR metaClass»
+ «ENDIF-»
+«ENDIF-»
+ «EXPAND checkLinkVisualID(genLink, inLoop)-»
+ «EXPAND defineLinkDestination(inLoop)-»
+ «IF null <> sourceMetaFeature-»
+ «EXPAND defineLinkSource(inLoop)-»
+ «IF sourceVarDefined-»
+ «EXPAND checkLinkSource(inLoop)-»
+ «ENDIF-»
+ «EXPAND addLinkDescriptor(genLink, 'src', 'dst')-»
+ «ELSE-»
+ «EXPAND addLinkDescriptor(genLink, 'container', 'dst')-»
+ «ENDIF-»
+«IF inLoop-»
+}
+«ENDIF-»
+ «ENDLET-»
+return result;
+«ENDDEFINE»
+
+«DEFINE addLinkDescriptor(genLink : gmfgen::GenLink, srcVar : String, dstVar : String) FOR gmfgen::TypeLinkModelFacet-»
+result.add(new «genLink.getDiagram().editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()»(«EXPAND MetaModel::DowncastToEObject(srcVar) FOR getSourceType()», «EXPAND MetaModel::DowncastToEObject(dstVar) FOR getTargetType()», «EXPAND MetaModel::DowncastToEObject('link') FOR metaClass», «EXPAND xpt::providers::ElementTypes::accessElementType FOR genLink», «EXPAND xpt::editor::VisualIDRegistry::visualID FOR genLink»));
+«ENDDEFINE»
+
+«DEFINE checkLinkVisualID(genLink : gmfgen::GenLink, inLoop : Boolean) FOR gmfgen::TypeLinkModelFacet-»
+if («EXPAND xpt::editor::VisualIDRegistry::visualID FOR genLink» != «EXPAND xpt::editor::VisualIDRegistry::getLinkWithClassVisualIDMethodCall FOR genLink.getDiagram()»(«EXPAND MetaModel::DowncastToEObject('link') FOR metaClass»)) {
+ «EXPAND stopLinkProcessing(inLoop)-»
+}
+«ENDDEFINE»
+
+«DEFINE defineLinkSource(inLoop : Boolean) FOR gmfgen::TypeLinkModelFacet-»
+ «IF isListType(sourceMetaFeature)-»
+java.util.List sources = «EXPAND MetaModel::getFeatureValue('link', metaClass) FOR sourceMetaFeature»;
+Object theSource = sources.size() == 1 ? sources.get(0) : null;
+if («EXPAND MetaModel::NotInstance('theSource') FOR getSourceType()») {
+ «EXPAND stopLinkProcessing(inLoop)-»
+}
+«EXPAND MetaModel::DeclareAndAssign('src', 'theSource', true) FOR getSourceType()»
+ «ELSE-»
+«EXPAND MetaModel::DeclareAndAssign('src', 'link', metaClass, sourceMetaFeature) FOR getSourceType()»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE checkLinkSource(inLoop : Boolean) FOR gmfgen::TypeLinkModelFacet-»
+if (src != source) {
+ «EXPAND stopLinkProcessing(inLoop)-»
+}
+«ENDDEFINE»
+
+«DEFINE defineLinkDestination(inLoop : Boolean) FOR gmfgen::TypeLinkModelFacet-»
+ «IF isListType(targetMetaFeature)-»
+java.util.List targets = «EXPAND MetaModel::getFeatureValue('link', metaClass) FOR targetMetaFeature»;
+Object theTarget = targets.size() == 1 ? targets.get(0) : null;
+if («EXPAND MetaModel::NotInstance('theTarget') FOR getTargetType()») {
+ «EXPAND stopLinkProcessing(inLoop)-»
+}
+«EXPAND MetaModel::DeclareAndAssign('dst', 'theTarget', true) FOR getTargetType()»
+ «ELSE-»
+«EXPAND MetaModel::DeclareAndAssign('dst', 'link', metaClass, targetMetaFeature) FOR getTargetType()»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE stopLinkProcessing(inLoop : Boolean) FOR gmfgen::TypeLinkModelFacet-»
+«IF inLoop-»
+continue;
+«ELSE-»
+return result;
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getIncomingLinksByTypeMethod FOR gmfgen::GenLink-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private static java.util.Collection «EXPAND getConnectedLinksByTypeMethodName(getIncomingLinksMethodNameSuffix())»(«EXPAND MetaModel::QualifiedClassName FOR modelFacet.getTargetType()» target, java.util.Map crossReferences) {
+ java.util.Collection result = new java.util.LinkedList();
+ java.util.Collection settings = (java.util.Collection) crossReferences.get(target);
+ for (java.util.Iterator it = settings.iterator(); it.hasNext();) {
+ org.eclipse.emf.ecore.EStructuralFeature.Setting setting = (org.eclipse.emf.ecore.EStructuralFeature.Setting) it.next();
+ «EXPAND getIncomingLinksByTypeMethodBody(self) FOR modelFacet-»
+ }
+ return result;
+}
+«ENDDEFINE»
+
+«DEFINE getIncomingLinksByTypeMethodBody(genLink : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+if (setting.getEStructuralFeature() != «EXPAND MetaModel::MetaFeature FOR targetMetaFeature» || «EXPAND MetaModel::NotInstance('setting.getEObject()') FOR metaClass») {
+ continue;
+}
+«EXPAND MetaModel::DeclareAndAssign('link', 'setting.getEObject()') FOR metaClass»
+ «EXPAND checkLinkVisualID(genLink, true)-»
+ «IF null <> sourceMetaFeature-»
+ «EXPAND defineLinkSource(true)-»
+ «EXPAND addLinkDescriptor(genLink, 'src', 'target')-»
+ «ELSE-»
+ «EXPAND defineLinkContainer(true)-»
+ «EXPAND addLinkDescriptor(genLink, 'container', 'target')-»
+«REM»TODO: continue here.«ENDREM»
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE defineLinkContainer(inLoop : Boolean) FOR gmfgen::TypeLinkModelFacet-»
+if (false == «EXPAND MetaModel::IsContainerInstance('link', metaClass) FOR containmentMetaFeature.genClass») {
+ «EXPAND stopLinkProcessing(inLoop)-»
+}
+«EXPAND MetaModel::DeclareAndAssignContainer('container', 'link', metaClass) FOR containmentMetaFeature.genClass»
+«ENDDEFINE»
+
+«DEFINE getIncomingLinksByTypeMethodBody(genLink : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet-»
+if (setting.getEStructuralFeature() == «EXPAND MetaModel::MetaFeature FOR metaFeature») {
+ result.add(new «genLink.getDiagram().editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()»(setting.getEObject(), «EXPAND MetaModel::DowncastToEObject('target') FOR getTargetType()», «EXPAND xpt::providers::ElementTypes::accessElementType FOR genLink», «EXPAND xpt::editor::VisualIDRegistry::visualID FOR genLink»));
+}
+«ENDDEFINE»
+
+«DEFINE getIncomingLinksByTypeMethodBody(genLink : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+ «EXPAND incorrectLinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE getOutgoingLinksByTypeMethod FOR gmfgen::GenLink-»
+ «EXPAND getOutgoingLinksByTypeMethod(self) FOR modelFacet-»
+«ENDDEFINE»
+
+«DEFINE getOutgoingLinksByTypeMethodSignature FOR gmfgen::GenLink»private static java.util.Collection «EXPAND getConnectedLinksByTypeMethodName(getOutgoingLinksMethodNameSuffix())»(«EXPAND MetaModel::QualifiedClassName FOR modelFacet.getSourceType()» source)«ENDDEFINE»
+
+«DEFINE getOutgoingLinksByTypeMethod(genLink : gmfgen::GenLink) FOR gmfgen::FeatureLinkModelFacet-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+«EXPAND getOutgoingLinksByTypeMethodSignature FOR genLink» {
+ java.util.Collection result = new java.util.LinkedList();
+ «IF isListType(metaFeature)-»
+ for (java.util.Iterator destinations = «EXPAND MetaModel::getFeatureValue('source', getSourceType()) FOR metaFeature».iterator(); destinations.hasNext();) {
+ «EXPAND MetaModel::DeclareAndAssign('destination', 'destinations.next()', true) FOR getTargetType()»
+ «ELSE-»
+ «EXPAND MetaModel::DeclareAndAssign('destination', 'source', getSourceType(), metaFeature) FOR getTargetType()»
+ if (destination == null) {
+ return result;
+ }
+ «ENDIF-»
+ result.add(new «genLink.getDiagram().editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()»(«EXPAND MetaModel::DowncastToEObject('source') FOR getSourceType()», «EXPAND MetaModel::DowncastToEObject('destination') FOR getTargetType()», «EXPAND xpt::providers::ElementTypes::accessElementType FOR genLink», «EXPAND xpt::editor::VisualIDRegistry::visualID FOR genLink»));
+ «IF isListType(metaFeature)-»
+ }
+ «ENDIF-»
+ return result;
+}
+«ENDDEFINE»
+
+«REM»More careful way to find container should be used here then GMF will be modified in accordance«ENDREM»
+«DEFINE getOutgoingLinksByTypeMethod(genLink : gmfgen::GenLink) FOR gmfgen::TypeLinkModelFacet-»
+ «IF null <> sourceMetaFeature-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+«EXPAND getOutgoingLinksByTypeMethodSignature FOR genLink» {
+ «EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» container = null;
+ // Find container element for the link.
+ // Climb up by containment hierarchy starting from the source
+ // and return the first element that is instance of the container class.
+ for (org.eclipse.emf.ecore.EObject element = «EXPAND MetaModel::DowncastToEObject('source') FOR getSourceType()»; element != null && container == null; element = element.eContainer()) {
+ if («EXPAND MetaModel::IsInstance('element') FOR containmentMetaFeature.genClass») {
+ container = «EXPAND MetaModel::CastEObject('element') FOR containmentMetaFeature.genClass»;
+ }
+ }
+ if (container == null) {
+ return java.util.Collections.EMPTY_LIST;
+ }
+ «EXPAND getContainedLinksByTypeMethodBody(genLink, true)-»
+}
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getOutgoingLinksByTypeMethod(genLink : gmfgen::GenLink) FOR gmfgen::LinkModelFacet-»
+ «EXPAND incorrectLinkModelFacet-»
+«ENDDEFINE»
+
+«DEFINE incorrectLinkModelFacet FOR gmfgen::LinkModelFacet-»
+ «ERROR 'Incorrect LinkModelFacet: ' + self.repr()»
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagramUpdater»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/LinkDescriptor.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/LinkDescriptor.xpt
new file mode 100644
index 000000000..5343f13dc
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/LinkDescriptor.xpt
@@ -0,0 +1,120 @@
+/*
+ * Copyright (c) 2007 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE LinkDescriptor FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «linkDescriptorClassName» extends «getNodeDescriptorQualifiedClassName()» {
+
+ «EXPAND attributes-»
+
+ «EXPAND _constructor-»
+
+ «EXPAND refOnlyLinkConstructor-»
+
+ «EXPAND typeLinkConstructor-»
+
+ «EXPAND getSource-»
+
+ «EXPAND getDestination-»
+
+ «EXPAND getSemanticAdapter-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+
+«DEFINE attributes FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.emf.ecore.EObject mySource;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.emf.ecore.EObject myDestination;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+private org.eclipse.core.runtime.IAdaptable mySemanticAdapter;
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private «linkDescriptorClassName»(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject destination, org.eclipse.emf.ecore.EObject linkElement, int linkVID) {
+ super(linkElement, linkVID);
+ mySource = source;
+ myDestination = destination;
+}
+«ENDDEFINE»
+
+«DEFINE refOnlyLinkConstructor FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public «linkDescriptorClassName»(org.eclipse.emf.ecore.EObject source, org.eclipse.emf.ecore.EObject destination, org.eclipse.gmf.runtime.emf.type.core.IElementType elementType, int linkVID) {
+ this(source, destination, (org.eclipse.emf.ecore.EObject) null, linkVID);
+ «EXPAND elementTypeCopy-»
+ mySemanticAdapter = new org.eclipse.core.runtime.IAdaptable() {
+ public Object getAdapter(Class adapter) {
+ «EXPAND elementTypeAdapter-»
+ return null;
+ }
+ };
+}
+«ENDDEFINE»
+
+«DEFINE typeLinkConstructor FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public «linkDescriptorClassName»(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, int linkVID) {
+ this(source, destination, linkElement, linkVID);
+ «EXPAND elementTypeCopy-»
+ mySemanticAdapter = new org.eclipse.gmf.runtime.emf.core.util.EObjectAdapter(linkElement) {
+ public Object getAdapter(Class adapter) {
+ «EXPAND elementTypeAdapter-»
+ return super.getAdapter(adapter);
+ }
+ };
+}
+«ENDDEFINE»
+
+«DEFINE elementTypeCopy FOR gmfgen::GenDiagramUpdater-»
+final org.eclipse.gmf.runtime.emf.type.core.IElementType elementTypeCopy = elementType;
+«ENDDEFINE»
+
+«DEFINE elementTypeAdapter FOR gmfgen::GenDiagramUpdater-»
+if (org.eclipse.gmf.runtime.emf.type.core.IElementType.class.equals(adapter)) {
+ return elementTypeCopy;
+}
+«ENDDEFINE»
+
+«DEFINE getSource FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.emf.ecore.EObject getSource() {
+ return mySource;
+}
+«ENDDEFINE»
+
+«DEFINE getDestination FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.emf.ecore.EObject getDestination() {
+ return myDestination;
+}
+«ENDDEFINE»
+
+«DEFINE getSemanticAdapter FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.core.runtime.IAdaptable getSemanticAdapter() {
+ return mySemanticAdapter;
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagramUpdater»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/NodeDescriptor.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/NodeDescriptor.xpt
new file mode 100644
index 000000000..6ed617fae
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/NodeDescriptor.xpt
@@ -0,0 +1,64 @@
+/*
+ * Copyright (c) 2007 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE NodeDescriptor FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «nodeDescriptorClassName» {
+
+ «EXPAND attributes-»
+
+ «EXPAND _constructor-»
+
+ «EXPAND getModelElement-»
+
+ «EXPAND getVisualID-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final org.eclipse.emf.ecore.EObject myModelElement;
+
+ «EXPAND xpt::Common::generatedMemberComment»
+ private final int myVisualID;
+«ENDDEFINE»
+
+«DEFINE _constructor FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public «nodeDescriptorClassName»(org.eclipse.emf.ecore.EObject modelElement, int visualID) {
+ myModelElement = modelElement;
+ myVisualID = visualID;
+}
+«ENDDEFINE»
+
+«DEFINE getModelElement FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public org.eclipse.emf.ecore.EObject getModelElement() {
+ return myModelElement;
+}
+«ENDDEFINE»
+
+«DEFINE getVisualID FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public int getVisualID() {
+ return myVisualID;
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagramUpdater»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/UpdateCommand.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/UpdateCommand.xpt
new file mode 100644
index 000000000..490e9c464
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/UpdateCommand.xpt
@@ -0,0 +1,93 @@
+/*
+ * Copyright (c) 2007 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE UpdateCommand FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::copyright FOR editorGen-»
+package «editorGen.editor.packageName»;
+
+ «EXPAND xpt::Common::generatedClassComment»
+public class «updateCommandClassName» implements org.eclipse.core.commands.IHandler {
+
+ «EXPAND addHandlerListener-»
+
+ «EXPAND dispose-»
+
+ «EXPAND execute-»
+
+ «EXPAND isEnabled-»
+
+ «EXPAND isHandled-»
+
+ «EXPAND removeHandlerListener-»
+
+ «EXPAND additions-»
+}
+«ENDDEFINE»
+
+«DEFINE addHandlerListener FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void addHandlerListener(org.eclipse.core.commands.IHandlerListener handlerListener) {
+}
+«ENDDEFINE»
+
+«DEFINE dispose FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void dispose() {
+}
+«ENDDEFINE»
+
+«DEFINE execute FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public Object execute(org.eclipse.core.commands.ExecutionEvent event) throws org.eclipse.core.commands.ExecutionException {
+ org.eclipse.jface.viewers.ISelection selection = org.eclipse.ui.PlatformUI.getWorkbench().getActiveWorkbenchWindow().getSelectionService().getSelection();
+ if (selection instanceof org.eclipse.jface.viewers.IStructuredSelection) {
+ org.eclipse.jface.viewers.IStructuredSelection structuredSelection = (org.eclipse.jface.viewers.IStructuredSelection) selection;
+ if (structuredSelection.size() != 1) {
+ return null;
+ }
+ if (structuredSelection.getFirstElement() instanceof org.eclipse.gef.EditPart && ((org.eclipse.gef.EditPart) structuredSelection.getFirstElement()).getModel() instanceof org.eclipse.gmf.runtime.notation.View) {
+ org.eclipse.emf.ecore.EObject modelElement = ((org.eclipse.gmf.runtime.notation.View) ((org.eclipse.gef.EditPart) structuredSelection.getFirstElement()).getModel()).getElement();
+ java.util.List editPolicies = org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy.getRegisteredEditPolicies(modelElement);
+ for (java.util.Iterator it = editPolicies.iterator(); it.hasNext();) {
+ org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy nextEditPolicy = (org.eclipse.gmf.runtime.diagram.ui.editpolicies.CanonicalEditPolicy) it.next();
+ nextEditPolicy.refresh();
+ }
+
+ }
+ }
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE isEnabled FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isEnabled() {
+ return true;
+}
+«ENDDEFINE»
+
+«DEFINE isHandled FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public boolean isHandled() {
+ return true;
+}
+«ENDDEFINE»
+
+«DEFINE removeHandlerListener FOR gmfgen::GenDiagramUpdater-»
+ «EXPAND xpt::Common::generatedMemberComment»
+public void removeHandlerListener(org.eclipse.core.commands.IHandlerListener handlerListener) {
+}
+«ENDDEFINE»
+
+«DEFINE additions FOR gmfgen::GenDiagramUpdater»«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/Utils.qvto b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/Utils.qvto
new file mode 100644
index 000000000..f461b32d2
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/Utils.qvto
@@ -0,0 +1,150 @@
+import xpt.diagram.editpolicies.LinkUtils;
+
+modeltype genModel uses "http://www.eclipse.org/gmf/2008/GenModel";
+modeltype genModel_1 uses "http://www.eclipse.org/emf/2002/GenModel";
+
+library Utils;
+
+helper getContainedLinksMethodNameSuffix() : String {
+ return 'Contained'
+}
+
+helper getIncomingLinksMethodNameSuffix() : String {
+ return 'Incoming'
+}
+
+helper getOutgoingLinksMethodNameSuffix() : String {
+ return 'Outgoing'
+}
+
+helper getContainedLinks(metaClass : genModel_1::GenClass, diagram : genModel::GenDiagram) : Sequence(genModel::GenLink) {
+ return diagram.links->select(link | canBeContainer(link, metaClass))->asSequence()
+}
+
+helper getOutgoingLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return linkEnd.getDiagram().links->select(link | linkEnd.genOutgoingLinks->includes(link))->asSequence()
+}
+
+helper getIncomingLinks(linkEnd : genModel::GenLinkEnd) : Sequence(genModel::GenLink) {
+ return linkEnd.getDiagram().links->select(link | linkEnd.genIncomingLinks->includes(link))->asSequence()
+}
+
+helper getAllContainedLinks(diagram : genModel::GenDiagram) : Sequence(genModel::GenLink) {
+ return diagram.links->select(link | not getAllSemanticElements(diagram)->select(commonBase | canBeContainer(link, commonBase.getMetaClass()))->isEmpty())->asSequence()
+}
+
+helper getAllIncomingLinks(diagram : genModel::GenDiagram) : Sequence(genModel::GenLink) {
+ return diagram.links->select(link | not link.targets->isEmpty())->asSequence()
+}
+
+helper getAllOutgoingLinks(diagram : genModel::GenDiagram) : Sequence(genModel::GenLink) {
+ return diagram.links->select(link | link.isOutgoingLink())->select(link | not link.sources->isEmpty())->asSequence()
+}
+
+helper genModel::GenLink::isOutgoingLink() : Boolean {
+ return null <> self.modelFacet and self.modelFacet.isOutgoingLink()
+}
+
+helper genModel::LinkModelFacet::isOutgoingLink() : Boolean {
+ return true
+}
+
+helper genModel::TypeLinkModelFacet::isOutgoingLink() : Boolean {
+ return null <> self.sourceMetaFeature
+}
+
+helper getAllSemanticDiagramElements(diagram : genModel::GenDiagram) : Sequence(genModel::GenLinkEnd) {
+ return ((diagram.getAllNodes()->asSequence())[genModel::GenLinkEnd]->union(diagram.links->asSequence()))[genModel::GenLinkEnd]->select(linkEnd | null <> linkEnd.getMetaClass())
+}
+
+helper getAllSemanticElements(diagram : genModel::GenDiagram) : Sequence(genModel::GenCommonBase) {
+ return (if null <> diagram.domainDiagramElement then (Sequence { diagram })[genModel::GenCommonBase]->union(getAllSemanticDiagramElements(diagram)) else getAllSemanticDiagramElements(diagram) endif)
+}
+
+helper genModel::GenCommonBase::getMetaClass() : genModel_1::GenClass {
+ return null
+}
+
+helper genModel::GenDiagram::getMetaClass() : genModel_1::GenClass {
+ return self.domainDiagramElement
+}
+
+helper genModel::GenNode::getMetaClass() : genModel_1::GenClass {
+ return self.modelFacet.metaClass
+}
+
+helper genModel::GenLink::getMetaClass() : genModel_1::GenClass {
+ return (if null <> self.modelFacet then self.modelFacet.getMetaClass() else null endif)
+}
+
+helper genModel::LinkModelFacet::getMetaClass() : genModel_1::GenClass {
+ return null
+}
+
+helper genModel::TypeLinkModelFacet::getMetaClass() : genModel_1::GenClass {
+ return self.metaClass
+}
+
+helper hasSemanticChildren(container : genModel::GenContainerBase) : Boolean {
+ return not container.sansDomain and not container.containedNodes->isEmpty()
+}
+
+helper genModel::GenContainerBase::getModelElementType() : genModel_1::GenClass {
+ return null
+}
+
+helper genModel::GenDiagram::getModelElementType() : genModel_1::GenClass {
+ return self.domainDiagramElement
+}
+
+helper genModel::GenCompartment::getModelElementType() : genModel_1::GenClass {
+ return self.node.getModelElementType()
+}
+
+helper genModel::GenNode::getModelElementType() : genModel_1::GenClass {
+ return self.modelFacet.metaClass
+}
+
+helper getSemanticChildrenChildFeatures(containerBase : genModel::GenContainerBase) : Set(genModel_1::GenFeature) {
+ return getNonPhantomSemanticChildren(containerBase)->collect(node | node.modelFacet.childMetaFeature)->asOrderedSet()
+}
+
+helper getSemanticChildrenContainmentFeatures(containerBase : genModel::GenContainerBase) : Set(genModel_1::GenFeature) {
+ return getNonPhantomSemanticChildren(containerBase)->collect(node | node.modelFacet.containmentMetaFeature)->asOrderedSet()
+}
+
+helper getSemanticChildren(containerBase : genModel::GenContainerBase, childMetaFeature : genModel_1::GenFeature) : Sequence(genModel::GenNode) {
+ return getNonPhantomSemanticChildren(containerBase)->select(node | node.modelFacet.childMetaFeature = childMetaFeature)
+}
+
+helper getNonPhantomSemanticChildren(containerBase : genModel::GenContainerBase) : Sequence(genModel::GenNode) {
+ return getSemanticChildren(containerBase)->select(node | not node.modelFacet.isPhantomElement())
+}
+
+helper genModel::GenContainerBase::getPhantomNodes() : Sequence(genModel::GenNode) {
+ return Sequence { }
+}
+
+helper genModel::GenDiagram::getPhantomNodes() : Sequence(genModel::GenNode) {
+ return getSemanticChildren(self)->select(node | node.modelFacet.isPhantomElement())
+}
+
+helper getSemanticChildren(containerBase : genModel::GenContainerBase) : Sequence(genModel::GenNode) {
+ return containerBase.containedNodes->select(node | null <> node.modelFacet)->asSequence()
+}
+
+helper hasConformableSemanticChildren(containerBase : genModel::GenContainerBase) : Boolean {
+ return let childMetaClasses = getSemanticChildren(containerBase)->collect(node | node.modelFacet.metaClass) in not childMetaClasses->forAll(mc | childMetaClasses->select(mc2 | mc = mc2)->size() = 1)
+}
+
+helper genModel::LinkModelFacet::getLinkEndType(methodNameSuffix : String) : genModel_1::GenClass {
+ return null
+}
+
+helper genModel::FeatureLinkModelFacet::getLinkEndType(methodNameSuffix : String) : genModel_1::GenClass {
+ return (if getIncomingLinksMethodNameSuffix() = methodNameSuffix then self.getTargetType() else self.getSourceType() endif)
+}
+
+helper genModel::TypeLinkModelFacet::getLinkEndType(methodNameSuffix : String) : genModel_1::GenClass {
+ return (if getIncomingLinksMethodNameSuffix() = methodNameSuffix then self.getTargetType() else (if getOutgoingLinksMethodNameSuffix() = methodNameSuffix and null <> self.sourceMetaFeature then self.getSourceType() else self.containmentMetaFeature.genClass endif) endif)
+}
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/containerBaseCanonicalMethods.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/containerBaseCanonicalMethods.xpt
new file mode 100644
index 000000000..4a2666aaa
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/containerBaseCanonicalMethods.xpt
@@ -0,0 +1,166 @@
+/*
+ * Copyright (c) 2007, 2008 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+«IMPORT 'http://www.eclipse.org/emf/2002/GenModel'»
+
+«EXTENSION xpt::diagram::updater::Utils»
+«EXTENSION xpt::GenModelUtils»
+
+«DEFINE containerBaseCanonicalMethods FOR gmfgen::GenContainerBase-»
+ «EXPAND attributes-»
+
+ «EXPAND getSemanticChildrenList-»
+ «EXPAND shouldDeleteView-»
+
+ «EXPAND isOrphaned-»
+ «IF hasConformableSemanticChildren(self)-»
+
+ «EXPAND populateViewProperties-»
+ «ENDIF-»
+
+ «EXPAND getDefaultFactoryHint-»
+ «EXPAND getFeaturesToSynchronize-»
+«ENDDEFINE»
+
+«DEFINE attributes FOR gmfgen::GenContainerBase-»
+«IF getSemanticChildrenContainmentFeatures(self)->size() > 0-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+java.util.Set myFeaturesToSynchronize;
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE getSemanticChildrenList FOR gmfgen::GenContainerBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected java.util.List getSemanticChildrenList() {
+ «IF hasSemanticChildren(self)-»
+ org.eclipse.gmf.runtime.notation.View viewObject = (org.eclipse.gmf.runtime.notation.View) getHost().getModel();
+ java.util.List result = new java.util.LinkedList();
+ for (java.util.Iterator it = «EXPAND xpt::diagram::updater::DiagramUpdater::getSemanticChildrenMethodCall»(viewObject).iterator(); it.hasNext();) {
+ result.add(((«getDiagram().editorGen.diagramUpdater.getNodeDescriptorQualifiedClassName()») it.next()).getModelElement());
+ }
+ return result;
+ «ELSE-»
+ return java.util.Collections.EMPTY_LIST;
+ «ENDIF-»
+}
+«ENDDEFINE»
+
+«DEFINE shouldDeleteView FOR gmfgen::GenContainerBase»«ENDDEFINE»
+
+«DEFINE shouldDeleteView FOR gmfgen::GenDiagram-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+protected boolean shouldDeleteView(org.eclipse.gmf.runtime.notation.View view) {
+ return true;
+}
+«ENDDEFINE»
+
+«DEFINE checkShortcutProperty FOR gmfgen::GenDiagram-»
+ «IF not containsShortcutsTo->isEmpty()-»
+if (view.getEAnnotation("Shortcut") != null) {«EXPAND xpt::Common::nonNLS»
+ return «editorGen.diagramUpdater.getDiagramUpdaterQualifiedClassName()».isShortcutOrphaned(view);
+}
+ «ENDIF-»
+«ENDDEFINE»
+
+«DEFINE checkShortcutProperty FOR gmfgen::GenContainerBase»«ENDDEFINE»
+
+«DEFINE getDefaultFactoryHint FOR gmfgen::GenContainerBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected String getDefaultFactoryHint() {
+ return null;
+}
+«ENDDEFINE»
+
+«DEFINE isOrphaned FOR gmfgen::GenContainerBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+protected boolean isOrphaned(java.util.Collection semanticChildren, final org.eclipse.gmf.runtime.notation.View view) {
+ «EXPAND checkShortcutProperty-»
+ «IF not getSemanticChildren(self)->isEmpty()-»
+ int visualID = «EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR getDiagram()»(view);
+ switch (visualID) {
+ «EXPAND xpt::Common::caseVisualID FOREACH getSemanticChildren(self)»
+ if (!semanticChildren.contains(view.getElement())) {
+ return true;
+ }
+ «IF hasConformableSemanticChildren(self)-»
+ «EXPAND updateNotationModelElement-»
+ «ENDIF-»
+ }
+ «ENDIF-»
+ return false;
+}
+«ENDDEFINE»
+
+«DEFINE updateNotationModelElement FOR gmfgen::GenCommonBase-»
+ org.eclipse.emf.ecore.EObject domainModelElement = view.getElement();
+ if (visualID != «EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall FOR getDiagram()»((org.eclipse.gmf.runtime.notation.View) getHost().getModel(), domainModelElement)) {
+ java.util.List createdViews = createViews(java.util.Collections.singletonList(domainModelElement));
+ «EXPAND xpt::Common::_assert('createdViews.size() == 1')-»
+ final org.eclipse.gmf.runtime.notation.View createdView = (org.eclipse.gmf.runtime.notation.View) ((org.eclipse.core.runtime.IAdaptable) createdViews.get(0)).getAdapter(org.eclipse.gmf.runtime.notation.View.class);
+ if (createdView != null) {
+ try {
+ new org.eclipse.emf.workspace.AbstractEMFOperation(host().getEditingDomain(), org.eclipse.gmf.runtime.common.core.util.StringStatics.BLANK, Collections.singletonMap(org.eclipse.emf.transaction.Transaction.OPTION_UNPROTECTED, Boolean.TRUE)) {
+ protected org.eclipse.core.runtime.IStatus doExecute(org.eclipse.core.runtime.IProgressMonitor monitor, org.eclipse.core.runtime.IAdaptable info) throws org.eclipse.core.commands.ExecutionException {
+ populateViewProperties(view, createdView);
+ return org.eclipse.core.runtime.Status.OK_STATUS;
+ }
+ }.execute(new org.eclipse.core.runtime.NullProgressMonitor(), null);
+ } catch (org.eclipse.core.commands.ExecutionException e) {
+ «getDiagram().editorGen.plugin.getActivatorQualifiedClassName()».getInstance().logError("Error while copyign view information to newly created view", e); //$NON-NLS-1$
+ }
+ }
+ deleteViews(java.util.Collections.singletonList(view).iterator());
+ }
+«ENDDEFINE»
+
+«DEFINE populateViewProperties FOR gmfgen::GenCommonBase-»
+ «EXPAND xpt::Common::generatedMemberComment»
+private void populateViewProperties(org.eclipse.gmf.runtime.notation.View oldView, org.eclipse.gmf.runtime.notation.View newView) {
+ if (oldView instanceof org.eclipse.gmf.runtime.notation.Node && newView instanceof org.eclipse.gmf.runtime.notation.Node) {
+ org.eclipse.gmf.runtime.notation.Node oldNode = (org.eclipse.gmf.runtime.notation.Node) oldView;
+ org.eclipse.gmf.runtime.notation.Node newNode = (org.eclipse.gmf.runtime.notation.Node) newView;
+ if (oldNode.getLayoutConstraint() instanceof org.eclipse.gmf.runtime.notation.Location && newNode.getLayoutConstraint() instanceof org.eclipse.gmf.runtime.notation.Location) {
+ ((org.eclipse.gmf.runtime.notation.Location) newNode.getLayoutConstraint()).setX(((org.eclipse.gmf.runtime.notation.Location) oldNode.getLayoutConstraint()).getX());
+ ((org.eclipse.gmf.runtime.notation.Location) newNode.getLayoutConstraint()).setY(((org.eclipse.gmf.runtime.notation.Location) oldNode.getLayoutConstraint()).getY());
+ }
+ if (oldNode.getLayoutConstraint() instanceof org.eclipse.gmf.runtime.notation.Size && newNode.getLayoutConstraint() instanceof org.eclipse.gmf.runtime.notation.Size) {
+ ((org.eclipse.gmf.runtime.notation.Size) newNode.getLayoutConstraint()).setWidth(((org.eclipse.gmf.runtime.notation.Size) oldNode.getLayoutConstraint()).getWidth());
+ ((org.eclipse.gmf.runtime.notation.Size) newNode.getLayoutConstraint()).setHeight(((org.eclipse.gmf.runtime.notation.Size) oldNode.getLayoutConstraint()).getHeight());
+ }
+ if (oldNode.getLayoutConstraint() instanceof org.eclipse.gmf.runtime.notation.Ratio && newNode.getLayoutConstraint() instanceof org.eclipse.gmf.runtime.notation.Ratio) {
+ ((org.eclipse.gmf.runtime.notation.Ratio) newNode.getLayoutConstraint()).setValue(((org.eclipse.gmf.runtime.notation.Ratio) oldNode.getLayoutConstraint()).getValue());
+ }
+ newNode.persist();
+ }
+}
+«ENDDEFINE»
+
+«DEFINE getFeaturesToSynchronize FOR gmfgen::GenContainerBase-»
+«IF getSemanticChildrenChildFeatures(self)->size() > 0-»
+
+ «EXPAND xpt::Common::generatedMemberComment»
+protected java.util.Set getFeaturesToSynchronize(){
+ if (myFeaturesToSynchronize == null) {
+ myFeaturesToSynchronize = new java.util.HashSet();
+ «EXPAND addContainmentFeature FOREACH getSemanticChildrenContainmentFeatures(self)-»
+ }
+ return myFeaturesToSynchronize;
+}
+«ENDIF-»
+«ENDDEFINE»
+
+«DEFINE addContainmentFeature FOR genmodel::GenFeature-»
+myFeaturesToSynchronize.add(«EXPAND MetaModel::MetaFeature»);
+«ENDDEFINE» \ No newline at end of file
diff --git a/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/extensions.xpt b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/extensions.xpt
new file mode 100644
index 000000000..49f34316f
--- /dev/null
+++ b/plugins/org.eclipse.gmf.codegen/templates.migrated/xpt/diagram/updater/extensions.xpt
@@ -0,0 +1,34 @@
+/*
+ * Copyright (c) 2007 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:
+ * Alexander Shatalin (Borland) - initial API and implementation
+ */
+
+«IMPORT 'http://www.eclipse.org/gmf/2008/GenModel'»
+
+«DEFINE extensions FOR gmfgen::GenDiagramUpdater-»
+ <extension point="org.eclipse.ui.commands" id="update-cmd">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <command
+ categoryId="org.eclipse.ui.category.edit"
+ defaultHandler="«getUpdateCommandQualifiedClassName()»"
+ description="%update.diagram.description"
+ id="«updateCommandID»"
+ name="%update.diagram.name"/>
+ </extension>
+
+ <extension point="org.eclipse.ui.bindings" id="update-cmd-binding">
+ «EXPAND xpt::Common::xmlGeneratedTag»
+ <key
+ commandId="«updateCommandID»"
+ contextId="«editorGen.editor.contextID»"
+ schemeId="org.eclipse.ui.defaultAcceleratorConfiguration"
+ sequence="F5"/>
+ </extension>
+«ENDDEFINE» \ No newline at end of file

Back to the top