KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > netbeans > modules > j2ee > sun > share > configbean > customizers > ejbmodule > PrefetchDisabledPanel


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  * PrefetchDisabledPanel.java
21  *
22  * Created on February 24, 2005, 12:55 AM
23  */

24
25 package org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule;
26
27 import java.util.List JavaDoc;
28 import java.util.ResourceBundle JavaDoc;
29
30 import javax.swing.JPanel JavaDoc;
31 import javax.swing.event.TableModelListener JavaDoc;
32
33 import org.netbeans.modules.j2ee.sun.share.configbean.ConfigQuery;
34 import org.netbeans.modules.j2ee.sun.share.configbean.CmpEntityEjb;
35 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.MethodTableModel;
36 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.common.MethodTablePanel;
37 import org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule.CmpEntityEjbCustomizer;
38
39 /**
40  *
41  * @author Rajeshwar Patil
42  */

43 public class PrefetchDisabledPanel extends MethodTablePanel {
44
45     private CmpEntityEjb cmpEntityEjb;
46     private CmpEntityEjbCustomizer customizer;
47     
48     /** Creates a new instance of PrefetchDisabledPanel */
49     public PrefetchDisabledPanel() {
50     }
51
52
53     private PrefetchDisabledModel model;
54
55     static final ResourceBundle JavaDoc bundle =
56         ResourceBundle.getBundle(
57             "org.netbeans.modules.j2ee.sun.share.configbean.customizers.ejbmodule.Bundle"); // NOI18N
58

59
60     /** Creates a new instance of PrefetchDisabledPanel */
61     public PrefetchDisabledPanel(CmpEntityEjb cmpEntityEjb, CmpEntityEjbCustomizer customizer) {
62         this.cmpEntityEjb = cmpEntityEjb;
63         this.customizer = customizer;
64     }
65
66     protected java.awt.GridBagConstraints JavaDoc getTableGridBagConstraints(){
67         java.awt.GridBagConstraints JavaDoc gridBagConstraints = new java.awt.GridBagConstraints JavaDoc();
68         gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
69         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
70         gridBagConstraints.weightx = 1.0;
71         gridBagConstraints.weighty = 1.0;
72         return gridBagConstraints;
73     }
74
75     protected MethodTableModel getMethodTableModel(){
76         List JavaDoc methodList = getMethodList();
77         List JavaDoc prefetchedMethodList = getPrefetchedMethodList();
78         //printList(methodList);
79
//printList(prefetchedMethodList);
80
model = new PrefetchDisabledModel(cmpEntityEjb, methodList, prefetchedMethodList);
81         model.addTableModelListener((TableModelListener JavaDoc)customizer);
82         return model;
83     }
84
85
86     protected String JavaDoc getTablePaneAcsblName(){
87         return bundle.getString("Prefetched_Method_Acsbl_Name"); //NOI18N
88
}
89
90
91     protected String JavaDoc getTablePaneAcsblDesc(){
92         return bundle.getString("Prefetched_Method_Acsbl_Desc"); //NOI18N
93
}
94
95
96     protected String JavaDoc getTablePaneToolTip(){
97         return bundle.getString("Prefetched_Method_Tool_Tip"); //NOI18N
98
}
99
100
101     protected String JavaDoc getToolTip(int row, int col){
102         if(col == 0){
103             ConfigQuery.MethodData method = (ConfigQuery.MethodData) getMethodList().get(row);
104             if(method != null){
105                 return getMethodSignature(method);
106             }
107         }
108         return null;
109     }
110
111
112     protected String JavaDoc getToolTip(int col){
113         if(col == 0){
114             return bundle.getString("Finder_Method"); //NOI18N
115
}
116         if(col == 1){
117             return bundle.getString("Disable_Prefetching"); //NOI18N
118
}
119         return null;
120     }
121
122
123     public void setData(CmpEntityEjb cmpEntityEjb){
124         this.cmpEntityEjb = cmpEntityEjb;
125         List JavaDoc methodList = getMethodList();
126         List JavaDoc prefetchedMethodList = getPrefetchedMethodList();
127         model.setData(cmpEntityEjb, methodList, prefetchedMethodList);
128         setData();
129     }
130
131
132     private List JavaDoc getMethodList(){
133         //List of all the finder methods of cmp bean
134
if(cmpEntityEjb != null){
135             return cmpEntityEjb.getFinderMethods();
136         }
137         return null;
138     }
139
140
141     private List JavaDoc getPrefetchedMethodList(){
142         //List of all the QueryMethod elements(elements from DD)
143
if(cmpEntityEjb != null){
144             return cmpEntityEjb.getPrefetchedMethods();
145         }
146         return null;
147     }
148
149
150     public void addTableModelListener(TableModelListener JavaDoc listner){
151         model.addTableModelListener(listner);
152     }
153
154
155     protected JPanel JavaDoc getPanel() {
156         return null;
157     }
158
159
160     private void printList(List JavaDoc list){
161        if(list != null){
162            System.out.println("printList list " + list); //NOI18N
163
System.out.println("printList list toString -- " + list.toString()); //NOI18N
164
int size = list.size();
165            for(int i=0; i<size; i++){
166                System.out.println("printList item no: i -- " + list.get(i)); //NOI18N
167
System.out.println("printList item no: i toSring() -- " + list.get(i).toString()); //NOI18N
168
}
169        }
170     }
171
172
173     private String JavaDoc getMethodSignature(ConfigQuery.MethodData method){
174         String JavaDoc signature = method.getOperationName();
175         if(signature != null){
176             signature = signature + "("; //NOI18N
177
List JavaDoc params = method.getParameters();
178             if(params != null){
179                 for(int i=0; i<params.size(); i++){
180                     if(i > 0 ){
181                         signature = signature + "," + params.get(i); //NOI18N
182
}else{
183                         signature = signature + params.get(i); //NOI18N
184
}
185                 }
186             }
187             signature = signature + ")"; //NOI18N
188
}
189         return signature;
190     }
191 }
192
Popular Tags