Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 34d248b58dc7b368b9da5877cd7766bd75afe218 (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
/*
 * 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::policies::ClassNames»
«EXTENSION xpt::diagram::policies::ComponentEditPolicy»
«EXTENSION xpt::diagram::LinkFinder»

«DEFINE ComponentEditPolicy FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::copyright FOR getDiagram().editorGen»
package «getDiagram().editPoliciesPackageName»;

«EXPAND xpt::Common::generatedClassComment»
public class «getComponentEditPolicyClassName()» «EXPAND supertypes» {
	«EXPAND createDeleteCommand-»
«IF needsGetGraphicalEditPart()-»
	«EXPAND getGraphicalEditPart-»
«ENDIF-»
	«EXPAND domainModelRemoveCommand-»
	«EXPAND getDiagramElement-»
	«EXPAND additions-»
}
«ENDDEFINE»

«DEFINE domainModelRemoveCommand FOR GenCommonBase»«ERROR "Unexpected type!"»«ENDDEFINE»

«DEFINE domainModelRemoveCommand FOR GenNode-»
«EXPAND xpt::commands::domainModelRemoveCommand::domainModelRemoveCommand("getDiagramNode()")-»
«ENDDEFINE»

«DEFINE domainModelRemoveCommand FOR GenLink-»
«EXPAND xpt::commands::domainModelRemoveCommand::domainModelRemoveCommand("getDiagramEdge()")-»
«ENDDEFINE»

«DEFINE getDiagramElement FOR GenCommonBase»«ERROR "Unexpected type!"»«ENDDEFINE»

«DEFINE getDiagramElement FOR GenNode-»
«EXPAND getDiagramNode-»
«ENDDEFINE»

«DEFINE getDiagramElement FOR GenLink-»
«EXPAND getDiagramEdge-»
«ENDDEFINE»

«DEFINE supertypes FOR gmfgen::GenCommonBase»extends org.eclipse.gef.editpolicies.ComponentEditPolicy«ENDDEFINE»

«DEFINE createDeleteCommand FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.gef.commands.Command createDeleteCommand(org.eclipse.gef.requests.GroupRequest deleteRequest) {
«LET incomingTypeLinks() AS incomingTypeLinks-»
«LET outgoingLinks() AS outgoingLinks-»
«IF incomingTypeLinks.size() > 0 || outgoingLinks.size() > 0-»
	org.eclipse.gef.commands.CompoundCommand result = new org.eclipse.gef.commands.CompoundCommand();
«ENDIF-»
«IF incomingTypeLinks.size() > 0-»
	for(java.util.Iterator it = getGraphicalEditPart().getTargetConnections().iterator(); it.hasNext(); ) {
		org.eclipse.gef.EditPart nextEditPart = (org.eclipse.gef.EditPart) it.next();
		org.eclipse.gmf.runtime.notation.Edge nextEdge = (org.eclipse.gmf.runtime.notation.Edge) nextEditPart.getModel();
		int visualID = «getDiagram().getVisualIDRegistryQualifiedClassName()».getVisualID(nextEdge);
		switch (visualID) {
«FOREACH incomingTypeLinks AS nextLink-»
		case «nextLink.getEditPartQualifiedClassName()».VISUAL_ID:
«ENDFOREACH-»
			«EXPAND deleteDependentLinks-»
		}
	}
«ENDIF-»
«IF outgoingLinks.size() > 0-»
	for(java.util.Iterator it = getGraphicalEditPart().getSourceConnections().iterator(); it.hasNext(); ) {
		org.eclipse.gef.EditPart nextEditPart = (org.eclipse.gef.EditPart) it.next();
		org.eclipse.gmf.runtime.notation.Edge nextEdge = (org.eclipse.gmf.runtime.notation.Edge) nextEditPart.getModel();
		int visualID = «getDiagram().getVisualIDRegistryQualifiedClassName()».getVisualID(nextEdge);
		switch (visualID) {
«FOREACH outgoingLinks AS nextLink-»
		case «nextLink.getEditPartQualifiedClassName()».VISUAL_ID:
«ENDFOREACH-»
			«EXPAND deleteDependentLinks-»
		}
	}
«ENDIF-»
	«EXPAND createDeleteCommandPrim-»
«IF incomingTypeLinks.size() > 0 || outgoingLinks.size() > 0-»
	result.add(new org.eclipse.gmf.runtime.lite.commands.WrappingCommand(editingDomain, cc));
	return result.unwrap();
«ELSE-»
	return new org.eclipse.gmf.runtime.lite.commands.WrappingCommand(editingDomain, cc);
«ENDIF-»
«ENDLET-»
«ENDLET-»
}
«ENDDEFINE»

«DEFINE deleteDependentLinks FOR gmfgen::GenCommonBase-»
{
	org.eclipse.gef.requests.GroupRequest deleteLinkRequest = new org.eclipse.gef.requests.GroupRequest(org.eclipse.gef.RequestConstants.REQ_DELETE);
	deleteLinkRequest.setEditParts(nextEditPart);
	result.add(nextEditPart.getCommand(deleteLinkRequest));
	break;
}
«ENDDEFINE»

«DEFINE getGraphicalEditPart FOR gmfgen::GenCommonBase-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.gef.GraphicalEditPart getGraphicalEditPart() {
	return (org.eclipse.gef.GraphicalEditPart) getHost();
}
«ENDDEFINE»

«DEFINE createDeleteCommandPrim FOR gmfgen::GenCommonBase»«ERROR "UnexpectedType"»«ENDDEFINE»

«DEFINE createDeleteCommandPrim FOR gmfgen::GenNode-»
org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(getDiagramNode().getDiagram().getElement());
org.eclipse.emf.common.command.CompoundCommand cc = new org.eclipse.emf.common.command.CompoundCommand();
cc.append(createDomainModelRemoveCommand(editingDomain));
cc.append(new org.eclipse.gmf.runtime.lite.commands.RemoveNotationalElementCommand((org.eclipse.gmf.runtime.notation.View) getDiagramNode().eContainer(), getDiagramNode()));
«ENDDEFINE»

«DEFINE createDeleteCommandPrim FOR gmfgen::GenLink-»
org.eclipse.emf.transaction.TransactionalEditingDomain editingDomain = org.eclipse.emf.transaction.util.TransactionUtil.getEditingDomain(getDiagramEdge().getDiagram().getElement());
org.eclipse.emf.common.command.CompoundCommand cc = new org.eclipse.emf.common.command.CompoundCommand();
cc.append(createDomainModelRemoveCommand(editingDomain));
cc.append(new org.eclipse.gmf.runtime.lite.commands.RemoveNotationalEdgeCommand(getDiagramEdge().getDiagram(), getDiagramEdge()));
«ENDDEFINE»

«DEFINE getDiagramNode FOR gmfgen::GenNode-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.gmf.runtime.notation.Node getDiagramNode() {
	return (org.eclipse.gmf.runtime.notation.Node) getHost().getModel();
}
«ENDDEFINE»

«DEFINE getDiagramEdge FOR gmfgen::GenLink-»
«EXPAND xpt::Common::generatedMemberComment»
protected org.eclipse.gmf.runtime.notation.Edge getDiagramEdge() {
	return (org.eclipse.gmf.runtime.notation.Edge) getHost().getModel();
}
«ENDDEFINE»

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

Back to the top