KickJava   Java API By Example, From Geeks To Geeks.

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


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.structures.AttributeInfo;
12 import org.gjt.jclasslib.structures.attributes.LineNumberTableAttribute;
13 import org.gjt.jclasslib.structures.attributes.LineNumberTableEntry;
14
15 /**
16     Detail pane showing a <tt>LineNumberTable</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 LineNumberTableAttributeDetailPane extends AbstractAttributeListDetailPane {
22
23     /**
24         Constructor.
25         @param services the associated browser services.
26      */

27     public LineNumberTableAttributeDetailPane(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 START_PC_COLUMN_INDEX = BASE_COLUMN_COUNT;
40         private static final int LINE_NUMBER_COLUMN_INDEX = BASE_COLUMN_COUNT + 1;
41         
42         private static final int LINE_NUMBER_COLUMN_WIDTH = 100;
43         
44         private LineNumberTableEntry[] lineNumberTable;
45         
46         private AttributeTableModel(AttributeInfo attribute) {
47             super(attribute);
48             lineNumberTable = ((LineNumberTableAttribute)attribute).getLineNumberTable();
49         }
50         
51         public int getColumnWidth(int column) {
52             switch (column) {
53                 case START_PC_COLUMN_INDEX:
54                     return NUMBER_COLUMN_WIDTH;
55                 case LINE_NUMBER_COLUMN_INDEX:
56                     return LINE_NUMBER_COLUMN_WIDTH;
57                 default:
58                    return NUMBER_COLUMN_WIDTH;
59             }
60         }
61         
62         public int getRowCount() {
63             return lineNumberTable.length;
64         }
65         
66         public int getColumnCount() {
67             return COLUMN_COUNT;
68         }
69         
70         protected String JavaDoc doGetColumnName(int column) {
71             switch (column) {
72                 case START_PC_COLUMN_INDEX:
73                    return "start_pc";
74                 case LINE_NUMBER_COLUMN_INDEX:
75                    return "line_number";
76                 default:
77                    return "";
78             }
79         }
80         
81         protected Class JavaDoc doGetColumnClass(int column) {
82             return Number JavaDoc.class;
83         }
84         
85         protected Object JavaDoc doGetValueAt(int row, int column) {
86
87             LineNumberTableEntry lineNumberTableEntry = lineNumberTable[row];
88             
89             switch (column) {
90                 case START_PC_COLUMN_INDEX:
91                     return String.valueOf(lineNumberTableEntry.getStartPc());
92                 case LINE_NUMBER_COLUMN_INDEX:
93                     return String.valueOf(lineNumberTableEntry.getLineNumber());
94                 default:
95                     return "";
96             }
97         }
98     }
99 }
100
101
Popular Tags