Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 6c22596d77628c0c1e06616741afed7ac2cda8fe (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
/*
 * 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:
 *    bblajer (Borland) - initial API and implementation
 */

«IMPORT "http://www.eclipse.org/gmf/2005/GenModel/2.0"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«IMPORT "http://www.eclipse.org/emf/2002/GenModel"»
«EXTENSION xpt::GenModelUtils»
«EXTENSION xpt::commands::CommandUtils»
«EXTENSION xpt::diagram::LinkFinder»
«EXTENSION xpt::diagram::parts::LinkNotationModelRefresher»

«DEFINE semanticChildLinks(String parentViewCode) FOR gmfgen::GenCommonBase-»
	«LET getLinkChildFeatures(containedTypeModelFacetLinks()) AS genTypeLinkFeatures-»
	«LET getLinkChildFeatures(containedFeatureModelFacetLinks()) AS genFeatureLinkFeatures-»
	«IF genTypeLinkFeatures.size() + genFeatureLinkFeatures.size() == 0-»
return java.util.Collections.EMPTY_LIST;
	«ELSE-»
java.util.List result = new java.util.LinkedList();
org.eclipse.emf.ecore.EObject modelObject = «parentViewCode».getElement();
org.eclipse.emf.ecore.EObject nextValue;
		«IF genTypeLinkFeatures.size() > 0-»
int linkVID;
		«ENDIF-»
		«FOREACH genTypeLinkFeatures AS metaFeature-»
			«LET getTypeGenLinksForFeature(metaFeature, containedLinks()) AS genLinksCollection-»
			«IF metaFeature.isListType()-»
for(java.util.Iterator it = «EXPAND xpt::commands::Common::getFeatureValue("modelObject", null, true) FOR metaFeature».iterator(); it.hasNext(); ) {
	nextValue = (org.eclipse.emf.ecore.EObject) it.next();
			«ELSE-»
	nextValue = (org.eclipse.emf.ecore.EObject) «EXPAND xpt::commands::Common::getFeatureValue("modelObject", null, false) FOR metaFeature»;
			«ENDIF-»
	linkVID = «getDiagram().getVisualIDRegistryQualifiedClassName()».INSTANCE.getLinkWithClassVisualID(nextValue);
			«LET genLinksCollection.size() > 1 AS generateSwitch-»
			«IF generateSwitch-»
	switch (linkVID) {
			«ENDIF-»
			«FOREACH genLinksCollection AS nextLink-»
				«IF generateSwitch-»
	case «nextLink.getEditPartQualifiedClassName()».VISUAL_ID: {
				«ELSE-»
	if («nextLink.getEditPartQualifiedClassName()».VISUAL_ID == linkVID) {
				«ENDIF-»
				«LET ((gmfgen::TypeLinkModelFacet) nextLink.modelFacet).sourceMetaFeature AS sourceFeature-»
				«IF sourceFeature != null-»
					«IF sourceFeature.isListType()-»
		java.util.List sources = «EXPAND xpt::commands::Common::getFeatureValue("nextValue", null, true) FOR sourceFeature»;
		org.eclipse.emf.ecore.EObject source = sources.size() == 1 ? (org.eclipse.emf.ecore.EObject) sources.get(0) : null;
					«ELSE-»
		org.eclipse.emf.ecore.EObject source = (org.eclipse.emf.ecore.EObject) «EXPAND xpt::commands::Common::getFeatureValue("nextValue", null, false) FOR sourceFeature»;
					«ENDIF-»
				«ELSE-»
		org.eclipse.emf.ecore.EObject source = modelObject;
				«ENDIF-»
				«ENDLET-»
				«LET ((gmfgen::TypeLinkModelFacet) nextLink.modelFacet).targetMetaFeature AS targetFeature-»
				«IF targetFeature != null-»
					«IF targetFeature.isListType()-»
		java.util.List targets = «EXPAND xpt::commands::Common::getFeatureValue("nextValue", null, true) FOR targetFeature»;
		org.eclipse.emf.ecore.EObject target = targets.size() == 1 ? (org.eclipse.emf.ecore.EObject) targets.get(0) : null;
					«ELSE-»
		org.eclipse.emf.ecore.EObject target = (org.eclipse.emf.ecore.EObject) «EXPAND xpt::commands::Common::getFeatureValue("nextValue", null, false) FOR targetFeature»;
					«ENDIF-»
				«ELSE-»
		org.eclipse.emf.ecore.EObject target = modelObject;
				«ENDIF-»
				«ENDLET-»
		if (source != null && target != null) {
			result.add(new org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.LinkDescriptor(source, target, nextValue, linkVID));
		}
				«IF generateSwitch-»
		break;
	}
				«ELSE-»
	}
				«ENDIF-»
			«ENDFOREACH-»
			«IF generateSwitch-»
	}
			«ENDIF-»
			«IF metaFeature.isListType()-»
}
			«ENDIF-»
			«ENDLET-»
			«ENDLET-»
		«ENDFOREACH-»
		«FOREACH genFeatureLinkFeatures AS metaFeature-»
			«LET getFeatureGenLinksForFeature(metaFeature, containedLinks()) AS genLinksCollection-»
			«IF metaFeature.isListType()-»
for(java.util.Iterator it = «EXPAND xpt::commands::Common::getFeatureValue("modelObject", null, true) FOR metaFeature».iterator(); it.hasNext(); ) {
	nextValue = (org.eclipse.emf.ecore.EObject) it.next();
			«ELSE-»
	nextValue = (org.eclipse.emf.ecore.EObject) «EXPAND xpt::commands::Common::getFeatureValue("modelObject", null, false) FOR metaFeature»;
			«ENDIF-»
	if (nextValue != null) {
			«FOREACH genLinksCollection AS nextLink-»
		result.add(new org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.LinkDescriptor(modelObject, nextValue, null, «nextLink.getEditPartQualifiedClassName()».VISUAL_ID));
			«ENDFOREACH-»
	}
			«IF metaFeature.isListType()-»
}
			«ENDIF-»
			«ENDLET-»
		«ENDFOREACH-»
return result;
	«ENDIF-»
	«ENDLET-»
	«ENDLET-»
«ENDDEFINE»

Back to the top