KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > gjt > jclasslib > browser > detail > attributes > InnerClassesAttributeDetailPane


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.attributes;
9
10 import org.gjt.jclasslib.browser.BrowserServices;
11 import org.gjt.jclasslib.browser.ConstantPoolHyperlinkListener;
12 import org.gjt.jclasslib.structures.AttributeInfo;
13 import org.gjt.jclasslib.structures.attributes.InnerClassesAttribute;
14 import org.gjt.jclasslib.structures.attributes.InnerClassesEntry;
15
16 /**
17     Detail pane showing an <tt>InnerClasses</tt> attribute.
18
19     @author <a HREF="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>
20     @version $Revision: 1.5 $ $Date: 2003/08/18 08:18:11 $
21 */

22 public class InnerClassesAttributeDetailPane extends AbstractAttributeListDetailPane {
23
24     /**
25         Constructor.
26         @param services the associated browser services.
27      */

28     public InnerClassesAttributeDetailPane(BrowserServices services) {
29         super(services);
30     }
31     
32     protected AbstractAttributeTableModel createTableModel(AttributeInfo attribute) {
33         return new AttributeTableModel(attribute);
34     }
35
36     protected float getRowHeightFactor() {
37         return 2f;
38     }
39
40     private class AttributeTableModel extends AbstractAttributeTableModel {
41         
42         private static final int COLUMN_COUNT = BASE_COLUMN_COUNT + 4;
43         
44         private static final int INNER_CLASS_INFO_INDEX_COLUMN_INDEX = BASE_COLUMN_COUNT;
45         private static final int OUTER_CLASS_INFO_INDEX_COLUMN_INDEX = BASE_COLUMN_COUNT + 1;
46         private static final int INNER_NAME_INDEX_COLUMN_INDEX = BASE_COLUMN_COUNT + 2;
47         private static final int INNER_CLASS_ACCESS_FLAGS_COLUMN_INDEX = BASE_COLUMN_COUNT + 3;
48
49         private static final int CLASS_LINK_COLUMN_WIDTH = 160;
50         private static final int NAME_LINK_COLUMN_WIDTH = 110;
51         private static final int INNER_CLASS_ACCESS_FLAGS_COLUMN_WIDTH = 200;
52         
53         private InnerClassesEntry[] innerClasses;
54         
55         private AttributeTableModel(AttributeInfo attribute) {
56             super(attribute);
57             innerClasses = ((InnerClassesAttribute)attribute).getClasses();
58         }
59
60         public int getColumnWidth(int column) {
61             switch (column) {
62                 case INNER_CLASS_INFO_INDEX_COLUMN_INDEX:
63                 case OUTER_CLASS_INFO_INDEX_COLUMN_INDEX:
64                    return CLASS_LINK_COLUMN_WIDTH;
65                 case INNER_NAME_INDEX_COLUMN_INDEX:
66                     return NAME_LINK_COLUMN_WIDTH;
67
68                 case INNER_CLASS_ACCESS_FLAGS_COLUMN_INDEX:
69                    return INNER_CLASS_ACCESS_FLAGS_COLUMN_WIDTH;
70                     
71                 default:
72                    return LINK_COLUMN_WIDTH;
73             }
74         }
75         
76         public void link(int row, int column) {
77             
78             int constantPoolIndex;
79             switch (column) {
80                 case INNER_CLASS_INFO_INDEX_COLUMN_INDEX:
81                     constantPoolIndex = innerClasses[row].getInnerClassInfoIndex();
82                     break;
83                 case OUTER_CLASS_INFO_INDEX_COLUMN_INDEX:
84                     constantPoolIndex = innerClasses[row].getOuterClassInfoIndex();
85                     break;
86                 case INNER_NAME_INDEX_COLUMN_INDEX:
87                     constantPoolIndex = innerClasses[row].getInnerNameIndex();
88                     break;
89                 default:
90                     return;
91             }
92             ConstantPoolHyperlinkListener.link(services, constantPoolIndex);
93         }
94         
95         public int getRowCount() {
96             return innerClasses.length;
97         }
98         
99         public int getColumnCount() {
100             return COLUMN_COUNT;
101         }
102         
103         protected String JavaDoc doGetColumnName(int column) {
104             switch (column) {
105                 case INNER_CLASS_INFO_INDEX_COLUMN_INDEX:
106                    return "inner_class";
107                 case OUTER_CLASS_INFO_INDEX_COLUMN_INDEX:
108                    return "outer_class";
109                 case INNER_NAME_INDEX_COLUMN_INDEX:
110                    return "inner_name";
111                 case INNER_CLASS_ACCESS_FLAGS_COLUMN_INDEX:
112                    return "access flags";
113                 default:
114                    return "";
115             }
116         }
117         
118         protected Class JavaDoc doGetColumnClass(int column) {
119             switch (column) {
120                 case INNER_CLASS_INFO_INDEX_COLUMN_INDEX:
121                 case OUTER_CLASS_INFO_INDEX_COLUMN_INDEX:
122                 case INNER_NAME_INDEX_COLUMN_INDEX:
123                    return Link.class;
124                 case INNER_CLASS_ACCESS_FLAGS_COLUMN_INDEX:
125                 default:
126                    return String JavaDoc.class;
127             }
128         }
129         
130         protected Object JavaDoc doGetValueAt(int row, int column) {
131
132             InnerClassesEntry innerClassesEntry = innerClasses[row];
133             switch (column) {
134                 case INNER_CLASS_INFO_INDEX_COLUMN_INDEX:
135                     return createCommentLink(innerClassesEntry.getInnerClassInfoIndex());
136                 case OUTER_CLASS_INFO_INDEX_COLUMN_INDEX:
137                     return createCommentLink(innerClassesEntry.getOuterClassInfoIndex());
138                 case INNER_NAME_INDEX_COLUMN_INDEX:
139                     return createCommentLink(innerClassesEntry.getInnerNameIndex());
140                 case INNER_CLASS_ACCESS_FLAGS_COLUMN_INDEX:
141                     return innerClassesEntry.getInnerClassFormattedAccessFlags() +
142                            " [" + innerClassesEntry.getInnerClassAccessFlagsVerbose() + "]";
143                 default:
144                     return "";
145             }
146         }
147     }
148 }
149
Popular Tags