carbidecpp22devenv/plugins/org.eclipse.gmf.templates.legacy_1.0.0.v20090614-0839/codegen.templates/xpt/diagram/updater/DiagramUpdater.xpt
author cawthron
Fri, 04 Dec 2009 11:06:59 -0600
changeset 422 033392511bf7
permissions -rw-r--r--
add files for RCL_2_2
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
422
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     1
/*
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     2
 * Copyright (c) 2007, 2008 Borland Software Corporation
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     3
 * 
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     4
 * All rights reserved. This program and the accompanying materials
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     5
 * are made available under the terms of the Eclipse Public License v1.0
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     6
 * which accompanies this distribution, and is available at
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     7
 * http://www.eclipse.org/legal/epl-v10.html
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     8
 *
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
     9
 * Contributors:
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    10
 *    Alexander Shatalin (Borland) - initial API and implementation
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    11
 */
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    12
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    13
«IMPORT "http://www.eclipse.org/gmf/2008/GenModel"»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    14
«IMPORT "http://www.eclipse.org/emf/2002/GenModel"»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    15
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    16
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    17
«EXTENSION xpt::diagram::updater::Utils»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    18
«EXTENSION xpt::diagram::editpolicies::LinkUtils»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    19
«EXTENSION xpt::GenModelUtils»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    20
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    21
«DEFINE DiagramUpdater FOR gmfgen::GenDiagramUpdater-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    22
	«EXPAND xpt::Common::copyright FOR editorGen-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    23
package «editorGen.editor.packageName»;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    24
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    25
	«EXPAND xpt::Common::generatedClassComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    26
public class «diagramUpdaterClassName» {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    27
	«EXPAND isShortcutOrphaned-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    28
«LET editorGen.diagram.getAllContainers().select(container | hasSemanticChildren(container)) AS semanticContainers-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    29
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    30
	«EXPAND getGenericSemanticChildrenOfView(semanticContainers)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    31
	«EXPAND getSemanticChildrenOfView FOREACH semanticContainers-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    32
	«EXPAND getPhantomNodesIterator-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    33
«ENDLET-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    34
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    35
	«EXPAND getGenericConnectedLinks(getAllSemanticElements(editorGen.diagram), getContainedLinksMethodNameSuffix())-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    36
	
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    37
	«EXPAND getGenericConnectedLinks(getAllSemanticDiagramElements(editorGen.diagram), getIncomingLinksMethodNameSuffix())-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    38
	
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    39
	«EXPAND getGenericConnectedLinks(getAllSemanticDiagramElements(editorGen.diagram), getOutgoingLinksMethodNameSuffix())-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    40
	«EXPAND getContainedLinks FOREACH getAllSemanticElements(editorGen.diagram)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    41
	«EXPAND getIncomingLinks FOREACH getAllSemanticDiagramElements(editorGen.diagram)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    42
	«EXPAND getOutgoingLinks FOREACH getAllSemanticDiagramElements(editorGen.diagram)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    43
	«EXPAND getContainedLinksByTypeMethod FOREACH getAllContainedLinks(editorGen.diagram)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    44
	«EXPAND getIncomingLinksByTypeMethod FOREACH getAllIncomingLinks(editorGen.diagram)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    45
	«EXPAND getOutgoingLinksByTypeMethod FOREACH getAllOutgoingLinks(editorGen.diagram)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    46
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    47
	«EXPAND additions-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    48
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    49
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    50
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    51
«REM»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    52
	Currently shortcuts are supported only for domain-based diagram element.
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    53
	This means, view.isSetElement() == true.
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    54
«ENDREM»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    55
«DEFINE isShortcutOrphaned FOR gmfgen::GenDiagramUpdater-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    56
	«IF !editorGen.diagram.containsShortcutsTo.isEmpty()-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    57
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    58
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    59
public static boolean isShortcutOrphaned(org.eclipse.gmf.runtime.notation.View view) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    60
	return !view.isSetElement() || view.getElement() == null || view.getElement().eIsProxy();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    61
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    62
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    63
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    64
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    65
«DEFINE getGenericSemanticChildrenOfView(List[gmfgen::GenContainerBase] semanticContainers) FOR gmfgen::GenDiagramUpdater-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    66
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    67
public static java.util.List getSemanticChildren(org.eclipse.gmf.runtime.notation.View view) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    68
	«IF !semanticContainers.isEmpty()-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    69
	switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR editorGen.diagram»(view)) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    70
		«EXPAND getSemanticChildrenCase FOREACH semanticContainers-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    71
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    72
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    73
	return java.util.Collections.EMPTY_LIST;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    74
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    75
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    76
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    77
«DEFINE getSemanticChildrenCase FOR gmfgen::GenContainerBase-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    78
«EXPAND xpt::Common::caseVisualID»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    79
	return «EXPAND getSemanticChildrenMethodName»(view);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    80
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    81
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    82
«DEFINE getSemanticChildrenOfView FOR gmfgen::GenContainerBase-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    83
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    84
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    85
public static java.util.List «EXPAND getSemanticChildrenMethodName»(org.eclipse.gmf.runtime.notation.View view) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    86
	«IF getSemanticChildrenChildFeatures(this).size() > 0 || getPhantomNodes(this).size() > 0-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    87
	«EXPAND defineModelElement-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    88
	java.util.List result = new java.util.LinkedList();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    89
