1 package debugger.gui.debugging.debugviews;
2
3 import debugger.resources.ResourcesFactory;
4 import gate.AnnotationSet;
5 import gate.Document;
6 import gate.LanguageResource;
7
8 import javax.swing.event.TableModelListener;
9 import javax.swing.table.TableModel;
10
11
13
19
20 public class RHSModel implements TableModel {
21
22 public int getRowCount() {
23 debugger.resources.lr.LrModel lrModel = ResourcesFactory.getCurrentLrModel();
26 if (null == lrModel) {
27 return 0;
28 }
29 LanguageResource lr = lrModel.getLr();
30 if (lr instanceof Document) {
31 if (null == ResourcesFactory.getCurrentRuleModel() ||
32 ResourcesFactory.getCurrentRuleModel().getAnnotationHistory() == null) {
33 return 0;
34 }
35 AnnotationSet annSet = ResourcesFactory.getCurrentRuleModel().getAnnotationHistory().getAnnotationSet((Document) lr);
36 if (null != annSet) {
37 return annSet.size();
38 } else {
39 return 0;
40 }
41 } else {
42 return 0;
43 }
44 }
45
46 public int getColumnCount() {
47 return 3;
48 }
49
50 public String getColumnName(int columnIndex) {
51 if (columnIndex == 0) return "Ann ID";
56 if (columnIndex == 1) return "Ann Type";
57 if (columnIndex == 2) return "Features";
58 return null;
59 }
60
61 public Class getColumnClass(int columnIndex) {
62 return String.class;
63 }
64
65 public boolean isCellEditable(int rowIndex, int columnIndex) {
66 return false;
67 }
68
69 public Object getValueAt(int rowIndex, int columnIndex) {
70 LanguageResource lr = ResourcesFactory.getCurrentLrModel().getLr();
71 if (lr instanceof Document) {
72 if (ResourcesFactory.getCurrentRuleModel().getAnnotationHistory() == null) return null;
73 gate.Annotation ann = (gate.Annotation) ResourcesFactory.getCurrentRuleModel().getAnnotationHistory().getAnnotationSet((Document) lr).toArray()[rowIndex];
74 if (null == ann) {
75 return null;
76 }
77 if (columnIndex == 0) return ann.getId();
78 if (columnIndex == 1) return ann.getType();
79 if (columnIndex == 2) return ann.getFeatures().toString();
80 return null;
81 } else {
82 return null;
83 }
84 }
86
87 public void setValueAt(Object aValue, int rowIndex, int columnIndex) {
88 }
89
90 public void addTableModelListener(TableModelListener l) {
91 }
92
93 public void removeTableModelListener(TableModelListener l) {
94 }
95 }
96