import net.mograsim.machine.mi.MicroInstructionMemory.ActiveMicroInstructionChangedListener;
import net.mograsim.machine.mi.MicroInstructionMemoryParseException;
import net.mograsim.machine.mi.MicroInstructionMemoryParser;
-import net.mograsim.plugin.MachineContext;
+import net.mograsim.plugin.nature.MachineContext;
+import net.mograsim.plugin.nature.ProjectMachineContext;
import net.mograsim.plugin.tables.DisplaySettings;
import net.mograsim.plugin.tables.LazyTableViewer;
import net.mograsim.plugin.tables.RadixSelector;
private boolean dirty = false;
private MicroInstructionMemory memory;
private InstructionTable table;
+ private MachineContext context;
@SuppressWarnings("unused")
@Override
Button activationButton = new Button(parent, SWT.PUSH);
activationButton.setText("Set Active");
activationButton.addListener(SWT.Selection,
- e -> MachineContext.getInstance().getMachine().getMicroInstructionMemory().bind(memory));
+ e -> context.getActiveMachine().ifPresent(m -> m.getMicroInstructionMemory().bind(memory)));
}
public void bindMicroInstructionMemory(MicroInstructionMemory memory)
{
try
{
- bindMicroInstructionMemory(MicroInstructionMemoryParser.parseMemory(
- MachineContext.getInstance().getMachine().getDefinition().getMicroInstructionMemoryDefinition(), file.getContents()));
+ bindMicroInstructionMemory(MicroInstructionMemoryParser.parseMemory(context.getMachineDefinition()
+ .orElseThrow(() -> new MicroInstructionMemoryParseException("No MachineDefinition assigned!"))
+ .getMicroInstructionMemoryDefinition(), file.getContents()));
}
catch (IOException | MicroInstructionMemoryParseException | CoreException e)
{
+
+ // TODO: Proper handling via IProgressMonitor
e.printStackTrace();
}
}
{
setSite(site);
setInput(input);
+
if (input instanceof IFileEditorInput)
{
IFileEditorInput fileInput = (IFileEditorInput) input;
+ context = ProjectMachineContext.getMachineContextOf(fileInput.getFile());
setPartName(fileInput.getName());
open(fileInput.getFile());
}