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 | |
package org.argouml.uml.diagram.state.ui; |
40 | |
|
41 | |
import java.awt.Graphics; |
42 | |
import java.awt.event.MouseEvent; |
43 | |
import java.util.Vector; |
44 | |
|
45 | |
import javax.swing.Action; |
46 | |
|
47 | |
import org.argouml.model.Model; |
48 | |
import org.argouml.notation.NotationProviderFactory2; |
49 | |
import org.argouml.ui.ArgoJMenu; |
50 | |
import org.argouml.ui.targetmanager.TargetManager; |
51 | |
import org.argouml.uml.diagram.DiagramSettings; |
52 | |
import org.argouml.uml.diagram.ui.FigEdgeModelElement; |
53 | |
import org.argouml.uml.diagram.ui.PathItemPlacement; |
54 | |
import org.argouml.uml.ui.behavior.common_behavior.ActionNewActionSequence; |
55 | |
import org.argouml.uml.ui.behavior.common_behavior.ActionNewCallAction; |
56 | |
import org.argouml.uml.ui.behavior.common_behavior.ActionNewCreateAction; |
57 | |
import org.argouml.uml.ui.behavior.common_behavior.ActionNewDestroyAction; |
58 | |
import org.argouml.uml.ui.behavior.common_behavior.ActionNewReturnAction; |
59 | |
import org.argouml.uml.ui.behavior.common_behavior.ActionNewSendAction; |
60 | |
import org.argouml.uml.ui.behavior.common_behavior.ActionNewTerminateAction; |
61 | |
import org.argouml.uml.ui.behavior.common_behavior.ActionNewUninterpretedAction; |
62 | |
import org.argouml.uml.ui.behavior.state_machines.ButtonActionNewGuard; |
63 | |
import org.tigris.gef.base.Layer; |
64 | |
import org.tigris.gef.presentation.ArrowHeadGreater; |
65 | |
import org.tigris.gef.presentation.Fig; |
66 | |
import org.tigris.gef.presentation.FigNode; |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
public class FigTransition extends FigEdgeModelElement { |
73 | |
|
74 | 0 | private ArrowHeadGreater endArrow = new ArrowHeadGreater(); |
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
private boolean dashed; |
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
public FigTransition(Object owner, DiagramSettings settings) { |
90 | 0 | super(owner, settings); |
91 | |
|
92 | 0 | initializeTransition(); |
93 | 0 | } |
94 | |
|
95 | |
private void initializeTransition() { |
96 | 0 | addPathItem(getNameFig(), |
97 | |
new PathItemPlacement(this, getNameFig(), 50, 10)); |
98 | 0 | getFig().setLineColor(LINE_COLOR); |
99 | 0 | setDestArrowHead(endArrow); |
100 | 0 | allowRemoveFromDiagram(false); |
101 | |
|
102 | 0 | updateDashed(); |
103 | 0 | } |
104 | |
|
105 | |
@Override |
106 | |
public void setLayer(Layer lay) { |
107 | 0 | super.setLayer(lay); |
108 | |
|
109 | |
|
110 | 0 | if (getLayer() != null && getOwner() != null) { |
111 | 0 | initPorts(lay, getOwner()); |
112 | |
} |
113 | 0 | } |
114 | |
|
115 | |
|
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
@Deprecated |
128 | |
private void initPorts(Layer lay, Object owner) { |
129 | 0 | final Object sourceSV = Model.getFacade().getSource(owner); |
130 | 0 | final FigNode sourceFN = (FigNode) lay.presentationFor(sourceSV); |
131 | 0 | if (sourceFN != null) { |
132 | |
|
133 | |
|
134 | |
|
135 | 0 | setSourcePortFig(sourceFN); |
136 | 0 | setSourceFigNode(sourceFN); |
137 | |
} |
138 | |
|
139 | 0 | final Object destSV = Model.getFacade().getTarget(owner); |
140 | 0 | final FigNode destFN = (FigNode) lay.presentationFor(destSV); |
141 | 0 | if (destFN != null) { |
142 | |
|
143 | |
|
144 | |
|
145 | 0 | setDestPortFig(destFN); |
146 | 0 | setDestFigNode(destFN); |
147 | |
} |
148 | 0 | } |
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
@Override |
163 | |
protected int getNotationProviderType() { |
164 | 0 | return NotationProviderFactory2.TYPE_TRANSITION; |
165 | |
} |
166 | |
|
167 | |
@Override |
168 | |
public void renderingChanged() { |
169 | 0 | super.renderingChanged(); |
170 | 0 | updateDashed(); |
171 | 0 | } |
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
private void updateDashed() { |
179 | 0 | if (Model.getFacade().isATransition(getOwner())) { |
180 | 0 | dashed = |
181 | |
Model.getFacade().isAObjectFlowState( |
182 | |
Model.getFacade().getSource(getOwner())) |
183 | |
|| Model.getFacade().isAObjectFlowState( |
184 | |
Model.getFacade().getTarget(getOwner())); |
185 | 0 | getFig().setDashed(dashed); |
186 | |
} |
187 | 0 | } |
188 | |
|
189 | |
@Override |
190 | |
public Vector getPopUpActions(MouseEvent me) { |
191 | 0 | Vector popUpActions = super.getPopUpActions(me); |
192 | |
|
193 | 0 | boolean ms = TargetManager.getInstance().getTargets().size() > 1; |
194 | |
|
195 | |
|
196 | 0 | if (ms) { |
197 | 0 | return popUpActions; |
198 | |
} |
199 | |
|
200 | |
Action a; |
201 | |
|
202 | 0 | ArgoJMenu triggerMenu = |
203 | |
new ArgoJMenu("menu.popup.trigger"); |
204 | 0 | a = new ButtonActionNewCallEvent(); |
205 | 0 | a.putValue(Action.NAME, a.getValue(Action.SHORT_DESCRIPTION)); |
206 | 0 | triggerMenu.add(a); |
207 | 0 | a = new ButtonActionNewChangeEvent(); |
208 | 0 | a.putValue(Action.NAME, a.getValue(Action.SHORT_DESCRIPTION)); |
209 | 0 | triggerMenu.add(a); |
210 | 0 | a = new ButtonActionNewSignalEvent(); |
211 | 0 | a.putValue(Action.NAME, a.getValue(Action.SHORT_DESCRIPTION)); |
212 | 0 | triggerMenu.add(a); |
213 | 0 | a = new ButtonActionNewTimeEvent(); |
214 | 0 | a.putValue(Action.NAME, a.getValue(Action.SHORT_DESCRIPTION)); |
215 | 0 | triggerMenu.add(a); |
216 | 0 | popUpActions.add( |
217 | |
popUpActions.size() - getPopupAddOffset(), |
218 | |
triggerMenu); |
219 | |
|
220 | 0 | a = new ButtonActionNewGuard(); |
221 | 0 | a.putValue(Action.NAME, a.getValue(Action.SHORT_DESCRIPTION)); |
222 | 0 | popUpActions.add(popUpActions.size() - getPopupAddOffset(), a); |
223 | |
|
224 | 0 | ArgoJMenu effectMenu = |
225 | |
new ArgoJMenu("menu.popup.effect"); |
226 | 0 | a = ActionNewCallAction.getButtonInstance(); |
227 | 0 | a.putValue(Action.NAME, a.getValue(Action.SHORT_DESCRIPTION)); |
228 | 0 | effectMenu.add(a); |
229 | 0 | a = ActionNewCreateAction.getButtonInstance(); |
230 | 0 | a.putValue(Action.NAME, a.getValue(Action.SHORT_DESCRIPTION)); |
231 | 0 | effectMenu.add(a); |
232 | 0 | a = ActionNewDestroyAction.getButtonInstance(); |
233 | 0 | a.putValue(Action.NAME, a.getValue(Action.SHORT_DESCRIPTION)); |
234 | 0 | effectMenu.add(a); |
235 | 0 | a = ActionNewReturnAction.getButtonInstance(); |
236 | 0 | a.putValue(Action.NAME, a.getValue(Action.SHORT_DESCRIPTION)); |
237 | 0 | effectMenu.add(a); |
238 | 0 | a = ActionNewSendAction.getButtonInstance(); |
239 | 0 | a.putValue(Action.NAME, a.getValue(Action.SHORT_DESCRIPTION)); |
240 | 0 | effectMenu.add(a); |
241 | 0 | a = ActionNewTerminateAction.getButtonInstance(); |
242 | 0 | a.putValue(Action.NAME, a.getValue(Action.SHORT_DESCRIPTION)); |
243 | 0 | effectMenu.add(a); |
244 | 0 | a = ActionNewUninterpretedAction.getButtonInstance(); |
245 | 0 | a.putValue(Action.NAME, a.getValue(Action.SHORT_DESCRIPTION)); |
246 | 0 | effectMenu.add(a); |
247 | 0 | a = ActionNewActionSequence.getButtonInstance(); |
248 | 0 | a.putValue(Action.NAME, a.getValue(Action.SHORT_DESCRIPTION)); |
249 | 0 | effectMenu.add(a); |
250 | 0 | popUpActions.add(popUpActions.size() - getPopupAddOffset(), |
251 | |
effectMenu); |
252 | |
|
253 | 0 | return popUpActions; |
254 | |
} |
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
@Override |
260 | |
public void setFig(Fig f) { |
261 | 0 | super.setFig(f); |
262 | 0 | getFig().setDashed(dashed); |
263 | 0 | } |
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
@Override |
269 | |
protected Object getDestination() { |
270 | 0 | if (getOwner() != null) { |
271 | 0 | return Model.getStateMachinesHelper().getDestination(getOwner()); |
272 | |
} |
273 | 0 | return null; |
274 | |
} |
275 | |
|
276 | |
|
277 | |
|
278 | |
|
279 | |
@Override |
280 | |
protected Object getSource() { |
281 | 0 | if (getOwner() != null) { |
282 | 0 | return Model.getStateMachinesHelper().getSource(getOwner()); |
283 | |
} |
284 | 0 | return null; |
285 | |
} |
286 | |
|
287 | |
|
288 | |
|
289 | |
|
290 | |
@Override |
291 | |
public void paint(Graphics g) { |
292 | 0 | endArrow.setLineColor(getLineColor()); |
293 | 0 | super.paint(g); |
294 | 0 | } |
295 | |
|
296 | |
|
297 | |
|
298 | |
|
299 | |
@Override |
300 | |
public void paintClarifiers(Graphics g) { |
301 | 0 | indicateBounds(getNameFig(), g); |
302 | 0 | super.paintClarifiers(g); |
303 | 0 | } |
304 | |
|
305 | |
} |