«REM»childMetaFeature can be null here!«ENDREM»«-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    90
		«FOREACH getSemanticChildrenChildFeatures(this) AS childMetaFeature-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    91
			«IF null == childMetaFeature-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    92
	{ /*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*/;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    93
			«ELSEIF isListType(childMetaFeature)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    94
	for (java.util.Iterator it = «EXPAND MetaModel::getFeatureValue("modelElement", getModelElementType()) FOR childMetaFeature».iterator(); it.hasNext();) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    95
		«EXPAND MetaModel::DeclareAndAssign("childElement", "it.next()", true) FOR getTypeGenClassX(childMetaFeature)»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    96
			«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    97
	{ «EXPAND MetaModel::DeclareAndAssign("childElement", "modelElement", getModelElementType(), childMetaFeature) FOR getTypeGenClassX(childMetaFeature)»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    98
			«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
    99
		int visualID = «EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall FOR getDiagram()»(view, «EXPAND MetaModel::DowncastToEObject("childElement") FOR getTypeGenClassX(childMetaFeature)»);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   100
			«EXPAND checkChildElementVisualID(null != childMetaFeature && isListType(childMetaFeature)) FOREACH getSemanticChildren(this, childMetaFeature)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   101
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   102
		«ENDFOREACH-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   103
		«IF !getPhantomNodes(this).isEmpty()-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   104
	org.eclipse.emf.ecore.resource.Resource resource = modelElement.eResource();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   105
	for (java.util.Iterator semanticIterator = getPhantomNodesIterator(resource); semanticIterator.hasNext();) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   106
		org.eclipse.emf.ecore.EObject childElement = (org.eclipse.emf.ecore.EObject) semanticIterator.next();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   107
		if (childElement == modelElement) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   108
			continue;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   109
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   110
			«EXPAND addNextIfPhantom FOREACH getPhantomNodes(this)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   111
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   112
		«ENDIF-»		
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   113
	return result;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   114
	«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   115
	return java.util.Collections.EMPTY_LIST;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   116
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   117
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   118
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   119
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   120
«DEFINE defineModelElement FOR gmfgen::GenContainerBase-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   121
if (!view.isSetElement()) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   122
	return java.util.Collections.EMPTY_LIST;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   123
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   124
«EXPAND MetaModel::DeclareAndAssign("modelElement", "view.getElement()") FOR getModelElementType()»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   125
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   126
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   127
«DEFINE defineModelElement FOR gmfgen::GenCompartment-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   128
if (false == view.eContainer() instanceof org.eclipse.gmf.runtime.notation.View) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   129
	return java.util.Collections.EMPTY_LIST;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   130
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   131
org.eclipse.gmf.runtime.notation.View containerView = (org.eclipse.gmf.runtime.notation.View) view.eContainer();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   132
if (!containerView.isSetElement()) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   133
	return java.util.Collections.EMPTY_LIST;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   134
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   135
«EXPAND MetaModel::DeclareAndAssign("modelElement", "containerView.getElement()") FOR getModelElementType()»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   136
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   137
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   138
«DEFINE getSemanticChildrenMethodName FOR gmfgen::GenContainerBase»get«getUniqueIdentifier()»SemanticChildren«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   139
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   140
«DEFINE getSemanticChildrenMethodCall FOR gmfgen::GenContainerBase»«getDiagram().editorGen.diagramUpdater.getDiagramUpdaterQualifiedClassName()».«EXPAND getSemanticChildrenMethodName»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   141
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   142
«DEFINE checkChildElementVisualID(boolean inLoop) FOR gmfgen::GenNode-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   143
if (visualID == «EXPAND xpt::editor::VisualIDRegistry::visualID») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   144
	result.add(new «getDiagram().editorGen.diagramUpdater.getNodeDescriptorQualifiedClassName()»(«IF null != modelFacet.childMetaFeature»«EXPAND MetaModel::DowncastToEObject("childElement") FOR getTypeGenClassX(modelFacet.childMetaFeature)»«ENDIF», visualID));
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   145
«IF inLoop-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   146
	continue;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   147
«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   148
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   149
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   150
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   151
«DEFINE addNextIfPhantom FOR gmfgen::GenNode-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   152
if («EXPAND xpt::editor::VisualIDRegistry::getNodeVisualIDMethodCall FOR getDiagram()»(view, childElement) == «EXPAND xpt::editor::VisualIDRegistry::visualID») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   153
	result.add(new «getDiagram().editorGen.diagramUpdater.getNodeDescriptorQualifiedClassName()»(childElement, «EXPAND xpt::editor::VisualIDRegistry::visualID»));
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   154
	continue;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   155
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   156
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   157
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   158
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   159
«DEFINE getPhantomNodesIterator FOR gmfgen::GenDiagramUpdater-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   160
	«IF !getPhantomNodes(editorGen.diagram).isEmpty()-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   161
	
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   162
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   163
private static java.util.Iterator getPhantomNodesIterator(org.eclipse.emf.ecore.resource.Resource resource) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   164
	return resource.getAllContents();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   165
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   166
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   167
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   168
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   169
«DEFINE getGenericConnectedLinks(List[gmfgen::GenCommonBase] linkContainers, String methodNameSuffix) FOR gmfgen::GenDiagramUpdater-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   170
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   171
public static java.util.List get«methodNameSuffix»Links(org.eclipse.gmf.runtime.notation.View view) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   172
	«IF !linkContainers.isEmpty()-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   173
	switch («EXPAND xpt::editor::VisualIDRegistry::getVisualIDMethodCall FOR editorGen.diagram»(view)) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   174
		«EXPAND getContainedLinksCase(methodNameSuffix) FOREACH linkContainers-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   175
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   176
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   177
	return java.util.Collections.EMPTY_LIST;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   178
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   179
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   180
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   181
«DEFINE getContainedLinksCase(String methodNameSuffix) FOR gmfgen::GenCommonBase-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   182
«EXPAND xpt::Common::caseVisualID»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   183
	return «EXPAND linkGetterName(methodNameSuffix)»(view);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   184
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   185
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   186
«REM»This DEFING can be used from other templates to inject call to the corresponding method«ENDREM»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   187
«DEFINE getContainedLinksMethodCall FOR gmfgen::GenCommonBase»«getDiagram().editorGen.diagramUpdater.getDiagramUpdaterQualifiedClassName()».«EXPAND linkGetterName(getContainedLinksMethodNameSuffix())»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   188
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   189
«REM»This DEFING can be used from other templates to inject call to the corresponding method«ENDREM»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   190
«DEFINE getIncomingLinksMethodCall FOR gmfgen::GenCommonBase»«getDiagram().editorGen.diagramUpdater.getDiagramUpdaterQualifiedClassName()».«EXPAND linkGetterName(getIncomingLinksMethodNameSuffix())»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   191
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   192
«REM»This DEFING can be used from other templates to inject call to the corresponding method«ENDREM»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   193
«DEFINE getOutgoingLinksMethodCall FOR gmfgen::GenCommonBase»«getDiagram().editorGen.diagramUpdater.getDiagramUpdaterQualifiedClassName()».«EXPAND linkGetterName(getOutgoingLinksMethodNameSuffix())»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   194
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   195
«DEFINE linkGetterName(String suffix) FOR gmfgen::GenCommonBase»get«getUniqueIdentifier()»«suffix»Links«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   196
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   197
«DEFINE getContainedLinks FOR gmfgen::GenCommonBase-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   198
	«EXPAND getConnectedLinks(getContainedLinks(getMetaClass(this), getDiagram()), getContainedLinksMethodNameSuffix(), false)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   199
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   200
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   201
«DEFINE getIncomingLinks FOR gmfgen::GenCommonBase-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   202
	«EXPAND getConnectedLinks(getIncomingLinks(getMetaClass(this), getDiagram()), getIncomingLinksMethodNameSuffix(), true)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   203
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   204
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   205
«DEFINE getOutgoingLinks FOR gmfgen::GenCommonBase-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   206
	«EXPAND getConnectedLinks(getOutgoingLinks(getMetaClass(this), getDiagram()), getOutgoingLinksMethodNameSuffix(), false)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   207
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   208
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   209
«DEFINE getConnectedLinks(List[gmfgen::GenLink] genLinks, String methodNameSuffix, boolean needCrossReferencer) FOR gmfgen::GenCommonBase-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   210
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   211
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   212
public static java.util.List «EXPAND linkGetterName(methodNameSuffix)»(org.eclipse.gmf.runtime.notation.View view) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   213
	«IF !genLinks.isEmpty()-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   214
		«LET getMetaClass(this) AS metaclass-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   215
	«EXPAND MetaModel::DeclareAndAssign("modelElement", "view.getElement()") FOR metaclass»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   216
			«IF needCrossReferencer-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   217
	java.util.Map crossReferences = org.eclipse.emf.ecore.util.EcoreUtil.CrossReferencer.find(view.eResource().getResourceSet().getResources());
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   218
			«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   219
	java.util.List result = new java.util.LinkedList();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   220
			«EXPAND colectConnectedLinks(methodNameSuffix, needCrossReferencer, metaclass.isExternalInterface()) FOREACH genLinks-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   221
	return result;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   222
		«ENDLET-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   223
	«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   224
	return java.util.Collections.EMPTY_LIST;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   225
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   226
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   227
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   228
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   229
«DEFINE colectConnectedLinks(String methodNameSuffix, boolean needCrossReferencer, boolean isExternalInterface) FOR gmfgen::GenLink-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   230
«IF isExternalInterface-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   231
	if («EXPAND MetaModel::IsInstance("modelElement") FOR modelFacet.getLinkEndType(methodNameSuffix)») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   232
«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   233
	result.addAll(«EXPAND chooseConnectedLinksByTypeMethodName(methodNameSuffix, this) FOR modelFacet»(«IF isExternalInterface-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   234
«EXPAND MetaModel::CastEObject("modelElement") FOR getLinkEndType(modelFacet, methodNameSuffix)»«ELSE»modelElement«ENDIF»«IF needCrossReferencer», crossReferences«ENDIF»));	
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   235
«IF isExternalInterface-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   236
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   237
«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   238
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   239
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   240
«DEFINE chooseConnectedLinksByTypeMethodName(String methodNameSuffix, gmfgen::GenLink genLink) FOR gmfgen::LinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   241
	«EXPAND incorrectLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   242
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   243
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   244
«REM»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   245
	For FeatureModelFacet-based links we are calling 
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   246
	getOutgoing???Links instead of getContained???Links
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   247
«ENDREM»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   248
«DEFINE chooseConnectedLinksByTypeMethodName(String methodNameSuffix, gmfgen::GenLink genLink) FOR gmfgen::FeatureLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   249
«IF getContainedLinksMethodNameSuffix() == methodNameSuffix»«EXPAND getConnectedLinksByTypeMethodName(getOutgoingLinksMethodNameSuffix()) FOR genLink-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   250
«ELSE»«EXPAND getConnectedLinksByTypeMethodName(methodNameSuffix) FOR genLink-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   251
«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   252
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   253
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   254
«REM»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   255
	For TypeModelFacet-based links we are calling 
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   256
	getContained???Links instead of getOutgoinf???Links 
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   257
	if sourceMetaFeature was not specified
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   258
«ENDREM»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   259
«DEFINE chooseConnectedLinksByTypeMethodName(String methodNameSuffix, gmfgen::GenLink genLink) FOR gmfgen::TypeLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   260
«IF getOutgoingLinksMethodNameSuffix() == methodNameSuffix && null == sourceMetaFeature»«EXPAND getConnectedLinksByTypeMethodName(getContainedLinksMethodNameSuffix()) FOR genLink-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   261
«ELSE»«EXPAND getConnectedLinksByTypeMethodName(methodNameSuffix) FOR genLink-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   262
«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   263
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   264
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   265
«DEFINE getContainedLinksByTypeMethod FOR gmfgen::GenLink»«EXPAND getContainedLinksByTypeMethod(this) FOR modelFacet»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   266
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   267
«DEFINE getConnectedLinksByTypeMethodName(String suffix) FOR gmfgen::GenLink»get«suffix»«EXPAND getConnectedLinksByTypeMethodFragment FOR modelFacet»_«visualID»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   268
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   269
«DEFINE getConnectedLinksByTypeMethodFragment FOR gmfgen::TypeLinkModelFacet»TypeModelFacetLinks_«metaClass.ecoreClass.name»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   270
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   271
«DEFINE getConnectedLinksByTypeMethodFragment FOR gmfgen::FeatureLinkModelFacet»FeatureModelFacetLinks_«metaFeature.genClass.ecoreClass.name»_«metaFeature.ecoreFeature.name.toFirstUpper()»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   272
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   273
«DEFINE getConnectedLinksByTypeMethodFragment FOR gmfgen::LinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   274
	«EXPAND incorrectLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   275
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   276
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   277
«DEFINE getContainedLinksByTypeMethod(gmfgen::GenLink genLink) FOR gmfgen::LinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   278
	«EXPAND incorrectLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   279
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   280
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   281
«DEFINE getContainedLinksByTypeMethod(gmfgen::GenLink genLink) FOR gmfgen::FeatureLinkModelFacet»«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   282
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   283
«DEFINE getContainedLinksByTypeMethod(gmfgen::GenLink genLink) FOR gmfgen::TypeLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   284
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   285
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   286
private static java.util.Collection «EXPAND getConnectedLinksByTypeMethodName(getContainedLinksMethodNameSuffix()) FOR genLink»(«EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» container) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   287
	«EXPAND getContainedLinksByTypeMethodBody(genLink, false)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   288
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   289
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   290
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   291
«DEFINE getContainedLinksByTypeMethodBody(gmfgen::GenLink genLink, boolean sourceVarDefined) FOR gmfgen::TypeLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   292
java.util.Collection result = new java.util.LinkedList();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   293
	«LET childMetaFeature.isListType() AS inLoop-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   294
«IF inLoop-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   295
for (java.util.Iterator links = «EXPAND MetaModel::getFeatureValue("container", containmentMetaFeature.genClass) FOR childMetaFeature».iterator(); links.hasNext();) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   296
	org.eclipse.emf.ecore.EObject linkObject = (org.eclipse.emf.ecore.EObject ) links.next();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   297
	if («EXPAND MetaModel::NotInstance("linkObject") FOR metaClass») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   298
		continue;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   299
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   300
	«EXPAND MetaModel::DeclareAndAssign("link", "linkObject") FOR metaClass»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   301
«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   302
	«IF getTypeGenClassX(childMetaFeature) == metaClass-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   303
		«EXPAND MetaModel::DeclareAndAssign("link", "container", getSourceType(), childMetaFeature) FOR metaClass»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   304
	«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   305
		«EXPAND MetaModel::DeclareAndAssign("linkObject", "container", getSourceType(), childMetaFeature) FOR getTypeGenClassX(childMetaFeature)»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   306
		if («EXPAND MetaModel::NotInstance("linkObject") FOR metaClass») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   307
			return result;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   308
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   309
		«EXPAND MetaModel::DeclareAndAssign("link", "linkObject") FOR metaClass»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   310
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   311
«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   312
		«EXPAND checkLinkVisualID(genLink, inLoop)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   313
		«EXPAND defineLinkDestination(inLoop)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   314
		«IF null != sourceMetaFeature-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   315
			«EXPAND defineLinkSource(inLoop)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   316
			«IF sourceVarDefined-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   317
				«EXPAND checkLinkSource(inLoop)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   318
			«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   319
			«EXPAND addLinkDescriptor(genLink, "src", "dst")-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   320
		«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   321
			«EXPAND addLinkDescriptor(genLink, "container", "dst")-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   322
		«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   323
«IF inLoop-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   324
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   325
«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   326
	«ENDLET-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   327
return result;	
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   328
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   329
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   330
«DEFINE addLinkDescriptor(gmfgen::GenLink genLink, String srcVar, String dstVar) FOR gmfgen::TypeLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   331
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», «genLink.getDiagram().getElementTypesQualifiedClassName()».«genLink.getUniqueIdentifier()», «EXPAND xpt::editor::VisualIDRegistry::visualID FOR genLink»));
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   332
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   333
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   334
«DEFINE checkLinkVisualID(gmfgen::GenLink genLink, boolean inLoop) FOR gmfgen::TypeLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   335
if («EXPAND xpt::editor::VisualIDRegistry::visualID FOR genLink» != «EXPAND xpt::editor::VisualIDRegistry::getLinkWithClassVisualIDMethodCall FOR genLink.getDiagram()»(«EXPAND MetaModel::DowncastToEObject("link") FOR metaClass»)) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   336
	«EXPAND stopLinkProcessing(inLoop)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   337
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   338
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   339
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   340
«DEFINE defineLinkSource(boolean inLoop) FOR gmfgen::TypeLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   341
	«IF sourceMetaFeature.isListType()-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   342
