Source Code Cross Referenced for ConnectionPanel1.java in  » IDE-Netbeans » form » org » netbeans » modules » form » wizard » 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 » form » org.netbeans.modules.form.wizard 
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-2006 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:        package org.netbeans.modules.form.wizard;
043:
044:        import java.util.*;
045:        import java.beans.EventSetDescriptor;
046:        import javax.swing.tree.*;
047:        import javax.swing.event.*;
048:
049:        import org.openide.awt.Mnemonics;
050:        import org.openide.util.NbBundle;
051:        import org.netbeans.modules.form.*;
052:
053:        /**
054:         * The UI component of the ConnectionWizardPanel1.
055:         *
056:         * @author Tomas Pavek
057:         */
058:
059:        class ConnectionPanel1 extends javax.swing.JPanel {
060:
061:            private ConnectionWizardPanel1 wizardPanel;
062:
063:            /** Creates new form ConnectionPanel1 */
064:            ConnectionPanel1(ConnectionWizardPanel1 wizardPanel) {
065:                this .wizardPanel = wizardPanel;
066:
067:                initComponents();
068:
069:                RADComponent source = wizardPanel.getSourceComponent();
070:
071:                java.util.ResourceBundle bundle = NbBundle
072:                        .getBundle(ConnectionPanel1.class);
073:
074:                setName(bundle.getString("CTL_CW_Step1_Title")); // NOI18N
075:                sourceComponentName.setText(source.getName());
076:
077:                eventNameCombo
078:                        .setEnabled(wizardPanel.getSelectedEvent() != null);
079:
080:                eventNameCombo
081:                        .addActionListener(new java.awt.event.ActionListener() {
082:                            public void actionPerformed(
083:                                    java.awt.event.ActionEvent e) {
084:                                ConnectionPanel1.this .wizardPanel
085:                                        .fireStateChanged();
086:                            }
087:                        });
088:
089:                eventNameCombo.getEditor().addActionListener(
090:                        new java.awt.event.ActionListener() {
091:                            public void actionPerformed(
092:                                    java.awt.event.ActionEvent e) {
093:                                ConnectionPanel1.this .wizardPanel
094:                                        .fireStateChanged();
095:                            }
096:                        });
097:
098:                // populate event tree
099:                final Vector<EventSetNode> eventNodes = new Vector<EventSetNode>();
100:                TreeNode rootNode = new TreeNode() {
101:                    public TreeNode getChildAt(int childIndex) {
102:                        return (TreeNode) eventNodes.elementAt(childIndex);
103:                    }
104:
105:                    public int getChildCount() {
106:                        return eventNodes.size();
107:                    }
108:
109:                    public TreeNode getParent() {
110:                        return null;
111:                    }
112:
113:                    public int getIndex(TreeNode node) {
114:                        return eventNodes.indexOf(node);
115:                    }
116:
117:                    public boolean getAllowsChildren() {
118:                        return true;
119:                    }
120:
121:                    public boolean isLeaf() {
122:                        return false;
123:                    }
124:
125:                    public Enumeration children() {
126:                        return eventNodes.elements();
127:                    }
128:                };
129:
130:                EventSetDescriptor lastEventSetDesc = null;
131:                EventSetNode eventSetNode = null;
132:                List<EventNode> eventSetEvents = null;
133:
134:                Event[] events = source.getAllEvents();
135:                for (int i = 0; i < events.length; i++) {
136:                    Event event = events[i];
137:                    EventSetDescriptor eventSetDesc = event
138:                            .getEventSetDescriptor();
139:
140:                    if (eventSetDesc != lastEventSetDesc) {
141:                        eventSetEvents = new ArrayList<EventNode>();
142:                        eventSetNode = new EventSetNode(eventSetDesc.getName(),
143:                                eventSetEvents);
144:                        eventNodes.add(eventSetNode);
145:                        lastEventSetDesc = eventSetDesc;
146:                    }
147:
148:                    eventSetEvents.add(new EventNode(eventSetNode, event));
149:                }
150:
151:                DefaultTreeSelectionModel treeSelectionModel = new DefaultTreeSelectionModel();
152:                treeSelectionModel
153:                        .addTreeSelectionListener(new TreeSelectionListener() {
154:                            public void valueChanged(TreeSelectionEvent evt) {
155:                                TreePath[] paths = eventSelectTree
156:                                        .getSelectionPaths();
157:                                if ((paths != null) && (paths.length == 1)) {
158:                                    TreeNode node = (TreeNode) paths[0]
159:                                            .getLastPathComponent();
160:                                    if ((node != null)
161:                                            && (node instanceof  EventNode)) {
162:                                        setSelectedEvent(((EventNode) node)
163:                                                .getEvent());
164:                                        return;
165:                                    }
166:                                }
167:                                setSelectedEvent(null);
168:                            }
169:                        });
170:
171:                treeSelectionModel
172:                        .setSelectionMode(DefaultTreeSelectionModel.SINGLE_TREE_SELECTION);
173:                eventSelectTree.setModel(new DefaultTreeModel(rootNode));
174:                eventSelectTree.setSelectionModel(treeSelectionModel);
175:
176:                // localization code
177:                Mnemonics.setLocalizedText(sourceNameLabel, bundle
178:                        .getString("CTL_CW_SourceComponent")); // NOI18N
179:                sourceComponentName.setToolTipText(bundle
180:                        .getString("CTL_CW_SourceComponent_Hint")); // NOI18N
181:                Mnemonics.setLocalizedText(eventSelectLabel, bundle
182:                        .getString("CTL_CW_Event")); // NOI18N
183:                eventSelectTree.setToolTipText(bundle
184:                        .getString("CTL_CW_Event_Hint"));
185:                sourcePanel.setToolTipText(bundle
186:                        .getString("CTL_CW_Event_Hint"));
187:                eventHandlerPanel
188:                        .setBorder(new javax.swing.border.CompoundBorder(
189:                                new javax.swing.border.TitledBorder(
190:                                        new javax.swing.border.EtchedBorder(),
191:                                        bundle
192:                                                .getString("CTL_CW_EventHandlerMethod")), // NOI18N
193:                                new javax.swing.border.EmptyBorder(
194:                                        new java.awt.Insets(5, 5, 5, 5))));
195:                Mnemonics.setLocalizedText(eventNameLabel, bundle
196:                        .getString("CTL_CW_MethodName")); // NOI18N
197:
198:                eventSelectTree.getAccessibleContext()
199:                        .setAccessibleDescription(
200:                                bundle.getString("ACSD_CW_EventTree")); // NOI18N
201:                eventNameCombo.getAccessibleContext().setAccessibleDescription(
202:                        bundle.getString("ACSD_CW_MethodName")); // NOI18N
203:                sourceComponentName.getAccessibleContext()
204:                        .setAccessibleDescription(
205:                                bundle.getString("ACSD_CW_SourceComponent")); // NOI18N
206:                getAccessibleContext().setAccessibleDescription(
207:                        bundle.getString("ACSD_CW_ConnectionPanel1")); // NOI18N
208:                putClientProperty("WizardPanel_contentSelectedIndex",
209:                        new Integer(0)); // NOI18N
210:            }
211:
212:            @Override
213:            public java.awt.Dimension getPreferredSize() {
214:                return new java.awt.Dimension(450, 300);
215:            }
216:
217:            String getEventName() {
218:                return (String) eventNameCombo.getEditor().getItem();
219:            }
220:
221:            private void setSelectedEvent(Event event) {
222:                eventNameCombo.removeAllItems();
223:
224:                if (event != null) {
225:                    eventNameCombo.setEnabled(true);
226:
227:                    FormEvents formEvents = wizardPanel.getSourceComponent()
228:                            .getFormModel().getFormEvents();
229:                    String defaultName = formEvents.findFreeHandlerName(event,
230:                            wizardPanel.getSourceComponent());
231:
232:                    eventNameCombo.addItem(defaultName);
233:
234:                    if (event.hasEventHandlers()) {
235:                        String[] handlers = event.getEventHandlers();
236:                        for (int i = 0; i < handlers.length; i++)
237:                            eventNameCombo.addItem(handlers[i]);
238:                    }
239:
240:                    eventNameCombo.setSelectedIndex(0);
241:                } else
242:                    eventNameCombo.setEnabled(false);
243:
244:                wizardPanel.setSelectedEvent(event);
245:            }
246:
247:            /** This method is called from within the constructor to
248:             * initialize the form.
249:             * WARNING: Do NOT modify this code. The content of this method is
250:             * always regenerated by the Form Editor.
251:             */
252:            private void initComponents() {//GEN-BEGIN:initComponents
253:                sourcePanel = new javax.swing.JPanel();
254:                sourceInfoPanel = new javax.swing.JPanel();
255:                sourceNamePanel = new javax.swing.JPanel();
256:                sourceNameLabel = new javax.swing.JLabel();
257:                sourceComponentName = new javax.swing.JTextField();
258:                eventSelectLabelPanel = new javax.swing.JPanel();
259:                eventSelectLabel = new javax.swing.JLabel();
260:                eventSelectScroll = new javax.swing.JScrollPane();
261:                eventSelectTree = new javax.swing.JTree();
262:                eventHandlerPanel = new javax.swing.JPanel();
263:                eventNameLabel = new javax.swing.JLabel();
264:                eventNameCombo = new javax.swing.JComboBox();
265:
266:                setLayout(new java.awt.BorderLayout(0, 11));
267:
268:                sourcePanel.setLayout(new java.awt.BorderLayout());
269:
270:                sourceInfoPanel.setLayout(new java.awt.GridLayout(2, 1));
271:
272:                sourceNamePanel.setLayout(new java.awt.FlowLayout(
273:                        java.awt.FlowLayout.LEFT, 0, 0));
274:
275:                sourceNameLabel.setLabelFor(sourceComponentName);
276:                sourceNameLabel.setText("Source Component:");
277:                sourceNameLabel.setBorder(new javax.swing.border.EmptyBorder(
278:                        new java.awt.Insets(0, 0, 0, 6)));
279:                sourceNamePanel.add(sourceNameLabel);
280:
281:                sourceComponentName.setEditable(false);
282:                sourceComponentName.setText("jTextField1");
283:                sourceNamePanel.add(sourceComponentName);
284:
285:                sourceInfoPanel.add(sourceNamePanel);
286:
287:                eventSelectLabelPanel.setLayout(new java.awt.FlowLayout(
288:                        java.awt.FlowLayout.LEFT, 0, 3));
289:
290:                eventSelectLabel.setLabelFor(eventSelectTree);
291:                eventSelectLabel.setText("Events");
292:                eventSelectLabelPanel.add(eventSelectLabel);
293:
294:                sourceInfoPanel.add(eventSelectLabelPanel);
295:
296:                sourcePanel.add(sourceInfoPanel, java.awt.BorderLayout.NORTH);
297:
298:                eventSelectScroll.setMaximumSize(new java.awt.Dimension(32767,
299:                        100));
300:                eventSelectTree.setRootVisible(false);
301:                eventSelectTree.setShowsRootHandles(true);
302:                eventSelectScroll.setViewportView(eventSelectTree);
303:
304:                sourcePanel
305:                        .add(eventSelectScroll, java.awt.BorderLayout.CENTER);
306:
307:                add(sourcePanel, java.awt.BorderLayout.CENTER);
308:
309:                eventHandlerPanel.setLayout(new java.awt.BorderLayout(8, 0));
310:
311:                eventHandlerPanel
312:                        .setBorder(new javax.swing.border.TitledBorder(
313:                                "Event Handler Method"));
314:                eventNameLabel.setLabelFor(eventNameCombo);
315:                eventNameLabel.setText("Method Name:");
316:                eventHandlerPanel.add(eventNameLabel,
317:                        java.awt.BorderLayout.WEST);
318:
319:                eventNameCombo.setEditable(true);
320:                eventHandlerPanel.add(eventNameCombo,
321:                        java.awt.BorderLayout.CENTER);
322:
323:                add(eventHandlerPanel, java.awt.BorderLayout.SOUTH);
324:
325:            }//GEN-END:initComponents
326:
327:            // Variables declaration - do not modify//GEN-BEGIN:variables
328:            private javax.swing.JTree eventSelectTree;
329:            private javax.swing.JLabel eventNameLabel;
330:            private javax.swing.JPanel sourcePanel;
331:            private javax.swing.JScrollPane eventSelectScroll;
332:            private javax.swing.JLabel eventSelectLabel;
333:            private javax.swing.JPanel sourceNamePanel;
334:            private javax.swing.JPanel sourceInfoPanel;
335:            private javax.swing.JPanel eventHandlerPanel;
336:            private javax.swing.JLabel sourceNameLabel;
337:            private javax.swing.JTextField sourceComponentName;
338:            private javax.swing.JComboBox eventNameCombo;
339:            private javax.swing.JPanel eventSelectLabelPanel;
340:
341:            // End of variables declaration//GEN-END:variables
342:
343:            // --------
344:            // Innerclasses
345:
346:            static class EventSetNode implements  TreeNode {
347:                private String eventSetName;
348:                private List<EventNode> subNodes;
349:
350:                public EventSetNode(String eventSetName,
351:                        List<EventNode> subNodes) {
352:                    this .eventSetName = eventSetName;
353:                    this .subNodes = subNodes;
354:                }
355:
356:                public TreeNode getChildAt(int childIndex) {
357:                    return subNodes.get(childIndex);
358:                }
359:
360:                public int getChildCount() {
361:                    return subNodes.size();
362:                }
363:
364:                public TreeNode getParent() {
365:                    return null;
366:                }
367:
368:                public int getIndex(TreeNode node) {
369:                    return subNodes.indexOf(node);
370:                }
371:
372:                public boolean getAllowsChildren() {
373:                    return true;
374:                }
375:
376:                public boolean isLeaf() {
377:                    return false;
378:                }
379:
380:                public Enumeration children() {
381:                    return Collections.enumeration(subNodes);
382:                }
383:
384:                @Override
385:                public String toString() {
386:                    return eventSetName;
387:                }
388:            }
389:
390:            static class EventNode implements  TreeNode {
391:                private TreeNode parent;
392:                private Event event;
393:
394:                public EventNode(TreeNode parent, Event event) {
395:                    this .parent = parent;
396:                    this .event = event;
397:                }
398:
399:                public TreeNode getChildAt(int childIndex) {
400:                    return null;
401:                }
402:
403:                public int getChildCount() {
404:                    return 0;
405:                }
406:
407:                public TreeNode getParent() {
408:                    return parent;
409:                }
410:
411:                public int getIndex(TreeNode node) {
412:                    return -1;
413:                }
414:
415:                public boolean getAllowsChildren() {
416:                    return false;
417:                }
418:
419:                public boolean isLeaf() {
420:                    return true;
421:                }
422:
423:                public Enumeration children() {
424:                    return null;
425:                }
426:
427:                @Override
428:                public String toString() {
429:                    if (!event.hasEventHandlers())
430:                        return event.getName();
431:                    String[] handlers = event.getEventHandlers();
432:                    if (handlers.length == 1)
433:                        return event.getName() + " [" + handlers[0] + "]"; // NOI18N
434:                    return event.getName() + " [...]"; // NOI18N
435:                }
436:
437:                Event getEvent() {
438:                    return event;
439:                }
440:            }
441:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.