KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > kelp > common > dods > GeneralPanel


1 /*
2  * Enhydra Java Application Server Project
3  *
4  * The contents of this file are subject to the Enhydra Public License
5  * Version 1.1 (the "License"); you may not use this file except in
6  * compliance with the License. You may obtain a copy of the License on
7  * the Enhydra web site ( http://www.enhydra.org/ ).
8  *
9  * Software distributed under the License is distributed on an "AS IS"
10  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
11  * the License for the specific terms governing rights and limitations
12  * under the License.
13  *
14  * The Initial Developer of the Enhydra Application Server is Lutris
15  * Technologies, Inc. The Enhydra Application Server and portions created
16  * by Lutris Technologies, Inc. are Copyright Lutris Technologies, Inc.
17  * All Rights Reserved.
18  *
19  * Contributor(s):
20  * Paul Mahar
21  *
22  */

23 package org.enhydra.kelp.common.dods;
24
25 // AddinCore
26
import org.enhydra.kelp.common.PathUtil;
27 import org.enhydra.kelp.common.event.WriteEvent;
28 import org.enhydra.kelp.common.event.WriteListener;
29 import org.enhydra.kelp.common.node.OtterProject;
30 import org.enhydra.kelp.common.node.OtterFileNode;
31 import org.enhydra.kelp.common.swing.OutputPanel;
32 import org.enhydra.kelp.common.Constants;
33 import org.enhydra.kelp.common.DirectoryFilter;
34
35 // ToolBox
36
import org.enhydra.tool.common.DataValidationException;
37 import org.enhydra.tool.common.ExtensionFilter;
38 import org.enhydra.tool.common.PathHandle;
39 import org.enhydra.tool.common.SwingUtil;
40 import org.enhydra.tool.common.ExtensionFilter;
41 import org.enhydra.tool.common.PathHandle;
42
43
44 // JDK
45
import java.awt.*;
46 import java.awt.event.ActionEvent JavaDoc;
47 import java.awt.event.ActionListener JavaDoc;
48 import java.awt.event.ItemEvent JavaDoc;
49 import java.awt.event.ItemListener JavaDoc;
50 import java.io.File JavaDoc;
51 import java.io.PrintWriter JavaDoc;
52 import java.lang.ref.WeakReference JavaDoc;
53 import javax.swing.*;
54 import javax.swing.border.EtchedBorder JavaDoc;
55 import javax.swing.border.TitledBorder JavaDoc;
56 import javax.swing.event.ChangeEvent JavaDoc;
57 import javax.swing.event.ChangeListener JavaDoc;
58 import java.beans.*;
59
60 // Standard imports
61
import java.awt.event.*;
62 import java.io.File JavaDoc;
63 import java.util.ResourceBundle JavaDoc;
64
65 import org.enhydra.dods.Common;
66 //import org.enhydra.dods.xml.XmlUtil;
67
//import org.enhydra.dods.xml.XmlUtilException;
68
import java.util.*;
69 import org.enhydra.dods.generator.DODSWizard;
70 import org.enhydra.dods.generator.DODSGenerator;
71
72 //
73
public class GeneralPanel extends JPanel implements Instructor, DodsStep {
74
75     static ResourceBundle JavaDoc res =
76         ResourceBundle.getBundle("org.enhydra.kelp.common.Res"); // nores
77
private GridBagLayout layoutMain;
78     private JPanel panelDomlFile;
79     private GridBagLayout layoutDomlFile;
80     private JTextField textDomlFile;
81     private JButton buttonDomlFile;
82     private JPanel panelRootPath;
83     private GridBagLayout layoutRootPath;
84     private JTextField textRootPath;
85     private JButton buttonRootPath;
86     private JPanel panelMessage;
87     private JCheckBox checkSqlGenerate;
88     private JButton buttonMessage;
89     private JCheckBox checkSqlSplitter;
90     private JCheckBox checkJavaGenerate;
91     private JCheckBox checkBuild;
92     private JTabbedPane tabMessage;
93     private JPanel panelMessageOption;
94     private OutputPanel outputPanel;
95     private GridBagLayout layoutMessageOption;
96     private BorderLayout layoutMessage;
97     private CheckBoxListener checkBoxListener = null;
98     private boolean ran = false;
99     private JComboBox comboType;
100     private WeakReference JavaDoc projectRef = null;
101     private GridBagLayout layoutType;
102     private LocalButtonListener buttonListener = null;
103
104     private JLabel jTemplateTypeLabel = new JLabel();
105     private JCheckBox jCheckBoxDoml2Html = new JCheckBox();
106     private JCheckBox jCheckBoxDoml2Pdf = new JCheckBox();
107     private JCheckBox jCheckBoxDoml2Xmi = new JCheckBox();
108     private JCheckBox jCheckBoxDoml2Ptl = new JCheckBox();
109     private JPanel panelDocumentation;
110     private JPanel panelTemplateSet;
111     private GridBagLayout layoutExtensions;
112
113     private JLabel labelRootPath;
114     private JLabel labelDomlFile;
115     private JLabel labelDocumentation;
116     private JLabel labelTemplateSet;
117     private JComboBox jComboBoxTemplateSet = new JComboBox();
118 // XYLayout xyLayout = new XYLayout();
119

120 // private DODSGenerator generator;
121

122     public GeneralPanel() {
123         try {
124             jbInit();
125             pmInit();
126         } catch (Exception JavaDoc e) {
127             e.printStackTrace();
128         }
129     }
130
131     // implements Instructor
132
public String JavaDoc getTab() {
133         return "General";
134     }
135
136     // implements Instructor
137
public String JavaDoc getTitle() {
138         return "Dods generator";
139     }
140
141     // implements Instructor
142
public String JavaDoc getInstructions() {
143         return "Please select Doml file and choose action.";
144     }
145
146     // implements DodsStep
147
public void refresh() {
148
149         // nothing to refresh
150
}
151
152     // implements DodsStep
153
public void clearAll() {
154         outputPanel.clearAll();
155         removeAll();
156     }
157
158     // implements DodsStep
159
public void read(OtterProject project) {
160
161 // if(project.getDodsRootPath()==null) {
162
PathHandle path = null;
163         int type = -1;
164         String JavaDoc projectRoot = project.getSourcePath();
165         if(projectRoot.indexOf(";")!=-1)
166           projectRoot = projectRoot.substring(0, projectRoot.indexOf(";"));
167         path = PathHandle.createPathHandle(projectRoot);
168
169         if (isValidDeployRoot(path)) {
170             textRootPath.setText(path.getPath());
171         } else {
172             textRootPath.setText(new String JavaDoc());
173         }
174 /* } else {
175             textRootPath.setText(project.getDodsRootPath());
176       } */

177
178         textRootPath.setToolTipText(textRootPath.getText());
179
180         PathHandle domlPath = null;
181         String JavaDoc[] ext = {"doml","DOML"};
182         OtterFileNode[] domlFileNodes = project.findFileNodesByType(ext);
183         String JavaDoc domlFileName= null;
184         if(domlFileNodes.length > 0)
185          {
186             domlFileName = domlFileNodes[0].getFilePath();
187          }
188         if(domlFileName!=null)
189         {
190             domlPath = PathHandle.createPathHandle(domlFileName);
191             if (domlPath.isFile()) {
192               textDomlFile.setText(domlPath.getPath());
193             } else {
194               textDomlFile.setText(new String JavaDoc());
195              }
196           textDomlFile.setToolTipText(textDomlFile.getText());
197         } else {
198             textDomlFile.setText(project.getDomlFilePath());
199         }
200
201        //Dusan 24.01.2003.
202
if (project.isOpenBuild()) {
203
204             // Primetime
205
checkBuild.setEnabled(true);
206             checkBuild.setSelected(project.isDodsBuild());
207         } else {
208
209             // Win32 and JDeveloper
210
checkBuild.setEnabled(false);
211             checkBuild.setSelected(false);
212         }
213
214       }
215
216     // implements DodsStep
217
public void write(OtterProject project) throws DataValidationException {
218
219        projectRef = new WeakReference JavaDoc(project);
220
221        project.setDomlFilePath(textDomlFile.getText());
222
223        project.setDodsRootPath(textRootPath.getText());
224
225
226       //Dusan 24.01.2003.
227
if (project.isOpenBuild()) {
228             project.setDodsBuild(checkBuild.isSelected());
229         } else {
230             // Win32 and JDeveloper
231
project.setDodsBuild(false);
232         }
233
234       //Dusan 15.3.2003.
235
saveParameters(project);
236
237   }
238
239     void saveParameters(OtterProject proj) {
240
241         OtterProject project = proj;
242
243         project.setDodsParameters("dods:build_all");
244         if (checkSqlGenerate.isSelected() && !checkSqlSplitter.isSelected() && !checkJavaGenerate.isSelected()) {
245             project.setDodsParameters("dods:sql");
246         }
247         if (checkSqlGenerate.isSelected() && checkSqlSplitter.isSelected() && !checkJavaGenerate.isSelected()) {
248             project.setDodsParameters("dods:sqlsplit");
249         }
250         if (!checkSqlGenerate.isSelected() && checkJavaGenerate.isSelected()) {
251             project.setDodsParameters("dods:javaNoCompile");
252         }
253         if (checkSqlGenerate.isSelected() && checkJavaGenerate.isSelected()) {
254             if (!checkSqlSplitter.isSelected())
255               project.setDodsParameters("dods:noCompile");
256         else
257             project.setDodsParameters("dods:noCompileSplit");
258         }
259
260         if (jCheckBoxDoml2Html.isSelected())
261             project.setDocumentationHtml("html");
262         else
263             project.setDocumentationHtml("");
264
265         if (jCheckBoxDoml2Pdf.isSelected())
266             project.setDocumentationPdf("pdf");
267         else
268             project.setDocumentationPdf("");
269
270         if (jCheckBoxDoml2Xmi.isSelected())
271             project.setDocumentationXmi("xmi");
272         else
273             project.setDocumentationXmi("");
274
275         if (jCheckBoxDoml2Ptl.isSelected())
276             project.setDocumentationPtl("ptl");
277         else
278             project.setDocumentationPtl("");
279
280         project.setTemplateSet(((String JavaDoc)jComboBoxTemplateSet.getSelectedItem()).substring(1));
281
282     }
283
284     //
285
protected WriteListener getWriteListener() {
286         return outputPanel;
287     }
288
289     protected Component[] getFirstFocusComponents() {
290         Component[] comps = new Component[9];
291
292         comps[0] = buttonDomlFile;
293         comps[1] = jCheckBoxDoml2Html;
294         comps[2] = jCheckBoxDoml2Pdf;
295         comps[3] = jCheckBoxDoml2Xmi;
296         comps[4] = jCheckBoxDoml2Ptl;
297         comps[5] = checkSqlGenerate;
298         comps[6] = checkSqlSplitter;
299         comps[7] = checkJavaGenerate;
300         comps[8] = checkBuild;
301         return comps;
302     }
303
304     //
305
private boolean isValidDodsRoot(PathHandle ph) {
306         boolean valid = false;
307
308         if (!ph.isFile()) {
309             if (ph.getParent() != null) {
310                 valid = ph.getParent().isDirectory();
311             }
312         }
313         return valid;
314     }
315
316     private boolean isValidLogFile(PathHandle ph) {
317         boolean valid = false;
318
319         if (ph.hasExtension("txt")) {
320             if (ph.isFile()) {
321                 valid = true;
322             } else if (ph.getParent() != null) {
323                 valid = ph.getParent().isDirectory();
324             }
325         }
326         return valid;
327     }
328
329     //
330
private void chooseDodsRoot() {
331         File JavaDoc choice = null;
332         PathHandle path = null;
333
334         choice =
335             SwingUtil.getDirectoryChoice(this, textDomlFile.getText(),
336                                          "Select Dods root directory");
337         path = PathHandle.createPathHandle(choice);
338         if (path.isDirectory()) {
339             textDomlFile.setText(path.getPath());
340             textDomlFile.setToolTipText(textDomlFile.getText());
341         }
342     }
343
344     private void pmInit() {
345         buttonListener = new LocalButtonListener();
346         buttonRootPath.addActionListener(buttonListener);
347         buttonDomlFile.addActionListener(buttonListener);
348         buttonMessage.addActionListener(buttonListener);
349
350         checkBoxListener = new CheckBoxListener();
351         checkSqlGenerate.addActionListener(checkBoxListener);
352         checkJavaGenerate.addActionListener(checkBoxListener);
353         checkBuild.addActionListener(checkBoxListener);
354         //Dusan 12.02.2003.
355
jCheckBoxDoml2Html.addActionListener(checkBoxListener);
356         jCheckBoxDoml2Pdf.addActionListener(checkBoxListener);
357         jCheckBoxDoml2Xmi.addActionListener(checkBoxListener);
358         jCheckBoxDoml2Ptl.addActionListener(checkBoxListener);
359    }
360
361     private void jbInit() throws Exception JavaDoc {
362         panelRootPath =
363             (JPanel) Beans.instantiate(getClass().getClassLoader(),
364                                        JPanel.class.getName());
365         layoutRootPath =
366             (GridBagLayout) Beans.instantiate(getClass().getClassLoader(),
367                                               GridBagLayout.class.getName());
368         textRootPath =
369             (JTextField) Beans.instantiate(getClass().getClassLoader(),
370                                            JTextField.class.getName());
371         buttonRootPath =
372             (JButton) Beans.instantiate(getClass().getClassLoader(),
373                                         JButton.class.getName());
374         labelRootPath = (JLabel) Beans.instantiate(getClass().getClassLoader(),
375                                               JLabel.class.getName());
376         labelDomlFile = (JLabel) Beans.instantiate(getClass().getClassLoader(),
377                                               JLabel.class.getName());
378         panelDomlFile =
379             (JPanel) Beans.instantiate(getClass().getClassLoader(),
380                                        JPanel.class.getName());
381         layoutDomlFile =
382             (GridBagLayout) Beans.instantiate(getClass().getClassLoader(),
383                                               GridBagLayout.class.getName());
384         textDomlFile =
385             (JTextField) Beans.instantiate(getClass().getClassLoader(),
386                                            JTextField.class.getName());
387         buttonDomlFile =
388             (JButton) Beans.instantiate(getClass().getClassLoader(),
389                                         JButton.class.getName());
390         panelMessage = (JPanel) Beans.instantiate(getClass().getClassLoader(),
391                                                   JPanel.class.getName());
392         //Dusan 12.02.2003.
393
panelDocumentation =
394             (JPanel) Beans.instantiate(getClass().getClassLoader(),
395                                        JPanel.class.getName());
396         labelDocumentation = (JLabel) Beans.instantiate(getClass().getClassLoader(),
397                                               JLabel.class.getName());
398         //Dusan 12.3.2003.
399
panelTemplateSet =
400             (JPanel) Beans.instantiate(getClass().getClassLoader(),
401                                        JPanel.class.getName());
402         labelTemplateSet = (JLabel) Beans.instantiate(getClass().getClassLoader(),
403                                               JLabel.class.getName());
404         layoutExtensions =
405             (GridBagLayout) Beans.instantiate(getClass().getClassLoader(),
406                                               GridBagLayout.class.getName());
407         jCheckBoxDoml2Html =
408             (JCheckBox) Beans.instantiate(getClass().getClassLoader(),
409                                           JCheckBox.class.getName());
410         jCheckBoxDoml2Pdf =
411             (JCheckBox) Beans.instantiate(getClass().getClassLoader(),
412                                           JCheckBox.class.getName());
413         jCheckBoxDoml2Xmi =
414             (JCheckBox) Beans.instantiate(getClass().getClassLoader(),
415                                           JCheckBox.class.getName());
416         jCheckBoxDoml2Ptl =
417             (JCheckBox) Beans.instantiate(getClass().getClassLoader(),
418                                           JCheckBox.class.getName());
419
420         checkSqlGenerate =
421             (JCheckBox) Beans.instantiate(getClass().getClassLoader(),
422                                           JCheckBox.class.getName());
423         checkSqlSplitter =
424             (JCheckBox) Beans.instantiate(getClass().getClassLoader(),
425                                           JCheckBox.class.getName());
426         checkJavaGenerate =
427             (JCheckBox) Beans.instantiate(getClass().getClassLoader(),
428                                           JCheckBox.class.getName());
429         checkBuild =
430             (JCheckBox) Beans.instantiate(getClass().getClassLoader(),
431                                           JCheckBox.class.getName());
432         buttonMessage =
433             (JButton) Beans.instantiate(getClass().getClassLoader(),
434                                         JButton.class.getName());
435         layoutMain =
436             (GridBagLayout) Beans.instantiate(getClass().getClassLoader(),
437                                               GridBagLayout.class.getName());
438         tabMessage =
439             (JTabbedPane) Beans.instantiate(getClass().getClassLoader(),
440                                             JTabbedPane.class.getName());
441         panelMessageOption =
442             (JPanel) Beans.instantiate(getClass().getClassLoader(),
443                                        JPanel.class.getName());
444         outputPanel =
445             (OutputPanel) Beans.instantiate(getClass().getClassLoader(),
446                                             OutputPanel.class.getName());
447         layoutMessageOption =
448             (GridBagLayout) Beans.instantiate(getClass().getClassLoader(),
449                                               GridBagLayout.class.getName());
450         layoutMessage =
451             (BorderLayout) Beans.instantiate(getClass().getClassLoader(),
452                                              BorderLayout.class.getName());
453         comboType = (JComboBox) Beans.instantiate(getClass().getClassLoader(),
454                                                   JComboBox.class.getName());
455         layoutType =
456             (GridBagLayout) Beans.instantiate(getClass().getClassLoader(),
457                                               GridBagLayout.class.getName());
458
459         DODSGenerator generator = new DODSGenerator();
460
461         HashSet dirs = Common.getAllTemplateSets();
462         String JavaDoc item= null;
463         int i = 0;
464         int selIndex = 0;
465         for (Iterator iter = dirs.iterator(); iter.hasNext(); i++) {
466             item = (String JavaDoc)iter.next();
467             jComboBoxTemplateSet.addItem(" "+item);
468             if (item.equals(generator.getTemplateSet()) )
469                 selIndex = i;
470         }
471         jComboBoxTemplateSet.setSelectedIndex(selIndex);
472         jComboBoxTemplateSet.setMinimumSize(new Dimension(121, 20));
473
474 // checkBuild = (JCheckBox) Beans.instantiate(getClass().getClassLoader(), JCheckBox.class.getName());
475
textRootPath.setEnabled(false);
476     textRootPath.setMinimumSize(new Dimension(200, 21));
477     textRootPath.setPreferredSize(new Dimension(200, 21));
478         textRootPath.setEditable(false);
479         textRootPath.setText("Output directory");
480         buttonRootPath.setText("Set...");
481     buttonRootPath.setMaximumSize(new Dimension(61, 24));
482     buttonRootPath.setMinimumSize(new Dimension(61, 24));
483     buttonRootPath.setToolTipText("");
484 // buttonRootPath.setMargin(new Insets(3, 130, 15, 65));
485
buttonRootPath.setMnemonic('0');
486     buttonRootPath.setText("Set...");
487
488     // panelRootPath.setLayout(xyLayout);
489
panelRootPath.setLayout(layoutDomlFile);
490     panelRootPath.setAlignmentX((float) 0.1);
491     panelRootPath.setAlignmentY((float) 0.1);
492 /* panelRootPath.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(),
493                 "Output directory"));
494     panelRootPath.setMinimumSize(new Dimension(97, 45)); */

495     panelRootPath.setMinimumSize(new Dimension(80, 45));
496
497     labelRootPath.setHorizontalAlignment(SwingConstants.RIGHT);
498     labelRootPath.setText("Output directory:");
499         textDomlFile.setEnabled(true);
500     textDomlFile.setMinimumSize(new Dimension(200, 21));
501     textDomlFile.setPreferredSize(new Dimension(200, 21));
502         textDomlFile.setEditable(true);
503         textDomlFile.setText("");
504         buttonDomlFile.setMaximumSize(new Dimension(61, 24));
505     buttonDomlFile.setMinimumSize(new Dimension(61, 24));
506     buttonDomlFile.setPreferredSize(new Dimension(61, 24));
507     buttonDomlFile.setText("Set...");
508         buttonMessage.setText("...");
509         panelDomlFile.setLayout(layoutDomlFile);
510 /* panelDomlFile.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(),
511                 "Doml file")); */

512     panelDomlFile.setMinimumSize(new Dimension(97, 45));
513     labelDomlFile.setHorizontalAlignment(SwingConstants.RIGHT);
514     labelDomlFile.setText("Doml file:");
515
516         //Dusan 12.02.2004.
517
panelDocumentation.setLayout(layoutExtensions);
518 /* panelDocumentation.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(),
519                 "Documentation:")); */

520     panelDocumentation.setMinimumSize(new Dimension(375, 45));
521     labelDocumentation.setHorizontalAlignment(SwingConstants.RIGHT);
522     labelDocumentation.setText("Documentation:");
523         panelTemplateSet.setLayout(layoutExtensions);
524 /* panelTemplateSet.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(),
525                 "Template set:")); */

526     labelTemplateSet.setHorizontalAlignment(SwingConstants.RIGHT);
527     labelTemplateSet.setText("Template set:");
528 // jTemplateTypeLabel.setText("Extensions :");
529
jCheckBoxDoml2Html.setText("HTML");
530         jCheckBoxDoml2Html.setSelected(false);
531         jCheckBoxDoml2Pdf.setText("PDF");
532         jCheckBoxDoml2Pdf.setSelected(false);
533         jCheckBoxDoml2Xmi.setText("XMI");
534         jCheckBoxDoml2Xmi.setSelected(false);
535         jCheckBoxDoml2Ptl.setText("PTL");
536         jCheckBoxDoml2Ptl.setSelected(false);
537
538         checkSqlGenerate.setText("SQL generate");
539         checkSqlGenerate.setSelected(true);
540         checkSqlSplitter.setText("SQL Splitter");
541         checkSqlSplitter.setSelected(true);
542         checkJavaGenerate.setText("Java generate");
543         checkJavaGenerate.setSelected(true);
544         checkBuild.setText("Invoke Dods Generator during Project Make/Rebuild");
545         checkBuild.setSelected(false);
546         panelMessageOption.setLayout(layoutMessageOption);
547         this.setAlignmentX((float) 0.1);
548     this.setAlignmentY((float) 0.1);
549     this.setPreferredSize(new Dimension(500, 670));
550     panelMessage.setMinimumSize(new Dimension(41, 70));
551
552 // panelRootPath.add(labelRootPath, new XYConstraints(1, 1, -1, -1));
553
// panelRootPath.add(textRootPath, new XYConstraints(130, 1, 130, 50));
554

555         panelRootPath.add(labelRootPath,
556                             new GridBagConstraints(0, 0, 1, 1, 0.8, 0.0,
557                                                    GridBagConstraints.WEST,
558                                                    GridBagConstraints.HORIZONTAL,
559 // new Insets(3, 5, 3, 5), 0,
560
// 0));
561
new Insets(1, 1, 1, 1), 0,
562                                                    0));
563     panelRootPath.add(textRootPath,
564                             new GridBagConstraints(1, 0, 1, 1, 0.8, 0.0,
565                                                    GridBagConstraints.WEST,
566                                                    GridBagConstraints.HORIZONTAL,
567 // new Insets(3, 5, 3, 5), 0,
568
// 0));
569
new Insets(1, 1, 1, 1), 0,
570                                                    0));
571         panelRootPath.add(buttonRootPath,
572                             new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
573                                                    GridBagConstraints.CENTER,
574                                                    GridBagConstraints.NONE,
575                                                    new Insets(3, 5, 3, 5), 0,
576                                                    0));
577
578         panelDomlFile.add(labelDomlFile,
579                               new GridBagConstraints(0, 0, 1, 1, 0.8, 0.0
580             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(1, 1, 1, 1), 0, 0));
581         panelDomlFile.add(textDomlFile,
582                                     new GridBagConstraints(1, 0, 1, 1, 0.8, 0.0
583             ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(1, 1, 1, 1), 0, 0));
584         panelDomlFile.add(buttonDomlFile,
585                             new GridBagConstraints(2, 0, 1, 1, 0.0, 0.0,
586                                                    GridBagConstraints.CENTER,
587                                                    GridBagConstraints.NONE,
588                                                    new Insets(3, 5, 3, 5), 0,
589                                                    0));
590
591         panelDocumentation.add(labelDocumentation,
592                              new GridBagConstraints(0, 0, 1, 1, 0.8, 0.0
593             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 5, 3, 5), 0, 0));
594         panelDocumentation.add(jCheckBoxDoml2Html,
595                              new GridBagConstraints(1, 0, 1, 1, 0.8, 0.0
596             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 5, 3, 5), 0, 0));
597         panelDocumentation.add(jCheckBoxDoml2Pdf,
598                              new GridBagConstraints(2, 0, 1, 1, 0.8, 0.0
599             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 5, 3, 5), 0, 0));
600         panelDocumentation.add(jCheckBoxDoml2Xmi,
601                              new GridBagConstraints(3, 0, 1, 1, 0.8, 0.0
602             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 5, 3, 5), 0, 0));
603         panelDocumentation.add(jCheckBoxDoml2Ptl,
604                              new GridBagConstraints(4, 0, 1, 1, 0.8, 0.0
605             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 5, 3, 5), 0, 0));
606
607         panelTemplateSet.add(labelTemplateSet,
608                              new GridBagConstraints(0, 0, 1, 1, 0.8, 0.0
609             ,GridBagConstraints.EAST, GridBagConstraints.NONE, new Insets(3, 5, 3, 5), 0, 0));
610         panelTemplateSet.add(jComboBoxTemplateSet,
611                              new GridBagConstraints(1, 0, 1, 1, 0.8, 0.0
612             ,GridBagConstraints.WEST, GridBagConstraints.NONE, new Insets(3, 5, 3, 5), 0, 0));
613
614         panelMessage.setLayout(layoutMessage);
615 /* panelMessage.setBorder(BorderFactory.createTitledBorder(new EtchedBorder(),
616                 "Dods messages")); */