java.util.List sources = «EXPAND MetaModel::getFeatureValue("link", metaClass) FOR sourceMetaFeature»;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   343
Object theSource = sources.size() == 1 ? sources.get(0) : null;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   344
if («EXPAND MetaModel::NotInstance("theSource") FOR getSourceType()») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   345
	«EXPAND stopLinkProcessing(inLoop)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   346
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   347
«EXPAND MetaModel::DeclareAndAssign("src", "theSource", true) FOR getSourceType()»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   348
	«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   349
«EXPAND MetaModel::DeclareAndAssign("src", "link", metaClass, sourceMetaFeature) FOR getSourceType()»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   350
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   351
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   352
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   353
«DEFINE checkLinkSource(boolean inLoop) FOR gmfgen::TypeLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   354
if (src != source) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   355
	«EXPAND stopLinkProcessing(inLoop)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   356
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   357
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   358
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   359
«DEFINE defineLinkDestination(boolean inLoop) FOR gmfgen::TypeLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   360
	«IF targetMetaFeature.isListType()-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   361
java.util.List targets = «EXPAND MetaModel::getFeatureValue("link", metaClass) FOR targetMetaFeature»;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   362
Object theTarget = targets.size() == 1 ? targets.get(0) : null;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   363
if («EXPAND MetaModel::NotInstance("theTarget") FOR getTargetType()») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   364
	«EXPAND stopLinkProcessing(inLoop)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   365
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   366
«EXPAND MetaModel::DeclareAndAssign("dst", "theTarget", true) FOR getTargetType()»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   367
	«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   368
