1 7 8 package org.gjt.jclasslib.browser.detail.attributes; 9 10 import org.gjt.jclasslib.browser.BrowserServices; 11 import org.gjt.jclasslib.structures.AttributeInfo; 12 import org.gjt.jclasslib.structures.attributes.LineNumberTableAttribute; 13 import org.gjt.jclasslib.structures.attributes.LineNumberTableEntry; 14 15 21 public class LineNumberTableAttributeDetailPane extends AbstractAttributeListDetailPane { 22 23 27 public LineNumberTableAttributeDetailPane(BrowserServices services) { 28 super(services); 29 } 30 31 protected AbstractAttributeTableModel createTableModel(AttributeInfo attribute) { 32 return new AttributeTableModel(attribute); 33 } 34 35 private class AttributeTableModel extends AbstractAttributeTableModel { 36 37 private static final int COLUMN_COUNT = BASE_COLUMN_COUNT + 2; 38 39 private static final int START_PC_COLUMN_INDEX = BASE_COLUMN_COUNT; 40 private static final int LINE_NUMBER_COLUMN_INDEX = BASE_COLUMN_COUNT + 1; 41 42 private static final int LINE_NUMBER_COLUMN_WIDTH = 100; 43 44 private LineNumberTableEntry[] lineNumberTable; 45 46 private AttributeTableModel(AttributeInfo attribute) { 47 super(attribute); 48 lineNumberTable = ((LineNumberTableAttribute)attribute).getLineNumberTable(); 49 } 50 51 public int getColumnWidth(int column) { 52 switch (column) { 53 case START_PC_COLUMN_INDEX: 54 return NUMBER_COLUMN_WIDTH; 55 case LINE_NUMBER_COLUMN_INDEX: 56 return LINE_NUMBER_COLUMN_WIDTH; 57 default: 58 return NUMBER_COLUMN_WIDTH; 59 } 60 } 61 62 public int getRowCount() { 63 return lineNumberTable.length; 64 } 65 66 public int getColumnCount() { 67 return COLUMN_COUNT; 68 } 69 70 protected String doGetColumnName(int column) { 71 switch (column) { 72 case START_PC_COLUMN_INDEX: 73 return "start_pc"; 74 case LINE_NUMBER_COLUMN_INDEX: 75 return "line_number"; 76 default: 77 return ""; 78 } 79 } 80 81 protected Class doGetColumnClass(int column) { 82 return Number .class; 83 } 84 85 protected Object doGetValueAt(int row, int column) { 86 87 LineNumberTableEntry lineNumberTableEntry = lineNumberTable[row]; 88 89 switch (column) { 90 case START_PC_COLUMN_INDEX: 91 return String.valueOf(lineNumberTableEntry.getStartPc()); 92 case LINE_NUMBER_COLUMN_INDEX: 93 return String.valueOf(lineNumberTableEntry.getLineNumber()); 94 default: 95 return ""; 96 } 97 } 98 } 99 } 100 101 | Popular Tags |