projects
/
Mograsim.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fixed crashbug in ActiveInstructionPreviewContentProvider
[Mograsim.git]
/
plugins
/
net.mograsim.plugin.core
/
src
/
net
/
mograsim
/
plugin
/
nature
/
MachineContext.java
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
1be6b2a
..
c84e622
100644
(file)
--- 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
@@
-122,9
+122,10
@@
public class MachineContext
*/
public final void setActiveMachine(Machine machine)
{
*/
public final void setActiveMachine(Machine machine)
{
+ Optional<Machine> oldMachine = activeMachine;
activeMachine = Optional.ofNullable(machine);
updateStatus();
activeMachine = Optional.ofNullable(machine);
updateStatus();
- notifyActiveMachineListeners();
+ notifyActiveMachineListeners(
oldMachine, activeMachine
);
}
public final Optional<String> getMachineId()
}
public final Optional<String> getMachineId()
@@
-208,8
+209,9
@@
public class MachineContext
{
if ((status == DEAD || status == CLOSED) && activeMachine.isPresent())
{
{
if ((status == DEAD || status == CLOSED) && activeMachine.isPresent())
{
+ Optional<Machine> oldMachine = activeMachine;
activeMachine = Optional.empty();
activeMachine = Optional.empty();
- notifyActiveMachineListeners();
+ notifyActiveMachineListeners(
oldMachine, activeMachine
);
}
}
}
}
@@
-247,15
+249,15
@@
public class MachineContext
}
}
}
}
- private void notifyActiveMachineListeners()
+ private void notifyActiveMachineListeners(
Optional<Machine> oldMachine, Optional<Machine> newMachine
)
{
{
- machineListeners.forEach(ob -> ob.setMachine(
active
Machine));
+ machineListeners.forEach(ob -> ob.setMachine(
oldMachine, new
Machine));
}
public void addActiveMachineListener(ActiveMachineListener ob)
{
machineListeners.add(ob);
}
public void addActiveMachineListener(ActiveMachineListener ob)
{
machineListeners.add(ob);
- ob.setMachine(activeMachine);
+ ob.setMachine(
Optional.empty(),
activeMachine);
}
public void removeActiveMachineListener(ActiveMachineListener ob)
}
public void removeActiveMachineListener(ActiveMachineListener ob)
@@
-282,7
+284,7
@@
public class MachineContext
@FunctionalInterface
public static interface ActiveMachineListener
{
@FunctionalInterface
public static interface ActiveMachineListener
{
- void setMachine(Optional<Machine>
m
achine);
+ void setMachine(Optional<Machine>
oldMachine, Optional<Machine> newM
achine);
}
@FunctionalInterface
}
@FunctionalInterface