617
618         this.setLayout(layoutMain);
619         this.add(panelDomlFile, new GridBagConstraints(0, 1, 2, 1, 0.1, 0.0
620             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(0, 10, 0, 5), 0, 0));
621         this.add(checkSqlGenerate,
622                      new GridBagConstraints(0, 5, 1, 1, 0.0, 0.0
623             ,GridBagConstraints.WEST, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
624         this.add(panelDocumentation,
625                          new GridBagConstraints(0, 3, 2, 1, 0.1, 0.0
626             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 5), 0, 0));
627         this.add(panelTemplateSet,
628                          new GridBagConstraints(0, 4, 2, 1, 0.1, 0.0
629             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 5), 0, 0));
630         this.add(checkSqlSplitter,
631                      new GridBagConstraints(1, 5, 1, 1, 0.1, 0.0
632             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
633         this.add(checkJavaGenerate,
634                       new GridBagConstraints(0, 6, 1, 1, 0.1, 0.0
635             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 10, 2, 10), 0, 0));
636     this.add(checkBuild, new GridBagConstraints(1, 6, 2, 1, 0.1, 0.0
637             ,GridBagConstraints.CENTER, GridBagConstraints.HORIZONTAL, new Insets(2, 5, 2, 5), 0, 0));
638     this.add(panelMessage, new GridBagConstraints(0, 2, 2, 1, 0.1, 0.0
639             ,GridBagConstraints.NORTHEAST, GridBagConstraints.HORIZONTAL, new Insets(-2, 8, 0, 2), 0, 60));
640     panelMessage.add(tabMessage, BorderLayout.CENTER);
641     this.add(panelRootPath, new GridBagConstraints(0, 0, 2, 1, 0.1, 0.0
642             ,GridBagConstraints.NORTH, GridBagConstraints.HORIZONTAL, new Insets(-5, 3, 0, 7), 0, 0));
643     tabMessage.add(outputPanel, "Messages");
644     }
645
646     private class CheckBoxListener implements ActionListener JavaDoc {
647         public void actionPerformed(ActionEvent JavaDoc event) {
648             Object JavaDoc source = event.getSource();
649
650             if (source == checkSqlGenerate) {
651          if (checkSqlGenerate.isSelected()) {
652            checkSqlSplitter.setSelected(true);
653            checkSqlSplitter.setEnabled(true);
654            }
655          else {
656         checkSqlSplitter.setSelected(false);
657         checkSqlSplitter.setEnabled(false);
658            }
659             }
660             //Dusan 25.01.2003.
661
if (source == checkSqlGenerate) {
662          if (!checkSqlGenerate.isSelected()) {
663            checkJavaGenerate.setSelected(true);
664            }
665             }
666             if (source == checkJavaGenerate) {
667          if (!checkJavaGenerate.isSelected()) {
668            checkSqlGenerate.setSelected(true);
669            checkSqlSplitter.setSelected(true);
670            checkSqlSplitter.setEnabled(true);
671            }
672             }
673       }
674     }
675
676     //
677
private void chooseDomlFile() {
678         File JavaDoc choice = null;
679         PathHandle path = null;
680         ExtensionFilter filter = null;
681
682         filter = new ExtensionFilter();
683         filter.addExtension("doml");
684
685 /* choice =
686             SwingUtil.getFileChoice(this, textDomlFile.getText(),
687               filter, "Select Doml file"); */

688         choice =
689             SwingUtil.getFileChoice(this, "c:\temp",
690               filter, "Select Doml file");
691         path = PathHandle.createPathHandle(choice);
692         if (path.isFile()) {
693             textDomlFile.setText(path.getPath());
694             textDomlFile.setToolTipText(textDomlFile.getText());
695         }
696     }
697
698     private class LocalButtonListener implements ActionListener JavaDoc {
699         public void actionPerformed(ActionEvent JavaDoc event) {
700             Object JavaDoc source = event.getSource();
701
702             if (source == buttonDomlFile) {
703 //Dusan 23.11.2002.
704
// chooseDomlFile();
705
browseForFile();
706             } else if(source == buttonRootPath) {
707                 browseForDirectory();
708             }
709         }
710
711     }
712
713     /**
714      * Method declaration
715      *
716      */

