1 7 8 package org.gjt.jclasslib.browser.detail.constants; 9 10 import org.gjt.jclasslib.browser.BrowserServices; 11 import org.gjt.jclasslib.structures.InvalidByteCodeException; 12 import org.gjt.jclasslib.structures.constants.ConstantReference; 13 import org.gjt.jclasslib.util.ExtendedJLabel; 14 15 import javax.swing.tree.TreePath ; 16 17 24 public class ConstantReferenceDetailPane extends AbstractConstantInfoDetailPane { 25 26 28 private ExtendedJLabel lblClass; 29 private ExtendedJLabel lblClassVerbose; 30 private ExtendedJLabel lblNameAndType; 31 private ExtendedJLabel lblNameAndTypeVerbose; 32 33 private ClassElementOpener classElementOpener; 34 35 39 public ConstantReferenceDetailPane(BrowserServices services) { 40 super(services); 41 } 42 43 protected void setupLabels() { 44 45 addDetailPaneEntry(normalLabel("Class name:"), 46 lblClass = linkLabel(), 47 lblClassVerbose = highlightLabel()); 48 49 addDetailPaneEntry(normalLabel("Name and type:"), 50 lblNameAndType = linkLabel(), 51 lblNameAndTypeVerbose = highlightLabel()); 52 } 53 54 protected int addSpecial(int gridy) { 55 56 classElementOpener = new ClassElementOpener(this); 57 if (getBrowserServices().canOpenClassFiles()) { 58 return classElementOpener.addSpecial(this, gridy); 59 } else { 60 return 0; 61 } 62 } 63 64 public void show(TreePath treePath) { 65 66 int constantPoolIndex = constantPoolIndex(treePath); 67 68 try { 69 ConstantReference entry = (ConstantReference)services.getClassFile().getConstantPoolEntry(constantPoolIndex, ConstantReference.class); 70 classElementOpener.setCPInfo(entry); 71 72 constantPoolHyperlink(lblClass, 73 lblClassVerbose, 74 entry.getClassIndex()); 75 76 constantPoolHyperlink(lblNameAndType, 77 lblNameAndTypeVerbose, 78 entry.getNameAndTypeIndex()); 79 80 } catch (InvalidByteCodeException ex) { 81 lblClassVerbose.setText(MESSAGE_INVALID_CONSTANT_POOL_ENTRY); 82 } 83 84 super.show(treePath); 85 } 86 87 } 88 89 | Popular Tags |