X-Git-Url: https://mograsim.net/gitweb/?a=blobdiff_plain;f=plugins%2Fnet.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Ftables%2Fmi%2FInstructionTable.java;h=2a3ad6c06e7d58489721170bc3ec97a492836118;hb=4c2b7a2100e55b5e4bf59666b9684d5a996bd0fb;hp=d598c3ff4477313be094cf2be94a7a110072e9af;hpb=ffee7830001cd868b1f665a59e8bb6a74598f1c5;p=Mograsim.git 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 d598c3ff..2a3ad6c0 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 @@ -3,8 +3,14 @@ package net.mograsim.plugin.tables.mi; import java.util.Arrays; import org.eclipse.jface.viewers.ColumnLabelProvider; +import org.eclipse.jface.viewers.ColumnViewerEditor; +import org.eclipse.jface.viewers.ColumnViewerEditorActivationEvent; +import org.eclipse.jface.viewers.ColumnViewerEditorActivationStrategy; import org.eclipse.jface.viewers.EditingSupport; +import org.eclipse.jface.viewers.FocusCellOwnerDrawHighlighter; import org.eclipse.jface.viewers.TableViewerColumn; +import org.eclipse.jface.viewers.TableViewerEditor; +import org.eclipse.jface.viewers.TableViewerFocusCellManager; import org.eclipse.swt.SWT; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.widgets.Composite; @@ -31,7 +37,7 @@ public class InstructionTable public InstructionTable(Composite parent, DisplaySettings displaySettings) { - viewer = new LazyTableViewer(parent, SWT.MULTI | SWT.H_SCROLL | SWT.V_SCROLL | SWT.FULL_SELECTION | SWT.BORDER | SWT.VIRTUAL); + viewer = new LazyTableViewer(parent, SWT.FULL_SELECTION | SWT.BORDER | SWT.VIRTUAL); this.displaySettings = displaySettings; Table table = viewer.getTable(); @@ -39,6 +45,23 @@ public class InstructionTable table.setLinesVisible(true); viewer.setUseHashlookup(true); + TableViewerFocusCellManager focusCellManager = new TableViewerFocusCellManager(viewer, new FocusCellOwnerDrawHighlighter(viewer)); + + ColumnViewerEditorActivationStrategy actSupport = new ColumnViewerEditorActivationStrategy(viewer) + { + @Override + protected boolean isEditorActivationEvent(ColumnViewerEditorActivationEvent event) + { + return event.eventType == ColumnViewerEditorActivationEvent.TRAVERSAL + || event.eventType == ColumnViewerEditorActivationEvent.MOUSE_DOUBLE_CLICK_SELECTION + || (event.eventType == ColumnViewerEditorActivationEvent.KEY_PRESSED && event.keyCode == SWT.CR) + || event.eventType == ColumnViewerEditorActivationEvent.PROGRAMMATIC; + } + }; + int features = ColumnViewerEditor.TABBING_HORIZONTAL | ColumnViewerEditor.TABBING_MOVE_TO_ROW_NEIGHBOR + | ColumnViewerEditor.TABBING_VERTICAL | ColumnViewerEditor.KEYBOARD_ACTIVATION; + TableViewerEditor.create(viewer, focusCellManager, actSupport, features); + GridData viewerData = new GridData(GridData.GRAB_HORIZONTAL | GridData.GRAB_VERTICAL | GridData.FILL_BOTH); viewerData.horizontalSpan = 3; viewer.getTable().setLayoutData(viewerData); @@ -107,8 +130,11 @@ public class InstructionTable public void bindMicroInstructionMemory(MicroInstructionMemory memory) { this.memory = memory; - this.miDef = memory.getDefinition().getMicroInstructionDefinition(); - setViewerInput(memory); + if (memory != null) + { + this.miDef = memory.getDefinition().getMicroInstructionDefinition(); + setViewerInput(memory); + } } private static final String[] HEX_DIGITS = { "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F" }; @@ -134,7 +160,6 @@ public class InstructionTable provider = new IntegerColumnLabelProvider(displaySettings, index); break; case MNEMONIC: -// viewerColumn.setEditingSupport(editingSupport) support = new MnemonicEditingSupport(viewer, miDef, index, this.provider); provider = new ParameterLabelProvider(index); break;