1 7 8 package org.gjt.jclasslib.browser; 9 10 import org.gjt.jclasslib.browser.detail.*; 11 12 import javax.swing.*; 13 import javax.swing.tree.TreePath ; 14 import java.awt.*; 15 import java.util.HashMap ; 16 17 25 public class BrowserDetailPane extends JPanel { 26 27 private static final Dimension detailMinimumSize = new Dimension(150, 150); 28 private static final Dimension detailPreferredSize = new Dimension(150, 150); 29 30 private BrowserServices services; 31 private HashMap nodeTypeToDetailPane = new HashMap (); 32 33 38 public BrowserDetailPane(BrowserServices services) { 39 this.services = services; 40 setupComponent(); 41 } 42 43 51 public void showPane(String nodeType, TreePath treePath) { 52 if (services.getClassFile() == null) { 53 return; 54 } 55 CardLayout layout = (CardLayout)getLayout(); 56 AbstractDetailPane detailPane = (AbstractDetailPane)nodeTypeToDetailPane.get(nodeType); 57 if (detailPane != null) { 58 detailPane.show(treePath); 59 } 60 61 layout.show(this, nodeType); 62 } 63 64 71 public AttributeDetailPane getAttributeDetailPane() { 72 return (AttributeDetailPane)nodeTypeToDetailPane.get(BrowserTreeNode.NODE_ATTRIBUTE); 73 } 74 75 private void setupComponent() { 76 77 setLayout(new CardLayout()); 78 79 add(new JPanel(), BrowserTreeNode.NODE_NO_CONTENT); 80 81 addScreen(new GeneralDetailPane(services), 82 BrowserTreeNode.NODE_GENERAL); 83 addScreen(new ConstantPoolDetailPane(services), 84 BrowserTreeNode.NODE_CONSTANT_POOL); 85 addScreen(new InterfaceDetailPane(services), 86 BrowserTreeNode.NODE_INTERFACE); 87 addScreen(new ClassMemberDetailPane(services, ClassMemberDetailPane.FIELDS), 88 BrowserTreeNode.NODE_FIELD); 89 addScreen(new ClassMemberDetailPane(services, ClassMemberDetailPane.METHODS), 90 BrowserTreeNode.NODE_METHOD); 91 addScreen(new AttributeDetailPane(services), 92 BrowserTreeNode.NODE_ATTRIBUTE); 93 addScreen(new AnnotationDetailPane(services), 94 BrowserTreeNode.NODE_ANNOTATION); 95 addScreen(new ElementValueDetailPane(services), 96 BrowserTreeNode.NODE_ELEMENTVALUE); 97 addScreen(new ElementValuePairDetailPane(services), 98 BrowserTreeNode.NODE_ELEMENTVALUEPAIR); 99 addScreen(new ArrayElementValueDetailPane(services), 100 BrowserTreeNode.NODE_ARRAYELEMENTVALUE); 101 102 setMinimumSize(detailMinimumSize); 103 setPreferredSize(detailPreferredSize); 104 105 } 106 107 private void addScreen(AbstractDetailPane detailPane, String nodeType) { 108 109 if (detailPane instanceof FixedListDetailPane) { 110 add(((FixedListDetailPane)detailPane).getScrollPane(), nodeType); 111 } else { 112 add(detailPane, nodeType); 113 } 114 nodeTypeToDetailPane.put(nodeType, detailPane); 115 } 116 117 } 118 | Popular Tags |