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  /******************************************************************************
25  * TablesTableModel.java
26  *
27  * The local model for the Tables Table
28  *****************************************************************************/
29  
30  package zeus.ontology.database;
31  
32  import java.util.*;
33  import javax.swing.event.*;
34  import javax.swing.table.*;
35  
36  import zeus.concepts.*;
37  import zeus.ontology.*;
38  
39  
40  public class TablesTableModel extends AbstractTableModel
41  {
42    protected String[]    columnNames = { "Table Name" };
43    protected String[][]  data = null;
44    protected boolean[][] validityInfo = null;
45    //protected OntologyDb  model = null;
46  
47    public TablesTableModel() 
48    {
49      // addChangeListener(parent frame);
50      // refresh();
51    }
52  
53    public void setValues(Vector tablesList)
54    {
55      int rows = tablesList.size();
56      data = new String[rows][1];
57      int r = 0;
58      Enumeration enum = tablesList.elements();
59      while (enum.hasMoreElements())
60      {
61        String s = (String)enum.nextElement();
62        data[r][0] = s;
63        r++;
64      }
65      refresh();
66    }
67  
68    void refresh() {
69      // refresh data from source
70      fireTableStructureChanged();
71    }
72  
73    public int      getColumnCount()     { return columnNames.length; }
74    public int      getRowCount()        { return (data != null) ? data.length : 0; }
75    public String[] getRow(int row)      { return data[row]; }
76  
77    public boolean isCellEditable(int r, int c) { return false;}
78    public String  getColumnName(int c)         { return columnNames[c]; }
79    public Object  getValueAt(int r, int c)     { return data[r][c]; }
80    public boolean isValidEntry(int r, int c)   { return validityInfo[r][c]; }
81  
82    String[][] getRows(int[] input) {
83       String[][] result = new String[input.length][columnNames.length];
84       for(int i = 0; i < result.length; i++ )
85          for(int j = 0; j < result[i].length; j++)
86             result[i][j] = data[input[i]][j];
87       return result;
88    }
89  }