«EXPAND MetaModel::DeclareAndAssign("dst", "link", metaClass, targetMetaFeature) FOR getTargetType()»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   369
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   370
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   371
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   372
«DEFINE stopLinkProcessing(boolean inLoop) FOR gmfgen::TypeLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   373
«IF inLoop-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   374
continue;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   375
«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   376
return result;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   377
«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   378
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   379
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   380
«DEFINE getIncomingLinksByTypeMethod FOR gmfgen::GenLink-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   381
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   382
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   383
private static java.util.Collection «EXPAND getConnectedLinksByTypeMethodName(getIncomingLinksMethodNameSuffix())»(«EXPAND MetaModel::QualifiedClassName FOR modelFacet.getTargetType()» target, java.util.Map crossReferences) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   384
	java.util.Collection result = new java.util.LinkedList();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   385
	java.util.Collection settings = (java.util.Collection) crossReferences.get(target);
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   386
	for (java.util.Iterator it = settings.iterator(); it.hasNext();) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   387
		org.eclipse.emf.ecore.EStructuralFeature.Setting setting = (org.eclipse.emf.ecore.EStructuralFeature.Setting) it.next();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   388
		«EXPAND getIncomingLinksByTypeMethodBody(this) FOR modelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   389
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   390
	return result;	
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   391
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   392
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   393
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   394
«DEFINE getIncomingLinksByTypeMethodBody(gmfgen::GenLink genLink) FOR gmfgen::TypeLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   395
if (setting.getEStructuralFeature() != «EXPAND MetaModel::MetaFeature FOR targetMetaFeature» || «EXPAND MetaModel::NotInstance("setting.getEObject()") FOR metaClass») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   396
	continue;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   397
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   398
«EXPAND MetaModel::DeclareAndAssign("link", "setting.getEObject()") FOR metaClass»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   399
	«EXPAND checkLinkVisualID(genLink, true)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   400
	«IF null != sourceMetaFeature-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   401
		«EXPAND defineLinkSource(true)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   402
		«EXPAND addLinkDescriptor(genLink, "src", "target")-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   403
	«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   404
		«EXPAND defineLinkContainer(true)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   405
		«EXPAND addLinkDescriptor(genLink, "container", "target")-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   406
