KickJava   Java API By Example, From Geeks To Geeks.

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


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.ExceptionsAttribute;
14
15 /**
16     Detail pane showing an <tt>Exceptions</tt> attribute.
17
18     @author <a HREF="mailto:jclasslib@ej-technologies.com">Ingo Kegel</a>
19     @version $Revision: 1.5 $ $Date: 2003/08/18 08:18:35 $
20 */

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

27     public ExceptionsAttributeDetailPane(BrowserServices services) {
28         super(services);
29     }
30     
31     protected AbstractAttributeTableModel createTableModel(AttributeInfo attribute) {
32         return new AttributeTableModel(attribute);
33     }
34     
35     private class AttributeTableModel extends AbstractAttributeTableModel {
36         
37         private static final int COLUMN_COUNT = BASE_COLUMN_COUNT + 2;
38         
39         private static final int EXCEPTION_INDEX_COLUMN_INDEX = BASE_COLUMN_COUNT;
40         private static final int EXCEPTION_VERBOSE_COLUMN_INDEX = BASE_COLUMN_COUNT + 1;
41         
42         private int[] exceptionIndexTable;
43         
44         private AttributeTableModel(AttributeInfo attribute) {
45             super(attribute);
46             exceptionIndexTable = ((ExceptionsAttribute)attribute).getExceptionIndexTable();
47         }
48
49         public int getColumnWidth(int column) {
50             switch (column) {
51                 case EXCEPTION_INDEX_COLUMN_INDEX:
52                    return LINK_COLUMN_WIDTH;
53                    
54                 case EXCEPTION_VERBOSE_COLUMN_INDEX:
55                    return VERBOSE_COLUMN_WIDTH;
56                     
57                 default:
58                    return LINK_COLUMN_WIDTH;
59             }
60         }
61         
62         public void link(int row, int column) {
63             
64             if (column == EXCEPTION_INDEX_COLUMN_INDEX) {
65                 int constantPoolIndex = exceptionIndexTable[row];
66                 ConstantPoolHyperlinkListener.link(services, constantPoolIndex);
67             }
68         }
69         
70         public int getRowCount() {
71             return exceptionIndexTable.length;
72         }
73         
74         public int getColumnCount() {
75             return COLUMN_COUNT;
76         }
77         
78         protected String JavaDoc doGetColumnName(int column) {
79             switch (column) {
80                 case EXCEPTION_INDEX_COLUMN_INDEX:
81                    return "exception";
82                 case EXCEPTION_VERBOSE_COLUMN_INDEX:
83                    return "verbose";
84                 default:
85                    return "";
86             }
87         }
88         
89         protected Class JavaDoc doGetColumnClass(int column) {
90             switch (column) {
91                 case EXCEPTION_INDEX_COLUMN_INDEX:
92                    return Link.class;
93                 case EXCEPTION_VERBOSE_COLUMN_INDEX:
94                 default:
95                    return String JavaDoc.class;
96             }
97         }
98         
99         protected Object JavaDoc doGetValueAt(int row, int column) {
100
101             int exceptionIndex = exceptionIndexTable[row];
102             
103             switch (column) {
104                 case EXCEPTION_INDEX_COLUMN_INDEX:
105                     return CPINFO_LINK_TEXT + String.valueOf(exceptionIndex);
106                 case EXCEPTION_VERBOSE_COLUMN_INDEX:
107                     return getConstantPoolEntryName(exceptionIndex);
108                 default:
109                     return "";
110             }
111         }
112     }
113 }
114
Popular Tags