|
25 | 25 | import org.eclipse.emf.common.util.EList;
|
26 | 26 | import org.eclipse.emf.ecore.util.EcoreUtil;
|
27 | 27 | import org.eclipse.uml2.uml.Activity;
|
| 28 | +import org.eclipse.uml2.uml.ConnectionPointReference; |
28 | 29 | import org.eclipse.uml2.uml.Constraint;
|
29 | 30 | import org.eclipse.uml2.uml.Event;
|
30 | 31 | import org.eclipse.uml2.uml.Model;
|
@@ -175,6 +176,24 @@ private void handleRegion(Region region) {
|
175 | 176 | }
|
176 | 177 | stateDatas.add(stateData);
|
177 | 178 |
|
| 179 | + // add states via entry/exit reference points |
| 180 | + for (ConnectionPointReference cpr : state.getConnections()) { |
| 181 | + if (cpr.getEntries() != null) { |
| 182 | + for (Pseudostate cp : cpr.getEntries()) { |
| 183 | + StateData<String, String> cpStateData = new StateData<>(parent, regionId, cp.getName(), false); |
| 184 | + cpStateData.setPseudoStateKind(PseudoStateKind.ENTRY); |
| 185 | + stateDatas.add(cpStateData); |
| 186 | + } |
| 187 | + } |
| 188 | + if (cpr.getExits() != null) { |
| 189 | + for (Pseudostate cp : cpr.getExits()) { |
| 190 | + StateData<String, String> cpStateData = new StateData<>(parent, regionId, cp.getName(), false); |
| 191 | + cpStateData.setPseudoStateKind(PseudoStateKind.EXIT); |
| 192 | + stateDatas.add(cpStateData); |
| 193 | + } |
| 194 | + } |
| 195 | + } |
| 196 | + |
178 | 197 | // add states via entry/exit points
|
179 | 198 | for (Pseudostate cp : state.getConnectionPoints()) {
|
180 | 199 | PseudoStateKind kind = null;
|
@@ -242,6 +261,21 @@ private void handleRegion(Region region) {
|
242 | 261 | // little unclear for now if link from points to a state should
|
243 | 262 | // have trigger?
|
244 | 263 | // anyway, we need to add entrys and exits to a model
|
| 264 | + |
| 265 | + if (transition.getSource() instanceof ConnectionPointReference) { |
| 266 | + // support ref points if only one is defined as for some |
| 267 | + // reason uml can define multiple ones which is not |
| 268 | + // realistic with state machines |
| 269 | + EList<Pseudostate> cprentries = ((ConnectionPointReference)transition.getSource()).getEntries(); |
| 270 | + if (cprentries != null && cprentries.size() == 1 && cprentries.get(0).getKind() == PseudostateKind.ENTRY_POINT_LITERAL) { |
| 271 | + entrys.add(new EntryData<String, String>(cprentries.get(0).getName(), transition.getTarget().getName())); |
| 272 | + } |
| 273 | + EList<Pseudostate> cprexits = ((ConnectionPointReference)transition.getSource()).getExits(); |
| 274 | + if (cprexits != null && cprexits.size() == 1 && cprexits.get(0).getKind() == PseudostateKind.EXIT_POINT_LITERAL) { |
| 275 | + exits.add(new ExitData<String, String>(cprexits.get(0).getName(), transition.getTarget().getName())); |
| 276 | + } |
| 277 | + } |
| 278 | + |
245 | 279 | if (transition.getSource() instanceof Pseudostate) {
|
246 | 280 | if (((Pseudostate)transition.getSource()).getKind() == PseudostateKind.ENTRY_POINT_LITERAL) {
|
247 | 281 | entrys.add(new EntryData<String, String>(transition.getSource().getName(), transition.getTarget().getName()));
|
@@ -305,9 +339,19 @@ private void handleRegion(Region region) {
|
305 | 339 | if (event instanceof SignalEvent) {
|
306 | 340 | Signal signal = ((SignalEvent)event).getSignal();
|
307 | 341 | if (signal != null) {
|
308 |
| - transitionDatas.add(new TransitionData<String, String>(transition.getSource().getName(), |
309 |
| - transition.getTarget().getName(), signal.getName(), UmlUtils.resolveTransitionActions(transition, resolver), |
310 |
| - guard, UmlUtils.mapUmlTransitionType(transition))); |
| 342 | + // special case for ref point |
| 343 | + if (transition.getTarget() instanceof ConnectionPointReference) { |
| 344 | + EList<Pseudostate> cprentries = ((ConnectionPointReference)transition.getTarget()).getEntries(); |
| 345 | + if (cprentries != null && cprentries.size() == 1) { |
| 346 | + transitionDatas.add(new TransitionData<String, String>(transition.getSource().getName(), |
| 347 | + cprentries.get(0).getName(), signal.getName(), UmlUtils.resolveTransitionActions(transition, resolver), |
| 348 | + guard, UmlUtils.mapUmlTransitionType(transition))); |
| 349 | + } |
| 350 | + } else { |
| 351 | + transitionDatas.add(new TransitionData<String, String>(transition.getSource().getName(), |
| 352 | + transition.getTarget().getName(), signal.getName(), UmlUtils.resolveTransitionActions(transition, resolver), |
| 353 | + guard, UmlUtils.mapUmlTransitionType(transition))); |
| 354 | + } |
311 | 355 | }
|
312 | 356 | } else if (event instanceof TimeEvent) {
|
313 | 357 | TimeEvent timeEvent = (TimeEvent)event;
|
|
0 commit comments