717     private void browseForFile() {
718         JFileChooser chooser;
719         ExtensionFilter filter;
720         File JavaDoc file;
721         String JavaDoc fileDir = new String JavaDoc();
722         String JavaDoc fileName = new String JavaDoc();
723
724         filter = new ExtensionFilter();
725         filter.addExtension(Constants.TYPE_DODS);
726         filter.setDescriptionTitle(res.getString("filter_Doml_DescriptionTitle"));
727         chooser = new JFileChooser();
728         if (textDomlFile.getText().trim().length() > 0) {
729             chooser.setCurrentDirectory(new File JavaDoc(textDomlFile.getText()));
730         } else {
731             PathHandle ph = null;
732             chooser.setCurrentDirectory(new File JavaDoc(""));
733         }
734         chooser.setFileFilter(filter);
735         chooser.setDialogTitle(res.getString("chooser_DODS_DialogTitle"));
736         chooser.setApproveButtonText(res.getString("OK"));
737         int v = chooser.showOpenDialog(this);
738
739         this.requestFocus();
740         buttonDomlFile.requestFocus();
741         if (v == JFileChooser.APPROVE_OPTION) {
742             if (chooser.getSelectedFile() == null
743                     || (!chooser.getSelectedFile().isFile())) {
744                 textDomlFile.setText(new String JavaDoc());
745             } else {
746                 fileDir = chooser.getCurrentDirectory().toString();
747                 fileDir = stripSlash(fileDir);
748                 fileName = chooser.getSelectedFile().getName();
749                 String JavaDoc strDomlFile = fileDir + File.separator + fileName;
750                 textDomlFile.setText(strDomlFile.replace('\\','/'));
751            }
752         }
753         chooser.removeAll();
754         chooser = null;
755     }
756
757     /**
758      * Method declaration
759      *
760      *
761      * @param dir
762      *
763      * @return
764      */

