improvement: manually-defined actions are now preserverd when plan is analyzed for new routes
This commit is contained in:
@@ -80,6 +80,10 @@ public abstract class Action extends BaseClass {
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean equals(Action other) {
|
||||
return this.toString().equals(other.toString());
|
||||
}
|
||||
|
||||
public abstract boolean fire(Context context) throws IOException;
|
||||
|
||||
|
||||
@@ -74,6 +74,29 @@ public class ActionList extends Vector<Action> implements Constants{
|
||||
return win;
|
||||
}
|
||||
|
||||
public void addActionsFrom(ActionList other) {
|
||||
for (Action otherAction : other) {
|
||||
LOG.debug("old action: {}",otherAction);
|
||||
boolean exists = false;
|
||||
int len = this.size();
|
||||
for (int i=0; i<len; i++) {
|
||||
Action thisAction = this.get(i);
|
||||
LOG.debug("→ {} ?",thisAction);
|
||||
if (thisAction.equals(otherAction)) {
|
||||
LOG.debug("Action already existing!");
|
||||
exists = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (exists) {
|
||||
LOG.debug("action not added.");
|
||||
} else {
|
||||
this.add(otherAction);
|
||||
LOG.debug("action added.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addTo(Tag link, String context) {
|
||||
Map<String, Object> props = new HashMap<String, Object>(Map.of(
|
||||
REALM,REALM_ACTIONS,
|
||||
@@ -121,7 +144,7 @@ public class ActionList extends Vector<Action> implements Constants{
|
||||
}
|
||||
|
||||
public boolean fire(Context context) {
|
||||
LOG.debug("Firing {}",this);
|
||||
LOG.debug(t("Firing {}"),this);
|
||||
boolean success = true;
|
||||
for (Action action : this) {
|
||||
try {
|
||||
|
||||
@@ -102,7 +102,7 @@ public class ConditionalAction extends Action {
|
||||
if (i>0) sb.append(t(" or "));
|
||||
sb.append(conditions.get(i).toString());
|
||||
}
|
||||
return t("if ({}):",sb);
|
||||
return t("if ({}): {}",sb,actions);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,7 +41,7 @@ public class DelayedAction extends Action {
|
||||
new Input(ACTION,ACTION_UPDATE).hideIn(form);
|
||||
new Input(CONTEXT,params.get(CONTEXT)).hideIn(form);
|
||||
|
||||
new Input(DELAY,delay).numeric().addTo(new Label(t("Delay")+NBSP)).content(" ms").addTo(form);
|
||||
new Input(DELAY,delay).numeric().addTo(new Label(t("Delay")+NBSP)).content(NBSP+"ms").addTo(form);
|
||||
return new Button(t("Apply"),form).addTo(form).addTo(fieldset);
|
||||
}
|
||||
|
||||
@@ -59,8 +59,6 @@ public class DelayedAction extends Action {
|
||||
}.start();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject json() {
|
||||
@@ -87,7 +85,7 @@ public class DelayedAction extends Action {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return t("Wait {} ms, then:",delay);
|
||||
return t("Wait {} ms, then: {}",delay,actions);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -78,7 +78,7 @@ public class SetRelay extends Action {
|
||||
|
||||
public String toString() {
|
||||
if (isNull(relay)) return "["+t("click here to setup relay")+"]";
|
||||
return t("Set "+relay+" to "+(state?relay.stateLabelA:relay.stateLabelB));
|
||||
return t("Set {} to {}",relay,state?relay.stateLabelA:relay.stateLabelB);
|
||||
};
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user