From 278fa8f97a6ba31f3cbdd0c65d370563b943eca9 Mon Sep 17 00:00:00 2001 From: Fabian Stemmler Date: Sun, 6 Oct 2019 18:52:23 +0200 Subject: [PATCH] Removed EditingSupports from Instruction Preview in SimulationView --- .../plugin/tables/mi/InstructionTable.java | 17 +++++++++++++---- .../mograsim/plugin/views/SimulationView.java | 3 ++- 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionTable.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionTable.java index 6ffc93e2..d7c23272 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionTable.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/tables/mi/InstructionTable.java @@ -40,12 +40,20 @@ public class InstructionTable private final RowHighlighter highlighter; private final FontAndColorHelper cProv; + private final boolean isEditable; + public InstructionTable(Composite parent, DisplaySettings displaySettings, IThemeManager themeManager) + { + this(parent, displaySettings, themeManager, true); + } + + public InstructionTable(Composite parent, DisplaySettings displaySettings, IThemeManager themeManager, boolean allowEditing) { viewer = new LazyTableViewer(parent, SWT.FULL_SELECTION | SWT.BORDER | SWT.VIRTUAL); this.displaySettings = displaySettings; this.cProv = new FontAndColorHelper(viewer, themeManager); this.highlighter = new RowHighlighter(viewer, cProv); + this.isEditable = allowEditing; Table table = viewer.getTable(); table.setHeaderVisible(true); @@ -183,22 +191,23 @@ public class InstructionTable switch (parameterClassification.getExpectedType()) { case BOOLEAN_IMMEDIATE: - support = new BooleanEditingSupport(viewer, miDef, index); + support = isEditable ? new BooleanEditingSupport(viewer, miDef, index) : null; provider = new ParameterLabelProvider(cProv, index); break; case INTEGER_IMMEDIATE: - support = new IntegerEditingSupport(viewer, miDef, index, displaySettings, this.provider); + support = isEditable ? new IntegerEditingSupport(viewer, miDef, index, displaySettings, this.provider) : null; provider = new IntegerColumnLabelProvider(displaySettings, cProv, index); break; case MNEMONIC: - support = new MnemonicEditingSupport(viewer, miDef, index, this.provider); + support = isEditable ? new MnemonicEditingSupport(viewer, miDef, index, this.provider) : null; provider = new ParameterLabelProvider(cProv, index); break; default: throw new IllegalStateException( "Unable to create EditingSupport for unknown ParameterType " + parameterClassification.getExpectedType()); } - col.setEditingSupport(support); + if (isEditable) + col.setEditingSupport(support); col.setLabelProvider(provider); col.getColumn().setToolTipText(miDef.getParameterDescription(index).orElse("")); } diff --git a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/views/SimulationView.java b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/views/SimulationView.java index a8fcfd7c..d1a90418 100644 --- a/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/views/SimulationView.java +++ b/plugins/net.mograsim.plugin.core/src/net/mograsim/plugin/views/SimulationView.java @@ -175,7 +175,8 @@ public class SimulationView extends ViewPart private void addInstructionPreviewControlWidgets(Composite parent) { - instPreview = new InstructionTable(parent, new DisplaySettings(), getSite().getWorkbenchWindow().getWorkbench().getThemeManager()); + instPreview = new InstructionTable(parent, new DisplaySettings(), getSite().getWorkbenchWindow().getWorkbench().getThemeManager(), + false); instPreview.getTableViewer().getControl().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, false)); contentProvider = new ActiveInstructionPreviewContentProvider(instPreview.getTableViewer()); instPreview.setContentProvider(contentProvider); -- 2.17.1