diff options
author | Matthew Davis | 2013-06-18 18:15:42 +0000 |
---|---|---|
committer | Matthew Davis | 2013-06-18 18:15:42 +0000 |
commit | 84bd66197dba818c62e5d63751e57fbd3adfb33f (patch) | |
tree | 2384e7b6269bf87d1ac08bc9c9422f819df6cc21 | |
parent | 69b90793eeb1dbc8e14d74536f5f419a4e4632a6 (diff) | |
download | org.eclipse.stem-84bd66197dba818c62e5d63751e57fbd3adfb33f.tar.gz org.eclipse.stem-84bd66197dba818c62e5d63751e57fbd3adfb33f.tar.xz org.eclipse.stem-84bd66197dba818c62e5d63751e57fbd3adfb33f.zip |
Can no longer connect a transition to a non-standard or non-deaths
compartment
2 files changed, 12 insertions, 2 deletions
diff --git a/modelgen/org.eclipse.stem.model.ui.editor/src/org/eclipse/stem/model/ui/editor/commands/TransitionCreateCommand.java b/modelgen/org.eclipse.stem.model.ui.editor/src/org/eclipse/stem/model/ui/editor/commands/TransitionCreateCommand.java index 30ff68609..192a39015 100644 --- a/modelgen/org.eclipse.stem.model.ui.editor/src/org/eclipse/stem/model/ui/editor/commands/TransitionCreateCommand.java +++ b/modelgen/org.eclipse.stem.model.ui.editor/src/org/eclipse/stem/model/ui/editor/commands/TransitionCreateCommand.java @@ -11,6 +11,7 @@ package org.eclipse.stem.model.ui.editor.commands; import org.eclipse.gef.commands.Command; +import org.eclipse.stem.model.metamodel.CompartmentType; import org.eclipse.stem.model.metamodel.MetamodelFactory; import org.eclipse.stem.model.metamodel.Transition; import org.eclipse.stem.model.ui.editor.vismodel.CompartmentElement; @@ -44,12 +45,23 @@ public class TransitionCreateCommand extends Command { if (target == null) { return false; } + if (source.equals(target)) { return false; } if (source.getModelElement() != target.getModelElement()) { return false; } + + if (source.getCompartment().getType() != CompartmentType.STANDARD) { + return false; + } + + if (target.getCompartment().getType() != CompartmentType.STANDARD && + target.getCompartment().getType() != CompartmentType.DEATHS) { + return false; + } + ModelElement model = source.getModelElement(); for (TransitionElement te : model.getTransitionElements()) { if (te.getSource() != null && te.getTarget() != null) { diff --git a/modelgen/org.eclipse.stem.model.ui.editor/src/org/eclipse/stem/model/ui/editor/commands/TransitionReconnectCommand.java b/modelgen/org.eclipse.stem.model.ui.editor/src/org/eclipse/stem/model/ui/editor/commands/TransitionReconnectCommand.java index dea1d48f8..bd3336557 100644 --- a/modelgen/org.eclipse.stem.model.ui.editor/src/org/eclipse/stem/model/ui/editor/commands/TransitionReconnectCommand.java +++ b/modelgen/org.eclipse.stem.model.ui.editor/src/org/eclipse/stem/model/ui/editor/commands/TransitionReconnectCommand.java @@ -81,8 +81,6 @@ public class TransitionReconnectCommand extends Command { } else if (newTarget != null) { transition.setSource(oldSource); transition.setTarget(newTarget); - } else { - throw new IllegalStateException("Should not happen"); } } |