01: /*
02: This library is free software; you can redistribute it and/or
03: modify it under the terms of the GNU General Public
04: License as published by the Free Software Foundation; either
05: version 2 of the license, or (at your option) any later version.
06: */
07:
08: package org.gjt.jclasslib.browser.detail.constants;
09:
10: import org.gjt.jclasslib.browser.BrowserServices;
11: import org.gjt.jclasslib.structures.InvalidByteCodeException;
12: import org.gjt.jclasslib.structures.constants.ConstantStringInfo;
13: import org.gjt.jclasslib.util.ExtendedJLabel;
14:
15: import javax.swing.tree.TreePath;
16:
17: /**
18: Detail pane showing a <tt>CONSTANT_String</tt> constant pool entry.
19:
20: @author <a href="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>
21: @version $Revision: 1.5 $ $Date: 2003/08/18 08:16:34 $
22: */
23: public class ConstantStringInfoDetailPane extends
24: AbstractConstantInfoDetailPane {
25:
26: // Visual components
27:
28: private ExtendedJLabel lblString;
29: private ExtendedJLabel lblStringVerbose;
30:
31: /**
32: Constructor.
33: @param services the associated browser services.
34: */
35: public ConstantStringInfoDetailPane(BrowserServices services) {
36: super (services);
37: }
38:
39: protected void setupLabels() {
40:
41: addDetailPaneEntry(normalLabel("String:"),
42: lblString = linkLabel(),
43: lblStringVerbose = highlightLabel());
44: }
45:
46: public void show(TreePath treePath) {
47:
48: int constantPoolIndex = constantPoolIndex(treePath);
49:
50: try {
51: ConstantStringInfo entry = (ConstantStringInfo) services
52: .getClassFile()
53: .getConstantPoolEntry(constantPoolIndex,
54: ConstantStringInfo.class);
55:
56: constantPoolHyperlink(lblString, lblStringVerbose, entry
57: .getStringIndex());
58:
59: } catch (InvalidByteCodeException ex) {
60: lblStringVerbose
61: .setText(MESSAGE_INVALID_CONSTANT_POOL_ENTRY);
62: }
63:
64: super.show(treePath);
65: }
66:
67: }
|