Source Code Cross Referenced for AddServerPropertiesVisualPanel.java in  » IDE-Netbeans » j2ee » org » netbeans » modules » j2ee » jboss4 » ide » 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 » j2ee » org.netbeans.modules.j2ee.jboss4.ide.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-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.jboss4.ide.ui;
042:
043:        import java.awt.GridBagConstraints;
044:        import java.awt.event.ActionEvent;
045:        import java.awt.event.ActionListener;
046:        import java.awt.event.KeyEvent;
047:        import java.awt.event.KeyListener;
048:        import java.io.File;
049:        import java.util.Enumeration;
050:        import java.util.HashSet;
051:        import java.util.Hashtable;
052:        import java.util.Iterator;
053:        import java.util.Set;
054:        import javax.swing.AbstractListModel;
055:        import javax.swing.ComboBoxModel;
056:        import javax.swing.JComboBox;
057:        import javax.swing.JFileChooser;
058:        import javax.swing.JLabel;
059:        import javax.swing.JPanel;
060:        import javax.swing.JPasswordField;
061:        import javax.swing.JTextField;
062:        import javax.swing.event.ChangeEvent;
063:        import javax.swing.event.ChangeListener;
064:        import org.openide.util.NbBundle;
065:
066:        /**
067:         *
068:         * @author Ivan Sidorkin
069:         */
070:        public class AddServerPropertiesVisualPanel extends JPanel {
071:
072:            private final Set listeners = new HashSet();
073:
074:            private javax.swing.JComboBox domainField; // Domain name (list of registered domains) can be edited
075:            private javax.swing.JTextField domainPathField; //   
076:            private javax.swing.JLabel domainLabel;
077:            private javax.swing.JLabel domainPathLabel;
078:            private javax.swing.JLabel label1;
079:            private javax.swing.JPanel panel1;
080:            private javax.swing.JLabel hostLabel;
081:            private javax.swing.JTextField hostField;
082:            private javax.swing.JLabel portLabel;
083:            private javax.swing.JTextField portField;
084:            private javax.swing.JLabel userLabel;
085:            private javax.swing.JTextField userField;
086:            private javax.swing.JLabel passwordLabel;
087:            private javax.swing.JPasswordField passwordField;
088:            private javax.swing.JComboBox serverType; // Local or Remote
089:
090:            /** Creates a new instance of AddServerPropertiesVisualPanel */
091:            public AddServerPropertiesVisualPanel() {
092:                init();
093:                setName(NbBundle.getMessage(
094:                        AddServerPropertiesVisualPanel.class,
095:                        "TITLE_ServerProperties")); //NOI18N 
096:            }
097:
098:            public void addChangeListener(ChangeListener l) {
099:                synchronized (listeners) {
100:                    listeners.add(l);
101:                }
102:            }
103:
104:            public void removeChangeListener(ChangeListener l) {
105:                synchronized (listeners) {
106:                    listeners.remove(l);
107:                }
108:            }
109:
110:            private void somethingChanged() {
111:                fireChangeEvent();
112:            }
113:
114:            private void fireChangeEvent() {
115:                Iterator it;
116:                synchronized (listeners) {
117:                    it = new HashSet(listeners).iterator();
118:                }
119:                ChangeEvent ev = new ChangeEvent(this );
120:                while (it.hasNext()) {
121:                    ((ChangeListener) it.next()).stateChanged(ev);
122:                }
123:            }
124:
125:            public boolean isLocalServer() {
126:                if (serverType.getSelectedItem().equals("Local"))
127:                    return true;
128:                else
129:                    return false;
130:            }
131:
132:            public String getHost() {
133:                return hostField.getText().trim();
134:            }
135:
136:            public String getPort() {
137:                return portField.getText().trim();
138:            }
139:
140:            public String getUser() {
141:                return userField.getText();
142:            }
143:
144:            public String getPassword() {
145:                return new String(passwordField.getPassword());
146:            }
147:
148:            public String getDomainPath() {
149:                return domainPathField.getText();
150:            }
151:
152:            public String getDomain() {
153:                return (String) domainField.getSelectedItem();
154:            }
155:
156:            private void domainChanged() {
157:                DomainComboModel model = (DomainComboModel) domainField
158:                        .getModel();
159:
160:                String path = model.getCurrentPath();
161:                domainPathField.setText(path);
162:                portField.setText(JBPluginUtils.getHTTPConnectorPort(path));
163:
164:                //    serverChanged();
165:                fireChangeEvent();
166:            }
167:
168:            void installLocationChanged() {
169:                DomainComboModel domainModel = (DomainComboModel) domainField
170:                        .getModel();
171:                String serverLocation = JBPluginProperties.getInstance()
172:                        .getInstallLocation();
173:                domainModel.setDomains(JBPluginUtils
174:                        .getRegisteredDomains(serverLocation));
175:                domainChanged();
176:            }
177:
178:            private void serverTypeChanged() {
179:
180:                if (serverType.getSelectedItem().equals("Local")) { //NOI18N 
181:                    domainLabel.setVisible(true);
182:                    domainField.setVisible(true);
183:
184:                    domainPathLabel.setVisible(true);
185:                    domainPathField.setVisible(true);
186:                    //            browseButton.setVisible(true);
187:
188:                    hostField.setEditable(false);
189:                    //      portField.setEditable(false);
190:
191:                    //            serverChanged();
192:
193:                } else { // REMOTE
194:
195:                    domainLabel.setVisible(false);
196:                    domainField.setVisible(false);
197:
198:                    domainPathLabel.setVisible(false);
199:                    domainPathField.setVisible(false);
200:                    //            browseButton.setVisible(false);
201:
202:                    //            serverListField.setVisible(false);
203:                    //            serverListLabel.setVisible(false);
204:
205:                    hostField.setEditable(true);
206:                    portField.setEditable(true);
207:                }
208:
209:                somethingChanged();
210:            }
211:
212:            private void init() {
213:
214:                // Object[] domainsList = WLPluginUtils.getRegisteredDomains().keySet().toArray(new String[WLPluginUtils.getRegisteredDomains().keySet().size()]);
215:
216:                java.awt.GridBagConstraints gridBagConstraints;
217:
218:                label1 = new JLabel(NbBundle.getMessage(
219:                        AddServerPropertiesVisualPanel.class,
220:                        "TXT_PROPERTY_TEXT")); //NOI18N
221:
222:                serverType = new JComboBox(new String[] { "Local", "Remote" });//NOI18N
223:                serverType.addActionListener(new ActionListener() {
224:                    public void actionPerformed(ActionEvent e) {
225:                        serverTypeChanged();
226:                    }
227:                });
228:
229:                domainPathLabel = new JLabel(NbBundle.getMessage(
230:                        AddServerPropertiesVisualPanel.class, "LBL_DomainPath"));//NOI18N
231:                domainPathField = new JTextField();
232:                domainPathField.setColumns(20);
233:                domainPathField.getAccessibleContext()
234:                        .setAccessibleDescription(
235:                                NbBundle.getMessage(
236:                                        AddServerPropertiesVisualPanel.class,
237:                                        "LBL_DomainPath"));
238:                domainPathField.getAccessibleContext().setAccessibleName(
239:                        NbBundle.getMessage(
240:                                AddServerPropertiesVisualPanel.class,
241:                                "LBL_DomainPath"));
242:
243:                panel1 = new JPanel();
244:
245:                //Domain combobox
246:                domainLabel = new JLabel();
247:                String serverLocation = JBPluginProperties.getInstance()
248:                        .getInstallLocation();
249:                domainField = new JComboBox(new DomainComboModel(JBPluginUtils
250:                        .getRegisteredDomains(serverLocation)));
251:                domainField.getAccessibleContext().setAccessibleName(
252:                        NbBundle.getMessage(
253:                                AddServerPropertiesVisualPanel.class,
254:                                "LBL_Domain"));
255:                domainField.getAccessibleContext().setAccessibleDescription(
256:                        NbBundle.getMessage(
257:                                AddServerPropertiesVisualPanel.class,
258:                                "LBL_Domain"));
259:                //domainField.setEditable(true);
260:                domainField.addActionListener(new ActionListener() {
261:                    public void actionPerformed(ActionEvent e) {
262:                        domainChanged();
263:                    }
264:                });
265:
266:                domainLabel.setLabelFor(domainField);
267:                org.openide.awt.Mnemonics.setLocalizedText(domainLabel,
268:                        org.openide.util.NbBundle.getMessage(
269:                                AddServerPropertiesVisualPanel.class,
270:                                "LBL_Domain")); // NOI18N
271:
272:                hostLabel = new JLabel();
273:                org.openide.awt.Mnemonics.setLocalizedText(hostLabel, NbBundle
274:                        .getMessage(AddServerPropertiesVisualPanel.class,
275:                                "LBL_Host")); // NOI18N
276:
277:                hostField = new JTextField();
278:                hostField.setColumns(20);
279:                hostField.setEditable(false);
280:                hostField.getAccessibleContext().setAccessibleDescription(
281:                        NbBundle.getMessage(
282:                                AddServerPropertiesVisualPanel.class,
283:                                "LBL_Host"));
284:                hostField.getAccessibleContext().setAccessibleName(
285:                        NbBundle.getMessage(
286:                                AddServerPropertiesVisualPanel.class,
287:                                "LBL_Host"));
288:                hostField.addKeyListener(new SomeChangesListener());
289:
290:                hostLabel.setLabelFor(hostField);
291:
292:                portLabel = new JLabel();
293:                org.openide.awt.Mnemonics.setLocalizedText(portLabel, NbBundle
294:                        .getMessage(AddServerPropertiesVisualPanel.class,
295:                                "LBL_Port")); // NOI18N
296:
297:                portField = new JTextField();
298:                portField.setColumns(20);
299:                portField.getAccessibleContext().setAccessibleDescription(
300:                        NbBundle.getMessage(
301:                                AddServerPropertiesVisualPanel.class,
302:                                "LBL_Port"));
303:                portField.getAccessibleContext().setAccessibleName(
304:                        NbBundle.getMessage(
305:                                AddServerPropertiesVisualPanel.class,
306:                                "LBL_Port"));
307:                //portField.setEditable(false);
308:                portField.addKeyListener(new SomeChangesListener());
309:
310:                portLabel.setLabelFor(portField);
311:
312:                userLabel = new JLabel(NbBundle.getMessage(
313:                        AddServerPropertiesVisualPanel.class, "LBL_User"));//NOI18N
314:                userField = new JTextField();
315:                userField.addKeyListener(new SomeChangesListener());
316:
317:                passwordLabel = new JLabel(NbBundle.getMessage(
318:                        AddServerPropertiesVisualPanel.class, "LBL_Password"));//NOI18N
319:                passwordField = new JPasswordField();
320:                passwordField.addKeyListener(new SomeChangesListener());
321:
322:                setLayout(new java.awt.GridBagLayout());
323:
324:                setFocusable(false);
325:
326:                setMinimumSize(new java.awt.Dimension(280, 217));
327:                //   setNextFocusableComponent(domainPathField);
328:
329:                //-------------- some label --------------------
330:                gridBagConstraints = new java.awt.GridBagConstraints();
331:                gridBagConstraints.gridwidth = 3;
332:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
333:                gridBagConstraints.weightx = 1.0;
334:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 5);
335:                add(label1, gridBagConstraints);
336:
337:                gridBagConstraints = new java.awt.GridBagConstraints();
338:                gridBagConstraints.gridy = 0;
339:                gridBagConstraints.gridx = 2;
340:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 5);
341:
342:                add(serverType, gridBagConstraints);
343:
344:                //-------------- domain ---------------
345:                gridBagConstraints = new java.awt.GridBagConstraints();
346:                gridBagConstraints.gridx = 0;
347:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 5);
348:                gridBagConstraints.anchor = GridBagConstraints.WEST;
349:                add(domainLabel, gridBagConstraints);
350:
351:                gridBagConstraints = new java.awt.GridBagConstraints();
352:                gridBagConstraints.gridy = 1;
353:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
354:                gridBagConstraints.weightx = 1.0;
355:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 5);
356:                add(domainField, gridBagConstraints);
357:
358:                //-------------- domain path ---------------
359:                gridBagConstraints = new java.awt.GridBagConstraints();
360:                gridBagConstraints.gridx = 0;
361:                gridBagConstraints.gridy = 2;
362:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 5);
363:                add(domainPathLabel, gridBagConstraints);
364:
365:                gridBagConstraints = new java.awt.GridBagConstraints();
366:                gridBagConstraints.gridy = 2;
367:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
368:                gridBagConstraints.weightx = 1.0;
369:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 5);
370:                add(domainPathField, gridBagConstraints);
371:
372:                //        gridBagConstraints = new java.awt.GridBagConstraints();
373:                //        gridBagConstraints.gridy = 2;
374:                //        gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
375:                //        add(browseButton, gridBagConstraints);
376:                //        
377:
378:                //-------------- host ---------------
379:                gridBagConstraints = new java.awt.GridBagConstraints();
380:                gridBagConstraints.gridx = 0;
381:                gridBagConstraints.gridy = 3;
382:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 5);
383:                gridBagConstraints.anchor = GridBagConstraints.WEST;
384:                add(hostLabel, gridBagConstraints);
385:
386:                gridBagConstraints = new java.awt.GridBagConstraints();
387:                gridBagConstraints.gridy = 3;
388:                gridBagConstraints.gridx = 1;
389:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
390:                gridBagConstraints.weightx = 1.0;
391:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 5);
392:                add(hostField, gridBagConstraints);
393:
394:                //-------------- port ---------------
395:                gridBagConstraints = new java.awt.GridBagConstraints();
396:                gridBagConstraints.gridx = 0;
397:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 0);
398:                gridBagConstraints.anchor = GridBagConstraints.WEST;
399:                add(portLabel, gridBagConstraints);
400:
401:                gridBagConstraints = new java.awt.GridBagConstraints();
402:                gridBagConstraints.gridy = 4;
403:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
404:                gridBagConstraints.weightx = 1.0;
405:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 5);
406:                add(portField, gridBagConstraints);
407:
408:                //-------------- User ---------------
409:                gridBagConstraints = new java.awt.GridBagConstraints();
410:                gridBagConstraints.gridx = 0;
411:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 5);
412:                gridBagConstraints.anchor = GridBagConstraints.WEST;
413:                add(userLabel, gridBagConstraints);
414:
415:                gridBagConstraints = new java.awt.GridBagConstraints();
416:                gridBagConstraints.gridy = 5;
417:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
418:                gridBagConstraints.weightx = 1.0;
419:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 5);
420:                add(userField, gridBagConstraints);
421:
422:                //-------------- Password ---------------
423:                gridBagConstraints = new java.awt.GridBagConstraints();
424:                gridBagConstraints.gridx = 0;
425:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 5);
426:                gridBagConstraints.anchor = GridBagConstraints.WEST;
427:                add(passwordLabel, gridBagConstraints);
428:
429:                gridBagConstraints = new java.awt.GridBagConstraints();
430:                gridBagConstraints.gridy = 6;
431:                gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
432:                gridBagConstraints.weightx = 1.0;
433:                gridBagConstraints.insets = new java.awt.Insets(0, 0, 12, 5);
434:                add(passwordField, gridBagConstraints);
435:
436:                //-------------  panell to fill out free space ------------------------
437:                gridBagConstraints = new java.awt.GridBagConstraints();
438:                gridBagConstraints.gridx = 0;
439:                gridBagConstraints.gridwidth = 3;
440:                gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
441:                gridBagConstraints.weightx = 1.0;
442:                gridBagConstraints.weighty = 1.0;
443:
444:                domainPathField.setEnabled(false);
445:                portField.setEditable(false);
446:
447:                userField.setVisible(false);
448:                userLabel.setVisible(false);
449:                passwordField.setVisible(false);
450:                passwordLabel.setVisible(false);
451:
452:                serverType.setVisible(false);
453:
454:                add(panel1, gridBagConstraints);
455:
456:                hostField.setText("localhost");//NOI18N
457:                portField.setText(JBPluginUtils
458:                        .getHTTPConnectorPort(domainPathField.getText()));//NOI18N
459:                //    serverTypeChanged();
460:                domainChanged();
461:
462:            }
463:
464:            class SomeChangesListener implements  KeyListener {
465:
466:                public void keyTyped(KeyEvent e) {
467:                }
468:
469:                public void keyPressed(KeyEvent e) {
470:                }
471:
472:                public void keyReleased(KeyEvent e) {
473:                    somethingChanged();
474:                }
475:
476:            }
477:
478:            private String browseDomainLocation() {
479:                String insLocation = null;
480:                JFileChooser chooser = getJFileChooser();
481:                int returnValue = chooser.showDialog(this , NbBundle.getMessage(
482:                        AddServerPropertiesVisualPanel.class,
483:                        "LBL_ChooseButton")); //NOI18N
484:
485:                if (returnValue == JFileChooser.APPROVE_OPTION) {
486:                    insLocation = chooser.getSelectedFile().getAbsolutePath();
487:                }
488:                return insLocation;
489:            }
490:
491:            private JFileChooser getJFileChooser() {
492:                JFileChooser chooser = new JFileChooser();
493:
494:                chooser.setDialogTitle("LBL_Chooser_Name"); //NOI18N
495:                chooser.setDialogType(JFileChooser.CUSTOM_DIALOG);
496:
497:                chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
498:                chooser.setApproveButtonMnemonic("Choose_Button_Mnemonic"
499:                        .charAt(0)); //NOI18N
500:                chooser.setMultiSelectionEnabled(false);
501:                chooser.addChoosableFileFilter(new dirFilter());
502:                chooser.setAcceptAllFileFilterUsed(false);
503:                chooser.setApproveButtonToolTipText("LBL_Chooser_Name"); //NOI18N
504:
505:                chooser.getAccessibleContext().setAccessibleName(
506:                        "LBL_Chooser_Name"); //NOI18N
507:                chooser.getAccessibleContext().setAccessibleDescription(
508:                        "LBL_Chooser_Name"); //NOI18N
509:
510:                return chooser;
511:            }
512:
513:            private static class dirFilter extends
514:                    javax.swing.filechooser.FileFilter {
515:
516:                public boolean accept(File f) {
517:                    if (!f.exists() || !f.canRead() || !f.isDirectory()) {
518:                        return false;
519:                    } else {
520:                        return true;
521:                    }
522:                }
523:
524:                public String getDescription() {
525:                    return NbBundle
526:                            .getMessage(AddServerPropertiesVisualPanel.class,
527:                                    "LBL_DirType"); //NOI18N
528:                }
529:
530:            }
531:
532:        }
533:
534:        class DomainComboModel extends AbstractListModel implements 
535:                ComboBoxModel {
536:            private int current = -1;
537:            private String[][] domains = null;
538:
539:            public void addDomain(String domain, String path) {
540:                String[][] newDomains = new String[domains.length + 1][2];
541:                int i = 0;
542:                for (; i < domains.length; i++) {
543:                    newDomains[i][0] = domains[i][0];
544:                    newDomains[i][1] = domains[i][1];
545:                }
546:                newDomains[i][0] = domain;
547:                newDomains[i][1] = path;
548:                domains = newDomains;
549:
550:            }
551:
552:            public DomainComboModel(Hashtable domains) {
553:                setDomains(domains);
554:            }
555:
556:            public void setDomains(Hashtable domains) {
557:
558:                current = -1;
559:                this .domains = null;
560:
561:                int len = domains.size();
562:                this .domains = new String[len][2];
563:                Enumeration en = domains.keys();
564:
565:                if (len > 0)
566:                    current = 0;
567:
568:                int i = 0;
569:                while (en.hasMoreElements()) {
570:                    this .domains[i][0] = (String) en.nextElement();
571:                    this .domains[i][1] = (String) domains
572:                            .get(this .domains[i][0]);
573:                    if (this .domains[i][0].equalsIgnoreCase("default")) //NOI18N
574:                        current = i;
575:                    i++;
576:                }
577:            }
578:
579:            public Object getSelectedItem() {
580:                if (current == -1)
581:                    return "";
582:                return domains[current][0];
583:            }
584:
585:            public void setSelectedItem(Object anItem) {
586:                for (int i = 0; i < getSize(); i++) {
587:                    if (domains[i][0].equals(anItem)) {
588:                        current = i;
589:                        fireContentsChanged(this , -1, -1);
590:                        return;
591:                    }
592:                }
593:                current = -1;
594:                //currentVal = (String)anItem;
595:                fireContentsChanged(this , -1, -1);
596:            }
597:
598:            public Object getElementAt(int index) {
599:                return domains[index][0];
600:            }
601:
602:            public int getSize() {
603:                return domains.length;
604:            }
605:
606:            //----------------------------------------------------
607:
608:            public String getCurrentPath() {
609:                if (current == -1)
610:                    return "";
611:                return domains[current][1];
612:            }
613:
614:            public boolean hasDomain(String domain) {
615:                for (int i = 0; i < getSize(); i++) {
616:                    if (domains[i][0].equals(domain)) {
617:                        return true;
618:                    }
619:                }
620:                return false;
621:            }
622:
623:        }
w__w___w_.___j___a_v___a___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.