«REM»TODO: continue here.«ENDREM»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   407
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   408
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   409
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   410
«DEFINE defineLinkContainer(boolean inLoop) FOR gmfgen::TypeLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   411
if (false == «EXPAND MetaModel::IsContainerInstance("link", metaClass) FOR containmentMetaFeature.genClass») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   412
	«EXPAND stopLinkProcessing(inLoop)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   413
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   414
«EXPAND MetaModel::DeclareAndAssignContainer("container", "link", metaClass) FOR containmentMetaFeature.genClass»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   415
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   416
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   417
«DEFINE getIncomingLinksByTypeMethodBody(gmfgen::GenLink genLink) FOR gmfgen::FeatureLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   418
if (setting.getEStructuralFeature() == «EXPAND MetaModel::MetaFeature FOR metaFeature») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   419
	result.add(new «genLink.getDiagram().editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()»(setting.getEObject(), «EXPAND MetaModel::DowncastToEObject("target") FOR getTargetType()», «genLink.getDiagram().getElementTypesQualifiedClassName()».«genLink.getUniqueIdentifier()», «EXPAND xpt::editor::VisualIDRegistry::visualID FOR genLink»));
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   420
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   421
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   422
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   423
«DEFINE getIncomingLinksByTypeMethodBody(gmfgen::GenLink genLink) FOR gmfgen::LinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   424
	«EXPAND incorrectLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   425
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   426
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   427
«DEFINE getOutgoingLinksByTypeMethod FOR gmfgen::GenLink-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   428
	«EXPAND getOutgoingLinksByTypeMethod(this) FOR modelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   429
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   430
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   431
«DEFINE getOutgoingLinksByTypeMethodSignature FOR gmfgen::GenLink»private static java.util.Collection «EXPAND getConnectedLinksByTypeMethodName(getOutgoingLinksMethodNameSuffix())»(«EXPAND MetaModel::QualifiedClassName FOR modelFacet.getSourceType()» source)«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   432
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   433
«DEFINE getOutgoingLinksByTypeMethod(gmfgen::GenLink genLink) FOR gmfgen::FeatureLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   434
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   435
	«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   436
