X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Ftables%2Fmemory%2FMemoryTableContentProvider.java;h=3d67c9dcd4ccdbc18b42555017001f3a175dd8a1;hb=90562c65d0eb70c77a3447e4186f0b848b00d6ec;hp=aaecc754fcdbd6f08ee510be6b5f568f3ba66f88;hpb=7d05144c25daa53e60fc9ed9fd503546a86567f8;p=Mograsim.git 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..3d67c9dc 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 @@ -6,9 +6,9 @@ import org.eclipse.jface.viewers.Viewer; import org.eclipse.swt.widgets.Display; import net.mograsim.machine.MainMemory; -import net.mograsim.machine.MemoryObserver; +import net.mograsim.machine.Memory.MemoryCellModifiedListener; -public class MemoryTableContentProvider implements ILazyContentProvider, MemoryObserver +public class MemoryTableContentProvider implements ILazyContentProvider, MemoryCellModifiedListener { private long lower; private TableViewer viewer; @@ -54,9 +54,12 @@ public class MemoryTableContentProvider implements ILazyContentProvider, MemoryO @Override public void updateElement(int index) { - long address = lower + index; - if (address <= memory.getDefinition().getMaximalAddress()) - viewer.replace(new MemoryTableRow(address, memory), index); + if (index < amount) + { + long address = lower + index; + if (address <= memory.getDefinition().getMaximalAddress()) + viewer.replace(new MemoryTableRow(address, memory), index); + } } @Override @@ -65,15 +68,16 @@ public class MemoryTableContentProvider implements ILazyContentProvider, MemoryO this.viewer = (TableViewer) viewer; this.memory = (MainMemory) newInput; if (oldInput != null) - ((MainMemory) oldInput).deregisterObserver(this); + ((MainMemory) oldInput).deregisterCellModifiedListener(this); if (memory != null) - memory.registerObserver(this); + memory.registerCellModifiedListener(this); setLowerBound(0L); } @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))); } }