KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > ddloaders > multiview > SelectMethodsTableModel


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-2006 Sun
17  * Microsystems, Inc. All Rights Reserved.
18  */

19
20 package org.netbeans.modules.j2ee.ddloaders.multiview;
21
22 import org.netbeans.modules.j2ee.dd.api.ejb.Query;
23
24 import javax.swing.*;
25 import javax.swing.table.TableCellEditor JavaDoc;
26
27 /**
28  * @author pfiala
29  */

30 public class SelectMethodsTableModel extends QueryMethodsTableModel {
31     
32     protected static final String JavaDoc[] COLUMN_NAMES = {Utils.getBundleMessage("LBL_Method"),
33     Utils.getBundleMessage("LBL_ReturnType"),
34     Utils.getBundleMessage("LBL_Query"),
35     Utils.getBundleMessage("LBL_Description")};
36     protected static final int[] COLUMN_WIDTHS = new int[]{200, 100, 200, 100};
37 // private JComboBox returnMethodComboBox = new JComboBox(FieldCustomizer.COMMON_TYPES);
38
// private TableCellEditor returnMethodEditor = new DefaultCellEditor(returnMethodComboBox);
39

40     public SelectMethodsTableModel(EntityHelper.Queries queries) {
41         super(COLUMN_NAMES, COLUMN_WIDTHS, queries);
42     }
43     
44     public int addRow() {
45 // queries.addSelectMethod();
46
return getRowCount() - 1;
47     }
48     
49     
50     public boolean editRow(int row) {
51         QueryMethodHelper helper = getQueryMethodHelper(row);
52 // QueryCustomizer customizer = new QueryCustomizer();
53
// Method method = helper.getPrototypeMethod();
54
// if (method == null || method.getTypeName() == null){
55
// return false;
56
// }
57
// method.setType(JMIUtils.resolveType(method.getTypeName().getName()));
58
// Query aQuery = (Query) helper.query.clone();
59
// boolean result = customizer.showSelectCustomizer(method, aQuery);
60
// if (result) {
61
// helper.updateSelectMethod(method, aQuery);
62
// }
63
return true;
64     }
65     
66     public QueryMethodHelper getQueryMethodHelper(int row) {
67         return queries.getSelectMethodHelper(row);
68     }
69     
70     public int getRowCount() {
71         return queries.getSelectMethodCount();
72     }
73     
74     public Object JavaDoc getValueAt(int rowIndex, int columnIndex) {
75         QueryMethodHelper queryMethodHelper = getQueryMethodHelper(rowIndex);
76         switch (columnIndex) {
77             case 0:
78                 return queryMethodHelper.getQueryMethod().getMethodName();
79             case 1:
80                 return queryMethodHelper.getReturnType();
81             case 2:
82                 return queryMethodHelper.getEjbQl();
83             case 3:
84                 return queryMethodHelper.getDefaultDescription();
85         }
86         return null;
87     }
88     
89     public void setValueAt(Object JavaDoc value, int rowIndex, int columnIndex) {
90         Query query = (Query) queries.getSelecMethod(rowIndex).clone();
91         if (columnIndex == 3) {
92             query.setDescription((String JavaDoc) value);
93         }
94         QueryMethodHelper helper = getQueryMethodHelper(rowIndex);
95 // Method method = helper.getPrototypeMethod();
96
// helper.updateSelectMethod(method, query);
97
}
98     
99     public TableCellEditor JavaDoc getCellEditor(int columnIndex) {
100 // return columnIndex == 1 ? returnMethodEditor : super.getCellEditor(columnIndex);
101
return null;
102     }
103     
104     public boolean isCellEditable(int rowIndex, int columnIndex) {
105         if (columnIndex == 3) {
106             return true;
107         } else {
108             return super.isCellEditable(rowIndex, columnIndex);
109         }
110     }
111 }
112
Popular Tags