«EXPAND getOutgoingLinksByTypeMethodSignature FOR genLink» {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   437
	java.util.Collection result = new java.util.LinkedList();
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   438
	«IF metaFeature.isListType()-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   439
	for (java.util.Iterator destinations = «EXPAND MetaModel::getFeatureValue("source", getSourceType()) FOR metaFeature».iterator(); destinations.hasNext();) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   440
		«EXPAND MetaModel::DeclareAndAssign("destination", "destinations.next()", true) FOR getTargetType()»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   441
	«ELSE-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   442
	«EXPAND MetaModel::DeclareAndAssign("destination", "source", getSourceType(), metaFeature) FOR getTargetType()»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   443
	if (destination == null) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   444
		return result;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   445
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   446
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   447
	result.add(new «genLink.getDiagram().editorGen.diagramUpdater.getLinkDescriptorQualifiedClassName()»(«EXPAND MetaModel::DowncastToEObject("source") FOR getSourceType()», «EXPAND MetaModel::DowncastToEObject("destination") FOR getTargetType()», «genLink.getDiagram().getElementTypesQualifiedClassName()».«genLink.getUniqueIdentifier()», «EXPAND xpt::editor::VisualIDRegistry::visualID FOR genLink»));
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   448
	«IF metaFeature.isListType()-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   449
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   450
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   451
	return result;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   452
}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   453
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   454
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   455
«REM»More careful way to find container should be used here then GMF will be modified in accordance«ENDREM»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   456
«DEFINE getOutgoingLinksByTypeMethod(gmfgen::GenLink genLink) FOR gmfgen::TypeLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   457
	«IF null != sourceMetaFeature-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   458
	
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   459
		«EXPAND xpt::Common::generatedMemberComment»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   460