765     private String JavaDoc stripSlash(String JavaDoc dir) {
766         String JavaDoc stripped = new String JavaDoc(dir);
767
768         if (dir != null) {
769             if (dir.length() > 0) {
770                 if (dir.endsWith(File.separator)) {
771                     stripped = dir.substring(0, dir.length() - 1);
772                 }
773             }
774         }
775         return stripped;
776     }
777
778     //
779
private boolean isValidDeployRoot(PathHandle ph) {
780         boolean valid = false;
781
782         if (!ph.isFile()) {
783             if (ph.getParent() != null) {
784                 valid = ph.getParent().isDirectory();
785             }
786         }
787         return valid;
788     }
789
790     /**
791      * Method declaration
792      *
793      */

794     private void browseForDirectory() {
795         JFileChooser chooser;
796         File JavaDoc file;
797         String JavaDoc fileDir = new String JavaDoc();
798         String JavaDoc fileName = new String JavaDoc();
799
800         chooser = new JFileChooser();
801         if (textRootPath.getText().trim().length() > 0) {
802             chooser.setCurrentDirectory(new File JavaDoc(textRootPath.getText()));
803         } else {
804             PathHandle ph = null;
805
806             chooser.setCurrentDirectory(new File JavaDoc(""));
807         }
808         chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
809         chooser.setFileFilter((javax.swing.filechooser.FileFilter JavaDoc) new DirectoryFilter());
810         chooser.setDialogTitle(res.getString("chooser_RootPath_DialogTitle"));
811         chooser.setApproveButtonText(res.getString("OK"));
812         int v = chooser.showOpenDialog(this);
813
814         this.requestFocus();
815         buttonRootPath.requestFocus();
816         if (v == JFileChooser.APPROVE_OPTION) {
817             if (chooser.getSelectedFile() == null) {
818                 textRootPath.setText(new String JavaDoc());
819             } else {
820                 fileDir = chooser.getCurrentDirectory().toString();
821                 fileDir = stripSlash(fileDir);
822                 fileName = chooser.getSelectedFile().getName();
823                 String JavaDoc strRootPath = fileDir + File.separator + fileName;
824                 textRootPath.setText(strRootPath.replace('\\','/'));
825             }
826         }
827         chooser.removeAll();
828         chooser = null;
829     }
830
831 /* public void setDODSGenerator(DODSGenerator gen) {
832       generator = gen;
833     } */

834
835 }
836
Popular Tags