422
|
1 |
/*
|
|
2 |
* Copyright (c) 2007 Borland Software Corporation
|
|
3 |
*
|
|
4 |
* All rights reserved. This program and the accompanying materials
|
|
5 |
* are made available under the terms of the Eclipse Public License v1.0
|
|
6 |
* which accompanies this distribution, and is available at
|
|
7 |
* http://www.eclipse.org/legal/epl-v10.html
|
|
8 |
*
|
|
9 |
* Contributors:
|
|
10 |
* Alexander Shatalin (Borland) - initial API and implementation
|
|
11 |
* Dmitry Stadnik (Borland) - creation logic was moved in commands
|
|
12 |
*/
|
|
13 |
|
|
14 |
«IMPORT "http://www.eclipse.org/gmf/2008/GenModel"»
|
|
15 |
«IMPORT "http://www.eclipse.org/emf/2002/Ecore"»
|
|
16 |
«EXTENSION xpt::diagram::editpolicies::Utils»
|
|
17 |
«EXTENSION xpt::GenModelUtils»
|
|
18 |
|
|
19 |
«REM»
|
|
20 |
* Start start of link creation.
|
|
21 |
* User click to this editpart and start dragging with link tool.
|
|
22 |
* Complete end of the command
|
|
23 |
* User points to this editpart as a link target and release mouse button.
|
|
24 |
*
|
|
25 |
* Outgoing the node is link source
|
|
26 |
* This element could be a source for this type of link.
|
|
27 |
* Incoming the node is link destination
|
|
28 |
* This element could be a target for this type of link.
|
|
29 |
*
|
|
30 |
* Parameters:
|
|
31 |
*
|
|
32 |
* diagram GenDiagram used to collect all defined links
|
|
33 |
*
|
|
34 |
* this Instance of TypeModelFacet for the element link could be creates to/from.
|
|
35 |
* This could be TypeModelFacet or TypeLinkModelFacet in case of links to links.
|
|
36 |
*
|
|
37 |
«ENDREM»
|
|
38 |
|
|
39 |
«DEFINE linkCommands(gmfgen::GenDiagram diagram) FOR gmfgen::TypeModelFacet-»
|
|
40 |
«IF getAllPotentialLinks(diagram).size() > 0-»
|
|
41 |
«EXPAND createLinkCommands(diagram)-»
|
|
42 |
«ENDIF-»
|
|
43 |
«IF getReroutableTypeLinks(diagram).size() > 0-»
|
|
44 |
«EXPAND reorientTypeLinkCommands(diagram)-»
|
|
45 |
«ENDIF-»
|
|
46 |
«IF getReroutableRefLinks(diagram).size() > 0-»
|
|
47 |
«EXPAND reorientRefLinkCommands(diagram)-»
|
|
48 |
«ENDIF-»
|
|
49 |
«ENDDEFINE»
|
|
50 |
|
|
51 |
«DEFINE createLinkCommands(gmfgen::GenDiagram diagram) FOR gmfgen::TypeModelFacet-»
|
|
52 |
|
|
53 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
54 |
protected org.eclipse.gef.commands.Command getCreateRelationshipCommand(
|
|
55 |
org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
|
|
56 |
org.eclipse.gef.commands.Command command = req.getTarget() == null ?
|
|
57 |
getStartCreateRelationshipCommand(req) : getCompleteCreateRelationshipCommand(req);
|
|
58 |
return command != null ? command : super.getCreateRelationshipCommand(req);
|
|
59 |
}
|
|
60 |
|
|
61 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
62 |
protected org.eclipse.gef.commands.Command getStartCreateRelationshipCommand(
|
|
63 |
org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
|
|
64 |
«EXPAND startLinkCommands(this) FOREACH getAllPotentialLinks(diagram)-»
|
|
65 |
return null;
|
|
66 |
}
|
|
67 |
|
|
68 |
«EXPAND xpt::Common::generatedMemberComment»
|
|
69 |
protected org.eclipse.gef.commands.Command getCompleteCreateRelationshipCommand(
|
|
70 |
org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest req) {
|
|
71 |
«EXPAND completeLinkCommands(this) FOREACH getAllPotentialLinks(diagram)-»
|
|
72 |
return null;
|
|
73 |
}
|
|
74 |
«ENDDEFINE»
|
|
75 |
|
|
76 |
«DEFINE startLinkCommands(gmfgen::TypeModelFacet typeModelFacet) FOR gmfgen::GenLink-»
|
|
77 |
if («getDiagram().getElementTypesQualifiedClassName()».«getUniqueIdentifier()» == req.getElementType()) {
|
|
78 |
«IF createStartLinkCommand(typeModelFacet)-»
|
|
79 |
return getGEFWrapper(new «getCreateCommandQualifiedClassName()»(req,
|
|
80 |
«IF createStartIncomingLinkCommand(typeModelFacet)-»
|
|
81 |
req.getTarget(), req.getSource()
|
|
82 |
«ELSE-»
|
|
83 |
req.getSource(), req.getTarget()
|
|
84 |
«ENDIF-»
|
|
85 |
));
|
|
86 |
«ELSE-»
|
|
87 |
return null;
|
|
88 |
«ENDIF-»
|
|
89 |
}
|
|
90 |
«ENDDEFINE»
|
|
91 |
|
|
92 |
«DEFINE completeLinkCommands(gmfgen::TypeModelFacet typeModelFacet) FOR gmfgen::GenLink-»
|
|
93 |
if («getDiagram().getElementTypesQualifiedClassName()».«getUniqueIdentifier()» == req.getElementType()) {
|
|
94 |
«IF createCompleteLinkCommand(typeModelFacet)-»
|
|
95 |
return getGEFWrapper(new «getCreateCommandQualifiedClassName()»(req,
|
|
96 |
«IF createCompleteOutgoingLinkCommand(typeModelFacet)-»
|
|
97 |
req.getTarget(), req.getSource()
|
|
98 |
«ELSE-»
|
|
99 |
req.getSource(), req.getTarget()
|
|
100 |
«ENDIF-»
|
|
101 |
));
|
|
102 |
«ELSE-»
|
|
103 |
return null;
|
|
104 |
«ENDIF-»
|
|
105 |
}
|
|
106 |
«ENDDEFINE»
|
|
107 |
|
|
108 |
«DEFINE reorientTypeLinkCommands(gmfgen::GenDiagram diagram) FOR gmfgen::TypeModelFacet-»
|
|
109 |
|
|
110 |
«EXPAND xpt::Common::generatedMemberComment(
|
|
111 |
"Returns command to reorient EClass based link. New link target or source\n" +
|
|
112 |
"should be the domain model element associated with this node.\n"
|
|
113 |
)»
|
|
114 |
protected org.eclipse.gef.commands.Command getReorientRelationshipCommand(
|
|
115 |
org.eclipse.gmf.runtime.emf.type.core.requests.ReorientRelationshipRequest req) {
|
|
116 |
switch (getVisualID(req)) {
|
|
117 |
«EXPAND reorientLinkCommand FOREACH getReroutableTypeLinks(diagram)-»
|
|
118 |
}
|
|
119 |
return super.getReorientRelationshipCommand(req);
|
|
120 |
}
|
|
121 |
«ENDDEFINE»
|
|
122 |
|
|
123 |
«DEFINE reorientRefLinkCommands(gmfgen::GenDiagram diagram) FOR gmfgen::TypeModelFacet-»
|
|
124 |
|
|
125 |
«EXPAND xpt::Common::generatedMemberComment(
|
|
126 |
"Returns command to reorient EReference based link. New link target or source\n" +
|
|
127 |
"should be the domain model element associated with this node.\n"
|
|
128 |
)»
|
|
129 |
protected org.eclipse.gef.commands.Command getReorientReferenceRelationshipCommand(
|
|
130 |
org.eclipse.gmf.runtime.emf.type.core.requests.ReorientReferenceRelationshipRequest req) {
|
|
131 |
switch (getVisualID(req)) {
|
|
132 |
«EXPAND reorientLinkCommand FOREACH getReroutableRefLinks(diagram)-»
|
|
133 |
}
|
|
134 |
return super.getReorientReferenceRelationshipCommand(req);
|
|
135 |
}
|
|
136 |
«ENDDEFINE»
|
|
137 |
|
|
138 |
«DEFINE reorientLinkCommand FOR gmfgen::GenLink-»
|
|
139 |
«EXPAND xpt::Common::caseVisualID»
|
|
140 |
return getGEFWrapper(new «getReorientCommandQualifiedClassName()»(req));
|
|
141 |
«ENDDEFINE»
|