«EXPAND getOutgoingLinksByTypeMethodSignature FOR genLink» {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   461
	«EXPAND MetaModel::QualifiedClassName FOR containmentMetaFeature.genClass» container = null;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   462
	// Find container element for the link.
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   463
	// Climb up by containment hierarchy starting from the source
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   464
	// and return the first element that is instance of the container class.
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   465
	for (org.eclipse.emf.ecore.EObject element = «EXPAND MetaModel::DowncastToEObject("source") FOR getSourceType()»; element != null && container == null; element = element.eContainer()) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   466
		if («EXPAND MetaModel::IsInstance("element") FOR containmentMetaFeature.genClass») {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   467
			container = «EXPAND MetaModel::CastEObject("element") FOR containmentMetaFeature.genClass»;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   468
		}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   469
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   470
	if (container == null) {
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   471
		return java.util.Collections.EMPTY_LIST;
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   472
	}
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   473
		«EXPAND getContainedLinksByTypeMethodBody(genLink, true)-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   474
}		
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   475
	«ENDIF-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   476
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   477
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   478
«DEFINE getOutgoingLinksByTypeMethod(gmfgen::GenLink genLink) FOR gmfgen::LinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   479
	«EXPAND incorrectLinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   480
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   481
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   482
«DEFINE incorrectLinkModelFacet FOR gmfgen::LinkModelFacet-»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   483
	«ERROR "Incorrect LinkModelFacet: " + this»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   484
«ENDDEFINE»
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   485
033392511bf7 add files for RCL_2_2
cawthron
parents:
diff changeset
   486
«DEFINE additions FOR gmfgen::GenDiagramUpdater»«ENDDEFINE»