KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > jclasslib > browser > detail > constants > ConstantClassInfoDetailPane


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.constants;
9
10 import org.gjt.jclasslib.browser.BrowserServices;
11 import org.gjt.jclasslib.structures.InvalidByteCodeException;
12 import org.gjt.jclasslib.structures.constants.ConstantClassInfo;
13 import org.gjt.jclasslib.util.ExtendedJLabel;
14
15 import javax.swing.tree.TreePath JavaDoc;
16
17 /**
18     Detail pane showing a <tt>CONSTANT_Class</tt> constant pool entry.
19  
20     @author <a HREF="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>
21     @version $Revision: 1.6 $ $Date: 2004/02/10 16:06:56 $
22 */

23 public class ConstantClassInfoDetailPane extends AbstractConstantInfoDetailPane {
24
25     // Visual components
26

27     private ExtendedJLabel lblClass;
28     private ExtendedJLabel lblClassVerbose;
29
30     private ClassElementOpener classElementOpener;
31
32     /**
33         Constructor.
34         @param services the associated browser services.
35      */

36     public ConstantClassInfoDetailPane(BrowserServices services) {
37         super(services);
38     }
39     
40     protected void setupLabels() {
41         
42         addDetailPaneEntry(normalLabel("Class name:"),
43                            lblClass = linkLabel(),
44                            lblClassVerbose = highlightLabel());
45     }
46
47     protected int addSpecial(int gridy) {
48
49         classElementOpener = new ClassElementOpener(this);
50         if (getBrowserServices().canOpenClassFiles()) {
51             return classElementOpener.addSpecial(this, gridy);
52         } else {
53             return 0;
54         }
55     }
56
57     public void show(TreePath JavaDoc treePath) {
58         
59         int constantPoolIndex = constantPoolIndex(treePath);
60
61         try {
62             ConstantClassInfo entry = (ConstantClassInfo)services.getClassFile().getConstantPoolEntry(constantPoolIndex, ConstantClassInfo.class);
63             classElementOpener.setCPInfo(entry);
64
65             constantPoolHyperlink(lblClass,
66                                   lblClassVerbose,
67                                   entry.getNameIndex());
68         
69         } catch (InvalidByteCodeException ex) {
70             lblClassVerbose.setText(MESSAGE_INVALID_CONSTANT_POOL_ENTRY);
71         }
72         
73         super.show(treePath);
74     }
75     
76 }
77
78
Popular Tags