Source Code Cross Referenced for RunPanel.java in  » J2EE » enhydra-IDE-plugin » org » enhydra » kelp » common » deployer » 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 » J2EE » enhydra IDE plugin » org.enhydra.kelp.common.deployer 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Enhydra Java Application Server Project
003:         *
004:         * The contents of this file are subject to the Enhydra Public License
005:         * Version 1.1 (the "License"); you may not use this file except in
006:         * compliance with the License. You may obtain a copy of the License on
007:         * the Enhydra web site ( http://www.enhydra.org/ ).
008:         *
009:         * Software distributed under the License is distributed on an "AS IS"
010:         * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
011:         * the License for the specific terms governing rights and limitations
012:         * under the License.
013:         *
014:         * The Initial Developer of the Enhydra Application Server is Lutris
015:         * Technologies, Inc. The Enhydra Application Server and portions created
016:         * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
017:         * All Rights Reserved.
018:         *
019:         * Contributor(s):
020:         * Paul Mahar
021:         *
022:         */
023:        package org.enhydra.kelp.common.deployer;
024:
025:        // AddinCore
026:        import org.enhydra.kelp.common.PathUtil;
027:        import org.enhydra.kelp.common.event.WriteListener;
028:        import org.enhydra.kelp.common.node.OtterProject;
029:        import org.enhydra.kelp.common.Constants;
030:        import org.enhydra.kelp.common.DirectoryFilter;
031:
032:        // ToolBox
033:        import org.enhydra.tool.common.DataValidationException;
034:        import org.enhydra.tool.common.SwingUtil;
035:        import org.enhydra.tool.common.PathHandle;
036:        import org.enhydra.tool.common.ExtensionFilter;
037:
038:        // JDK
039:        import java.awt.*;
040:        import java.awt.event.ActionEvent;
041:        import java.awt.event.ActionListener;
042:        import java.awt.event.ItemEvent;
043:        import java.awt.event.ItemListener;
044:        import java.beans.*;
045:        import java.io.File;
046:        import java.lang.ref.WeakReference;
047:        import javax.swing.*;
048:        import javax.swing.event.ChangeEvent;
049:        import javax.swing.event.ChangeListener;
050:
051:        // Standard imports
052:        import java.util.ResourceBundle;
053:
054:        //
055:        public class RunPanel extends JPanel implements  Instructor, DeployStep {
056:            static ResourceBundle res = ResourceBundle
057:                    .getBundle("org.enhydra.kelp.common.Res"); // nores
058:            private GridBagLayout layoutMain;
059:            private JRadioButton radioAuto;
060:            private JRadioButton radioIDE;
061:            private JLabel labelAuto;
062:            private JTextField textAuto;
063:            private JButton buttonAuto;
064:            private JLabel labelBoot;
065:            private JTextField textBoot;
066:            private JButton buttonBoot;
067:            private JLabel labelConf;
068:            private JTextField textConf;
069:            private JCheckBox checkStartupJava;
070:            private JLabel labelAutoFile;
071:            private JTextField textAutoFile;
072:            private JButton buttonAutoFile;
073:            private JCheckBox checkEnable;
074:            private LocalCheckListener checkListener = null;
075:            private LocalRadioListener radioListener = null;
076:            private LocalButtonListener buttonListener = null;
077:            private WeakReference projectRef = null;
078:            private boolean ran = false;
079:
080:            //
081:            public RunPanel() {
082:                try {
083:                    jbInit();
084:                    pmInit();
085:                } catch (Exception ex) {
086:                    ex.printStackTrace();
087:                }
088:            }
089:
090:            // implements Instructor
091:            public String getTab() {
092:                return "Run";
093:            }
094:
095:            // implements Instructor
096:            public String getTitle() {
097:                return "Run configuration";
098:            }
099:
100:            // implements Instructor
101:            public String getInstructions() {
102:                return "The deployer can deploy archives to a running locally server or "
103:                        + "setup your project so that you can launch the server from your IDE.";
104:            }
105:
106:            // implements DeployStep
107:            public void refresh() {
108:                if (getProject() != null) {
109:                    //Dusan
110:                    //            if (getProject().getDeployType() == OtterProject.TYPE_SERVICE) {
111:                    if (true) {
112:                        radioAuto.setSelected(true);
113:                        radioIDE.setEnabled(false);
114:                        radioIDE.setSelected(false);
115:                    }
116:                }
117:                radioRefresh();
118:            }
119:
120:            // implements DeployStep
121:            public void clearAll() {
122:                radioAuto.removeItemListener(radioListener);
123:                radioIDE.removeItemListener(radioListener);
124:                buttonAuto.removeActionListener(buttonListener);
125:                buttonBoot.removeActionListener(buttonListener);
126:                checkEnable.removeChangeListener(checkListener);
127:                removeAll();
128:                if (projectRef != null) {
129:                    projectRef.clear();
130:                }
131:                projectRef = null;
132:                checkListener = null;
133:                radioListener = null;
134:                buttonListener = null;
135:            }
136:
137:            // implements DeployStep
138:            public boolean isDataValid() {
139:                return DeployStepUtil.isDataValid(this );
140:            }
141:
142:            // implements DeployStep
143:            public boolean isDataEqual(OtterProject project) {
144:                boolean equal = true;
145:                PathHandle projectPath = null;
146:                PathHandle panelPath = null;
147:
148:                projectRef = new WeakReference(project);
149:                if (!project.isDeployStartupJavaReadOnly()) {
150:                    if (project.isDeployStartupJava() != checkStartupJava
151:                            .isSelected()) {
152:                        equal = false;
153:                    }
154:                }
155:                if (equal) {
156:                    if (project.isDeployRun() != checkEnable.isSelected()) {
157:                        equal = false;
158:                    }
159:                }
160:                if (equal) {
161:                    projectPath = PathHandle.createPathHandle(project
162:                            .getDeployBootstrapPath());
163:                    if (radioAuto.isSelected()) {
164:                        panelPath = PathHandle.createPathHandle(textAuto
165:                                .getText());
166:                    } else {
167:                        panelPath = PathHandle.createPathHandle(textBoot
168:                                .getText());
169:                    }
170:                    if (!projectPath.equals(panelPath)) {
171:                        equal = false;
172:                    }
173:                }
174:                if (equal) {
175:                    projectPath = PathHandle.createPathHandle(project
176:                            .getAutoDeployFilePath());
177:                    panelPath = PathHandle.createPathHandle(textAutoFile
178:                            .getText());
179:                    if (!projectPath.equals(panelPath)) {
180:                        equal = false;
181:                    }
182:                }
183:                return equal;
184:            }
185:
186:            // implements DeployStep
187:            public void validateData() throws DataValidationException {
188:                PathHandle path = null;
189:
190:                if (checkEnable.isSelected()) {
191:                    if (radioAuto.isSelected()) {
192:                        path = PathHandle.createPathHandle(textAuto.getText());
193:                        if (!path.isDirectory()) {
194:                            throw new DataValidationException(
195:                                    "Invalid auto deployment directory: "
196:                                            + path.getPath());
197:                        }
198:                    } else {
199:                        path = PathHandle.createPathHandle(textBoot.getText());
200:                        if (!path.isFile()) {
201:                            throw new DataValidationException(
202:                                    "Invalid server configuration file: "
203:                                            + path.getPath());
204:                        }
205:                    }
206:                }
207:            }
208:
209:            // implements DeployStep
210:            public boolean isBuilt(OtterProject project) {
211:                projectRef = new WeakReference(project);
212:                ran = DeployStepUtil.isBuilt(this , ran, project);
213:                return ran;
214:            }
215:
216:            // implements DeployStep
217:            public boolean isSelectable(OtterProject project, DeployStep[] steps) {
218:                boolean able = false;
219:                boolean generalBuilt = false;
220:                boolean inputBuilt = false;
221:                boolean contentBuilt = false;
222:                boolean archiveBuilt = false;
223:
224:                projectRef = new WeakReference(project);
225:                for (int i = 0; i < steps.length; i++) {
226:                    if (steps[i] instanceof  GeneralPanel) {
227:                        generalBuilt = steps[i].isBuilt(project);
228:                    } else if (steps[i] instanceof  InputPanel) {
229:                        inputBuilt = steps[i].isBuilt(project);
230:                    } else if (steps[i] instanceof  ContentPanel) {
231:                        contentBuilt = steps[i].isBuilt(project);
232:                    } else if (steps[i] instanceof  ArchivePanel) {
233:                        archiveBuilt = steps[i].isBuilt(project);
234:                    }
235:                }
236:                able = generalBuilt && inputBuilt && contentBuilt
237:                        && archiveBuilt;
238:                return able;
239:            }
240:
241:            // implements DeployStep
242:            public void build(OtterProject project, WriteListener listener)
243:                    throws DataValidationException {
244:                RunBuilder builder = null;
245:
246:                projectRef = new WeakReference(project);
247:                if (!isBuilt(project)) {
248:                    write(project);
249:                    builder = new RunBuilder(listener);
250:                    builder.setProject(project);
251:                    builder.setEcho(true);
252:                    builder.buildInCurrentThread();
253:                    ran = true;
254:                }
255:            }
256:
257:            // implements DeployStep
258:            public void read(OtterProject project) {
259:                PathHandle path = null;
260:
261:                projectRef = new WeakReference(project);
262:                refresh();
263:                path = PathHandle.createPathHandle(project
264:                        .getDeployBootstrapPath());
265:                checkEnable.setSelected(project.isDeployRun());
266:                if (path.isDirectory()) {
267:                    textAuto.setText(path.getPath());
268:                    textBoot.setText(new String());
269:                    radioAuto.setSelected(true);
270:                    radioIDE.setSelected(false);
271:                } else if (path.hasExtension("conf")) {
272:                    textAuto.setText(new String());
273:                    textBoot.setText(path.getPath());
274:                    radioAuto.setSelected(false);
275:                    radioIDE.setSelected(true);
276:                } else {
277:                    textAuto.setText(new String());
278:                    textBoot.setText(new String());
279:                    radioAuto.setSelected(false);
280:                    radioIDE.setSelected(true);
281:                }
282:                textAutoFile.setText(project.getAutoDeployFilePath());
283:                textAutoFile.setToolTipText(textAutoFile.getText());
284:                textAuto.setToolTipText(textAuto.getText());
285:                textBoot.setToolTipText(textBoot.getText());
286:                textConf.setText(PathUtil.getDeployConfPath(project
287:                        .getDeployRootPath()));
288:                textConf.setToolTipText(textConf.getText());
289:                if (project.isDeployStartupJavaReadOnly()) {
290:                    checkStartupJava.setVisible(false);
291:                } else {
292:                    checkStartupJava.setSelected(project.isDeployStartupJava());
293:                }
294:            }
295:
296:            // implements DeployStep
297:            public void write(OtterProject project)
298:                    throws DataValidationException {
299:                PathHandle path = null;
300:
301:                projectRef = new WeakReference(project);
302:                validateData();
303:                if (!isDataEqual(project)) {
304:                    if (radioAuto.isSelected()) {
305:                        path = PathHandle.createPathHandle(textAuto.getText());
306:                    } else {
307:                        path = PathHandle.createPathHandle(textBoot.getText());
308:                    }
309:                    project.setDeployBootstrapPath(path.getPath());
310:                    project.setAutoDeployFile(textAutoFile.getText());
311:                    if (!project.isDeployStartupJavaReadOnly()) {
312:                        project.setDeployStartupJava(checkStartupJava
313:                                .isSelected());
314:                    }
315:                    project.setDeployRun(checkEnable.isSelected());
316:                }
317:            }
318:
319:            //
320:            private void chooseDirectory(JTextField text, String title) {
321:                File choice = null;
322:                PathHandle path = null;
323:
324:                choice = SwingUtil.getDirectoryChoice(this , text.getText(),
325:                        title);
326:                path = PathHandle.createPathHandle(choice);
327:                if (path.isDirectory()) {
328:                    text.setText(path.getPath());
329:                    text.setToolTipText(text.getText());
330:                }
331:            }
332:
333:            private void chooseBootFile() {
334:                File choice = null;
335:                PathHandle path = null;
336:                ExtensionFilter filter = null;
337:
338:                filter = new ExtensionFilter();
339:                filter.setDescriptionTitle("Server Configuration");
340:                filter.addExtension("conf");
341:                choice = SwingUtil.getFileChoice(this , textBoot.getText(),
342:                        filter, "Select a server bootstrap configuration file");
343:                path = PathHandle.createPathHandle(choice);
344:                if (path.isFile()) {
345:                    textBoot.setText(path.getPath());
346:                    textBoot.setToolTipText(textBoot.getText());
347:                }
348:            }
349:
350:            private void chooseAutoFile() {
351:                File choice = null;
352:                PathHandle path = null;
353:                ExtensionFilter filter = null;
354:                int type = OtterProject.TYPE_UNKNOWN;
355:
356:                if (getProject() != null) {
357:                    type = getProject().getDeployType();
358:                }
359:                filter = new ExtensionFilter();
360:                switch (type) {
361:                case OtterProject.TYPE_EN3APP:
362:                    filter.setDescriptionTitle("Enhydra App Configuration");
363:                    filter.addExtension("conf");
364:                    break;
365:                case OtterProject.TYPE_WEBAPP:
366:                    filter.setDescriptionTitle("Application Archive");
367:                    filter.addExtension("war");
368:                    filter.addExtension("ear");
369:                    break;
370:                //Dusan
371:                /*        case OtterProject.TYPE_SERVICE:
372:                 filter.setDescriptionTitle("Service Archive");
373:                 filter.addExtension("jar");
374:                 break; */
375:                default:
376:                    filter.setDescriptionTitle("Deployment File");
377:                    break;
378:                }
379:                choice = SwingUtil.getFileChoice(this , textAutoFile.getText(),
380:                        filter, "Select file to copy to server");
381:                path = PathHandle.createPathHandle(choice);
382:                if (path.isFile()) {
383:                    textAutoFile.setText(path.getPath());
384:                    textAutoFile.setToolTipText(textAutoFile.getText());
385:                }
386:            }
387:
388:            private void radioRefresh() {
389:                boolean auto = radioAuto.isSelected();
390:                PathHandle ph = null;
391:                String def = null;
392:                int type = OtterProject.TYPE_UNKNOWN;
393:
394:                buttonBoot.setEnabled(!auto);
395:                labelBoot.setEnabled(!auto);
396:                labelConf.setEnabled(!auto);
397:                checkStartupJava.setEnabled(!auto);
398:                buttonAuto.setEnabled(auto);
399:                buttonAutoFile.setEnabled(auto);
400:                labelAuto.setEnabled(auto);
401:                labelAutoFile.setEnabled(auto);
402:                if (auto) {
403:                    if (getProject() != null) {
404:                        type = getProject().getDeployType();
405:                    }
406:                    textBoot.setBackground(SystemColor.control);
407:                    textConf.setBackground(SystemColor.control);
408:                    textAuto.setBackground(SystemColor.info);
409:                    textAutoFile.setBackground(SystemColor.info);
410:                    if (textAuto.getText().trim().length() == 0) {
411:                        def = PathUtil.getAutoDeployPath(type);
412:                        ph = PathHandle.createPathHandle(def);
413:                        if (ph.isDirectory()) {
414:                            textAuto.setText(ph.getPath());
415:                        }
416:                    }
417:                } else {
418:                    textBoot.setBackground(SystemColor.info);
419:                    textConf.setBackground(SystemColor.info);
420:                    textAuto.setBackground(SystemColor.control);
421:                    textAutoFile.setBackground(SystemColor.control);
422:                    if (textBoot.getText().trim().length() == 0) {
423:                        if (getProject() != null) {
424:                            def = PathUtil
425:                                    .getDefaultDeployBootstrapPath(getProject());
426:                            ph = PathHandle.createPathHandle(def);
427:                            if (ph.isFile()) {
428:                                textBoot.setText(ph.getPath());
429:                            }
430:                        }
431:                    }
432:                }
433:            }
434:
435:            private OtterProject getProject() {
436:                OtterProject project = null;
437:
438:                if (projectRef != null) {
439:                    project = (OtterProject) projectRef.get();
440:                }
441:                return project;
442:            }
443:
444:            private void pmInit() {
445:                ButtonGroup group = null;
446:
447:                group = new ButtonGroup();
448:                group.add(radioAuto);
449:                group.add(radioIDE);
450:
451:                //
452:                radioListener = new LocalRadioListener();
453:                radioAuto.addItemListener(radioListener);
454:                radioIDE.addItemListener(radioListener);
455:
456:                //
457:                buttonListener = new LocalButtonListener();
458:                buttonAuto.addActionListener(buttonListener);
459:                buttonAutoFile.addActionListener(buttonListener);
460:                buttonBoot.addActionListener(buttonListener);
461:
462:                checkListener = new LocalCheckListener();
463:                checkEnable.addChangeListener(checkListener);
464:            }
465:
466:            private void refreshEnable() {
467:                if (checkEnable.isSelected()) {
468:                    radioAuto.setEnabled(true);
469:                    if (getProject() == null) {
470:                        radioIDE.setEnabled(true);
471:                        //Dusan
472:                        /*            } else if (getProject().getDeployType()
473:                         == OtterProject.TYPE_SERVICE) {
474:                         radioIDE.setEnabled(false); */
475:                    } else {
476:                        radioIDE.setEnabled(true);
477:                    }
478:                    radioRefresh();
479:                } else {
480:                    buttonAuto.setEnabled(false);
481:                    buttonAutoFile.setEnabled(false);
482:                    buttonBoot.setEnabled(false);
483:                    checkStartupJava.setEnabled(false);
484:                    labelAuto.setEnabled(false);
485:                    labelAutoFile.setEnabled(false);
486:                    labelBoot.setEnabled(false);
487:                    labelConf.setEnabled(false);
488:                    radioAuto.setEnabled(false);
489:                    radioIDE.setEnabled(false);
490:                    textAuto.setBackground(SystemColor.control);
491:                    textAutoFile.setBackground(SystemColor.control);
492:                    textBoot.setBackground(SystemColor.control);
493:                    textConf.setBackground(SystemColor.control);
494:                }
495:            }
496:
497:            private void jbInit() throws Exception {
498:                checkStartupJava = (JCheckBox) Beans.instantiate(getClass()
499:                        .getClassLoader(), JCheckBox.class.getName());
500:                labelConf = (JLabel) Beans.instantiate(getClass()
501:                        .getClassLoader(), JLabel.class.getName());
502:                textConf = (JTextField) Beans.instantiate(getClass()
503:                        .getClassLoader(), JTextField.class.getName());
504:                labelBoot = (JLabel) Beans.instantiate(getClass()
505:                        .getClassLoader(), JLabel.class.getName());
506:                textBoot = (JTextField) Beans.instantiate(getClass()
507:                        .getClassLoader(), JTextField.class.getName());
508:                buttonBoot = (JButton) Beans.instantiate(getClass()
509:                        .getClassLoader(), JButton.class.getName());
510:                radioIDE = (JRadioButton) Beans.instantiate(getClass()
511:                        .getClassLoader(), JRadioButton.class.getName());
512:                labelAuto = (JLabel) Beans.instantiate(getClass()
513:                        .getClassLoader(), JLabel.class.getName());
514:                textAuto = (JTextField) Beans.instantiate(getClass()
515:                        .getClassLoader(), JTextField.class.getName());
516:                buttonAuto = (JButton) Beans.instantiate(getClass()
517:                        .getClassLoader(), JButton.class.getName());
518:                layoutMain = (GridBagLayout) Beans.instantiate(getClass()
519:                        .getClassLoader(), GridBagLayout.class.getName());
520:                radioAuto = (JRadioButton) Beans.instantiate(getClass()
521:                        .getClassLoader(), JRadioButton.class.getName());
522:                labelAutoFile = (JLabel) Beans.instantiate(getClass()
523:                        .getClassLoader(), JLabel.class.getName());
524:                textAutoFile = (JTextField) Beans.instantiate(getClass()
525:                        .getClassLoader(), JTextField.class.getName());
526:                buttonAutoFile = (JButton) Beans.instantiate(getClass()
527:                        .getClassLoader(), JButton.class.getName());
528:                checkEnable = (JCheckBox) Beans.instantiate(getClass()
529:                        .getClassLoader(), JCheckBox.class.getName());
530:                radioAuto.setText("Auto-deploy to locally running server");
531:                radioIDE
532:                        .setText("Configure project for starting server from IDE");
533:                textAuto.setEnabled(false);
534:                textAuto.setEditable(false);
535:                textAuto.setText("AUTODEPLOY DIRECTORY");
536:                buttonAuto.setText("...");
537:                textBoot.setEnabled(false);
538:                textBoot.setEditable(false);
539:                textBoot.setText("BOOT CONF");
540:                buttonBoot.setToolTipText("");
541:                buttonBoot.setText("...");
542:                textConf.setEnabled(false);
543:                textConf.setEditable(false);
544:                textConf.setText("TEXT CONF");
545:                labelAuto.setText("Deploy directory:");
546:                labelBoot.setText("Server configuration:");
547:
548:                //
549:                labelConf.setText("Configuration root:");
550:                //        checkStartupJava.setText("Create StartServer.java");
551:                labelAutoFile.setText("Deploy file:");
552:                textAutoFile.setEnabled(false);
553:                textAutoFile.setEditable(false);
554:                textAutoFile.setText("AUTODEPLOY FILE");
555:                buttonAutoFile.setText("...");
556:                checkEnable.setSelected(true);
557:                checkEnable.setText("Enable run configuration");
558:                checkEnable.setActionCommand("checkEnable");
559:                this .setLayout(layoutMain);
560:                this .add(labelConf, new GridBagConstraints(0, 6, 1, 1, 0.1,
561:                        0.0, GridBagConstraints.WEST,
562:                        GridBagConstraints.HORIZONTAL, new Insets(3, 35, 3, 5),
563:                        0, 0));
564:                this .add(textConf, new GridBagConstraints(1, 6, 2, 1, 0.6, 0.0,
565:                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
566:                        new Insets(3, 5, 3, 5), 0, 0));
567:                this .add(labelBoot, new GridBagConstraints(0, 5, 1, 1, 0.1,
568:                        0.0, GridBagConstraints.CENTER,
569:                        GridBagConstraints.HORIZONTAL, new Insets(3, 35, 3, 5),
570:                        0, 0));
571:                this .add(textBoot, new GridBagConstraints(1, 5, 1, 1, 0.6, 0.0,
572:                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
573:                        new Insets(3, 5, 3, 5), 0, 0));
574:                this .add(buttonBoot, new GridBagConstraints(2, 5, 1, 1, 0.0,
575:                        0.0, GridBagConstraints.CENTER,
576:                        GridBagConstraints.NONE, new Insets(3, 5, 3, 5), 0, 0));
577:                this .add(radioAuto, new GridBagConstraints(0, 1, 3, 1, 0.1,
578:                        0.0, GridBagConstraints.WEST,
579:                        GridBagConstraints.HORIZONTAL, new Insets(5, 20, 0, 5),
580:                        0, 0));
581:                this .add(radioIDE, new GridBagConstraints(0, 4, 3, 1, 0.1, 0.0,
582:                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
583:                        new Insets(10, 20, 0, 5), 0, 0));
584:                this .add(labelAuto, new GridBagConstraints(0, 2, 1, 1, 0.1,
585:                        0.0, GridBagConstraints.CENTER,
586:                        GridBagConstraints.HORIZONTAL, new Insets(3, 35, 3, 5),
587:                        0, 0));
588:                this .add(textAuto, new GridBagConstraints(1, 2, 1, 1, 0.6, 0.0,
589:                        GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL,
590:                        new Insets(3, 5, 3, 5), 0, 0));
591:                this .add(buttonAuto, new GridBagConstraints(2, 2, 1, 1, 0.0,
592:                        0.0, GridBagConstraints.CENTER,
593:                        GridBagConstraints.NONE, new Insets(3, 5, 3, 5), 0, 0));
594:                /*        this.add(checkStartupJava,
595:                 new GridBagConstraints(0, 7, 3, 1, 0.0, 0.0,
596:                 GridBagConstraints.WEST,
597:                 GridBagConstraints.HORIZONTAL,
598:                 new Insets(3, 35, 3, 5), 0, 0));
599:                 */this .add(labelAutoFile, new GridBagConstraints(0, 3, 1, 1,
600:                        0.0, 0.0, GridBagConstraints.WEST,
601:                        GridBagConstraints.HORIZONTAL, new Insets(3, 35, 3, 0),
602:                        0, 0));
603:                this .add(textAutoFile, new GridBagConstraints(1, 3, 1, 1, 0.6,
604:                        0.0, GridBagConstraints.CENTER,
605:                        GridBagConstraints.HORIZONTAL, new Insets(3, 5, 3, 5),
606:                        0, 0));
607:                this .add(buttonAutoFile, new GridBagConstraints(2, 3, 1, 1,
608:                        0.0, 0.0, GridBagConstraints.CENTER,
609:                        GridBagConstraints.NONE, new Insets(3, 5, 3, 5), 0, 0));
610:                this .add(checkEnable, new GridBagConstraints(0, 0, 3, 1, 0.0,
611:                        0.0, GridBagConstraints.WEST,
612:                        GridBagConstraints.HORIZONTAL,
613:                        new Insets(0, 10, 0, 10), 0, 0));
614:            }
615:
616:            //
617:            private class LocalRadioListener implements  ItemListener {
618:                public void itemStateChanged(ItemEvent e) {
619:                    if (e.getStateChange() == ItemEvent.SELECTED) {
620:                        radioRefresh();
621:                    }
622:                }
623:
624:            }
625:
626:            //
627:            private class LocalButtonListener implements  ActionListener {
628:                public void actionPerformed(ActionEvent event) {
629:                    Object source = event.getSource();
630:
631:                    if (source == buttonAuto) {
632:                        //Dusan 24.11.2002.
633:                        //                chooseDirectory(textAuto, "Select the auto-deploy directory");
634:                        browseForAutoDirectory();
635:                    } else if (source == buttonAutoFile) {
636:                        //Dusan 24.11.2002.
637:                        //                chooseAutoFile();
638:                        browseForAutoFile();
639:                    } else if (source == buttonBoot) {
640:                        //Dusan 24.11.2002.
641:                        //                chooseBootFile();
642:                        browseForBootFile();
643:                    }
644:                }
645:
646:            }
647:
648:            //
649:            private class LocalCheckListener implements  ChangeListener {
650:                public void stateChanged(ChangeEvent e) {
651:                    Object source = e.getSource();
652:
653:                    if (source == checkEnable) {
654:                        refreshEnable();
655:                    }
656:                }
657:
658:            }
659:
660:            /**
661:             * Method declaration
662:             *
663:             */
664:            private void browseForAutoDirectory() {
665:                JFileChooser chooser;
666:                File file;
667:                String fileDir = new String();
668:                String fileName = new String();
669:
670:                chooser = new JFileChooser();
671:                if (textAuto.getText().trim().length() > 0) {
672:                    chooser.setCurrentDirectory(new File(textAuto.getText()));
673:                } else {
674:                    PathHandle ph = null;
675:
676:                    chooser.setCurrentDirectory(new File(""));
677:                }
678:                chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
679:                chooser
680:                        .setFileFilter((javax.swing.filechooser.FileFilter) new DirectoryFilter());
681:                chooser.setDialogTitle(res
682:                        .getString("chooser_AutoDeployDirectory_DialogTitle"));
683:                chooser.setApproveButtonText(res.getString("OK"));
684:                int v = chooser.showOpenDialog(this );
685:
686:                this .requestFocus();
687:                buttonAuto.requestFocus();
688:                if (v == JFileChooser.APPROVE_OPTION) {
689:                    if (chooser.getSelectedFile() == null) {
690:                        textAuto.setText(new String());
691:                    } else {
692:                        fileDir = chooser.getCurrentDirectory().toString();
693:                        fileDir = stripSlash(fileDir);
694:                        fileName = chooser.getSelectedFile().getName();
695:                        String strDeployRoot = fileDir + File.separator
696:                                + fileName;
697:                        textAuto.setText(strDeployRoot.replace('\\', '/'));
698:                    }
699:                }
700:                chooser.removeAll();
701:                chooser = null;
702:            }
703:
704:            /**
705:             * Method declaration
706:             *
707:             */
708:            private void browseForBootFile() {
709:                JFileChooser chooser;
710:                ExtensionFilter filter;
711:                File file;
712:                String fileDir = new String();
713:                String fileName = new String();
714:
715:                filter = new ExtensionFilter();
716:                filter.addExtension(Constants.TYPE_CONF);
717:                filter.setDescriptionTitle(res
718:                        .getString("filter_Conf_DescriptionTitle"));
719:                chooser = new JFileChooser();
720:                if (textBoot.getText().trim().length() > 0) {
721:                    chooser.setCurrentDirectory(new File(textBoot.getText()));
722:                } else {
723:                    PathHandle ph = null;
724:                    chooser.setCurrentDirectory(new File(""));
725:                }
726:                chooser.setFileFilter(filter);
727:                chooser.setDialogTitle(res
728:                        .getString("chooser_BootFile_DialogTitle"));
729:                chooser.setApproveButtonText(res.getString("OK"));
730:                int v = chooser.showOpenDialog(this );
731:
732:                this .requestFocus();
733:                buttonBoot.requestFocus();
734:                if (v == JFileChooser.APPROVE_OPTION) {
735:                    if (chooser.getSelectedFile() == null
736:                            || (!chooser.getSelectedFile().isFile())) {
737:                        textBoot.setText(new String());
738:                    } else {
739:                        fileDir = chooser.getCurrentDirectory().toString();
740:                        fileDir = stripSlash(fileDir);
741:                        fileName = chooser.getSelectedFile().getName();
742:                        textBoot.setText(fileDir + File.separator + fileName);
743:                    }
744:                }
745:                chooser.removeAll();
746:                chooser = null;
747:            }
748:
749:            /**
750:             * Method declaration
751:             *
752:             */
753:            private void browseForAutoFile() {
754:                JFileChooser chooser;
755:                ExtensionFilter filter;
756:                File file;
757:                String fileDir = new String();
758:                String fileName = new String();
759:
760:                filter = new ExtensionFilter();
761:                filter.addExtension(Constants.TYPE_WAR);
762:                filter.setDescriptionTitle(res
763:                        .getString("filter_War_DescriptionTitle"));
764:                chooser = new JFileChooser();
765:                if (textAutoFile.getText().trim().length() > 0) {
766:                    chooser
767:                            .setCurrentDirectory(new File(textAutoFile
768:                                    .getText()));
769:                } else {
770:                    PathHandle ph = null;
771:                    chooser.setCurrentDirectory(new File(""));
772:                }
773:                chooser.setFileFilter(filter);
774:                chooser.setDialogTitle(res
775:                        .getString("chooser_AutoDeployFile_DialogTitle"));
776:                chooser.setApproveButtonText(res.getString("OK"));
777:                int v = chooser.showOpenDialog(this );
778:
779:                this .requestFocus();
780:                buttonAutoFile.requestFocus();
781:                if (v == JFileChooser.APPROVE_OPTION) {
782:                    if (chooser.getSelectedFile() == null
783:                            || (!chooser.getSelectedFile().isFile())) {
784:                        textAutoFile.setText(new String());
785:                    } else {
786:                        fileDir = chooser.getCurrentDirectory().toString();
787:                        fileDir = stripSlash(fileDir);
788:                        fileName = chooser.getSelectedFile().getName();
789:                        textAutoFile.setText(fileDir + File.separator
790:                                + fileName);
791:                    }
792:                }
793:                chooser.removeAll();
794:                chooser = null;
795:            }
796:
797:            /**
798:             * Method declaration
799:             *
800:             *
801:             * @param dir
802:             *
803:             * @return
804:             */
805:            private String stripSlash(String dir) {
806:                String stripped = new String(dir);
807:
808:                if (dir != null) {
809:                    if (dir.length() > 0) {
810:                        if (dir.endsWith(File.separator)) {
811:                            stripped = dir.substring(0, dir.length() - 1);
812:                        }
813:                    }
814:                }
815:                return stripped;
816:            }
817:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.