1 /*
2 * The contents of this file are subject to the BT "ZEUS" Open Source
3 * Licence (L77741), Version 1.0 (the "Licence"); you may not use this file
4 * except in compliance with the Licence. You may obtain a copy of the Licence
5 * from $ZEUS_INSTALL/licence.html or alternatively from
6 * http://www.labs.bt.com/projects/agents/zeus/licence.htm
7 *
8 * Except as stated in Clause 7 of the Licence, software distributed under the
9 * Licence is distributed WITHOUT WARRANTY OF ANY KIND, either express or
10 * implied. See the Licence for the specific language governing rights and
11 * limitations under the Licence.
12 *
13 * The Original Code is within the package zeus.*.
14 * The Initial Developer of the Original Code is British Telecommunications
15 * public limited company, whose registered office is at 81 Newgate Street,
16 * London, EC1A 7AJ, England. Portions created by British Telecommunications
17 * public limited company are Copyright 1996-9. All Rights Reserved.
18 *
19 * THIS NOTICE MUST BE INCLUDED ON ANY COPY OF THIS FILE
20 */
21
22
23
24 package zeus.agentviewer.task;
25
26 import javax.swing.table.*;
27 import java.util.*;
28 import zeus.concepts.Fact;
29
30
31
32 public class TaskConditionsTableModel extends AbstractTableModel {
33
34 static final int TYPE = 0;
35 static final int INSTANCE = 1;
36 static final int MODIFIERS = 2;
37
38 protected static final String[] columnNames = {
39 "Fact Type", "Instance", "Modifiers"
40 };
41 private Fact[] data = null;
42 //------------------------------------------------------------------------------
43 public TaskConditionsTableModel() {
44 data = null;
45 }
46 //------------------------------------------------------------------------------
47 public int getRowCount() {
48 if (data == null)
49 return 0;
50 else
51 return data.length;
52 }
53 //------------------------------------------------------------------------------
54 public int getColumnCount() {
55 return columnNames.length;
56 }
57 //------------------------------------------------------------------------------
58 public Object getValueAt(int row, int col) {
59 Fact f = data[row];
60 switch(col) {
61 case TYPE:
62 return f.getType();
63 case INSTANCE:
64 return f.getId();
65 case MODIFIERS:
66 // Note: This should really be done by a cell renderer
67 String s = "";
68 int x = f.getModifiers();
69
70 if ( Fact.isNegative(x) ) s += "NOT ";
71 if ( Fact.isReadOnly(x) ) s += "READ_ONLY";
72 if ( Fact.isLocal(x) ) s += "LOCAL";
73 if ( Fact.isReplaced(x) ) s += "REPLACED";
74 if ( Fact.isSideEffect(x) ) s += "SIDE_EFFECT";
75 return s;
76 }
77 return null;
78 }
79 //------------------------------------------------------------------------------
80 public String getColumnName(int col) {
81 return columnNames[col];
82 }
83
84 //------------------------------------------------------------------------------
85 public void setFacts(Fact[] data){
86 this.data = data;
87 fireTableDataChanged();
88 }
89 //------------------------------------------------------------------------------
90 public Fact getFact(int row){
91 return data[row];
92 }
93 }