Source Code Cross Referenced for GeneralPanel.java in  » J2EE » enhydra-IDE-plugin » org » enhydra » kelp » common » dods » 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.dods 
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.dods;
024:
025:        // AddinCore
026:        import org.enhydra.kelp.common.PathUtil;
027:        import org.enhydra.kelp.common.event.WriteEvent;
028:        import org.enhydra.kelp.common.event.WriteListener;
029:        import org.enhydra.kelp.common.node.OtterProject;
030:        import org.enhydra.kelp.common.node.OtterFileNode;
031:        import org.enhydra.kelp.common.swing.OutputPanel;
032:        import org.enhydra.kelp.common.Constants;
033:        import org.enhydra.kelp.common.DirectoryFilter;
034:
035:        // ToolBox
036:        import org.enhydra.tool.common.DataValidationException;
037:        import org.enhydra.tool.common.ExtensionFilter;
038:        import org.enhydra.tool.common.PathHandle;
039:        import org.enhydra.tool.common.SwingUtil;
040:        import org.enhydra.tool.common.ExtensionFilter;
041:        import org.enhydra.tool.common.PathHandle;
042:
043:        // JDK
044:        import java.awt.*;
045:        import java.awt.event.ActionEvent;
046:        import java.awt.event.ActionListener;
047:        import java.awt.event.ItemEvent;
048:        import java.awt.event.ItemListener;
049:        import java.io.File;
050:        import java.io.PrintWriter;
051:        import java.lang.ref.WeakReference;
052:        import javax.swing.*;
053:        import javax.swing.border.EtchedBorder;
054:        import javax.swing.border.TitledBorder;
055:        import javax.swing.event.ChangeEvent;
056:        import javax.swing.event.ChangeListener;
057:        import java.beans.*;
058:
059:        // Standard imports
060:        import java.awt.event.*;
061:        import java.io.File;
062:        import java.util.ResourceBundle;
063:
064:        //
065:        public class GeneralPanel extends JPanel implements  Instructor,
066:                DodsStep {
067:
068:            static ResourceBundle res = ResourceBundle
069:                    .getBundle("org.enhydra.kelp.common.Res"); // nores
070:            private GridBagLayout layoutMain;
071:            private JPanel panelDomlFile;
072:            private GridBagLayout layoutDomlFile;
073:            private JTextField textDomlFile;
074:            private JButton buttonDomlFile;
075:            private JPanel panelRootPath;
076:            private GridBagLayout layoutRootPath;
077:            private JTextField textRootPath;
078:            private JButton buttonRootPath;
079:            private JPanel panelMessage;
080:            private JCheckBox checkSqlGenerate;
081:            private JButton buttonMessage;
082:            private JCheckBox checkSqlSplitter;
083:            private JCheckBox checkJavaGenerate;
084:            private JCheckBox checkBuild;
085:            private JTabbedPane tabMessage;
086:            private JPanel panelMessageOption;
087:            private OutputPanel outputPanel;
088:            private GridBagLayout layoutMessageOption;
089:            private BorderLayout layoutMessage;
090:            private CheckBoxListener checkBoxListener = null;
091:            private boolean ran = false;
092:            private JPanel panelType;
093:            private JComboBox comboType;
094:            private WeakReference projectRef = null;
095:            private GridBagLayout layoutType;
096:            private LocalButtonListener buttonListener = null;
097:
098:            private JLabel jTemplateTypeLabel = new JLabel();
099:            private JCheckBox jCheckBoxMultiDB = new JCheckBox();
100:            private JCheckBox jCheckBoxWebDocWF = new JCheckBox();
101:            private JPanel panelExtensions;
102:            private GridBagLayout layoutExtensions;
103:
104:            public GeneralPanel() {
105:                try {
106:                    jbInit();
107:                    pmInit();
108:                } catch (Exception e) {
109:                    e.printStackTrace();
110:                }
111:            }
112:
113:            // implements Instructor
114:            public String getTab() {
115:                return "General";
116:            }
117:
118:            // implements Instructor
119:            public String getTitle() {
120:                return "Dods generator";
121:            }
122:
123:            // implements Instructor
124:            public String getInstructions() {
125:                return "Please select Doml file and choose action.";
126:            }
127:
128:            // implements DodsStep
129:            public void refresh() {
130:
131:                // nothing to refresh
132:            }
133:
134:            // implements DodsStep
135:            public void clearAll() {
136:                outputPanel.clearAll();
137:                removeAll();
138:            }
139:
140:            // implements DodsStep
141:            public void read(OtterProject project) {
142:                PathHandle path = null;
143:                int type = -1;
144:                String projectRoot = project.getSourcePath();
145:                if (projectRoot.indexOf(";") != -1)
146:                    projectRoot = projectRoot.substring(0, projectRoot
147:                            .indexOf(";"));
148:                path = PathHandle.createPathHandle(projectRoot);
149:
150:                if (isValidDeployRoot(path)) {
151:                    textRootPath.setText(path.getPath());
152:                } else {
153:                    textRootPath.setText(new String());
154:                }
155:
156:                textRootPath.setToolTipText(textRootPath.getText());
157:
158:                PathHandle domlPath = null;
159:                String[] ext = { "doml", "DOML" };
160:                OtterFileNode[] domlFileNodes = project
161:                        .findFileNodesByType(ext);
162:                String domlFileName = null;
163:                if (domlFileNodes.length > 0) {
164:                    domlFileName = domlFileNodes[0].getFilePath();
165:                }
166:                if (domlFileName != null) {
167:                    domlPath = PathHandle.createPathHandle(domlFileName);
168:                    if (domlPath.isFile()) {
169:                        textDomlFile.setText(domlPath.getPath());
170:                    } else {
171:                        textDomlFile.setText(new String());
172:                    }
173:                    textDomlFile.setToolTipText(textDomlFile.getText());
174:                }
175:
176:                //Dusan 24.01.2003.
177:                if (project.isOpenBuild()) {
178:
179:                    // Primetime
180:                    checkBuild.setEnabled(true);
181:                    checkBuild.setSelected(project.isDodsBuild());
182:                } else {
183:
184:                    // Win32 and JDeveloper
185:                    checkBuild.setEnabled(false);
186:                    checkBuild.setSelected(false);
187:                }
188:
189:            }
190:
191:            // implements DodsStep
192:            public void write(OtterProject project)
193:                    throws DataValidationException {
194:
195:                projectRef = new WeakReference(project);
196:
197:                project.setDomlFilePath(textDomlFile.getText());
198:
199:                project.setDodsRootPath(textRootPath.getText());
200:
201:                //Dusan 12.02.2003.
202:                project.setExstensionParameter("");
203:                if (jCheckBoxMultiDB.isSelected()
204:                        && jCheckBoxWebDocWF.isSelected()) {
205:                    project.setExstensionParameter("mdbwdwf");
206:                } else {
207:                    if (jCheckBoxMultiDB.isSelected())
208:                        project.setExstensionParameter("mdb");
209:                    if (jCheckBoxWebDocWF.isSelected())
210:                        project.setExstensionParameter("wdwf");
211:                }
212:
213:                if (checkSqlGenerate.isSelected()
214:                        && !checkSqlSplitter.isSelected()
215:                        && !checkJavaGenerate.isSelected()) {
216:                    project.setDodsParameters("dods:sql");
217:                }
218:
219:                if (checkSqlGenerate.isSelected()
220:                        && checkSqlSplitter.isSelected()
221:                        && !checkJavaGenerate.isSelected()) {
222:                    project.setDodsParameters("dods:sqlsplit");
223:                }
224:
225:                if (!checkSqlGenerate.isSelected()
226:                        && checkJavaGenerate.isSelected()) {
227:                    project.setDodsParameters("dods:javaNoCompile");
228:                }
229:
230:                if (checkSqlGenerate.isSelected()
231:                        && checkJavaGenerate.isSelected()) {
232:                    if (!checkSqlSplitter.isSelected())
233:                        project.setDodsParameters("dods:noCompile");
234:                    else
235:                        project.setDodsParameters("dods:noCompileSplit");
236:                }
237:
238:                //Dusan 24.01.2003.
239:                if (project.isOpenBuild()) {
240:                    project.setDodsBuild(checkBuild.isSelected());
241:                } else {
242:                    // Win32 and JDeveloper
243:                    project.setDodsBuild(false);
244:                }
245:            }
246:
247:            //
248:            protected WriteListener getWriteListener() {
249:                return outputPanel;
250:            }
251:
252:            protected Component[] getFirstFocusComponents() {
253:                Component[] comps = new Component[7];
254:
255:                comps[0] = buttonDomlFile;
256:                comps[1] = jCheckBoxMultiDB;
257:                comps[2] = jCheckBoxWebDocWF;
258:                comps[3] = checkSqlGenerate;
259:                comps[4] = checkSqlSplitter;
260:                comps[5] = checkJavaGenerate;
261:                comps[6] = checkBuild;
262:                return comps;
263:            }
264:
265:            //
266:            private boolean isValidDodsRoot(PathHandle ph) {
267:                boolean valid = false;
268:
269:                if (!ph.isFile()) {
270:                    if (ph.getParent() != null) {
271:                        valid = ph.getParent().isDirectory();
272:                    }
273:                }
274:                return valid;
275:            }
276:
277:            private boolean isValidLogFile(PathHandle ph) {
278:                boolean valid = false;
279:
280:                if (ph.hasExtension("txt")) {
281:                    if (ph.isFile()) {
282:                        valid = true;
283:                    } else if (ph.getParent() != null) {
284:                        valid = ph.getParent().isDirectory();
285:                    }
286:                }
287:                return valid;
288:            }
289:
290:            //
291:            private void chooseDodsRoot() {
292:                File choice = null;
293:                PathHandle path = null;
294:
295:                choice = SwingUtil.getDirectoryChoice(this , textDomlFile
296:                        .getText(), "Select Dods root directory");
297:                path = PathHandle.createPathHandle(choice);
298:                if (path.isDirectory()) {
299:                    textDomlFile.setText(path.getPath());
300:                    textDomlFile.setToolTipText(textDomlFile.getText());
301:                }
302:            }
303:
304:            private void pmInit() {
305:                buttonListener = new LocalButtonListener();
306:                buttonRootPath.addActionListener(buttonListener);
307:                buttonDomlFile.addActionListener(buttonListener);
308:                buttonMessage.addActionListener(buttonListener);
309:
310:                checkBoxListener = new CheckBoxListener();
311:                checkSqlGenerate.addActionListener(checkBoxListener);
312:                checkJavaGenerate.addActionListener(checkBoxListener);
313:                checkBuild.addActionListener(checkBoxListener);
314:                //Dusan 12.02.2003.
315:                jCheckBoxMultiDB.addActionListener(checkBoxListener);
316:                jCheckBoxWebDocWF.addActionListener(checkBoxListener);
317:            }
318:
319:            private void jbInit() throws Exception {
320:                panelRootPath = (JPanel) Beans.instantiate(getClass()
321:                        .getClassLoader(), JPanel.class.getName());
322:                layoutRootPath = (GridBagLayout) Beans.instantiate(getClass()
323:                        .getClassLoader(), GridBagLayout.class.getName());
324:                textRootPath = (JTextField) Beans.instantiate(getClass()
325:                        .getClassLoader(), JTextField.class.getName());
326:                buttonRootPath = (JButton) Beans.instantiate(getClass()
327:                        .getClassLoader(), JButton.class.getName());
328:                panelDomlFile = (JPanel) Beans.instantiate(getClass()
329:                        .getClassLoader(), JPanel.class.getName());
330:                layoutDomlFile = (GridBagLayout) Beans.instantiate(getClass()
331:                        .getClassLoader(), GridBagLayout.class.getName());
332:                textDomlFile = (JTextField) Beans.instantiate(getClass()
333:                        .getClassLoader(), JTextField.class.getName());
334:                buttonDomlFile = (JButton) Beans.instantiate(getClass()
335:                        .getClassLoader(), JButton.class.getName());
336:                panelMessage = (JPanel) Beans.instantiate(getClass()
337:                        .getClassLoader(), JPanel.class.getName());
338:                //Dusan 12.02.2003.
339:                panelExtensions = (JPanel) Beans.instantiate(getClass()
340:                        .getClassLoader(), JPanel.class.getName());
341:                layoutExtensions = (GridBagLayout) Beans.instantiate(getClass()
342:                        .getClassLoader(), GridBagLayout.class.getName());
343:                jCheckBoxMultiDB = (JCheckBox) Beans.instantiate(getClass()
344:                        .getClassLoader(), JCheckBox.class.getName());
345:                jCheckBoxWebDocWF = (JCheckBox) Beans.instantiate(getClass()
346:                        .getClassLoader(), JCheckBox.class.getName());
347:
348:                checkSqlGenerate = (JCheckBox) Beans.instantiate(getClass()
349:                        .getClassLoader(), JCheckBox.class.getName());
350:                checkSqlSplitter = (JCheckBox) Beans.instantiate(getClass()
351:                        .getClassLoader(), JCheckBox.class.getName());
352:                checkJavaGenerate = (JCheckBox) Beans.instantiate(getClass()
353:                        .getClassLoader(), JCheckBox.class.getName());
354:                checkBuild = (JCheckBox) Beans.instantiate(getClass()
355:                        .getClassLoader(), JCheckBox.class.getName());
356:                buttonMessage = (JButton) Beans.instantiate(getClass()
357:                        .getClassLoader(), JButton.class.getName());
358:                layoutMain = (GridBagLayout) Beans.instantiate(getClass()
359:                        .getClassLoader(), GridBagLayout.class.getName());
360:                tabMessage = (JTabbedPane) Beans.instantiate(getClass()
361:                        .getClassLoader(), JTabbedPane.class.getName());
362:                panelMessageOption = (JPanel) Beans.instantiate(getClass()
363:                        .getClassLoader(), JPanel.class.getName());
364:                outputPanel = (OutputPanel) Beans.instantiate(getClass()
365:                        .getClassLoader(), OutputPanel.class.getName());
366:                layoutMessageOption = (GridBagLayout) Beans.instantiate(
367:                        getClass().getClassLoader(), GridBagLayout.class
368:                                .getName());
369:                layoutMessage = (BorderLayout) Beans.instantiate(getClass()
370:                        .getClassLoader(), BorderLayout.class.getName());
371:                panelType = (JPanel) Beans.instantiate(getClass()
372:                        .getClassLoader(), JPanel.class.getName());
373:                comboType = (JComboBox) Beans.instantiate(getClass()
374:                        .getClassLoader(), JComboBox.class.getName());
375:                layoutType = (GridBagLayout) Beans.instantiate(getClass()
376:                        .getClassLoader(), GridBagLayout.class.getName());
377:                //        checkBuild = (JCheckBox) Beans.instantiate(getClass().getClassLoader(), JCheckBox.class.getName());
378:                textRootPath.setEnabled(false);
379:                textRootPath.setEditable(false);
380:                textRootPath.setText("Output directory");
381:                buttonRootPath.setText("Set...");
382:                buttonRootPath.setToolTipText("");
383:                buttonRootPath.setText("Set...");
384:                panelRootPath.setLayout(layoutDomlFile);
385:                panelRootPath.setBorder(BorderFactory.createTitledBorder(
386:                        new EtchedBorder(), "Output directory"));
387:                textDomlFile.setEnabled(true);
388:                textDomlFile.setEditable(true);
389:                textDomlFile.setText("");
390:                buttonDomlFile.setText("Set...");
391:                buttonMessage.setText("...");
392:                panelDomlFile.setLayout(layoutDomlFile);
393:                panelDomlFile.setBorder(BorderFactory.createTitledBorder(
394:                        new EtchedBorder(), "Doml file"));
395:                //Dusan 12.02.2004.
396:                panelExtensions.setLayout(layoutExtensions);
397:                panelExtensions.setBorder(BorderFactory.createTitledBorder(
398:                        new EtchedBorder(), "Extensions:"));
399:                //        jTemplateTypeLabel.setText("Extensions :");
400:                jCheckBoxMultiDB.setText("Multi Database");
401:                jCheckBoxMultiDB.setSelected(false);
402:                jCheckBoxWebDocWF.setText("WebDocWF");
403:                jCheckBoxWebDocWF.setSelected(false);
404:
405:                checkSqlGenerate.setText("SQL generate");
406:                checkSqlGenerate.setSelected(true);
407:                checkSqlSplitter.setText("SQL Splitter");
408:                checkSqlSplitter.setSelected(true);
409:                checkJavaGenerate.setText("Java generate");
410:                checkJavaGenerate.setSelected(true);
411:                checkBuild
412:                        .setText("Invoke Dods Generator during Project Make/Rebuild");
413:                checkBuild.setSelected(false);
414:                panelMessageOption.setLayout(layoutMessageOption);
415:                this .setPreferredSize(new Dimension(483, 670));
416:                panelRootPath.add(textRootPath, new GridBagConstraints(0, 0, 1,
417:                        1, 0.8, 0.0, GridBagConstraints.WEST,
418:                        GridBagConstraints.HORIZONTAL, new Insets(3, 5, 3, 5),
419:                        0, 0));
420:                panelRootPath.add(buttonRootPath, new GridBagConstraints(1, 0,
421:                        1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
422:                        GridBagConstraints.NONE, new Insets(3, 5, 3, 5), 0, 0));
423:                panelDomlFile.add(textDomlFile, new GridBagConstraints(0, 0, 1,
424:                        1, 0.8, 0.0, GridBagConstraints.WEST,
425:                        GridBagConstraints.HORIZONTAL, new Insets(3, 5, 3, 5),
426:                        0, 0));
427:                panelDomlFile.add(buttonDomlFile, new GridBagConstraints(1, 0,
428:                        1, 1, 0.0, 0.0, GridBagConstraints.CENTER,
429:                        GridBagConstraints.NONE, new Insets(3, 5, 3, 5), 0, 0));
430:                panelExtensions.add(jCheckBoxMultiDB, new GridBagConstraints(0,
431:                        0, 1, 1, 0.8, 0.0, GridBagConstraints.WEST,
432:                        GridBagConstraints.NONE, new Insets(3, 5, 3, 5), 0, 0));
433:                panelExtensions
434:                        .add(jCheckBoxWebDocWF, new GridBagConstraints(1, 0, 1,
435:                                1, 0.8, 0.0, GridBagConstraints.WEST,
436:                                GridBagConstraints.NONE,
437:                                new Insets(3, 5, 3, 5), 63, 0));
438:                panelMessage.setLayout(layoutMessage);
439:                panelMessage.setBorder(BorderFactory.createTitledBorder(
440:                        new EtchedBorder(), "Dods messages"));
441:                this .setLayout(layoutMain);
442:                this .add(checkSqlGenerate, new GridBagConstraints(0, 4, 1, 1,
443:                        0.0, 0.0, GridBagConstraints.WEST,
444:                        GridBagConstraints.HORIZONTAL,
445:                        new Insets(2, 10, 2, 10), 0, 0));
446:                this .add(panelRootPath, new GridBagConstraints(0, 0, 2, 1, 0.1,
447:                        0.0, GridBagConstraints.CENTER,
448:                        GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5),
449:                        0, 0));
450:                this .add(panelDomlFile, new GridBagConstraints(0, 1, 2, 1, 0.1,
451:                        0.0, GridBagConstraints.CENTER,
452:                        GridBagConstraints.HORIZONTAL,
453:                        new Insets(2, 10, 15, 5), 0, 0));
454:                this .add(panelExtensions, new GridBagConstraints(0, 3, 2, 1,
455:                        0.1, 0.0, GridBagConstraints.CENTER,
456:                        GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 5),
457:                        0, 0));
458:                this .add(checkSqlSplitter, new GridBagConstraints(1, 4, 1, 1,
459:                        0.1, 0.0, GridBagConstraints.CENTER,
460:                        GridBagConstraints.HORIZONTAL,
461:                        new Insets(2, 10, 2, 10), 0, 0));
462:                this .add(checkJavaGenerate, new GridBagConstraints(0, 5, 1, 1,
463:                        0.1, 0.0, GridBagConstraints.CENTER,
464:                        GridBagConstraints.HORIZONTAL,
465:                        new Insets(2, 10, 2, 10), 0, 0));
466:                this .add(panelType, new GridBagConstraints(0, 1, 2, 1, 0.0,
467:                        0.0, GridBagConstraints.CENTER,
468:                        GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5),
469:                        2, 0));
470:                this .add(checkBuild, new GridBagConstraints(1, 5, 2, 1, 0.1,
471:                        0.0, GridBagConstraints.CENTER,
472:                        GridBagConstraints.HORIZONTAL,
473:                        new Insets(2, 10, 2, 10), 0, 0));
474:                this .add(panelMessage, new GridBagConstraints(0, 2, 2, 1, 0.1,
475:                        0.0, GridBagConstraints.NORTHEAST,
476:                        GridBagConstraints.HORIZONTAL, new Insets(-2, 8, 0, 2),
477:                        0, 71));
478:                panelMessage.add(tabMessage, BorderLayout.CENTER);
479:                tabMessage.add(outputPanel, "Messages");
480:            }
481:
482:            private class CheckBoxListener implements  ActionListener {
483:                public void actionPerformed(ActionEvent event) {
484:                    Object source = event.getSource();
485:
486:                    if (source == checkSqlGenerate) {
487:                        if (checkSqlGenerate.isSelected()) {
488:                            checkSqlSplitter.setSelected(true);
489:                            checkSqlSplitter.setEnabled(true);
490:                        } else {
491:                            checkSqlSplitter.setSelected(false);
492:                            checkSqlSplitter.setEnabled(false);
493:                        }
494:                    }
495:                    //Dusan 25.01.2003.
496:                    if (source == checkSqlGenerate) {
497:                        if (!checkSqlGenerate.isSelected()) {
498:                            checkJavaGenerate.setSelected(true);
499:                        }
500:                    }
501:                    if (source == checkJavaGenerate) {
502:                        if (!checkJavaGenerate.isSelected()) {
503:                            checkSqlGenerate.setSelected(true);
504:                            checkSqlSplitter.setSelected(true);
505:                            checkSqlSplitter.setEnabled(true);
506:                        }
507:                    }
508:                }
509:            }
510:
511:            //
512:            private void chooseDomlFile() {
513:                File choice = null;
514:                PathHandle path = null;
515:                ExtensionFilter filter = null;
516:
517:                filter = new ExtensionFilter();
518:                filter.addExtension("doml");
519:
520:                /*        choice =
521:                 SwingUtil.getFileChoice(this, textDomlFile.getText(),
522:                 filter, "Select Doml file"); */
523:                choice = SwingUtil.getFileChoice(this , "c:\temp", filter,
524:                        "Select Doml file");
525:                path = PathHandle.createPathHandle(choice);
526:                if (path.isFile()) {
527:                    textDomlFile.setText(path.getPath());
528:                    textDomlFile.setToolTipText(textDomlFile.getText());
529:                }
530:            }
531:
532:            private class LocalButtonListener implements  ActionListener {
533:                public void actionPerformed(ActionEvent event) {
534:                    Object source = event.getSource();
535:
536:                    if (source == buttonDomlFile) {
537:                        //Dusan 23.11.2002.
538:                        //                chooseDomlFile();
539:                        browseForFile();
540:                    } else if (source == buttonRootPath) {
541:                        browseForDirectory();
542:                    }
543:                }
544:
545:            }
546:
547:            /**
548:             * Method declaration
549:             *
550:             */
551:            private void browseForFile() {
552:                JFileChooser chooser;
553:                ExtensionFilter filter;
554:                File file;
555:                String fileDir = new String();
556:                String fileName = new String();
557:
558:                filter = new ExtensionFilter();
559:                filter.addExtension(Constants.TYPE_DODS);
560:                filter.setDescriptionTitle(res
561:                        .getString("filter_Doml_DescriptionTitle"));
562:                chooser = new JFileChooser();
563:                if (textDomlFile.getText().trim().length() > 0) {
564:                    chooser
565:                            .setCurrentDirectory(new File(textDomlFile
566:                                    .getText()));
567:                } else {
568:                    PathHandle ph = null;
569:                    chooser.setCurrentDirectory(new File(""));
570:                }
571:                chooser.setFileFilter(filter);
572:                chooser.setDialogTitle(res
573:                        .getString("chooser_DODS_DialogTitle"));
574:                chooser.setApproveButtonText(res.getString("OK"));
575:                int v = chooser.showOpenDialog(this );
576:
577:                this .requestFocus();
578:                buttonDomlFile.requestFocus();
579:                if (v == JFileChooser.APPROVE_OPTION) {
580:                    if (chooser.getSelectedFile() == null
581:                            || (!chooser.getSelectedFile().isFile())) {
582:                        textDomlFile.setText(new String());
583:                    } else {
584:                        fileDir = chooser.getCurrentDirectory().toString();
585:                        fileDir = stripSlash(fileDir);
586:                        fileName = chooser.getSelectedFile().getName();
587:                        String strDomlFile = fileDir + File.separator
588:                                + fileName;
589:                        textDomlFile.setText(strDomlFile.replace('\\', '/'));
590:                    }
591:                }
592:                chooser.removeAll();
593:                chooser = null;
594:            }
595:
596:            /**
597:             * Method declaration
598:             *
599:             *
600:             * @param dir
601:             *
602:             * @return
603:             */
604:            private String stripSlash(String dir) {
605:                String stripped = new String(dir);
606:
607:                if (dir != null) {
608:                    if (dir.length() > 0) {
609:                        if (dir.endsWith(File.separator)) {
610:                            stripped = dir.substring(0, dir.length() - 1);
611:                        }
612:                    }
613:                }
614:                return stripped;
615:            }
616:
617:            //
618:            private boolean isValidDeployRoot(PathHandle ph) {
619:                boolean valid = false;
620:
621:                if (!ph.isFile()) {
622:                    if (ph.getParent() != null) {
623:                        valid = ph.getParent().isDirectory();
624:                    }
625:                }
626:                return valid;
627:            }
628:
629:            /**
630:             * Method declaration
631:             *
632:             */
633:            private void browseForDirectory() {
634:                JFileChooser chooser;
635:                File file;
636:                String fileDir = new String();
637:                String fileName = new String();
638:
639:                chooser = new JFileChooser();
640:                if (textRootPath.getText().trim().length() > 0) {
641:                    chooser
642:                            .setCurrentDirectory(new File(textRootPath
643:                                    .getText()));
644:                } else {
645:                    PathHandle ph = null;
646:
647:                    chooser.setCurrentDirectory(new File(""));
648:                }
649:                chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
650:                chooser
651:                        .setFileFilter((javax.swing.filechooser.FileFilter) new DirectoryFilter());
652:                chooser.setDialogTitle(res
653:                        .getString("chooser_RootPath_DialogTitle"));
654:                chooser.setApproveButtonText(res.getString("OK"));
655:                int v = chooser.showOpenDialog(this );
656:
657:                this .requestFocus();
658:                buttonRootPath.requestFocus();
659:                if (v == JFileChooser.APPROVE_OPTION) {
660:                    if (chooser.getSelectedFile() == null) {
661:                        textRootPath.setText(new String());
662:                    } else {
663:                        fileDir = chooser.getCurrentDirectory().toString();
664:                        fileDir = stripSlash(fileDir);
665:                        fileName = chooser.getSelectedFile().getName();
666:                        String strRootPath = fileDir + File.separator
667:                                + fileName;
668:                        textRootPath.setText(strRootPath.replace('\\', '/'));
669:                    }
670:                }
671:                chooser.removeAll();
672:                chooser = null;
673:            }
674:
675:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.