final ScopedPreferenceStore prefs;
Optional<String> machineId = Optional.empty();
Optional<MachineDefinition> machineDefinition = Optional.empty();
+ @Deprecated(forRemoval = true)
Optional<Machine> activeMachine = Optional.empty();
private MachineContextStatus status = UNKOWN;
+ @Deprecated(forRemoval = true)
private final Set<ActiveMachineListener> machineListeners = new HashSet<>();
private final Set<MachineContextStatusListener> stateListeners = new HashSet<>();
*/
public final boolean isCurrentyValid()
{
- return status == READY || status == ACTIVE;
+ return status == READY || isActive();
}
/**
/**
* Returns true if a machine is instantiated and (possibly) running
*/
+ @Deprecated(forRemoval = true)
public final boolean isActive()
{
return status == ACTIVE || status == ACTIVE_CHANGED;
/**
* Sets the active machine in the {@link MachineContext}'s project scope.
*/
+ @Deprecated(forRemoval = true)
public final void setActiveMachine(Machine machine)
{
+ Optional<Machine> oldMachine = activeMachine;
activeMachine = Optional.ofNullable(machine);
updateStatus();
- notifyActiveMachineListeners();
+ notifyActiveMachineListeners(oldMachine, activeMachine);
}
public final Optional<String> getMachineId()
return machineDefinition;
}
+ @Deprecated(forRemoval = true)
public final Optional<Machine> getActiveMachine()
{
// activateMachine(); // TODO is this the best way to deal with this?
*
* @return true if the activation was successful
*/
+ @Deprecated(forRemoval = true)
public final boolean activateMachine()
{
if (status == ACTIVE)
*
* @return the raw status of the project at the time of the call.
*/
+ @SuppressWarnings("removal")
public final MachineContextStatus reevaluateStatus()
{
if (!owner.exists())
return ACTIVE;
}
+ @Deprecated(forRemoval = true)
private void doPostStatusChangedAction()
{
if ((status == DEAD || status == CLOSED) && activeMachine.isPresent())
{
+ Optional<Machine> oldMachine = activeMachine;
activeMachine = Optional.empty();
- notifyActiveMachineListeners();
+ notifyActiveMachineListeners(oldMachine, activeMachine);
}
}
return;
machineId = newMachineDefinitionId;
machineDefinition = machineId.map(MachineRegistry::getMachine);
+ if (machineDefinition.isEmpty() && newMachineDefinitionId.isPresent())
+ {
+ // TODO open a dialog
+ System.err.println("Machine definition for ID " + newMachineDefinitionId.get() + " not found");
+ }
updateStatus();
ProjectMachineContext.notifyListeners(new ProjectContextEvent(this, ProjectContextEventType.MACHINE_DEFINITION_CHANGE));
}
}
}
- private void notifyActiveMachineListeners()
+ @Deprecated(forRemoval = true)
+ private void notifyActiveMachineListeners(Optional<Machine> oldMachine, Optional<Machine> 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);
}
@FunctionalInterface
+ @Deprecated(forRemoval = true)
public static interface ActiveMachineListener
{
- void setMachine(Optional<Machine> machine);
+ void setMachine(Optional<Machine> oldMachine, Optional<Machine> newMachine);
}
@FunctionalInterface