X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Feditors%2FSimulationViewEditor.java;h=651852edfad7d8aaed6f0c3f923a26d78172b939;hb=0eb525202d3c871a2a20f789af1728248f3cff11;hp=31dd8995623080153e7e4021685a3828a7b35ba3;hpb=82ec13e2acd627b132c868591ef20bb9cb0a2fc1;p=Mograsim.git diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/editors/SimulationViewEditor.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/editors/SimulationViewEditor.java index 31dd8995..651852ed 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/editors/SimulationViewEditor.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/editors/SimulationViewEditor.java @@ -30,6 +30,7 @@ import net.mograsim.logic.core.LogicObserver; import net.mograsim.logic.core.components.CoreClock; import net.mograsim.logic.model.LogicExecuter; import net.mograsim.logic.model.LogicUICanvas; +import net.mograsim.logic.model.serializing.IndirectModelComponentCreator; import net.mograsim.machine.Machine; import net.mograsim.machine.Memory.MemoryCellModifiedListener; import net.mograsim.machine.mi.AssignableMicroInstructionMemory; @@ -71,7 +72,7 @@ public class SimulationViewEditor extends EditorPart public SimulationViewEditor() { - activeMachineListener = m -> recreateContextDependentControls(); + activeMachineListener = (oldM, newM) -> recreateContextDependentControls(); memCellListener = a -> instPreview.refresh(); clockObserver = o -> { @@ -158,6 +159,9 @@ public class SimulationViewEditor extends EditorPart canvasParent.layout(); + // update preview + ((ActiveInstructionPreviewContentProvider) instPreview.getTableViewer().getContentProvider()).setMachine(machine); + // initialize executer exec = new LogicExecuter(machine.getTimeline()); updateSpeedFactorFromInput(simSpeedInput.getValue()); @@ -189,12 +193,21 @@ public class SimulationViewEditor extends EditorPart { Composite c = new Composite(parent, SWT.NONE); c.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - c.setLayout(new GridLayout(6, false)); + c.setLayout(new GridLayout(7, false)); resetButton = new Button(c, SWT.PUSH); resetButton.setText("Reset machine"); resetButton.addListener(SWT.Selection, e -> context.getActiveMachine().get().reset()); + // TODO do we want this button in the final product? + Button reloadMachineButton = new Button(c, SWT.PUSH); + reloadMachineButton.setText("Reload machine"); + reloadMachineButton.addListener(SWT.Selection, e -> + { + IndirectModelComponentCreator.clearComponentCache(); + context.setActiveMachine(context.getMachineDefinition().get().createNew()); + }); + sbseButton = new Button(c, SWT.CHECK); pauseButton = new Button(c, SWT.TOGGLE); @@ -288,9 +301,11 @@ public class SimulationViewEditor extends EditorPart private void addInstructionPreviewControlWidgets(Composite parent) { - instPreview = new InstructionTable(parent, new DisplaySettings()); + instPreview = new InstructionTable(parent, new DisplaySettings(), getSite().getWorkbenchWindow().getWorkbench().getThemeManager()); instPreview.getTableViewer().getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); - instPreview.setContentProvider(new ActiveInstructionPreviewContentProvider(instPreview.getTableViewer())); + ActiveInstructionPreviewContentProvider cProv; + instPreview.setContentProvider(cProv = new ActiveInstructionPreviewContentProvider(instPreview.getTableViewer())); + cProv.setMachine(machine); } private static void setPauseText(Button pauseButton, boolean hovered)