Source Code Cross Referenced for MethodDetailPanel.java in  » IDE-Netbeans » visualweb.api.designer » org » netbeans » modules » visualweb » ejb » ui » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » IDE Netbeans » visualweb.api.designer » org.netbeans.modules.visualweb.ejb.ui 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
003:         *
004:         * Copyright 1997-2007 Sun Microsystems, Inc. All rights reserved.
005:         *
006:         * The contents of this file are subject to the terms of either the GNU
007:         * General Public License Version 2 only ("GPL") or the Common
008:         * Development and Distribution License("CDDL") (collectively, the
009:         * "License"). You may not use this file except in compliance with the
010:         * License. You can obtain a copy of the License at
011:         * http://www.netbeans.org/cddl-gplv2.html
012:         * or nbbuild/licenses/CDDL-GPL-2-CP. See the License for the
013:         * specific language governing permissions and limitations under the
014:         * License.  When distributing the software, include this License Header
015:         * Notice in each file and include the License file at
016:         * nbbuild/licenses/CDDL-GPL-2-CP.  Sun designates this
017:         * particular file as subject to the "Classpath" exception as provided
018:         * by Sun in the GPL Version 2 section of the License file that
019:         * accompanied this code. If applicable, add the following below the
020:         * License Header, with the fields enclosed by brackets [] replaced by
021:         * your own identifying information:
022:         * "Portions Copyrighted [year] [name of copyright owner]"
023:         *
024:         * Contributor(s):
025:         *
026:         * The Original Software is NetBeans. The Initial Developer of the Original
027:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
028:         * Microsystems, Inc. All Rights Reserved.
029:         *
030:         * If you wish your version of this file to be governed by only the CDDL
031:         * or only the GPL Version 2, indicate your decision by adding
032:         * "[Contributor] elects to include this software in this distribution
033:         * under the [CDDL or GPL Version 2] license." If you do not indicate a
034:         * single choice of license, a recipient has the option to distribute
035:         * your version of this file under either the CDDL, the GPL Version 2 or
036:         * to extend the choice of license to its licensees as provided above.
037:         * However, if you add GPL Version 2 code and therefore, elected the GPL
038:         * Version 2 license, then the option applies only if the new code is
039:         * made subject to such option by the copyright holder.
040:         */
041:        /*
042:         * MethodPanel.java
043:         *
044:         * Created on March 1, 2005, 5:39 PM
045:         */
046:
047:        package org.netbeans.modules.visualweb.ejb.ui;
048:
049:        import org.netbeans.modules.visualweb.ejb.datamodel.EjbGroup;
050:        import org.netbeans.modules.visualweb.ejb.datamodel.MethodInfo;
051:        import org.netbeans.modules.visualweb.ejb.datamodel.MethodParam;
052:        import org.netbeans.modules.visualweb.ejb.load.EjbLoaderHelper;
053:        import org.netbeans.modules.visualweb.ejb.util.InvalidParameterNameException;
054:        import org.netbeans.modules.visualweb.ejb.util.MethodParamValidator;
055:        import java.net.URLClassLoader;
056:        import javax.swing.DefaultCellEditor;
057:        import javax.swing.JTextField;
058:        import javax.swing.table.AbstractTableModel;
059:        import javax.swing.table.DefaultTableModel;
060:        import org.openide.DialogDisplayer;
061:        import org.openide.NotifyDescriptor;
062:
063:        /**
064:         * This panel displays the information for the given method.
065:         *
066:         * @author  cao
067:         */
068:        public class MethodDetailPanel extends javax.swing.JPanel {
069:
070:            private EjbGroup ejbGroup;
071:            private MethodInfo methodInfo;
072:
073:            private URLClassLoader classloader;
074:
075:            public MethodDetailPanel(EjbGroup ejbGrp, MethodInfo methodInfo) {
076:                initComponents();
077:                paramTable.setPreferredScrollableViewportSize(paramTable
078:                        .getPreferredSize());
079:
080:                this .ejbGroup = ejbGrp;
081:                this .methodInfo = methodInfo;
082:
083:                displayValue();
084:            }
085:
086:            private void displayValue() {
087:                if (methodInfo != null) {
088:                    signatureTextArea.setText(methodInfo.toString());
089:
090:                    // the method return type is a collection, then the combo box will be
091:                    // enabled to ask for the element class type.
092:                    if (methodInfo.getReturnType().isCollection()) {
093:                        returnTypeTextField.setText(methodInfo.getReturnType()
094:                                .getClassName());
095:                        classNameTextField.setEditable(true);
096:                        classNameTextField.setText(methodInfo.getReturnType()
097:                                .getElemClassName());
098:                    } else {
099:                        returnTypeTextField.setText(methodInfo.getReturnType()
100:                                .getClassName());
101:                        classNameTextField.setText(null);
102:                        classNameTextField.setEditable(false);
103:                    }
104:
105:                    // Init the table with the parameter information
106:                    MethodParamTableModel tableModel = new MethodParamTableModel(
107:                            methodInfo);
108:                    paramTable.setModel(tableModel);
109:
110:                    paramTable.setDefaultEditor(String.class,
111:                            new DefaultCellEditor(new JTextField()));
112:                } else {
113:                    paramTable.setModel(new DefaultTableModel());
114:                    paramTable.setDefaultEditor(String.class,
115:                            new DefaultCellEditor(new JTextField()));
116:                    classNameTextField.setText(null);
117:                    returnTypeTextField.setText(null);
118:                    classNameTextField.setEditable(false);
119:                }
120:            }
121:
122:            public void updateColElemClassName() {
123:                if (methodInfo == null)
124:                    return;
125:
126:                String className = classNameTextField.getText();
127:                if (className != null && className.trim().length() != 0) {
128:                    // Validating
129:                    if (classloader == null)
130:                        classloader = EjbLoaderHelper
131:                                .getEjbGroupClassLoader(ejbGroup);
132:
133:                    // Make sure that the element class specified by the user is a valid one
134:                    try {
135:                        Class c = Class.forName(className, true, classloader);
136:                    } catch (java.lang.ClassNotFoundException ce) {
137:                        NotifyDescriptor d = new NotifyDescriptor.Message(
138:                                "Class " + className + " not found", /*NbBundle.getMessage(MethodNode.class, "PARAMETER_NAME_NOT_UNIQUE", name ),*/
139:                                NotifyDescriptor.ERROR_MESSAGE);
140:                        DialogDisplayer.getDefault().notify(d);
141:                        return;
142:                    }
143:
144:                    methodInfo.getReturnType().setElemClassName(
145:                            className.trim());
146:                } else
147:                    methodInfo.getReturnType().setElemClassName(null);
148:            }
149:
150:            public void stopLastCellEditing() {
151:                // If the table is editing mode, programmatically stop the CellEditor
152:                if (paramTable.isEditing())
153:                    paramTable.getCellEditor().stopCellEditing();
154:            }
155:
156:            public void setMethod(MethodInfo method) {
157:                methodInfo = method;
158:
159:                displayValue();
160:
161:            }
162:
163:            /** This method is called from within the constructor to
164:             * initialize the form.
165:             * WARNING: Do NOT modify this code. The content of this method is
166:             * always regenerated by the Form Editor.
167:             */
168:            // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
169:            private void initComponents() {
170:                java.awt.GridBagConstraints gridBagConstraints;
171:
172:                returnTypeLabel = new javax.swing.JLabel();
173:                paramLabel = new javax.swing.JLabel();
174:                jScrollPane2 = new javax.swing.JScrollPane();
175:                signatureTextArea = new javax.swing.JTextArea();
176:                methodSigLabel = new javax.swing.JLabel();
177:                jScrollPane1 = new javax.swing.JScrollPane();
178:                paramTable = new javax.swing.JTable();
179:                returnTypeTextField = new javax.swing.JTextField();
180:                elemClassTypeLabel = new javax.swing.JLabel();
181:                classNameTextField = new javax.swing.JTextField();
182:
183:                setLayout(new java.awt.GridBagLayout());
184:
185:                returnTypeLabel.setDisplayedMnemonic(java.util.ResourceBundle
186:                        .getBundle(
187:                                "org/netbeans/modules/visualweb/ejb/ui/Bundle")
188:                        .getString("RETURN_TYPE_LABEL_MNEMONIC").charAt(0));
189:                returnTypeLabel.setLabelFor(returnTypeTextField);
190:                java.util.ResourceBundle bundle = java.util.ResourceBundle
191:                        .getBundle("org/netbeans/modules/visualweb/ejb/ui/Bundle"); // NOI18N
192:                returnTypeLabel.setText(bundle.getString("RETURN_TYPE")); // NOI18N
193:                gridBagConstraints = new java.awt.GridBagConstraints();
194:                gridBagConstraints.gridx = 0;
195:                gridBagConstraints.gridy = 2;
196:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
197:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
198:                gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
199:                add(returnTypeLabel, gridBagConstraints);
200:                returnTypeLabel.getAccessibleContext()
201:                        .setAccessibleDescription(
202:                                bundle.getString("RETURN_TYPE_DESC")); // NOI18N
203:
204:                paramLabel.setDisplayedMnemonic(java.util.ResourceBundle
205:                        .getBundle(
206:                                "org/netbeans/modules/visualweb/ejb/ui/Bundle")
207:                        .getString("METHOD_PARAMETERS_LABEL_MNEMONIC")
208:                        .charAt(0));
209:                paramLabel.setLabelFor(paramTable);
210:                paramLabel.setText(bundle.getString("PARAMETER")); // NOI18N
211:                gridBagConstraints = new java.awt.GridBagConstraints();
212:                gridBagConstraints.gridx = 0;
213:                gridBagConstraints.gridy = 4;
214:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
215:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
216:                gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
217:                add(paramLabel, gridBagConstraints);
218:                paramLabel.getAccessibleContext().setAccessibleDescription(
219:                        bundle.getString("PARAMETER_DESC")); // NOI18N
220:
221:                jScrollPane2.setAutoscrolls(true);
222:
223:                signatureTextArea.setEditable(false);
224:                signatureTextArea.setLineWrap(true);
225:                signatureTextArea.setRows(3);
226:                signatureTextArea.setAutoscrolls(false);
227:                jScrollPane2.setViewportView(signatureTextArea);
228:                signatureTextArea.getAccessibleContext().setAccessibleName(
229:                        bundle.getString("METHOD_SIGNATURE")); // NOI18N
230:                signatureTextArea.getAccessibleContext()
231:                        .setAccessibleDescription(
232:                                bundle.getString("METHOD_SIGNATURE")); // NOI18N
233:
234:                gridBagConstraints = new java.awt.GridBagConstraints();
235:                gridBagConstraints.gridx = 0;
236:                gridBagConstraints.gridy = 1;
237:                gridBagConstraints.gridwidth = 2;
238:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
239:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
240:                gridBagConstraints.weightx = 1.0;
241:                gridBagConstraints.weighty = 0.2;
242:                gridBagConstraints.insets = new java.awt.Insets(6, 0, 0, 0);
243:                add(jScrollPane2, gridBagConstraints);
244:
245:                methodSigLabel.setLabelFor(signatureTextArea);
246:                org.openide.awt.Mnemonics.setLocalizedText(methodSigLabel,
247:                        org.openide.util.NbBundle.getMessage(
248:                                MethodDetailPanel.class, "METHOD_SIGNATURE")); // NOI18N
249:                gridBagConstraints = new java.awt.GridBagConstraints();
250:                gridBagConstraints.gridx = 0;
251:                gridBagConstraints.gridy = 0;
252:                gridBagConstraints.gridwidth = java.awt.GridBagConstraints.REMAINDER;
253:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
254:                add(methodSigLabel, gridBagConstraints);
255:                methodSigLabel.getAccessibleContext().setAccessibleDescription(
256:                        org.openide.util.NbBundle.getMessage(
257:                                MethodDetailPanel.class, "METHOD_SIGNATURE")); // NOI18N
258:
259:                paramTable.setModel(new javax.swing.table.DefaultTableModel(
260:                        new Object[][] { { null, null, null, null },
261:                                { null, null, null, null },
262:                                { null, null, null, null },
263:                                { null, null, null, null } }, new String[] {
264:                                "Title 1", "Title 2", "Title 3", "Title 4" }));
265:                jScrollPane1.setViewportView(paramTable);
266:                paramTable.getAccessibleContext().setAccessibleName(
267:                        bundle.getString("PARAMETER_DESC")); // NOI18N
268:                paramTable.getAccessibleContext().setAccessibleDescription(
269:                        bundle.getString("PARAMETER_DESC")); // NOI18N
270:
271:                gridBagConstraints = new java.awt.GridBagConstraints();
272:                gridBagConstraints.gridx = 0;
273:                gridBagConstraints.gridy = 5;
274:                gridBagConstraints.gridwidth = 2;
275:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
276:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
277:                gridBagConstraints.weighty = 0.7;
278:                gridBagConstraints.insets = new java.awt.Insets(12, 0, 6, 0);
279:                add(jScrollPane1, gridBagConstraints);
280:                jScrollPane1.getAccessibleContext().setAccessibleName(
281:                        bundle.getString("PARAMETER")); // NOI18N
282:                jScrollPane1.getAccessibleContext().setAccessibleDescription(
283:                        bundle.getString("PARAMETER_DESC")); // NOI18N
284:
285:                returnTypeTextField.setEditable(false);
286:                gridBagConstraints = new java.awt.GridBagConstraints();
287:                gridBagConstraints.gridx = 1;
288:                gridBagConstraints.gridy = 2;
289:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
290:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
291:                gridBagConstraints.insets = new java.awt.Insets(12, 10, 0, 2);
292:                add(returnTypeTextField, gridBagConstraints);
293:                returnTypeTextField.getAccessibleContext().setAccessibleName(
294:                        bundle.getString("RETURN_TYPE_DESC")); // NOI18N
295:                returnTypeTextField.getAccessibleContext()
296:                        .setAccessibleDescription(
297:                                bundle.getString("RETURN_TYPE_DESC")); // NOI18N
298:
299:                elemClassTypeLabel
300:                        .setDisplayedMnemonic(java.util.ResourceBundle
301:                                .getBundle(
302:                                        "org/netbeans/modules/visualweb/ejb/ui/Bundle")
303:                                .getString("ELEMENT_CLASS_LABEL_MNEMONIC")
304:                                .charAt(0));
305:                elemClassTypeLabel.setLabelFor(classNameTextField);
306:                elemClassTypeLabel.setText(bundle
307:                        .getString("ELEMENT_CLASS_TYPE")); // NOI18N
308:                gridBagConstraints = new java.awt.GridBagConstraints();
309:                gridBagConstraints.gridx = 0;
310:                gridBagConstraints.gridy = 3;
311:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
312:                gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
313:                gridBagConstraints.insets = new java.awt.Insets(12, 0, 0, 0);
314:                add(elemClassTypeLabel, gridBagConstraints);
315:                elemClassTypeLabel.getAccessibleContext()
316:                        .setAccessibleDescription(
317:                                bundle.getString("ELEMENT_CLASS_TYPE_DESC")); // NOI18N
318:
319:                classNameTextField.setText("jTextField1");
320:                gridBagConstraints = new java.awt.GridBagConstraints();
321:                gridBagConstraints.gridx = 1;
322:                gridBagConstraints.gridy = 3;
323:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
324:                gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
325:                gridBagConstraints.insets = new java.awt.Insets(12, 10, 0, 2);
326:                add(classNameTextField, gridBagConstraints);
327:                classNameTextField.getAccessibleContext()
328:                        .setAccessibleDescription(
329:                                bundle.getString("ELEMENT_CLASS_TYPE")); // NOI18N
330:            }// </editor-fold>//GEN-END:initComponents
331:
332:            // Variables declaration - do not modify//GEN-BEGIN:variables
333:            private javax.swing.JTextField classNameTextField;
334:            private javax.swing.JLabel elemClassTypeLabel;
335:            private javax.swing.JScrollPane jScrollPane1;
336:            private javax.swing.JScrollPane jScrollPane2;
337:            private javax.swing.JLabel methodSigLabel;
338:            private javax.swing.JLabel paramLabel;
339:            private javax.swing.JTable paramTable;
340:            private javax.swing.JLabel returnTypeLabel;
341:            private javax.swing.JTextField returnTypeTextField;
342:            private javax.swing.JTextArea signatureTextArea;
343:
344:            // End of variables declaration//GEN-END:variables
345:
346:            public class MethodParamTableModel extends AbstractTableModel {
347:
348:                private MethodInfo method;
349:                private final String[] columnNames = { "Name", "Type" };
350:
351:                public MethodParamTableModel(MethodInfo method) {
352:                    this .method = method;
353:                }
354:
355:                public String getColumnName(int column) {
356:
357:                    return columnNames[column];
358:                }
359:
360:                /**
361:                 * Returns the column class for column <code>column</code>. This
362:                 * is set in the constructor.
363:                 */
364:                public Class getColumnClass(int column) {
365:                    return String.class;
366:                }
367:
368:                public boolean isCellEditable(int row, int column) {
369:                    if (column == 0)
370:                        return true;
371:                    else
372:                        return false;
373:
374:                }
375:
376:                /**
377:                 * Sets the value to <code>aValue</code> for the object
378:                 * <code>node</code> in column <code>column</code>. This is done
379:                 * by using the setter method name, and coercing the passed in
380:                 * value to the specified type.
381:                 */
382:                public void setValueAt(Object aValue, int row, int column) {
383:
384:                    // Ignore null or empty string
385:                    if (aValue == null
386:                            || ((String) aValue).trim().length() == 0)
387:                        return;
388:                    else {
389:                        String argName = ((String) aValue).trim();
390:
391:                        // Make sure it is a legal parameter name
392:                        try {
393:                            MethodParamValidator.validate(argName, method, row);
394:                        } catch (InvalidParameterNameException e) {
395:                            NotifyDescriptor d = new NotifyDescriptor.Message(e
396:                                    .getMessage(),
397:                                    NotifyDescriptor.ERROR_MESSAGE);
398:                            DialogDisplayer.getDefault().notify(d);
399:
400:                            return;
401:                        }
402:
403:                        // Update the methodParam with the new name
404:                        MethodParam param = (MethodParam) method
405:                                .getParameters().get(row);
406:                        param.setName(argName);
407:
408:                        // Temporary here. Will be in the a listener
409:                        signatureTextArea.setText(methodInfo.toString());
410:                    }
411:
412:                }
413:
414:                public int getColumnCount() {
415:                    return columnNames.length;
416:                }
417:
418:                public int getRowCount() {
419:                    if (method.getParameters() == null)
420:                        return 0;
421:                    else
422:                        return method.getParameters().size();
423:
424:                }
425:
426:                public Object getValueAt(int rowIndex, int columnIndex) {
427:                    MethodParam param = (MethodParam) method.getParameters()
428:                            .get(rowIndex);
429:
430:                    if (columnIndex == 0)
431:                        return param.getName();
432:                    else
433:                        //if( columnIndex == 1 )
434:                        return param.getType();
435:
436:                }
437:
438:            }
439:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.