Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: e0467a55ed1cae7ed27b72d8d3af24e086def0ed (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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
 * 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/2006/GenModel"»
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
«IMPORT "http://www.eclipse.org/emf/2002/GenModel"»
«EXTENSION xpt::GenModelUtils»
«EXTENSION xpt::diagram::parts::NotationModelRefresher»
«EXTENSION xpt::commands::CommandUtils»

«DEFINE installClause FOR gmfgen::GenContainerBase-»
«IF needsNotationModelRefresher()-»
installNotationModelRefresher();
«ENDIF-»
«ENDDEFINE»

«DEFINE uninstallClause FOR gmfgen::GenContainerBase-»
«IF needsNotationModelRefresher()-»
uninstallNotationModelRefresher();
«ENDIF-»
«ENDDEFINE»

«DEFINE all FOR gmfgen::GenContainerBase-»
«IF needsNotationModelRefresher()-»
«EXPAND install-»
«EXPAND uninstall-»
«EXPAND getNotationModelRefresher-»
«EXPAND refresh-»
«EXPAND NotationModelRefresher-»
«ENDIF-»
«ENDDEFINE»

«DEFINE install FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
private void installNotationModelRefresher() {
	org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ChildNotationModelRefresher refresher = getNotationModelRefresher();
	getTransactionalUpdateManager().addNotationModelRefresher(refresher);
}
«ENDDEFINE»

«DEFINE uninstall FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
private void uninstallNotationModelRefresher() {
	org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ChildNotationModelRefresher refresher = getNotationModelRefresher();
	getTransactionalUpdateManager().removeNotationModelRefresher(refresher);
}
«ENDDEFINE»

«DEFINE getNotationModelRefresher FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ChildNotationModelRefresher notationModelRefresher;

«EXPAND xpt::Common::generatedMemberComment»
private org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ChildNotationModelRefresher getNotationModelRefresher() {
	if (notationModelRefresher == null) {
		notationModelRefresher = new «EXPAND className»();
	}
	return notationModelRefresher;
}
«ENDDEFINE»

«DEFINE className FOR gmfgen::GenContainerBase»NotationModelRefresher«ENDDEFINE»

«DEFINE refresh FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected void refreshNotationModel() {
	org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ChildNotationModelRefresher childRefresher = getNotationModelRefresher();
	if (!childRefresher.isInstalled()) {
		return;
	}
	org.eclipse.emf.common.command.Command command = childRefresher.buildRefreshNotationModelCommand();
	if (command == null) {
		return;
	}
	org.eclipse.emf.transaction.TransactionalEditingDomain domainModelEditDomain = org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(«EXPAND xpt::diagram::parts::Common::getDiagramElementCode»);
	getViewer().getEditDomain().getCommandStack().execute(new org.eclipse.gmf.runtime.lite.commands.WrappingCommand(domainModelEditDomain, command));
}
«ENDDEFINE»

«DEFINE NotationModelRefresher FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedClassComment»
private class «EXPAND className» «EXPAND supertypes» {
	«EXPAND getConstrainedChildrenFilter-»
	«EXPAND createFilter-»
	«EXPAND getCreateNotationalElementCommand-»
	«EXPAND getSemanticChildNodes-»
	«EXPAND shouldCreateView-»
	«EXPAND getHost-»
	«EXPAND additions-»
}
«ENDDEFINE»

«DEFINE supertypes FOR gmfgen::GenContainerBase»extends org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ChildNotationModelRefresher«ENDDEFINE»

«DEFINE getConstrainedChildrenFilter FOR gmfgen::GenContainerBase-»
«IF getConstraintsInChildren().size() > 0-»
«EXPAND xpt::Common::generatedMemberComment("TODO: Children of this element are selected based on constraint declared in " + getDiagram().getVisualIDRegistryQualifiedClassName() + ". \n" + 
  "Since no assumptions may be made concerning the runtime behavior of the constraint, <b>any</b> non-touch notification may result in \n" + 
  "notational model having to be updated.\n" + 
  "<p/>User is encouraged to change implementation of this method to provide an optimization if it is safe to assume that not all notifications\n" + 
  "result in such an update.")»
private org.eclipse.emf.transaction.NotificationFilter getConstrainedChildrenFilter() {
	return org.eclipse.emf.transaction.NotificationFilter.NOT_TOUCH;
}
«ENDIF-»
«ENDDEFINE»

«DEFINE createFilter FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment("Creates a notification filter which filters notifications that may possibly affect the notational model")»
protected org.eclipse.emf.transaction.NotificationFilter createFilter() {
«LET getChildFeatures() AS genChildFeatures-»
	«FOREACH genChildFeatures AS nextFeature ITERATOR it-»
		«IF it.isFirstIteration()»org.eclipse.emf.transaction.NotificationFilter filter = «EXPAND createFeatureFilter FOR nextFeature»;«ELSE-»
		filter = filter.or(«EXPAND createFeatureFilter FOR nextFeature»);«ENDIF-»
	«ENDFOREACH-»
	«IF genChildFeatures.size() > 0»filter = filter.and(«EXPAND createNotifierFilter»);«ELSE-»
	org.eclipse.emf.transaction.NotificationFilter filter = «EXPAND createNotifierFilter»;«ENDIF-»
	«IF getConstraintsInChildren().size() > 0-»
	filter = getConstrainedChildrenFilter().or(filter);
	«ENDIF-»
«ENDLET-»
	return filter;
}
«ENDDEFINE»

«DEFINE createFeatureFilter FOR genmodel::GenFeature»org.eclipse.emf.transaction.NotificationFilter.createFeatureFilter(«EXPAND xpt::Common::metaFeatureAccessor»)«ENDDEFINE»

«DEFINE createNotifierFilter FOR gmfgen::GenContainerBase»org.eclipse.emf.transaction.NotificationFilter.createNotifierFilter(«EXPAND xpt::diagram::parts::Common::getViewCode».getElement())«ENDDEFINE»

«DEFINE getCreateNotationalElementCommand FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.gmf.runtime.lite.commands.CreateNotationalElementCommand getCreateNotationalElementCommand(org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ElementDescriptor descriptor) {
«EXPAND xpt::commands::createNotationalElementCommand::createNotationalNodeCommand("getHost()")-»
}
«ENDDEFINE»

«DEFINE getSemanticChildNodes FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected java.util.List getSemanticChildNodes() {
«EXPAND xpt::diagram::parts::semanticChildren::semanticChildren("getHost()")-»
}
«ENDDEFINE»

«DEFINE shouldCreateView FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment("Returns whether a notational element should be created for the given domain element. \n" + 
  "The generated code respects canonical style. If the canonycal style is not present, " + (getDiagram().synchronized ? "true" : "false") + " is always returned. \n" + 
  "User can change implementation of this method to handle a more sophisticated logic.")»
protected boolean shouldCreateView(org.eclipse.gmf.runtime.lite.edit.parts.update.canonical.ElementDescriptor descriptor) {
	org.eclipse.gmf.runtime.notation.CanonicalStyle style = (org.eclipse.gmf.runtime.notation.CanonicalStyle) «EXPAND xpt::diagram::parts::Common::getViewCode».getStyle(org.eclipse.gmf.runtime.notation.NotationPackage.eINSTANCE.getCanonicalStyle());
	if (style == null) {
		return «getDiagram().synchronized»;
	}
	return style.isCanonical();
}
«ENDDEFINE»

«DEFINE getHost FOR gmfgen::GenContainerBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.gmf.runtime.notation.View getHost() {
	return «EXPAND xpt::diagram::parts::Common::getViewCode»;
}
«ENDDEFINE»

«DEFINE additions FOR gmfgen::GenContainerBase»«ENDDEFINE»

Back to the top