Source Code Cross Referenced for ServerPropertiesPanel.java in  » IDE-Netbeans » j2ee » org » netbeans » modules » j2ee » websphere6 » ui » 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 » j2ee » org.netbeans.modules.j2ee.websphere6.ui.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:        package org.netbeans.modules.j2ee.websphere6.ui.wizard;
042:
043:        import java.util.*;
044:        import java.awt.*;
045:        import java.awt.event.*;
046:        import javax.swing.*;
047:        import javax.swing.event.*;
048:
049:        import org.openide.*;
050:        import org.openide.awt.Mnemonics;
051:        import org.openide.util.*;
052:        import org.netbeans.modules.j2ee.websphere6.ui.Instance;
053:        import org.netbeans.modules.j2ee.websphere6.ui.Customizer;
054:        import org.netbeans.modules.j2ee.websphere6.ui.InstancesModel;
055:        import org.netbeans.modules.j2ee.websphere6.ui.ServerProperties;
056:
057:        /**
058:         * The second panel of the custom wizard used for registering an instance of
059:         * the server. Here user should choose among the the existing local instances,
060:         * or enter the host/port/username/password conbination for a remote one
061:         *
062:         * @author Kirill Sorokin
063:         */
064:        public class ServerPropertiesPanel extends JPanel implements 
065:                WizardDescriptor.Panel {
066:            /**
067:             * Since the WizardDescriptor does not expose the property name for the
068:             * error message label, we have to keep it here also
069:             */
070:            private final static String PROP_ERROR_MESSAGE = "WizardPanel_errorMessage"; // NOI18N
071:
072:            /**
073:             * The parent wizard descriptor handle
074:             */
075:            private transient WizardDescriptor wizardDescriptor;
076:
077:            /**
078:             * The parent instantiaing iterator handle
079:             */
080:            private transient WSInstantiatingIterator instantiatingIterator;
081:
082:            public class WizardServerProperties extends ServerProperties {
083:                public WizardServerProperties(JComboBox serverCombobox,
084:                        JComboBox localInstancesCombobox,
085:                        JTextField domainPathField, JTextField hostField,
086:                        JTextField portField) {
087:                    super (serverCombobox, localInstancesCombobox,
088:                            domainPathField, hostField, portField);
089:                }
090:
091:                public WizardServerProperties() {
092:                    super ();
093:                }
094:
095:                public class WizardServerTypeActionListener extends
096:                        ServerTypeActionListener {
097:                    public void actionPerformed(ActionEvent e) {
098:                        super .actionPerformed(e);
099:                        isValid();
100:                    }
101:                }
102:            }
103:
104:            private WizardServerProperties wizardServerProperties = new WizardServerProperties();
105:
106:            /**
107:             * Returns wizardServerProperties;
108:             */
109:            public WizardServerProperties getWizardServerProperties() {
110:                return wizardServerProperties;
111:            }
112:
113:            /**
114:             * Creates a new instance of the ServerPropertiesPanel. It initializes all
115:             * the GUI components that appear on the panel.
116:             *
117:             * @param steps the names of the steps in the wizard
118:             * @param index index of this panel in the wizard
119:             * @param listener a listener that will propagate the chage event higher in
120:             *      the hierarchy
121:             * @param instantiatingIterator the parent instantiating iterator
122:             */
123:
124:            public ServerPropertiesPanel(String[] steps, int index,
125:                    ChangeListener listener,
126:                    WSInstantiatingIterator instantiatingIterator) {
127:                // save the instantiating iterator
128:                this .instantiatingIterator = instantiatingIterator;
129:
130:                // set the required properties, so that the panel appear correct in
131:                // the steps
132:                putClientProperty("WizardPanel_contentData", steps); // NOI18N
133:                putClientProperty("WizardPanel_contentSelectedIndex", Integer
134:                        .valueOf(index)); // NOI18N
135:
136:                // register the supplied listener
137:                addChangeListener(listener);
138:
139:                // set the panel's name
140:                setName(steps[index]);
141:
142:                // init the GUI
143:                init();
144:            }
145:
146:            /**
147:             * Returns the named help article associated with this panel
148:             *
149:             * @return the associated help article
150:             */
151:            public HelpCtx getHelp() {
152:                return new HelpCtx("j2eeplugins_registering_app_" + // NOI18N
153:                        "server_websphere"); // NOI18N
154:            }
155:
156:            /**
157:             * Gets the panel's AWT Component object, in our case it coincides with this
158:             * object
159:             *
160:             * @return this
161:             */
162:            public Component getComponent() {
163:                return this ;
164:            }
165:
166:            /**
167:             * Checks whether the data input is valid
168:             *
169:             * @return true if the entered installation directory is valid, false
170:             *      otherwise
171:             */
172:            public boolean isValid() {
173:                // clear the error message
174:                wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, ""); // NOI18N
175:
176:                // if the server instance is local, then check the profile root
177:                // directory for validity
178:                if (serverTypeCombo.getSelectedItem().equals(
179:                        NbBundle.getMessage(Customizer.class,
180:                                "TXT_ServerTypeLocal"))) { // NOI18N
181:                    if (!wizardServerProperties
182:                            .isValidDomainRoot(domainPathField.getText())) {
183:                        wizardDescriptor.putProperty(PROP_ERROR_MESSAGE,
184:                                NbBundle.getMessage(
185:                                        ServerPropertiesPanel.class,
186:                                        "ERR_INVALID_DOMAIN_ROOT")); // NOI18N
187:                        return false;
188:                    }
189:                }
190:
191:                // check the host field (not empty)
192:                if (hostField.getText().trim().equals("")) {
193:                    wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle
194:                            .getMessage(ServerPropertiesPanel.class,
195:                                    "ERR_INVALID_HOST")); // NOI18N
196:                }
197:
198:                // check the port field (not empty and a positive integer)
199:                //if (!portField.getValue().toString().trim().matches("[0-9]+")) {
200:                if (!portField.getText().trim().matches("[0-9]+")) {
201:                    wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle
202:                            .getMessage(ServerPropertiesPanel.class,
203:                                    "ERR_INVALID_PORT")); // NOI18N
204:                }
205:                if (portField.getText().trim().matches("[0-9]+")
206:                        && new java.lang.Integer(portField.getText().trim())
207:                                .intValue() > 65535) {
208:                    wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle
209:                            .getMessage(ServerPropertiesPanel.class,
210:                                    "ERR_INVALID_PORT")); // NOI18N
211:                }
212:
213:                if (((Instance) localInstancesCombo.getSelectedItem())
214:                        .isSecurityEnabled()) {
215:                    wizardDescriptor.putProperty(PROP_ERROR_MESSAGE, NbBundle
216:                            .getMessage(ServerPropertiesPanel.class,
217:                                    "ERR_SECURITY_ENABLED")); // NOI18N
218:                    return false;
219:                }
220:                // no checks for username & password as they may be intentionally blank
221:
222:                // save the data to the parent instantiating iterator
223:                instantiatingIterator.setDomainRoot(domainPathField.getText());
224:                instantiatingIterator.setHost(hostField.getText());
225:                //instantiatingIterator.setPort(portField.getValue().toString());
226:                instantiatingIterator.setPort(portField.getText());
227:                instantiatingIterator.setUsername(usernameField.getText());
228:                instantiatingIterator.setPassword(new String(passwordField
229:                        .getPassword()));
230:                instantiatingIterator.setIsLocal(serverTypeCombo
231:                        .getSelectedItem().equals(
232:                                NbBundle.getMessage(Customizer.class,
233:                                        "TXT_ServerTypeLocal")) ? "true"
234:                        : "false"); // NOI18N
235:                instantiatingIterator
236:                        .setServerName(((Instance) localInstancesCombo
237:                                .getSelectedItem()).getName());
238:                instantiatingIterator
239:                        .setConfigXmlPath(((Instance) localInstancesCombo
240:                                .getSelectedItem()).getConfigXmlPath());
241:                instantiatingIterator
242:                        .setAdminPort(((Instance) localInstancesCombo
243:                                .getSelectedItem()).getAdminPort());
244:                instantiatingIterator
245:                        .setDefaultHostPort(((Instance) localInstancesCombo
246:                                .getSelectedItem()).getDefaultHostPort());
247:
248:                // everything seems ok
249:                return true;
250:            }
251:
252:            ////////////////////////////////////////////////////////////////////////////
253:            // JPanel section
254:            ////////////////////////////////////////////////////////////////////////////
255:            private JLabel domainPathLabel;
256:            private JLabel hostLabel;
257:            private JLabel portLabel;
258:            private JLabel userNameLabel;
259:            private JLabel passwordLabel;
260:            private JPasswordField passwordField;
261:            private JTextField domainPathField;
262:            private JTextField hostField;
263:            private JTextField portField;
264:            private JTextField usernameField;
265:            private JComboBox serverTypeCombo;
266:            private JComboBox localInstancesCombo;
267:            private JLabel localInstanceLabel;
268:            private JLabel serverTypeLabel;
269:            private JTextArea remoteWarningLabel;
270:
271:            /**
272:             * Inits the GUI components
273:             */
274:            private void init() {
275:                // we use the GridBagLayout so we need the GridBagConstraints to
276:                // properly place the components
277:                GridBagConstraints gridBagConstraints;
278:                getAccessibleContext()
279:                        .setAccessibleDescription(
280:                                java.util.ResourceBundle
281:                                        .getBundle(
282:                                                "org/netbeans/modules/j2ee/websphere6/ui/Bundle")
283:                                        .getString(
284:                                                "MSG_ServerPropertiesPanelDescription"));
285:                // initialize the components
286:                domainPathLabel = new JLabel();
287:                domainPathField = new JTextField();
288:                hostLabel = new JLabel();
289:                hostField = new JTextField();
290:                portLabel = new JLabel();
291:                portField = new JTextField();
292:                userNameLabel = new JLabel();
293:                usernameField = new JTextField();
294:                passwordLabel = new JLabel();
295:                passwordField = new JPasswordField();
296:                serverTypeLabel = new JLabel();
297:                serverTypeCombo = new JComboBox(new Object[] { NbBundle
298:                        .getMessage(Customizer.class, "TXT_ServerTypeLocal") /*,
299:                        //NbBundle.getMessage(Customizer.class,
300:                                "TXT_ServerTypeRemote")*/});// NOI18N
301:                localInstanceLabel = new JLabel();
302:                localInstancesCombo = new JComboBox(new InstancesModel(
303:                        wizardServerProperties
304:                                .getServerInstances(instantiatingIterator
305:                                        .getServerRoot())));
306:                remoteWarningLabel = new JTextArea(NbBundle.getMessage(
307:                        ServerPropertiesPanel.class,
308:                        "LBL_remoteIncompatibilityWarning")); // NOI18N
309:
310:                // set the desired layout
311:                setLayout(new GridBagLayout());
312:
313:                // add server type field label
314:                serverTypeLabel.setText(NbBundle.getMessage(Customizer.class,
315:                        "LBL_LocalRemote")); // NOI18N
316:                gridBagConstraints = new GridBagConstraints();
317:                gridBagConstraints.gridx = 0;
318:                gridBagConstraints.gridy = 0;
319:                gridBagConstraints.anchor = GridBagConstraints.EAST;
320:                gridBagConstraints.insets = new Insets(0, 0, 5, 0);
321:                add(serverTypeLabel, gridBagConstraints);
322:
323:                // add server type combobox
324:                serverTypeCombo.addActionListener(wizardServerProperties
325:                        .getServerTypeActionListener());
326:                gridBagConstraints = new GridBagConstraints();
327:                gridBagConstraints.gridx = 1;
328:                gridBagConstraints.gridy = 0;
329:                gridBagConstraints.anchor = GridBagConstraints.WEST;
330:                gridBagConstraints.insets = new Insets(0, 10, 5, 0);
331:                serverTypeCombo
332:                        .getAccessibleContext()
333:                        .setAccessibleName(
334:                                java.util.ResourceBundle
335:                                        .getBundle(
336:                                                "org/netbeans/modules/j2ee/websphere6/ui/Bundle")
337:                                        .getString("TTL_AccessMethod"));
338:                serverTypeCombo
339:                        .getAccessibleContext()
340:                        .setAccessibleDescription(
341:                                java.util.ResourceBundle
342:                                        .getBundle(
343:                                                "org/netbeans/modules/j2ee/websphere6/ui/Bundle")
344:                                        .getString(
345:                                                "MSG_AccessMethodDescription"));
346:                add(serverTypeCombo, gridBagConstraints);
347:
348:                // add local instances field label
349:                localInstanceLabel.setText(NbBundle.getMessage(
350:                        Customizer.class, "LBL_LocalInstances")); // NOI18N
351:                gridBagConstraints = new GridBagConstraints();
352:                gridBagConstraints.gridx = 0;
353:                gridBagConstraints.gridy = 1;
354:                gridBagConstraints.anchor = GridBagConstraints.EAST;
355:                gridBagConstraints.insets = new Insets(0, 0, 5, 0);
356:                add(localInstanceLabel, gridBagConstraints);
357:
358:                // add local instances combobox
359:                localInstancesCombo.addActionListener(wizardServerProperties
360:                        .getInstanceSelectionListener());
361:                localInstancesCombo.addActionListener(new ActionListener() {
362:                    public void actionPerformed(ActionEvent e) {
363:                        fireChangeEvent();
364:                    }
365:                });
366:
367:                gridBagConstraints = new GridBagConstraints();
368:                gridBagConstraints.gridx = 1;
369:                gridBagConstraints.gridy = 1;
370:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
371:                gridBagConstraints.insets = new Insets(0, 10, 5, 0);
372:                localInstancesCombo
373:                        .getAccessibleContext()
374:                        .setAccessibleName(
375:                                java.util.ResourceBundle
376:                                        .getBundle(
377:                                                "org/netbeans/modules/j2ee/websphere6/ui/Bundle")
378:                                        .getString("TTL_LocalInstances"));
379:                localInstancesCombo
380:                        .getAccessibleContext()
381:                        .setAccessibleDescription(
382:                                java.util.ResourceBundle
383:                                        .getBundle(
384:                                                "org/netbeans/modules/j2ee/websphere6/ui/Bundle")
385:                                        .getString("MSG_LocalInstances"));
386:                add(localInstancesCombo, gridBagConstraints);
387:
388:                // add domain path field label
389:                domainPathLabel.setText(NbBundle.getMessage(Customizer.class,
390:                        "LBL_ProfilePath")); // NOI18N
391:                gridBagConstraints = new GridBagConstraints();
392:                gridBagConstraints.gridx = 0;
393:                gridBagConstraints.gridy = 2;
394:                gridBagConstraints.anchor = GridBagConstraints.EAST;
395:                gridBagConstraints.insets = new Insets(0, 0, 5, 0);
396:                add(domainPathLabel, gridBagConstraints);
397:
398:                // add domain path field
399:                domainPathField.setText(""); // NOI18N
400:                domainPathField.setEditable(false);
401:                gridBagConstraints = new GridBagConstraints();
402:                gridBagConstraints.gridx = 1;
403:                gridBagConstraints.gridy = 2;
404:                gridBagConstraints.weightx = 1.0;
405:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
406:                gridBagConstraints.insets = new Insets(0, 10, 5, 0);
407:                domainPathField
408:                        .getAccessibleContext()
409:                        .setAccessibleName(
410:                                java.util.ResourceBundle
411:                                        .getBundle(
412:                                                "org/netbeans/modules/j2ee/websphere6/ui/Bundle")
413:                                        .getString("TTL_ProfilePath"));
414:                domainPathField
415:                        .getAccessibleContext()
416:                        .setAccessibleDescription(
417:                                java.util.ResourceBundle
418:                                        .getBundle(
419:                                                "org/netbeans/modules/j2ee/websphere6/ui/Bundle")
420:                                        .getString("MSG_ProfilePath"));
421:                add(domainPathField, gridBagConstraints);
422:
423:                // add host field label
424:                hostLabel.setText(NbBundle.getMessage(Customizer.class,
425:                        "LBL_Host")); // NOI18N
426:                gridBagConstraints = new GridBagConstraints();
427:                gridBagConstraints.gridx = 0;
428:                gridBagConstraints.gridy = 3;
429:                gridBagConstraints.anchor = GridBagConstraints.EAST;
430:                gridBagConstraints.insets = new Insets(0, 0, 5, 0);
431:                add(hostLabel, gridBagConstraints);
432:
433:                // add host field
434:                hostField.setText(""); // NOI18N
435:                hostField.addKeyListener(new KeyListener());
436:                gridBagConstraints = new GridBagConstraints();
437:                gridBagConstraints.gridx = 1;
438:                gridBagConstraints.gridy = 3;
439:                gridBagConstraints.fill = GridBagConstraints.HORIZONTAL;
440:                gridBagConstraints.insets = new Insets(0, 10, 5, 0);
441:                hostField
442:                        .getAccessibleContext()
443:                        .setAccessibleName(
444:                                java.util.ResourceBundle
445:                                        .getBundle(
446:                                                "org/netbeans/modules/j2ee/websphere6/ui/Bundle")
447:                                        .getString("TTL_Host"));
448:                hostField
449:                        .getAccessibleContext()
450:                        .setAccessibleDescription(
451:                                java.util.ResourceBundle
452:                                        .getBundle(
453:                                                "org/netbeans/modules/j2ee/websphere6/ui/Bundle")
454:                                        .getString("MSG_Host"));
455:                add(hostField, gridBagConstraints);
456:                hostField.setEditable(false);
457:
458:                // add port field label
459:                portLabel.setText(NbBundle.getMessage(Customizer.class,
460:                        "LBL_Port")); // NOI18N
461:                gridBagConstraints = new GridBagConstraints();
462:                gridBagConstraints.gridx = 0;
463:                gridBagConstraints.gridy = 4;
464:                gridBagConstraints.anchor = GridBagConstraints.EAST;
465:                gridBagConstraints.insets = new Insets(0, 0, 5, 0);
466:                add(portLabel, gridBagConstraints);
467:
468:                // add port field
469:
470:                //portField.setModel(new SpinnerNumberModel(0,0,65535,1));
471:                //portField.setValue(new Integer(8880)); // NOI18N
472:                portField.setText("8880");// NOI18N
473:                portField.addKeyListener(new KeyListener());
474:                portField.setPreferredSize(new Dimension(50, 20));
475:                portField.setFont(hostField.getFont());
476:                gridBagConstraints = new GridBagConstraints();
477:                gridBagConstraints.gridx = 1;
478:                gridBagConstraints.gridy = 4;
479:                gridBagConstraints.anchor = GridBagConstraints.WEST;
480:                gridBagConstraints.insets = new Insets(0, 10, 5, 0);
481:                portField
482:                        .getAccessibleContext()
483:                        .setAccessibleName(
484:                                java.util.ResourceBundle
485:                                        .getBundle(
486:                                                "org/netbeans/modules/j2ee/websphere6/ui/Bundle")
487:                                        .getString("TTL_Port"));
488:                portField
489:                        .getAccessibleContext()
490:                        .setAccessibleDescription(
491:                                java.util.ResourceBundle
492:                                        .getBundle(
493:                                                "org/netbeans/modules/j2ee/websphere6/ui/Bundle")
494:                                        .getString("MSG_Port"));
495:                add(portField, gridBagConstraints);
496:                portField.setEditable(false);
497:
498:                // add username field label
499:                userNameLabel.setText(NbBundle.getMessage(Customizer.class,
500:                        "LBL_Username")); // NOI18N
501:                gridBagConstraints = new GridBagConstraints();
502:                gridBagConstraints.gridx = 0;
503:                gridBagConstraints.gridy = 5;
504:                gridBagConstraints.anchor = GridBagConstraints.EAST;
505:                gridBagConstraints.insets = new Insets(0, 0, 5, 0);
506:                add(userNameLabel, gridBagConstraints);
507:
508:                // add username field
509:                usernameField.setText(""); // NOI18N
510:                usernameField.addKeyListener(new KeyListener());
511:                usernameField.setPreferredSize(new Dimension(100, 20));
512:                gridBagConstraints = new GridBagConstraints();
513:                gridBagConstraints.gridx = 1;
514:                gridBagConstraints.gridy = 5;
515:                gridBagConstraints.anchor = GridBagConstraints.WEST;
516:                gridBagConstraints.insets = new Insets(0, 10, 5, 0);
517:                usernameField
518:                        .getAccessibleContext()
519:                        .setAccessibleName(
520:                                java.util.ResourceBundle
521:                                        .getBundle(
522:                                                "org/netbeans/modules/j2ee/websphere6/ui/Bundle")
523:                                        .getString("TTL_Username"));
524:                usernameField
525:                        .getAccessibleContext()
526:                        .setAccessibleDescription(
527:                                java.util.ResourceBundle
528:                                        .getBundle(
529:                                                "org/netbeans/modules/j2ee/websphere6/ui/Bundle")
530:                                        .getString("MSG_Username"));
531:                add(usernameField, gridBagConstraints);
532:
533:                // add password field label
534:                passwordLabel.setText(NbBundle.getMessage(Customizer.class,
535:                        "LBL_Password")); // NOI18N
536:                gridBagConstraints = new GridBagConstraints();
537:                gridBagConstraints.gridx = 0;
538:                gridBagConstraints.gridy = 6;
539:                gridBagConstraints.anchor = GridBagConstraints.EAST;
540:                gridBagConstraints.insets = new Insets(0, 0, 5, 0);
541:                add(passwordLabel, gridBagConstraints);
542:
543:                // add password field
544:                passwordField.setPreferredSize(new Dimension(100, 20));
545:                passwordField.addKeyListener(new KeyListener());
546:                gridBagConstraints = new GridBagConstraints();
547:                gridBagConstraints.gridx = 1;
548:                gridBagConstraints.gridy = 6;
549:                gridBagConstraints.anchor = GridBagConstraints.WEST;
550:                gridBagConstraints.insets = new Insets(0, 10, 5, 0);
551:                passwordField
552:                        .getAccessibleContext()
553:                        .setAccessibleName(
554:                                java.util.ResourceBundle
555:                                        .getBundle(
556:                                                "org/netbeans/modules/j2ee/websphere6/ui/Bundle")
557:                                        .getString("TTL_Password"));
558:                passwordField
559:                        .getAccessibleContext()
560:                        .setAccessibleDescription(
561:                                java.util.ResourceBundle
562:                                        .getBundle(
563:                                                "org/netbeans/modules/j2ee/websphere6/ui/Bundle")
564:                                        .getString("MSG_Password"));
565:                add(passwordField, gridBagConstraints);
566:
567:                // remote warning label
568:                remoteWarningLabel.setEditable(false);
569:                remoteWarningLabel.setWrapStyleWord(true);
570:                remoteWarningLabel.setLineWrap(true);
571:                remoteWarningLabel.setOpaque(false);
572:                remoteWarningLabel
573:                        .getAccessibleContext()
574:                        .setAccessibleName(
575:                                java.util.ResourceBundle
576:                                        .getBundle(
577:                                                "org/netbeans/modules/j2ee/websphere6/ui/wizard/Bundle")
578:                                        .getString("TTL_RemoteWarningA11Name"));
579:                remoteWarningLabel
580:                        .getAccessibleContext()
581:                        .setAccessibleDescription(
582:                                java.util.ResourceBundle
583:                                        .getBundle(
584:                                                "org/netbeans/modules/j2ee/websphere6/ui/wizard/Bundle")
585:                                        .getString(
586:                                                "MSG_RemoteWarningA11Description"));
587:
588:                gridBagConstraints = new GridBagConstraints();
589:                gridBagConstraints.gridx = 0;
590:                gridBagConstraints.gridy = 7;
591:                gridBagConstraints.gridwidth = 2;
592:                gridBagConstraints.fill = GridBagConstraints.BOTH;
593:                gridBagConstraints.anchor = GridBagConstraints.NORTH;
594:                gridBagConstraints.weighty = 1.0;
595:                gridBagConstraints.insets = new Insets(10, 0, 5, 0);
596:                add(remoteWarningLabel, gridBagConstraints);
597:
598:                setMnemonics(domainPathLabel);
599:                domainPathLabel.setLabelFor(domainPathField);
600:                setMnemonics(serverTypeLabel);
601:                serverTypeLabel.setLabelFor(serverTypeCombo);
602:                setMnemonics(localInstanceLabel);
603:                localInstanceLabel.setLabelFor(localInstancesCombo);
604:                setMnemonics(hostLabel);
605:                hostLabel.setLabelFor(hostField);
606:                setMnemonics(portLabel);
607:                portLabel.setLabelFor(portField);
608:                setMnemonics(userNameLabel);
609:                userNameLabel.setLabelFor(usernameField);
610:                setMnemonics(passwordLabel);
611:                passwordLabel.setLabelFor(passwordField);
612:
613:                wizardServerProperties.setVariables(serverTypeCombo,
614:                        localInstancesCombo, domainPathField, hostField,
615:                        portField, instantiatingIterator);
616:            }
617:
618:            private void setMnemonics(JLabel label) {
619:                String name = label.getText();
620:                int index = Mnemonics.findMnemonicAmpersand(name);
621:                if (index < 0) {
622:                    Mnemonics.setLocalizedText(label, name);
623:                    label.setDisplayedMnemonic(name.charAt(0));
624:                } else {
625:                    Mnemonics.setLocalizedText(label, name.substring(0, index)
626:                            + name.substring(index + 1));
627:                    label.setDisplayedMnemonic(name.charAt(index + 1));
628:                }
629:            }
630:
631:            ////////////////////////////////////////////////////////////////////////////
632:            // Settings section
633:            ////////////////////////////////////////////////////////////////////////////
634:            /**
635:             * Reads the supplied setting. The only one that can arrive this way is the
636:             * WizardDescriptor, thus we only convert the incoming object and save
637:             *
638:             * @param object the incoming setting (WizardDescriptor)
639:             */
640:            public void readSettings(Object object) {
641:                this .wizardDescriptor = (WizardDescriptor) object;
642:            }
643:
644:            /**
645:             * Stores the supplied setting. I don't know the purpose of this method
646:             * thus we do not implement it
647:             */
648:            public void storeSettings(Object object) {
649:            }
650:
651:            ////////////////////////////////////////////////////////////////////////////
652:            // Listeners section
653:            ////////////////////////////////////////////////////////////////////////////
654:            /**
655:             * The registrered listeners vector
656:             */
657:            private final ChangeSupport changeSupport = new ChangeSupport(this );
658:
659:            /**
660:             * Removes a registered listener
661:             *
662:             * @param listener the listener to be removed
663:             */
664:            public void removeChangeListener(ChangeListener listener) {
665:                changeSupport.removeChangeListener(listener);
666:            }
667:
668:            /**
669:             * Adds a listener
670:             *
671:             * @param listener the listener to be added
672:             */
673:            public void addChangeListener(ChangeListener listener) {
674:                changeSupport.addChangeListener(listener);
675:            }
676:
677:            /**
678:             * Fires a change event originating from this panel
679:             */
680:            private void fireChangeEvent() {
681:                changeSupport.fireChange();
682:            }
683:
684:            ////////////////////////////////////////////////////////////////////////////
685:            // Inner classes
686:            ////////////////////////////////////////////////////////////////////////////
687:            /**
688:             * Simple key listener that delegates the event to its parent's listeners
689:             *
690:             * @author Kirill Sorokin
691:             */
692:            public class KeyListener extends KeyAdapter {
693:                /**
694:                 * This method is called when a user presses a key on the keyboard
695:                 */
696:                public void keyTyped(KeyEvent event) {
697:                    fireChangeEvent();
698:                }
699:
700:                /**
701:                 * This method is called when a user releases a key on the keyboard
702:                 */
703:                public void keyReleased(KeyEvent event) {
704:                    fireChangeEvent();
705:                }
706:            }
707:        }
ww___w___.___j__a_va__2_s_.__c__o_m__ | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.