Added listener and event structure to ProjectMachineContexts
[Mograsim.git] / plugins / net.mograsim.plugin.core / src / net / mograsim / plugin / nature / MachineContext.java
index b170848..2e02e31 100644 (file)
@@ -13,6 +13,7 @@ import org.eclipse.ui.preferences.ScopedPreferenceStore;
 import net.mograsim.machine.Machine;
 import net.mograsim.machine.MachineDefinition;
 import net.mograsim.machine.MachineRegistry;
+import net.mograsim.plugin.nature.ProjectContextEvent.ProjectContextEventType;
 
 public class MachineContext
 {
@@ -112,6 +113,8 @@ public class MachineContext
        final void updateDefinition()
        {
                machineDefinition = machineId.map(MachineRegistry::getMachine);
+               machineDefinition.ifPresent(md -> setActiveMachine(md.createNew()));
+               ProjectMachineContext.notifyListeners(new ProjectContextEvent(this, ProjectContextEventType.MACHINE_DEFINITION_CHANGE));
        }
 
        private void preferenceListener(PropertyChangeEvent changeEvent)