1 7 8 package org.gjt.jclasslib.browser.detail; 9 10 import org.gjt.jclasslib.browser.BrowserServices; 11 import org.gjt.jclasslib.structures.*; 12 import org.gjt.jclasslib.util.ExtendedJLabel; 13 14 import javax.swing.tree.TreePath ; 15 16 22 public class ClassMemberDetailPane extends FixedListDetailPane { 23 24 25 public static final int FIELDS = 1; 26 27 public static final int METHODS = 2; 28 29 private int mode; 30 31 33 private ExtendedJLabel lblName; 34 private ExtendedJLabel lblNameVerbose; 35 36 private ExtendedJLabel lblDescriptor; 37 private ExtendedJLabel lblDescriptorVerbose; 38 39 private ExtendedJLabel lblAccessFlags; 40 private ExtendedJLabel lblAccessFlagsVerbose; 41 42 48 public ClassMemberDetailPane(BrowserServices services, int mode) { 49 super(services); 50 this.mode = mode; 51 } 52 53 protected void setupLabels() { 54 55 addDetailPaneEntry(normalLabel("Name:"), 56 lblName = linkLabel(), 57 lblNameVerbose = highlightLabel()); 58 59 addDetailPaneEntry(normalLabel("Descriptor:"), 60 lblDescriptor = linkLabel(), 61 lblDescriptorVerbose = highlightLabel()); 62 63 addDetailPaneEntry(normalLabel("Access flags:"), 64 lblAccessFlags = highlightLabel(), 65 lblAccessFlagsVerbose = highlightLabel()); 66 } 67 68 public void show(TreePath treePath) { 69 70 int index = getIndex(treePath); 71 ClassMember classMember; 72 if (mode == FIELDS) { 73 FieldInfo[] fields = services.getClassFile().getFields(); 74 if (index >= fields.length) { 75 return; 76 } 77 classMember = fields[index]; 78 } else { 79 MethodInfo[] methods = services.getClassFile().getMethods(); 80 if (index >= methods.length) { 81 return; 82 } 83 classMember = methods[index]; 84 } 85 86 constantPoolHyperlink(lblName, 87 lblNameVerbose, 88 classMember.getNameIndex()); 89 90 constantPoolHyperlink(lblDescriptor, 91 lblDescriptorVerbose, 92 classMember.getDescriptorIndex()); 93 94 lblAccessFlags.setText(classMember.getFormattedAccessFlags()); 95 lblAccessFlagsVerbose.setText("[" + classMember.getAccessFlagsVerbose() + "]"); 96 97 super.show(treePath); 98 99 } 100 101 } 102 103 | Popular Tags |