Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraradermache2013-03-28 23:48:34 +0000
committeraradermache2013-03-28 23:48:34 +0000
commit31a44ddfd66a90cb9fcbefe6a1ce882df31b4a48 (patch)
tree1c76616744d7772bef3d1fa9945db1539c3a36a9
parentbe770ccce7438248a5a3763d4d5931ebb1d4ee08 (diff)
downloadorg.eclipse.papyrus-31a44ddfd66a90cb9fcbefe6a1ce882df31b4a48.tar.gz
org.eclipse.papyrus-31a44ddfd66a90cb9fcbefe6a1ce882df31b4a48.tar.xz
org.eclipse.papyrus-31a44ddfd66a90cb9fcbefe6a1ce882df31b4a48.zip
Bug 397477 - [State Machine] EntryPoint node does not allow to draw outgoing transition
-rw-r--r--plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/commands/TransitionCreateCommand.java34
1 files changed, 32 insertions, 2 deletions
diff --git a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/commands/TransitionCreateCommand.java b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/commands/TransitionCreateCommand.java
index aa7fdfa1fa5..41e8e933778 100644
--- a/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/commands/TransitionCreateCommand.java
+++ b/plugins/uml/diagram/org.eclipse.papyrus.uml.diagram.statemachine/src/org/eclipse/papyrus/uml/diagram/statemachine/edit/commands/TransitionCreateCommand.java
@@ -13,7 +13,11 @@ import org.eclipse.gmf.runtime.emf.type.core.requests.CreateElementRequest;
import org.eclipse.gmf.runtime.emf.type.core.requests.CreateRelationshipRequest;
import org.eclipse.papyrus.uml.diagram.statemachine.edit.policies.UMLBaseItemSemanticEditPolicy;
import org.eclipse.papyrus.uml.diagram.statemachine.providers.ElementInitializers;
+import org.eclipse.uml2.uml.Pseudostate;
+import org.eclipse.uml2.uml.PseudostateKind;
import org.eclipse.uml2.uml.Region;
+import org.eclipse.uml2.uml.State;
+import org.eclipse.uml2.uml.StateMachine;
import org.eclipse.uml2.uml.Transition;
import org.eclipse.uml2.uml.UMLFactory;
import org.eclipse.uml2.uml.Vertex;
@@ -27,13 +31,39 @@ public class TransitionCreateCommand extends EditElementCommand {
* Default approach is to traverse ancestors of the source to find instance
* of container. Modify with appropriate logic.
*
- * @generated
+ * @generated NOT
*/
protected Region deduceContainer(EObject source, EObject target) {
// Find container element for the new link.
// Climb up by containment hierarchy starting from the source
// and return the first element that is instance of the container class.
- for(EObject element = source; element != null; element = element.eContainer()) {
+ EObject searchFrom = source;
+ if (source instanceof Pseudostate) {
+ // Entry pseudo state must be handled differently: a transition starting from here
+ // targets an inner region of the state machine or state, but this region depends
+ // on target (in case of multi-regions)
+ if (((Pseudostate) source).getKind() == PseudostateKind.ENTRY_POINT_LITERAL) {
+ if (target != null) {
+ searchFrom = target;
+ }
+ else {
+ // target not available yet, use first region
+ // of state or statemachine (will be refined later)
+ StateMachine sm = ((Pseudostate) source).getStateMachine();
+ if (sm != null) {
+ if (!sm.getRegions().isEmpty()) {
+ return sm.getRegions().get(0);
+ }
+ }
+ State state = ((Pseudostate) source).getState();
+ if (state != null) {
+ if (!state.getRegions().isEmpty()) {
+ return state.getRegions().get(0);
+ }
+ } }
+ }
+ }
+ for(EObject element = searchFrom; element != null; element = element.eContainer()) {
if(element instanceof Region) {
return (Region)element;
}

Back to the top