KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > jclasslib > browser > detail > GeneralDetailPane


1 /*
2     This library is free software; you can redistribute it and/or
3     modify it under the terms of the GNU General Public
4     License as published by the Free Software Foundation; either
5     version 2 of the license, or (at your option) any later version.
6 */

7
8 package org.gjt.jclasslib.browser.detail;
9
10 import org.gjt.jclasslib.browser.BrowserServices;
11 import org.gjt.jclasslib.structures.ClassFile;
12 import org.gjt.jclasslib.util.ExtendedJLabel;
13
14 import javax.swing.tree.TreePath JavaDoc;
15
16 /**
17     Detail pane showing general information on the class file structure.
18     All fields in the <tt>ClassFile</tt> structure without substructure
19     are incorporated in theis pane.
20  
21     @author <a HREF="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>
22     @version $Revision: 1.5 $ $Date: 2003/08/18 08:14:22 $
23 */

24 public class GeneralDetailPane extends FixedListDetailPane {
25     
26     // Visual components
27

28     private ExtendedJLabel lblMinorVersion;
29     private ExtendedJLabel lblMajorVersion;
30     private ExtendedJLabel lblConstantPoolCount;
31     private ExtendedJLabel lblAccessFlags;
32     private ExtendedJLabel lblAccessFlagsVerbose;
33     private ExtendedJLabel lblThisClass;
34     private ExtendedJLabel lblThisClassVerbose;
35     private ExtendedJLabel lblSuperClass;
36     private ExtendedJLabel lblSuperClassVerbose;
37     private ExtendedJLabel lblInterfacesCount;
38     private ExtendedJLabel lblFieldsCount;
39     private ExtendedJLabel lblMethodsCount;
40     private ExtendedJLabel lblAttributesCount;
41
42     /**
43         Constructor.
44         @param services the associated browser services.
45      */

46     public GeneralDetailPane(BrowserServices services) {
47         super(services);
48     }
49     
50     protected void setupLabels() {
51         
52         addDetailPaneEntry(normalLabel("Minor version:"),
53                            lblMinorVersion = highlightLabel());
54
55         addDetailPaneEntry(normalLabel("Major version:"),
56                            lblMajorVersion = highlightLabel());
57         
58         addDetailPaneEntry(normalLabel("Constant pool count:"),
59                            lblConstantPoolCount = highlightLabel());
60         
61         addDetailPaneEntry(normalLabel("Access flags:"),
62                            lblAccessFlags = highlightLabel(),
63                            lblAccessFlagsVerbose = highlightLabel());
64         
65         addDetailPaneEntry(normalLabel("This class:"),
66                            lblThisClass = linkLabel(),
67                            lblThisClassVerbose = highlightLabel());
68         
69         addDetailPaneEntry(normalLabel("Super class:"),
70                            lblSuperClass = linkLabel(),
71                            lblSuperClassVerbose = highlightLabel());
72         
73         addDetailPaneEntry(normalLabel("Interfaces count:"),
74                            lblInterfacesCount = highlightLabel());
75         
76         addDetailPaneEntry(normalLabel("Fields count:"),
77                            lblFieldsCount = highlightLabel());
78         
79         addDetailPaneEntry(normalLabel("Methods count:"),
80                            lblMethodsCount = highlightLabel());
81         
82         addDetailPaneEntry(normalLabel("Attributes count:"),
83                            lblAttributesCount = highlightLabel());
84
85     }
86
87     public void show(TreePath JavaDoc treePath) {
88         
89         ClassFile classFile = services.getClassFile();
90         
91         lblMinorVersion.setText(classFile.getMinorVersion());
92         lblMajorVersion.setText(classFile.getMajorVersion());
93         lblConstantPoolCount.setText(classFile.getConstantPool().length);
94
95         lblAccessFlags.setText(classFile.getFormattedAccessFlags());
96         lblAccessFlagsVerbose.setText("[" + classFile.getAccessFlagsVerbose() + "]");
97
98         constantPoolHyperlink(lblThisClass,
99                               lblThisClassVerbose,
100                               classFile.getThisClass());
101
102         constantPoolHyperlink(lblSuperClass,
103                               lblSuperClassVerbose,
104                               classFile.getSuperClass());
105         
106         lblInterfacesCount.setText(classFile.getInterfaces().length);
107         lblFieldsCount.setText(classFile.getFields().length);
108         lblMethodsCount.setText(classFile.getMethods().length);
109         lblAttributesCount.setText(classFile.getAttributes().length);
110
111         super.show(treePath);
112     }
113     
114 }
115
116
Popular Tags