Fixed the "Set active" button in InstructionView
authorDaniel Kirschten <daniel.kirschten@gmx.de>
Tue, 17 Sep 2019 21:13:20 +0000 (23:13 +0200)
committerDaniel Kirschten <daniel.kirschten@gmx.de>
Tue, 17 Sep 2019 21:15:00 +0000 (23:15 +0200)
plugins/net.mograsim.machine/src/net/mograsim/machine/mi/AssignableMicroInstructionMemory.java
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/memory/MemoryTableContentProvider.java
plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionView.java

index 5fe753e..b0ab5a4 100644 (file)
@@ -21,6 +21,7 @@ public class AssignableMicroInstructionMemory implements MicroInstructionMemory,
                this.real.deregisterObserver(this);
                this.real = real;
                real.registerObserver(this);
+               notifyObservers(-1);
        }
 
        @Override
index aaecc75..95d1835 100644 (file)
@@ -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)));
        }
 }
index aa1df4d..76d4a69 100644 (file)
@@ -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)