1 19 20 package org.netbeans.modules.tasklist.bugs.issues; 21 22 import java.awt.BorderLayout ; 23 import java.io.FileNotFoundException ; 24 import java.io.IOException ; 25 import javax.swing.JLabel ; 26 import javax.swing.JScrollPane ; 27 import javax.swing.JTable ; 28 import javax.swing.table.AbstractTableModel ; 29 import javax.xml.parsers.ParserConfigurationException ; 30 import org.openide.filesystems.FileObject; 31 import org.openide.windows.TopComponent; 32 import org.xml.sax.SAXException ; 33 34 37 public class IssuesView extends TopComponent { 38 private static final String [] COLUMN_NAMES = { 40 "summary", 41 "component", 42 "subcomponent", 43 "priority", 44 "status", 45 "resolution" 46 }; 47 48 private static final Class COLUMN_CLASSES[] = { 49 String .class, 50 Integer .class, 51 Integer .class, 52 Integer .class, 53 Integer .class, 54 Integer .class 55 }; 56 57 private FileObject fo; 58 private JTable table; 59 60 63 public IssuesView(FileObject fo) { 64 this.fo = fo; 65 66 javax.xml.parsers.DocumentBuilderFactory builderFactory = 67 javax.xml.parsers.DocumentBuilderFactory.newInstance(); 68 69 builderFactory.setValidating(false); 71 builderFactory.setExpandEntityReferences(false); 72 73 javax.xml.parsers.DocumentBuilder builder; 74 try { 75 builder = builderFactory.newDocumentBuilder(); 76 } catch (ParserConfigurationException e) { 77 e.printStackTrace(); return; 79 } 80 org.w3c.dom.Document document; 81 try { 82 document = builder.parse(new org.xml.sax.InputSource (fo.getInputStream())); 83 } catch (FileNotFoundException e) { 84 e.printStackTrace(); return; 86 } catch (IOException e) { 87 e.printStackTrace(); return; 89 } catch (SAXException e) { 90 e.printStackTrace(); return; 92 } 93 IssuesScanner scanner = new IssuesScanner(document); 94 final IssuesList list = scanner.visitDocument(); 95 96 System.out.println("list.issues.size " + list.issues.size()); 98 99 table = new JTable (); 100 table.setModel(new AbstractTableModel () { 101 public int getRowCount() { 102 return list.issues.size(); 103 } 104 public int getColumnCount() { 105 return 6; 106 } 107 public String getColumnName(int columnIndex) { 108 return COLUMN_NAMES[columnIndex]; 109 } 110 public Class getColumnClass(int columnIndex) { 111 return COLUMN_CLASSES[columnIndex]; 112 } 113 public Object 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 (issue.component); 120 case 2: 121 return new Integer (issue.subcomponent); 122 case 3: 123 return new Integer (issue.priority); 124 case 4: 125 return new Integer (issue.status); 126 case 5: 127 return new Integer (issue.resolution); 128 } 129 return null; 130 } 131 }); 132 133 setLayout(new BorderLayout ()); 134 add(new JScrollPane (table), BorderLayout.CENTER); 135 } 136 137 public int getPersistenceType() { 138 return PERSISTENCE_NEVER; 139 } 140 141 protected String preferredID() { 142 return "issues"; 143 } 144 } 145 | Popular Tags |