1 7 package org.gjt.jclasslib.browser.detail.attributes; 8 9 import org.gjt.jclasslib.browser.BrowserServices; 10 import org.gjt.jclasslib.browser.ConstantPoolHyperlinkListener; 11 import org.gjt.jclasslib.structures.AttributeInfo; 12 import org.gjt.jclasslib.structures.attributes.LocalVariableCommonAttribute; 13 import org.gjt.jclasslib.structures.attributes.LocalVariableCommonEntry; 14 15 21 public abstract class LocalVariableCommonAttributeDetailPane extends AbstractAttributeListDetailPane { 22 23 28 public LocalVariableCommonAttributeDetailPane(BrowserServices services) { 29 super(services); 30 } 31 32 protected AbstractAttributeTableModel createTableModel(AttributeInfo attribute, String descriptorOrSignatureDescription) { 33 return new AttributeTableModel(attribute, descriptorOrSignatureDescription); 34 } 35 36 protected float getRowHeightFactor() { 37 return 2f; 38 } 39 40 private class AttributeTableModel extends AbstractAttributeTableModel { 41 private static final int COLUMN_COUNT = BASE_COLUMN_COUNT + 5; 42 43 private static final int START_PC_COLUMN_INDEX = BASE_COLUMN_COUNT; 44 private static final int LENGTH_COLUMN_INDEX = BASE_COLUMN_COUNT + 1; 45 private static final int INDEX_COLUMN_INDEX = BASE_COLUMN_COUNT + 2; 46 private static final int NAME_COLUMN_INDEX = BASE_COLUMN_COUNT + 3; 47 private static final int DESCRIPTOR_OR_SIGNATURE_COLUMN_INDEX = BASE_COLUMN_COUNT + 4; 48 49 private final String descriptorOrSignatureVerbose; 50 51 private static final int COMMENT_LINK_COLUMN_WIDTH = 200; 52 53 private LocalVariableCommonEntry[] localVariableEntries; 54 55 private AttributeTableModel(AttributeInfo attribute, 56 String descriptorOrSignatureVerbose) { 57 58 super(attribute); 59 localVariableEntries = ((LocalVariableCommonAttribute)attribute).getLocalVariableEntries(); 60 this.descriptorOrSignatureVerbose = descriptorOrSignatureVerbose; 61 } 62 63 public int getColumnWidth(int column) { 64 switch (column) { 65 case START_PC_COLUMN_INDEX: 66 case LENGTH_COLUMN_INDEX: 67 case INDEX_COLUMN_INDEX: 68 return NUMBER_COLUMN_WIDTH; 69 70 case NAME_COLUMN_INDEX: 71 case DESCRIPTOR_OR_SIGNATURE_COLUMN_INDEX: 72 return COMMENT_LINK_COLUMN_WIDTH; 73 74 default: 75 return LINK_COLUMN_WIDTH; 76 } 77 } 78 79 public void link(int row, int column) { 80 int constantPoolIndex; 81 switch (column) { 82 case NAME_COLUMN_INDEX: 83 constantPoolIndex = localVariableEntries[row].getNameIndex(); 84 break; 85 case DESCRIPTOR_OR_SIGNATURE_COLUMN_INDEX: 86 constantPoolIndex = localVariableEntries[row].getDescriptorOrSignatureIndex(); 87 break; 88 default: 89 return; 90 } 91 ConstantPoolHyperlinkListener.link(services, constantPoolIndex); 92 } 93 94 public int getRowCount() { 95 return localVariableEntries.length; 96 } 97 98 public int getColumnCount() { 99 return COLUMN_COUNT; 100 } 101 102 protected String doGetColumnName(int column) { 103 switch (column) { 104 case START_PC_COLUMN_INDEX: 105 return "start_pc"; 106 case LENGTH_COLUMN_INDEX: 107 return "length"; 108 case INDEX_COLUMN_INDEX: 109 return "index"; 110 case NAME_COLUMN_INDEX: 111 return "name"; 112 case DESCRIPTOR_OR_SIGNATURE_COLUMN_INDEX: 113 return descriptorOrSignatureVerbose; 114 default: 115 return ""; 116 } 117 } 118 119 protected Class doGetColumnClass(int column) { 120 switch (column) { 121 case START_PC_COLUMN_INDEX: 122 case LENGTH_COLUMN_INDEX: 123 case INDEX_COLUMN_INDEX: 124 return Number .class; 125 case NAME_COLUMN_INDEX: 126 case DESCRIPTOR_OR_SIGNATURE_COLUMN_INDEX: 127 return Link.class; 128 default: 129 return String .class; 130 } 131 } 132 133 protected Object doGetValueAt(int row, int column) { 134 LocalVariableCommonEntry localVariableEntry = localVariableEntries[row]; 135 136 switch (column) { 137 case START_PC_COLUMN_INDEX: 138 return String.valueOf(localVariableEntry.getStartPc()); 139 case LENGTH_COLUMN_INDEX: 140 return String.valueOf(localVariableEntry.getLength()); 141 case INDEX_COLUMN_INDEX: 142 return String.valueOf(localVariableEntry.getIndex()); 143 case NAME_COLUMN_INDEX: 144 return createCommentLink(localVariableEntry.getNameIndex()); 145 case DESCRIPTOR_OR_SIGNATURE_COLUMN_INDEX: 146 return createCommentLink(localVariableEntry.getDescriptorOrSignatureIndex()); 147 default: 148 return ""; 149 } 150 } 151 } 152 } 153 | Popular Tags |