When a new fsm transition is created, the last condition is preset.

This commit is contained in:
hneemann 2019-07-24 13:06:53 +02:00
parent 00bb9af059
commit a772ae3eba

View File

@ -50,6 +50,7 @@ public class FSMComponent extends JComponent {
private Vector lastMousePos;
private State newTransitionFromState;
private Vector newTransitionStartPos;
private String lastCondition = "";
/**
* Creates a new component
@ -102,7 +103,7 @@ public class FSMComponent extends JComponent {
if (newTransitionStartPos.sub(posVector).len() > MIN_NEW_TRANS_DIST) {
Movable target = fsm.getMovable(posVector);
if (target instanceof State)
fsm.add(new Transition(newTransitionFromState, (State) target, ""));
fsm.add(new Transition(newTransitionFromState, (State) target, lastCondition));
}
newTransitionFromState = null;
repaint();
@ -235,7 +236,8 @@ public class FSMComponent extends JComponent {
point, attr, KEY_CONDITION, KEY_VALUES);
ElementAttributes newAttr = ad.showDialog();
if (newAttr != null) {
transition.setCondition(newAttr.get(KEY_CONDITION));
lastCondition = newAttr.get(KEY_CONDITION);
transition.setCondition(lastCondition);
transition.setValues(newAttr.get(KEY_VALUES));
repaint();
}