View Javadoc

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.protocol;
25  
26  import javax.swing.table.*;
27  import zeus.concepts.*;
28  import zeus.util.*;
29  
30  public class StrategyModel  extends AbstractTableModel {
31  
32        static final int MODE       = 0;
33        static final int FACT       = 1;
34        static final int AGENTS     = 2;
35        static final int RELATIONS  = 3;
36        static final int STRATEGY   = 4;
37        static final int PARAMETERS = 5;
38  
39        static final int      USE    = StrategyInfo.USE;
40        static final int      NO_USE = StrategyInfo.NO_USE;
41  
42        protected String[]  columnNames     = {
43             "Mode", "Fact", "Agents", "Relations", "Strategy", "Parameters"
44        };
45  
46        private StrategyInfo[]   data;
47  
48  
49  //------------------------------------------------------------------------------
50        public StrategyModel() {
51           data = null;
52        }
53  //------------------------------------------------------------------------------
54        public int getRowCount() {
55           return (data == null) ? 0 : data.length;
56        }
57  //------------------------------------------------------------------------------
58        public int getColumnCount() {
59           return columnNames.length;
60        }
61  //------------------------------------------------------------------------------
62        public Object getValueAt(int row, int column) {
63           StrategyInfo info = data[row];
64           switch(column) {
65              case MODE:
66                   return new Boolean(info.getType() == USE);
67  
68              case AGENTS:
69  	         return info.getAgents();
70  
71  	    case RELATIONS:
72                   return info.getRelations();
73  
74              case STRATEGY:
75                   return (info.getType() == USE) ? info.getStrategy() : null;
76  
77              case FACT:
78                   return (info.getFact()).getType();
79  
80              case PARAMETERS:
81                   return info.getParameters();
82           }
83           return null;
84       }
85  //------------------------------------------------------------------------------
86       public String getColumnName(int col) {
87          return  columnNames[col];
88       }
89  //------------------------------------------------------------------------------
90       public Fact getFact(int row) {
91          StrategyInfo info = data[row];
92          return info.getFact();
93       }
94  //------------------------------------------------------------------------------
95       public void setStrategies(StrategyInfo[] data) {
96          this.data = data;
97          fireTableDataChanged();
98       }
99  }