X-Git-Url: https://mograsim.net/gitweb/?p=Mograsim.git;a=blobdiff_plain;f=plugins%2Fnet.mograsim.plugin.core%2Fsrc%2Fnet%2Fmograsim%2Fplugin%2Ftables%2Fmi%2FInstructionTable.java;h=936ba5c49a1b4bc69439c45d6f08dfe0db7a80ba;hp=914fb2f3c0832720c75dd966c5220546e05ada34;hb=363c9377b3c542c87fc5e7f57674751439246dbd;hpb=38902818500a67f6a55973b9acbd4194f7a82838 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 914fb2f3..936ba5c4 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 @@ -57,10 +57,12 @@ public class InstructionTable int size = miDef.size(); columns = new TableViewerColumn[size + 1]; - TableViewerColumn col = createTableViewerColumn("Address", generateLongestHexStrings(12)); + TableViewerColumn col = createTableViewerColumn("Address"); columns[0] = col; col.setLabelProvider(new AddressLabelProvider()); + String[] columnTitles = new String[size]; + int bit = miDef.sizeInBits(); ParameterClassification[] classes = miDef.getParameterClassifications(); @@ -68,8 +70,17 @@ public class InstructionTable { int startBit = bit - 1; int endBit = bit = bit - classes[i].getExpectedBits(); - String name = startBit == endBit ? Integer.toString(startBit) : startBit + "..." + endBit; + String columnTitle = calculateColumnTitle(startBit, endBit); + columnTitles[i] = columnTitle; + col = createTableViewerColumn(columnTitle); + columns[i + 1] = col; + createEditingAndLabel(col, miDef, i); + } + + calculateOptimalColumnSize(0, "Address", generateLongestHexStrings(12)); + for (int i = 0; i < size; i++) + { String[] longestPossibleContents; switch (classes[i].getExpectedType()) { @@ -84,13 +95,15 @@ public class InstructionTable longestPossibleContents = new String[0]; break; } - - col = createTableViewerColumn(name, longestPossibleContents); - columns[i + 1] = col; - createEditingAndLabel(col, miDef, i); + calculateOptimalColumnSize(i + 1, columnTitles[i], longestPossibleContents); } } + private static String calculateColumnTitle(int startBit, int endBit) + { + return startBit == endBit ? Integer.toString(startBit) : startBit + "..." + endBit; + } + public void bindMicroInstructionMemory(MicroInstructionMemory memory) { this.memory = memory; @@ -124,6 +137,7 @@ 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; @@ -136,10 +150,19 @@ public class InstructionTable col.getColumn().setToolTipText(miDef.getParameterDescription(index).orElse("")); } - private TableViewerColumn createTableViewerColumn(String title, String... longestPossibleContents) + private TableViewerColumn createTableViewerColumn(String title) { TableViewerColumn viewerColumn = new TableViewerColumn(viewer, SWT.NONE); TableColumn column = viewerColumn.getColumn(); + column.setText(title); + column.setResizable(true); + column.setMoveable(false); + return viewerColumn; + } + + private void calculateOptimalColumnSize(int i, String title, String... longestPossibleContents) + { + TableColumn column = viewer.getTable().getColumn(i); int maxWidth = 0; for (String s : longestPossibleContents) { @@ -152,9 +175,6 @@ public class InstructionTable column.pack(); if (column.getWidth() < maxWidth) column.setWidth(maxWidth); - column.setResizable(true); - column.setMoveable(false); - return viewerColumn; } public LazyTableViewer getTableViewer()