KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > tasklist > bugs > issues > IssuesView


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.tasklist.bugs.issues;
21
22 import java.awt.BorderLayout JavaDoc;
23 import java.io.FileNotFoundException JavaDoc;
24 import java.io.IOException JavaDoc;
25 import javax.swing.JLabel JavaDoc;
26 import javax.swing.JScrollPane JavaDoc;
27 import javax.swing.JTable JavaDoc;
28 import javax.swing.table.AbstractTableModel JavaDoc;
29 import javax.xml.parsers.ParserConfigurationException JavaDoc;
30 import org.openide.filesystems.FileObject;
31 import org.openide.windows.TopComponent;
32 import org.xml.sax.SAXException JavaDoc;
33
34 /**
35  * View for issues
36  */

37 public class IssuesView extends TopComponent {
38     // TODO: i18n
39
private static final String JavaDoc[] COLUMN_NAMES = {
40         "summary",
41         "component",
42         "subcomponent",
43         "priority",
44         "status",
45         "resolution"
46     };
47     
48     private static final Class JavaDoc COLUMN_CLASSES[] = {
49         String JavaDoc.class,
50         Integer JavaDoc.class,
51         Integer JavaDoc.class,
52         Integer JavaDoc.class,
53         Integer JavaDoc.class,
54         Integer JavaDoc.class
55     };
56     
57     private FileObject fo;
58     private JTable JavaDoc table;
59     
60     /**
61      * Creates a new instance of BugsView
62      */

63     public IssuesView(FileObject fo) {
64         this.fo = fo;
65         
66         javax.xml.parsers.DocumentBuilderFactory JavaDoc builderFactory =
67             javax.xml.parsers.DocumentBuilderFactory.newInstance();
68         
69         // TODO: turn the validation on
70
builderFactory.setValidating(false);
71         builderFactory.setExpandEntityReferences(false);
72         
73         javax.xml.parsers.DocumentBuilder JavaDoc builder;
74         try {
75             builder = builderFactory.newDocumentBuilder();
76         } catch (ParserConfigurationException JavaDoc e) {
77             e.printStackTrace(); // TODO
78
return;
79         }
80         org.w3c.dom.Document JavaDoc document;
81         try {
82             document = builder.parse(new org.xml.sax.InputSource JavaDoc(fo.getInputStream()));
83         } catch (FileNotFoundException JavaDoc e) {
84             e.printStackTrace(); // TODO
85
return;
86         } catch (IOException JavaDoc e) {
87             e.printStackTrace(); // TODO
88
return;
89         } catch (SAXException JavaDoc e) {
90             e.printStackTrace(); // TODO
91
return;
92         }
93         IssuesScanner scanner = new IssuesScanner(document);
94         final IssuesList list = scanner.visitDocument();
95
96         // TODO: remove
97
System.out.println("list.issues.size " + list.issues.size());
98
99         table = new JTable JavaDoc();
100         table.setModel(new AbstractTableModel JavaDoc() {
101             public int getRowCount() {
102                 return list.issues.size();
103             }
104             public int getColumnCount() {
105                 return 6;
106             }
107             public String JavaDoc getColumnName(int columnIndex) {
108                 return COLUMN_NAMES[columnIndex];
109             }
110             public Class JavaDoc getColumnClass(int columnIndex) {
111                 return COLUMN_CLASSES[columnIndex];
112             }
113             public Object JavaDoc getValueAt(int rowIndex, int columnIndex) {
114                 Issue issue = (Issue) list.issues.get(rowIndex);
115                 switch (columnIndex) {
116                     case 0:
117                         return issue.summary;
118                     case 1:
119                         return new Integer JavaDoc(issue.component);
120                     case 2:
121                         return new Integer JavaDoc(issue.subcomponent);
122                     case 3:
123                         return new Integer JavaDoc(issue.priority);
124                     case 4:
125                         return new Integer JavaDoc(issue.status);
126                     case 5:
127                         return new Integer JavaDoc(issue.resolution);
128                 }
129                 return null;
130             }
131         });
132         
133         setLayout(new BorderLayout JavaDoc());
134         add(new JScrollPane JavaDoc(table), BorderLayout.CENTER);
135     }
136     
137     public int getPersistenceType() {
138         return PERSISTENCE_NEVER;
139     }
140     
141     protected String JavaDoc preferredID() {
142         return "issues";
143     }
144 }
145
Popular Tags