KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > tool > archive > wizard > DDTableModel


1
2 /*
3  * Enhydra Java Application Server Project
4  *
5  * The contents of this file are subject to the Enhydra Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License on
8  * the Enhydra web site ( http://www.enhydra.org/ ).
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific terms governing rights and limitations
13  * under the License.
14  *
15  * The Initial Developer of the Enhydra Application Server is Lutris
16  * Technologies, Inc. The Enhydra Application Server and portions created
17  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
18  * All Rights Reserved.
19  *
20  * Contributor(s):
21  * Paul Mahar
22  *
23  */

24
25 package org.enhydra.tool.archive.wizard;
26
27 // ToolBox
28
import org.enhydra.tool.archive.Descriptor;
29
30 // JDK
31
import javax.swing.table.DefaultTableModel JavaDoc;
32 //
33
public class DDTableModel extends DefaultTableModel JavaDoc {
34     public DDTableModel() {
35         super();
36         addColumn("Required");
37         addColumn("Type");
38         addColumn("Path");
39     }
40
41     public boolean isCellEditable(int row, int col) {
42         return false;
43     }
44
45     protected void setDescriptor(int row, Descriptor ddRow) {
46         Boolean JavaDoc b = new Boolean JavaDoc(ddRow.isRequired());
47
48         setValueAt(b, row, 0);
49         setValueAt(ddRow.getType(), row, 1);
50         setValueAt(ddRow.getPath(), row, 2);
51     }
52
53     protected Descriptor getDescriptor(int row) {
54         Descriptor dd = null;
55         Boolean JavaDoc req = (Boolean JavaDoc) getValueAt(row, 0);
56         String JavaDoc type = (String JavaDoc) getValueAt(row, 1);
57         String JavaDoc path = (String JavaDoc) getValueAt(row, 2);
58         dd = new Descriptor(req.booleanValue(), type);
59         dd.setPath(path);
60         return dd;
61     }
62
63     protected Descriptor[] getDescriptors() {
64        Descriptor[] dd = new Descriptor[getRowCount()];
65        for (int i = 0 ; i < dd.length ; i++) {
66          dd[i] = getDescriptor(i);
67        }
68        return dd;
69     }
70
71     protected void addDescriptor(Descriptor ddRow) {
72         Object JavaDoc[] row = new Object JavaDoc[3];
73
74         row[0] = new Boolean JavaDoc(ddRow.isRequired());
75         row[1] = ddRow.getType();
76         row[2] = ddRow.getPath();
77         addRow(row);
78     }
79
80     protected void clear() {
81         while (getRowCount() > 0) {
82             removeRow(0);
83         }
84     }
85
86 }
87
Popular Tags