KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > db > sql > visualeditor > querybuilder > QueryBuilderInputTableModel


1 /*
2  * The contents of this file are subject to the terms of the Common Development
3  * and Distribution License (the License). You may not use this file except in
4  * compliance with the License.
5  *
6  * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
7  * or http://www.netbeans.org/cddl.txt.
8  *
9  * When distributing Covered Code, include this CDDL Header Notice in each file
10  * and include the License file at http://www.netbeans.org/cddl.txt.
11  * If applicable, add the following below the CDDL Header, with the fields
12  * enclosed by brackets [] replaced by your own identifying information:
13  * "Portions Copyrighted [year] [name of copyright owner]"
14  *
15  * The Original Software is NetBeans. The Initial Developer of the Original
16  * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19 package org.netbeans.modules.db.sql.visualeditor.querybuilder;
20
21 import org.openide.util.NbBundle;
22 import javax.swing.table.DefaultTableModel JavaDoc;
23
24 class QueryBuilderInputTableModel extends DefaultTableModel JavaDoc {
25
26     // Variables
27

28     final String JavaDoc[] columnNames = {
29         // "Column",
30
NbBundle.getMessage(QueryBuilderInputTableModel.class, "COLUMN"), // NOI18N
31
// "Alias",
32
NbBundle.getMessage(QueryBuilderInputTableModel.class, "ALIAS"), // NOI18N
33
// "Table",
34
NbBundle.getMessage(QueryBuilderInputTableModel.class, "TABLE"), // NOI18N
35
// "Output",
36
NbBundle.getMessage(QueryBuilderInputTableModel.class, "OUTPUT"), // NOI18N
37
// "Sort Type",
38
NbBundle.getMessage(QueryBuilderInputTableModel.class, "SORT_TYPE"), // NOI18N
39
// "Sort Order",
40
NbBundle.getMessage(QueryBuilderInputTableModel.class, "SORT_ORDER"), // NOI18N
41
// "Criteria",
42
NbBundle.getMessage(QueryBuilderInputTableModel.class, "CRITERIA"), // NOI18N
43
// "Criteria Order"
44
NbBundle.getMessage(QueryBuilderInputTableModel.class, "CRITERIA_ORDER"), // NOI18N
45
// "Or...",
46
// NbBundle.getMessage(QueryBuilderInputTableModel.class, "OR"), // NOI18N
47
// "Or...",
48
// NbBundle.getMessage(QueryBuilderInputTableModel.class, "OR"), // NOI18N
49
// "Or..."
50
// NbBundle.getMessage(QueryBuilderInputTableModel.class, "OR"), // NOI18N
51
};
52
53     Object JavaDoc[][] data = {
54         { "", "", "", "", Boolean.FALSE, "", "", "" /*, "", "", "" */ } // NOI18N
55
};
56
57
58     // Constructor
59

60     public QueryBuilderInputTableModel ()
61     {
62         super(0, 10);
63         setColumnIdentifiers ( columnNames );
64     }
65
66
67     /*
68      * JTable uses this method to determine the default renderer/
69      * editor for each cell. If we didn't implement this method,
70      * then the last column would contain text ("true"/"false"),
71      * rather than a check box.
72      */

73     public Class JavaDoc getColumnClass(int c) {
74         if ( getRowCount() == 0 ) return (new String JavaDoc("").getClass()); // NOI18N
75
if ( getValueAt(0,c) == null ) return (new String JavaDoc("").getClass()); // NOI18N
76
return getValueAt(0, c).getClass();
77     }
78
79
80     /*
81      * Don't need to implement this method unless your table's editable.
82      */

83     public boolean isCellEditable(int row, int col) {
84         //Note that the data/cell address is constant,
85
//no matter where the cell appears onscreen.
86
if ((col==QueryBuilderInputTable.Column_COLUMN) ||
87             (col==QueryBuilderInputTable.Table_COLUMN)) {
88             return false;
89         }
90         else if ( col==QueryBuilderInputTable.Criteria_COLUMN &&
91                   getValueAt(row, col).equals (
92                       QueryBuilderInputTable.Criteria_Uneditable_String) ) {
93             return false;
94         }
95         else if ( col==QueryBuilderInputTable.CriteriaOrder_COLUMN &&
96                   getValueAt(row, col).equals (
97                     QueryBuilderInputTable.CriteriaOrder_Uneditable_String ) ) {
98             return false;
99         }
100         else {
101             return true;
102         }
103     }
104 }
105
106
Popular Tags