Source Code Cross Referenced for JDBCWizardNamePanel.java in  » IDE-Netbeans » sql.project » org » netbeans » modules » jdbcwizard » wizards » 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 » sql.project » org.netbeans.modules.jdbcwizard.wizards 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * The contents of this file are subject to the terms of the Common Development
003:         * and Distribution License (the License). You may not use this file except in
004:         * compliance with the License.
005:         * 
006:         * You can obtain a copy of the License at http://www.netbeans.org/cddl.html
007:         * or http://www.netbeans.org/cddl.txt.
008:         * 
009:         * When distributing Covered Code, include this CDDL Header Notice in each file
010:         * and include the License file at http://www.netbeans.org/cddl.txt.
011:         * If applicable, add the following below the CDDL Header, with the fields
012:         * enclosed by brackets [] replaced by your own identifying information:
013:         * "Portions Copyrighted [year] [name of copyright owner]"
014:         * 
015:         * The Original Software is NetBeans. The Initial Developer of the Original
016:         * Software is Sun Microsystems, Inc. Portions Copyright 1997-2007 Sun
017:         * Microsystems, Inc. All Rights Reserved.
018:         */
019:
020:        /*
021:         * 
022:         * Copyright 2005 Sun Microsystems, Inc.
023:         * 
024:         * Licensed under the Apache License, Version 2.0 (the "License");
025:         * you may not use this file except in compliance with the License.
026:         * You may obtain a copy of the License at
027:         * 
028:         * 	http://www.apache.org/licenses/LICENSE-2.0
029:         * 
030:         * Unless required by applicable law or agreed to in writing, software
031:         * distributed under the License is distributed on an "AS IS" BASIS,
032:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
033:         * See the License for the specific language governing permissions and
034:         * limitations under the License.
035:         * 
036:         */
037:        package org.netbeans.modules.jdbcwizard.wizards;
038:
039:        import java.awt.BorderLayout;
040:        import java.awt.Component;
041:        import java.awt.GridBagConstraints;
042:        import java.awt.GridBagLayout;
043:        import java.awt.event.KeyAdapter;
044:        import java.awt.event.KeyEvent;
045:        import java.util.HashSet;
046:        import java.util.Iterator;
047:        import java.util.Set;
048:
049:        import javax.swing.JLabel;
050:        import javax.swing.JPanel;
051:        import javax.swing.JTextField;
052:        import javax.swing.event.ChangeEvent;
053:        import javax.swing.event.ChangeListener;
054:
055:        import org.openide.NotifyDescriptor;
056:        import org.openide.WizardDescriptor;
057:        import org.openide.util.HelpCtx;
058:        import org.openide.util.NbBundle;
059:
060:        /**
061:         * Accepts input of unique name for new JDBC Collaboration instance.
062:         * 
063:         * @author
064:         */
065:        public class JDBCWizardNamePanel extends JPanel implements 
066:                WizardDescriptor.Panel {
067:
068:            /**
069:             * 
070:             */
071:            private static final long serialVersionUID = 1L;
072:
073:            class NameFieldKeyAdapter extends KeyAdapter {
074:                /**
075:                 * Overrides default implementation to notify listeners of new collab name value in
076:                 * associated textfield.
077:                 * 
078:                 * @param e KeyEvent to be handled
079:                 */
080:                public void keyReleased(final KeyEvent e) {
081:                    final String collaborationName = JDBCWizardNamePanel.this .textField
082:                            .getText();
083:
084:                    if (collaborationName != null
085:                            && collaborationName.trim().length() != 0) {
086:                        JDBCWizardNamePanel.this .collabName = collaborationName
087:                                .trim();
088:                    } else {
089:                        JDBCWizardNamePanel.this .collabName = null;
090:                    }
091:
092:                    JDBCWizardNamePanel.this .fireChangeEvent();
093:                }
094:            }
095:
096:            protected String collabName;
097:
098:            /* Set <ChangeListeners> */
099:            protected final Set listeners = new HashSet(1);
100:
101:            protected JDBCCollaborationWizard owner;
102:
103:            protected JTextField textField;
104:
105:            protected String title;
106:
107:            /**
108:             * No-arg constructor for this wizard descriptor.
109:             */
110:            public JDBCWizardNamePanel() {
111:                this .setLayout(new BorderLayout());
112:
113:                final JPanel outerPanel = new JPanel();
114:                outerPanel.setLayout(new GridBagLayout());
115:
116:                // Top filler panel to absorb 20% of any expansion up and down the page.
117:                GridBagConstraints gbc = new GridBagConstraints();
118:                gbc.gridx = 0;
119:                gbc.gridy = 0;
120:                gbc.anchor = GridBagConstraints.PAGE_START;
121:                gbc.fill = GridBagConstraints.BOTH;
122:                gbc.weightx = 1.0;
123:                gbc.weighty = 0.2;
124:                outerPanel.add(new JPanel(), gbc);
125:
126:                // Text field label.
127:                final JLabel header = new JLabel(NbBundle.getMessage(
128:                        JDBCWizardNamePanel.class, "LBL_tblwizard_namefield"));
129:                gbc = new GridBagConstraints();
130:                gbc.gridx = 0;
131:                gbc.gridy = 1;
132:                gbc.anchor = GridBagConstraints.LINE_START;
133:                gbc.fill = GridBagConstraints.NONE;
134:                gbc.insets.right = 10;
135:                gbc.weightx = 0.0;
136:                gbc.weighty = 0.0;
137:                outerPanel.add(header, gbc);
138:
139:                // Text field.
140:                this .textField = new JTextField();
141:                this .textField.addKeyListener(new NameFieldKeyAdapter());
142:
143:                gbc = new GridBagConstraints();
144:                gbc.gridx = 0;
145:                gbc.gridy = 2;
146:                gbc.anchor = GridBagConstraints.LINE_START;
147:                gbc.fill = GridBagConstraints.HORIZONTAL;
148:                gbc.weightx = 1.0;
149:                gbc.weighty = 0.0;
150:                outerPanel.add(this .textField, gbc);
151:
152:                // Bottom filler panel to absorb 80% of any expansion up and down the page.
153:                gbc = new GridBagConstraints();
154:                gbc.gridx = 0;
155:                gbc.gridy = 3;
156:                gbc.anchor = GridBagConstraints.PAGE_START;
157:                gbc.fill = GridBagConstraints.BOTH;
158:                gbc.weightx = 1.0;
159:                gbc.weighty = 0.8;
160:                outerPanel.add(new JPanel(), gbc);
161:
162:                this .add(outerPanel, BorderLayout.CENTER);
163:            }
164:
165:            /**
166:             * Create the wizard panel descriptor, using the given panel title, content panel
167:             * 
168:             * @param myOwner JDBCWizard that owns this panel
169:             * @param panelTitle text to display as panel title
170:             */
171:            public JDBCWizardNamePanel(final JDBCCollaborationWizard myOwner,
172:                    final String panelTitle) {
173:                this ();
174:
175:                this .title = panelTitle;
176:                this .setName(this .title);
177:                this .owner = myOwner;
178:            }
179:
180:            /**
181:             * @see JDBCWizardPanel#addChangeListener
182:             */
183:            public final void addChangeListener(final ChangeListener l) {
184:                synchronized (this .listeners) {
185:                    this .listeners.add(l);
186:                }
187:            }
188:
189:            /**
190:             * @see JDBCWizardPanel#fireChangeEvent
191:             */
192:            public void fireChangeEvent() {
193:                Iterator it;
194:
195:                synchronized (this .listeners) {
196:                    it = new HashSet(this .listeners).iterator();
197:                }
198:
199:                final ChangeEvent ev = new ChangeEvent(this );
200:                while (it.hasNext()) {
201:                    ((ChangeListener) it.next()).stateChanged(ev);
202:                }
203:            }
204:
205:            // Get the visual component for the panel. In this template, the component
206:            // is kept separate. This can be more efficient: if the wizard is created
207:            // but never displayed, or not all panels are displayed, it is better to
208:            // create only those which really need to be visible.
209:            /**
210:             * @see JDBCWizardPanel#getComponent
211:             */
212:            public Component getComponent() {
213:                return this ;
214:            }
215:
216:            /**
217:             * Gets current value of collaboration name as entered by user.
218:             * 
219:             * @return current user-specified name
220:             */
221:            public String getCollabName() {
222:                return this .collabName;
223:            }
224:
225:            /**
226:             * @seeJDBCWizardPanel#getHelp
227:             */
228:            public HelpCtx getHelp() {
229:                // Show no Help button for this panel:
230:                return new HelpCtx(JDBCWizardNamePanel.class);
231:
232:            }
233:
234:            /**
235:             * Indicates whether current contents of collaboration name textfield correspond to the name of
236:             * an existing collaboration in the current project.
237:             * 
238:             * @return true if textfield contains the name of an existing collab; false otherwise
239:             */
240:            public boolean isDuplicateCollabName() {
241:                return false;
242:            }
243:
244:            /**
245:             * @see JDBCWizardPanel#isValid
246:             */
247:            public boolean isValid() {
248:                boolean returnVal = false;
249:                if (this .collabName != null) {
250:                    returnVal = true;
251:                }
252:                return returnVal;
253:            }
254:
255:            /**
256:             * @see JDBCWizardPanel#readSettings
257:             */
258:            public void readSettings(final Object settings) {
259:                WizardDescriptor wd = null;
260:                if (settings instanceof  JDBCWizardContext) {
261:                    final JDBCWizardContext wizardContext = (JDBCWizardContext) settings;
262:                    wd = (WizardDescriptor) wizardContext
263:                            .getProperty(JDBCWizardContext.WIZARD_DESCRIPTOR);
264:                } else if (settings instanceof  WizardDescriptor) {
265:                    wd = (WizardDescriptor) settings;
266:                }
267:
268:                if (wd != null) {
269:                    final String myCollabName = (String) wd
270:                            .getProperty(JDBCCollaborationWizard.COLLABORATION_NAME);
271:                    this .textField.setText(myCollabName);
272:                }
273:            }
274:
275:            /**
276:             * @see JDBCWizardPanel#removeChangeListener
277:             */
278:            public final void removeChangeListener(final ChangeListener l) {
279:                synchronized (this .listeners) {
280:                    this .listeners.remove(l);
281:                }
282:            }
283:
284:            /**
285:             * @see JDBCWizardPanel#storeSettings
286:             */
287:            public void storeSettings(final Object settings) {
288:                WizardDescriptor wd = null;
289:                if (settings instanceof  JDBCWizardContext) {
290:                    final JDBCWizardContext wizardContext = (JDBCWizardContext) settings;
291:                    wd = (WizardDescriptor) wizardContext
292:                            .getProperty(JDBCWizardContext.WIZARD_DESCRIPTOR);
293:                } else if (settings instanceof  WizardDescriptor) {
294:                    wd = (WizardDescriptor) settings;
295:                    this .owner.setDescriptor(wd);
296:                }
297:
298:                if (wd != null) {
299:
300:                    final Object selectedOption = wd.getValue();
301:                    if (NotifyDescriptor.CANCEL_OPTION == selectedOption
302:                            || NotifyDescriptor.CLOSED_OPTION == selectedOption) {
303:                        return;
304:                    }
305:
306:                    wd.putProperty(JDBCCollaborationWizard.COLLABORATION_NAME,
307:                            this.collabName);
308:
309:                }
310:            }
311:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.