X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Fnature%2FMachineContext.java;h=147b2441ccfcbd929e1e8959b1e490b5e7b2e3b8;hb=cc800d982ab9fe3e7d026655847a2160e34a5f8e;hp=3e5c9dea024c98e503043c920e8f0b3a6240fb48;hpb=fdca28097a0721d6145b244b18cd62545ef5daa6;p=Mograsim.git diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/nature/MachineContext.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/nature/MachineContext.java index 3e5c9dea..147b2441 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/nature/MachineContext.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/nature/MachineContext.java @@ -40,10 +40,12 @@ public class MachineContext final ScopedPreferenceStore prefs; Optional machineId = Optional.empty(); Optional machineDefinition = Optional.empty(); + @Deprecated(forRemoval = true) Optional activeMachine = Optional.empty(); private MachineContextStatus status = UNKOWN; + @Deprecated(forRemoval = true) private final Set machineListeners = new HashSet<>(); private final Set stateListeners = new HashSet<>(); @@ -70,7 +72,7 @@ public class MachineContext */ public final boolean isCurrentyValid() { - return status == READY || status == ACTIVE; + return status == READY || isActive(); } /** @@ -86,6 +88,7 @@ public class MachineContext /** * Returns true if a machine is instantiated and (possibly) running */ + @Deprecated(forRemoval = true) public final boolean isActive() { return status == ACTIVE || status == ACTIVE_CHANGED; @@ -120,11 +123,13 @@ public class MachineContext /** * Sets the active machine in the {@link MachineContext}'s project scope. */ + @Deprecated(forRemoval = true) public final void setActiveMachine(Machine machine) { + Optional oldMachine = activeMachine; activeMachine = Optional.ofNullable(machine); updateStatus(); - notifyActiveMachineListeners(); + notifyActiveMachineListeners(oldMachine, activeMachine); } public final Optional getMachineId() @@ -137,6 +142,7 @@ public class MachineContext return machineDefinition; } + @Deprecated(forRemoval = true) public final Optional getActiveMachine() { // activateMachine(); // TODO is this the best way to deal with this? @@ -149,6 +155,7 @@ public class MachineContext * * @return true if the activation was successful */ + @Deprecated(forRemoval = true) public final boolean activateMachine() { if (status == ACTIVE) @@ -187,6 +194,7 @@ public class MachineContext * * @return the raw status of the project at the time of the call. */ + @SuppressWarnings("removal") public final MachineContextStatus reevaluateStatus() { if (!owner.exists()) @@ -204,12 +212,14 @@ public class MachineContext return ACTIVE; } + @Deprecated(forRemoval = true) private void doPostStatusChangedAction() { if ((status == DEAD || status == CLOSED) && activeMachine.isPresent()) { + Optional oldMachine = activeMachine; activeMachine = Optional.empty(); - notifyActiveMachineListeners(); + notifyActiveMachineListeners(oldMachine, activeMachine); } } @@ -247,17 +257,20 @@ public class MachineContext } } - private void notifyActiveMachineListeners() + @Deprecated(forRemoval = true) + private void notifyActiveMachineListeners(Optional oldMachine, Optional newMachine) { - machineListeners.forEach(ob -> ob.setMachine(activeMachine)); + machineListeners.forEach(ob -> ob.setMachine(oldMachine, newMachine)); } + @Deprecated(forRemoval = true) public void addActiveMachineListener(ActiveMachineListener ob) { machineListeners.add(ob); - ob.setMachine(activeMachine); + ob.setMachine(Optional.empty(), activeMachine); } + @Deprecated(forRemoval = true) public void removeActiveMachineListener(ActiveMachineListener ob) { machineListeners.remove(ob); @@ -280,9 +293,10 @@ public class MachineContext } @FunctionalInterface + @Deprecated(forRemoval = true) public static interface ActiveMachineListener { - void setMachine(Optional machine); + void setMachine(Optional oldMachine, Optional newMachine); } @FunctionalInterface