KickJava   Java API By Example, From Geeks To Geeks.

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


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 /**
25  * @author pfiala
26  */

27 public class FinderMethodsTableModel extends QueryMethodsTableModel {
28
29     protected static final String JavaDoc[] COLUMN_NAMES = {Utils.getBundleMessage("LBL_Method"),
30                                                     Utils.getBundleMessage("LBL_ReturnsCollection"),
31                                                     Utils.getBundleMessage("LBL_ResultInterface"),
32                                                     Utils.getBundleMessage("LBL_Query"),
33                                                     Utils.getBundleMessage("LBL_Description")};
34     protected static final int[] COLUMN_WIDTHS = new int[]{200, 100, 120, 200, 100};
35
36     public FinderMethodsTableModel(EntityHelper.Queries queries) {
37         super(COLUMN_NAMES, COLUMN_WIDTHS, queries);
38     }
39
40     public void editRow(int row) {
41 // QueryMethodHelper helper = getQueryMethodHelper(row);
42
// boolean hasLocal = queries.getLocal() != null;
43
// boolean hasRemote = queries.getRemote() != null;
44
// boolean hasLocalMethod = helper.localMethod != null;
45
// boolean hasRemoteMethod = helper.remoteMethod != null;
46
// boolean returnsCollection = helper.returnsCollection();
47
// QueryCustomizer customizer = new QueryCustomizer();
48
// Method method = helper.getPrototypeMethod();
49
// JMIUtils.addException(method, "javax.ejb.FinderException");
50
// Query aQuery = (Query) queries.getFinderMethod(row).clone();
51
// boolean result = customizer.showFinderCustomizer(method, aQuery, returnsCollection,
52
// hasLocal, hasRemote, hasLocalMethod, hasRemoteMethod);
53
// if (result) {
54
// helper.updateFinderMethod(method, aQuery, customizer.finderReturnIsSingle(),
55
// customizer.publishToLocal(), customizer.publishToRemote());
56
// }
57
}
58
59     public int addRow() {
60 // queries.addFinderMethod();
61
return getRowCount() - 1;
62     }
63
64     public QueryMethodHelper getQueryMethodHelper(int row) {
65         return queries.getFinderMethodHelper(row);
66     }
67
68     public int getRowCount() {
69         return queries.getFinderMethodCount();
70     }
71
72     public Object JavaDoc getValueAt(int rowIndex, int columnIndex) {
73         QueryMethodHelper queryMethodHelper = getQueryMethodHelper(rowIndex);
74         switch (columnIndex) {
75             case 0:
76                 return queryMethodHelper.getQueryMethod().getMethodName();
77             case 1:
78                 return new Boolean JavaDoc(queryMethodHelper.returnsCollection());
79             case 2:
80                 return queryMethodHelper.getResultInterface();
81             case 3:
82                 return queryMethodHelper.getEjbQl();
83             case 4:
84                 return queryMethodHelper.getDefaultDescription();
85         }
86         return null;
87     }
88
89     public void setValueAt(Object JavaDoc value, int rowIndex, int columnIndex) {
90         QueryMethodHelper helper = getQueryMethodHelper(rowIndex);
91 // boolean publishToLocal = helper.localMethod != null;
92
// boolean publishToRemote = helper.remoteMethod != null;
93
// boolean returnsCollection = helper.returnsCollection();
94
// Method method = helper.getPrototypeMethod();
95
// Query query = (Query) queries.getFinderMethod(rowIndex).clone();
96
// switch (columnIndex) {
97
// case 1:
98
// returnsCollection = Boolean.TRUE.equals(value);
99
// break;
100
// case 4:
101
// query.setDescription((String) value);
102
// break;
103
// }
104
// helper.updateFinderMethod(method, query, !returnsCollection, publishToLocal, publishToRemote);
105
}
106
107     public Class JavaDoc getColumnClass(int columnIndex) {
108         return columnIndex == 1 ? Boolean JavaDoc.class : String JavaDoc.class;
109     }
110
111     public boolean isCellEditable(int rowIndex, int columnIndex) {
112         if (columnIndex == 1 || columnIndex == 4) {
113             return true;
114         } else {
115             return super.isCellEditable(rowIndex, columnIndex);
116         }
117     }
118 }
119
Popular Tags