From 5d7d8cbfe74873cffa0682d66e8812b58c2b47f9 Mon Sep 17 00:00:00 2001 From: Daniel Kirschten Date: Tue, 17 Sep 2019 23:13:20 +0200 Subject: [PATCH] Fixed the "Set active" button in InstructionView --- .../mi/AssignableMicroInstructionMemory.java | 1 + .../memory/MemoryTableContentProvider.java | 3 ++- .../plugin/tables/mi/InstructionView.java | 21 ++----------------- 3 files changed, 5 insertions(+), 20 deletions(-) diff --git a/plugins/net.mograsim.machine/src/net/mograsim/machine/mi/AssignableMicroInstructionMemory.java b/plugins/net.mograsim.machine/src/net/mograsim/machine/mi/AssignableMicroInstructionMemory.java index 5fe753eb..b0ab5a4e 100644 --- a/plugins/net.mograsim.machine/src/net/mograsim/machine/mi/AssignableMicroInstructionMemory.java +++ b/plugins/net.mograsim.machine/src/net/mograsim/machine/mi/AssignableMicroInstructionMemory.java @@ -21,6 +21,7 @@ public class AssignableMicroInstructionMemory implements MicroInstructionMemory, this.real.deregisterObserver(this); this.real = real; real.registerObserver(this); + notifyObservers(-1); } @Override diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/memory/MemoryTableContentProvider.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/memory/MemoryTableContentProvider.java index aaecc754..95d18358 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/memory/MemoryTableContentProvider.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/memory/MemoryTableContentProvider.java @@ -74,6 +74,7 @@ public class MemoryTableContentProvider implements ILazyContentProvider, MemoryO @Override public void update(long address) { - Display.getDefault().asyncExec(() -> updateElement((int) (address - lower))); + // TODO check if viewer.refresh() does what we expect + Display.getDefault().asyncExec(address == -1 ? viewer::refresh : () -> updateElement((int) (address - lower))); } } diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionView.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionView.java index aa1df4d2..76d4a693 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionView.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionView.java @@ -11,8 +11,6 @@ import org.eclipse.jface.viewers.ColumnLabelProvider; import org.eclipse.jface.viewers.EditingSupport; import org.eclipse.jface.viewers.TableViewerColumn; import org.eclipse.swt.SWT; -import org.eclipse.swt.events.SelectionEvent; -import org.eclipse.swt.events.SelectionListener; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; @@ -84,23 +82,8 @@ public class InstructionView extends EditorPart implements MemoryObserver { Button activationButton = new Button(parent, SWT.PUSH); activationButton.setText("Set Active"); - activationButton.addSelectionListener(new SelectionListener() - { - - @Override - public void widgetSelected(SelectionEvent e) - { - if (e.detail == SWT.PUSH) - MachineContext.getInstance().getMachine().getMicroInstructionMemory().bind(memory); - // TODO register this in project context - } - - @Override - public void widgetDefaultSelected(SelectionEvent e) - { - widgetSelected(e); - } - }); + activationButton.addListener(SWT.Selection, + e -> MachineContext.getInstance().getMachine().getMicroInstructionMemory().bind(memory)); } public void highlight(int index) -- 2.17.1