From 7958e659b3ea9aac43c1a67a0b2921c5323e4c84 Mon Sep 17 00:00:00 2001 From: Fabian Stemmler Date: Mon, 9 Sep 2019 10:53:21 +0200 Subject: [PATCH] Fixed an issue: InstructionView now updates when immediates are modified --- .../machine/mi/StandardMicroInstructionMemory.java | 1 + .../tables/mi/InstructionTableContentProvider.java | 9 +++++++++ .../mograsim/plugin/tables/mi/InstructionView.java | 8 +++++--- .../plugin/tables/mi/IntegerEditingSupport.java | 12 ++++++++++-- 4 files changed, 25 insertions(+), 5 deletions(-) diff --git a/net.mograsim.machine/src/net/mograsim/machine/mi/StandardMicroInstructionMemory.java b/net.mograsim.machine/src/net/mograsim/machine/mi/StandardMicroInstructionMemory.java index 6d38491c..c983561a 100644 --- a/net.mograsim.machine/src/net/mograsim/machine/mi/StandardMicroInstructionMemory.java +++ b/net.mograsim.machine/src/net/mograsim/machine/mi/StandardMicroInstructionMemory.java @@ -38,6 +38,7 @@ public class StandardMicroInstructionMemory implements MicroInstructionMemory public void setCell(long address, MicroInstruction data) { this.data[translate(address)] = data; + notifyObservers(address); } @Override diff --git a/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionTableContentProvider.java b/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionTableContentProvider.java index ddca5787..b8021b74 100644 --- a/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionTableContentProvider.java +++ b/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionTableContentProvider.java @@ -10,6 +10,7 @@ public class InstructionTableContentProvider implements ILazyContentProvider { private TableViewer viewer; private MicroInstructionMemory memory; + private long minAddr = 0; @Override public void updateElement(int index) @@ -24,6 +25,14 @@ public class InstructionTableContentProvider implements ILazyContentProvider this.viewer = (TableViewer) viewer; this.memory = (MicroInstructionMemory) newInput; if (this.memory != null) + { this.viewer.setItemCount((int) memory.size()); + this.minAddr = memory.getDefinition().getMinimalAddress(); + } + } + + public void update(long address) + { + updateElement((int) (address - minAddr)); } } diff --git a/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionView.java b/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionView.java index f0db46fe..d8644918 100644 --- a/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionView.java +++ b/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionView.java @@ -25,7 +25,6 @@ import net.mograsim.machine.mi.MicroInstructionMemoryParser; import net.mograsim.machine.mi.parameters.ParameterClassification; import net.mograsim.plugin.MachineContext; import net.mograsim.plugin.MachineContext.ContextObserver; -import net.mograsim.plugin.asm.AsmNumberUtil.NumberType; import net.mograsim.plugin.tables.AddressLabelProvider; import net.mograsim.plugin.tables.DisplaySettings; import net.mograsim.plugin.tables.RadixSelector; @@ -40,12 +39,13 @@ public class InstructionView extends ViewPart implements ContextObserver private MicroInstructionDefinition miDef; private MicroInstructionMemory memory; private DisplaySettings displaySettings; + private InstructionTableContentProvider provider; @SuppressWarnings("unused") @Override public void createPartControl(Composite parent) { - InstructionTableContentProvider provider = new InstructionTableContentProvider(); + provider = new InstructionTableContentProvider(); GridLayout layout = new GridLayout(3, false); setupMenuButtons(parent); @@ -54,11 +54,13 @@ public class InstructionView extends ViewPart implements ContextObserver parent.setLayout(layout); viewer = new TableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER | SWT.VIRTUAL); + Table table = viewer.getTable(); table.setHeaderVisible(true); table.setLinesVisible(true); viewer.setUseHashlookup(true); viewer.setContentProvider(provider); + getSite().setSelectionProvider(viewer); GridData viewerData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH); viewerData.horizontalSpan = 3; @@ -152,7 +154,7 @@ public class InstructionView extends ViewPart implements ContextObserver provider = new ParameterLabelProvider(index); break; case INTEGER_IMMEDIATE: - support = new IntegerEditingSupport(viewer, miDef, index, new DisplaySettings(NumberType.DECIMAL)); + support = new IntegerEditingSupport(viewer, miDef, index, displaySettings, this.provider); provider = new IntegerColumnLabelProvider(displaySettings, index); break; case MNEMONIC: diff --git a/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/IntegerEditingSupport.java b/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/IntegerEditingSupport.java index 0a7ad281..c8f7e083 100644 --- a/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/IntegerEditingSupport.java +++ b/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/IntegerEditingSupport.java @@ -14,18 +14,26 @@ public class IntegerEditingSupport extends NumberCellEditingSupport { private IntegerClassification classification; private int index; + private TableViewer viewer; + private InstructionTableContentProvider provider; - public IntegerEditingSupport(TableViewer viewer, MicroInstructionDefinition miDef, int index, DisplaySettings displaySettings) + public IntegerEditingSupport(TableViewer viewer, MicroInstructionDefinition miDef, int index, DisplaySettings displaySettings, + InstructionTableContentProvider provider) { super(viewer, displaySettings); classification = (IntegerClassification) miDef.getParameterClassifications()[index]; this.index = index; + this.viewer = viewer; + this.provider = provider; } @Override protected void setAsBigInteger(Object element, BigInteger value) { - ((InstructionTableRow) element).data.setParameter(index, new IntegerImmediate(value, classification.getExpectedBits())); + InstructionTableRow row = ((InstructionTableRow) element); + row.data.setParameter(index, new IntegerImmediate(value, classification.getExpectedBits())); + provider.update(row.address); +// viewer.update(element, null); Does not do anything for some reason } @Override -- 2.17.1