KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > enhydra > dods > wizard > WizardFrame1


1 package org.enhydra.dods.wizard;
2
3 import java.awt.AWTEvent JavaDoc;
4 import java.awt.BorderLayout JavaDoc;
5 import java.awt.Color JavaDoc;
6 import java.awt.Dimension JavaDoc;
7 import java.awt.FlowLayout JavaDoc;
8 import java.awt.GridBagLayout JavaDoc;
9 import java.awt.Image JavaDoc;
10 import java.awt.Insets JavaDoc;
11 import java.awt.Toolkit JavaDoc;
12 import java.awt.event.ActionEvent JavaDoc;
13 import java.awt.event.WindowEvent JavaDoc;
14 import java.io.File JavaDoc;
15 import java.util.HashSet JavaDoc;
16 import java.util.Iterator JavaDoc;
17 import java.util.ResourceBundle JavaDoc;
18 import java.util.Set JavaDoc;
19
20 import javax.swing.DebugGraphics JavaDoc;
21 import javax.swing.ImageIcon JavaDoc;
22 import javax.swing.JButton JavaDoc;
23 import javax.swing.JCheckBox JavaDoc;
24 import javax.swing.JComboBox JavaDoc;
25 import javax.swing.JFileChooser JavaDoc;
26 import javax.swing.JFrame JavaDoc;
27 import javax.swing.JLabel JavaDoc;
28 import javax.swing.JOptionPane JavaDoc;
29 import javax.swing.JPanel JavaDoc;
30 import javax.swing.JTextField JavaDoc;
31
32 import org.enhydra.dods.Common;
33 import org.enhydra.dods.xml.XmlUtil;
34
35 /**
36  * DODS Generator Wizard main frame
37  * @author Nenad Vico
38  * @version 1.0
39  */

40 public class WizardFrame1 extends JFrame JavaDoc {
41     JPanel JavaDoc contentPane;
42     JPanel JavaDoc jButtonPanel = new JPanel JavaDoc();
43     JPanel JavaDoc jPictPanel = new JPanel JavaDoc();
44     JPanel JavaDoc jContentPanel = new JPanel JavaDoc();
45     BorderLayout JavaDoc borderLayout1 = new BorderLayout JavaDoc();
46     FlowLayout JavaDoc flowLayout1 = new FlowLayout JavaDoc();
47     GridBagLayout JavaDoc gridBagLayout1 = new GridBagLayout JavaDoc();
48     XYLayout xyLayout = new XYLayout();
49     JLabel JavaDoc jIconLabel = new JLabel JavaDoc();
50     JLabel JavaDoc jTitleLabel = new JLabel JavaDoc();
51     JLabel JavaDoc jOutputDirLabel = new JLabel JavaDoc();
52     JLabel JavaDoc jDomlRootLabel = new JLabel JavaDoc();
53     JLabel JavaDoc jTemplateTypeLabel = new JLabel JavaDoc();
54     JLabel JavaDoc jDocLabel = new JLabel JavaDoc();
55     JLabel JavaDoc jVendorTypeLabel = new JLabel JavaDoc();
56     JLabel JavaDoc jJavaLabel = new JLabel JavaDoc();
57     JLabel JavaDoc jConfigDirLabel = new JLabel JavaDoc();
58     JTextField JavaDoc jOutputDirTextField = new JTextField JavaDoc();
59     JTextField JavaDoc jDomlTextField = new JTextField JavaDoc();
60     JTextField JavaDoc jConfigDirTextField = new JTextField JavaDoc();
61     JButton JavaDoc jDomlButton = new JButton JavaDoc();
62     JButton JavaDoc jSpaceButton = new JButton JavaDoc();
63     JButton JavaDoc jGenerateButton = new JButton JavaDoc();
64     JButton JavaDoc jCancelButton = new JButton JavaDoc();
65     JButton JavaDoc jOutputDirButton = new JButton JavaDoc();
66     JButton JavaDoc jSpace = new JButton JavaDoc();
67     JButton JavaDoc jCloseButton = new JButton JavaDoc();
68     JButton JavaDoc jSpace1 = new JButton JavaDoc();
69     JButton JavaDoc jConfigDirButton = new JButton JavaDoc();
70     Image JavaDoc appImage = Toolkit.getDefaultToolkit().getImage(getClass().getResource("smallicon.gif"));
71     ImageIcon JavaDoc enhydra = new ImageIcon JavaDoc(Toolkit.getDefaultToolkit().getImage(getClass().getResource("Enhydra.gif")));
72     ResourceBundle JavaDoc rb;
73     JCheckBox JavaDoc jCheckBoxSQL = new JCheckBox JavaDoc();
74     JCheckBox JavaDoc jCheckBoxSQLSplitter = new JCheckBox JavaDoc();
75     JCheckBox JavaDoc jCheckBoxJava = new JCheckBox JavaDoc();
76     JCheckBox JavaDoc jCheckBoxCompile = new JCheckBox JavaDoc();
77     JCheckBox JavaDoc jCheckBoxDoml2Html = new JCheckBox JavaDoc();
78     JCheckBox JavaDoc jCheckBoxDoml2Pdf = new JCheckBox JavaDoc();
79     JCheckBox JavaDoc jCheckBoxDoml2Xmi = new JCheckBox JavaDoc();
80     JCheckBox JavaDoc jCheckBoxDoml2Ptl = new JCheckBox JavaDoc();
81     JCheckBox JavaDoc jCheckBoxForce = new JCheckBox JavaDoc();
82     JCheckBox JavaDoc jCheckBoxInvoke = new JCheckBox JavaDoc();
83     JComboBox JavaDoc jComboBoxTemplateSet = new JComboBox JavaDoc();
84     JComboBox JavaDoc jComboBoxVendors = new JComboBox JavaDoc();
85     // Construct the frame
86
public WizardFrame1() {
87         enableEvents(AWTEvent.WINDOW_EVENT_MASK);
88         try {
89             jbInit();
90         } catch (Exception JavaDoc e) {
91             e.printStackTrace();
92         }
93     }
94
95     // Component initialization
96
private void jbInit() throws Exception JavaDoc {
97         setIconImage(appImage);
98         this.setResizable(false);
99         contentPane = (JPanel JavaDoc) this.getContentPane();
100         contentPane.setLayout(borderLayout1);
101         this.setSize(new Dimension JavaDoc(570, 550));
102         this.setTitle("DODS Generator Wizard");
103         jButtonPanel.setDebugGraphicsOptions(DebugGraphics.NONE_OPTION);
104         jButtonPanel.setMinimumSize(new Dimension JavaDoc(233, 50));
105         jButtonPanel.setPreferredSize(new Dimension JavaDoc(500, 50));
106         jContentPanel.setLayout(xyLayout);
107         jGenerateButton.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 11));
108         if (DefaultDODSWizard.getGenerator().getKelp()) {
109             jGenerateButton.setNextFocusableComponent(jCheckBoxInvoke);
110         } else {
111             jGenerateButton.setNextFocusableComponent(jConfigDirTextField);
112         }
113         jGenerateButton.setActionCommand("Generate");
114         jGenerateButton.setSelected(true);
115         jGenerateButton.setText("Generate");
116         jGenerateButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
117             public void actionPerformed(ActionEvent JavaDoc e) {
118                 jGenerateButton_actionPerformed(e);
119             }
120         });
121         jCancelButton.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 11));
122         if (DefaultDODSWizard.getGenerator().getKelp()) {
123             jCancelButton.setNextFocusableComponent(jCloseButton);
124         } else {
125             jCancelButton.setNextFocusableComponent(jGenerateButton);
126         }
127         jCancelButton.setText("Cancel");
128         jCancelButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
129             public void actionPerformed(ActionEvent JavaDoc e) {
130                 jCancelButton_actionPerformed(e);
131             }
132         });
133         jCloseButton.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 11));
134         jCloseButton.setNextFocusableComponent(jGenerateButton);
135         jCloseButton.setText(" Close ");
136         jCloseButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
137             public void actionPerformed(ActionEvent JavaDoc e) {
138                 jCloseButton_actionPerformed(e);
139             }
140         });
141         jConfigDirTextField.setNextFocusableComponent(jConfigDirButton);
142         jConfigDirTextField.setText(Common.getConfigDir());
143         jConfigDirLabel.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 12));
144         jConfigDirLabel.setText("Config directory :");
145         jConfigDirButton.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 12));
146         jConfigDirButton.setMaximumSize(new Dimension JavaDoc(55, 25));
147         jConfigDirButton.setMinimumSize(new Dimension JavaDoc(55, 25));
148         jConfigDirButton.setNextFocusableComponent(jOutputDirTextField);
149         jConfigDirButton.setPreferredSize(new Dimension JavaDoc(55, 25));
150         jConfigDirButton.setMargin(new Insets JavaDoc(2, 14, 3, 14));
151         jConfigDirButton.setText("Set ...");
152         jConfigDirButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
153             public void actionPerformed(ActionEvent JavaDoc e) {
154                 jConfigDirButton_actionPerformed(e);
155             }
156         });
157         jSpace.setEnabled(false);
158         jSpace.setBorder(null);
159         jSpace.setPreferredSize(new Dimension JavaDoc(30, 20));
160         jSpace.setFocusPainted(false);
161         jSpace.setMargin(new Insets JavaDoc(2, 50, 2, 14));
162         jSpace1.setEnabled(false);
163         jSpace1.setBorder(null);
164         jSpace1.setPreferredSize(new Dimension JavaDoc(30, 20));
165         jSpace1.setFocusPainted(false);
166         jSpace1.setMargin(new Insets JavaDoc(2, 50, 2, 14));
167         jOutputDirTextField.setNextFocusableComponent(jOutputDirButton);
168         jOutputDirTextField.setText(DefaultDODSWizard.getGenerator().getOutputDir());
169         jDomlTextField.setNextFocusableComponent(jDomlButton);
170         jDomlTextField.setText(DefaultDODSWizard.getGenerator().getDoml());
171         jTitleLabel.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 12));
172         jTitleLabel.setText("Please select config directory, output directory, doml file, template set and choose actions.");
173         jOutputDirLabel.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 12));
174         jOutputDirLabel.setText("Output directory :");
175         jOutputDirButton.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 12));
176         jOutputDirButton.setMaximumSize(new Dimension JavaDoc(55, 25));
177         jOutputDirButton.setMinimumSize(new Dimension JavaDoc(55, 25));
178         jOutputDirButton.setNextFocusableComponent(jDomlTextField);
179         jOutputDirButton.setPreferredSize(new Dimension JavaDoc(55, 25));
180         jOutputDirButton.setMargin(new Insets JavaDoc(2, 14, 3, 14));
181         jOutputDirButton.setText("Set ...");
182         jOutputDirButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
183             public void actionPerformed(ActionEvent JavaDoc e) {
184                 jOutputDirButton_actionPerformed(e);
185             }
186         });
187         jDomlRootLabel.setText("Doml file :");
188         jDomlRootLabel.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 12));
189         jDomlButton.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 12));
190         jDomlButton.setMaximumSize(new Dimension JavaDoc(50, 25));
191         jDomlButton.setMinimumSize(new Dimension JavaDoc(55, 25));
192         jDomlButton.setNextFocusableComponent(jCheckBoxDoml2Html);
193         jDomlButton.setPreferredSize(new Dimension JavaDoc(55, 25));
194         jDomlButton.setMargin(new Insets JavaDoc(2, 14, 3, 14));
195         jDomlButton.setText("Set ...");
196         jDomlButton.addActionListener(new java.awt.event.ActionListener JavaDoc() {
197             public void actionPerformed(ActionEvent JavaDoc e) {
198                 jDomlButton_actionPerformed(e);
199             }
200         });
201         jDocLabel.setText("Documentation :");
202         jDocLabel.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 12));
203         jCheckBoxDoml2Html.setMaximumSize(new Dimension JavaDoc(100, 22));
204         jCheckBoxDoml2Html.setMinimumSize(new Dimension JavaDoc(100, 22));
205         jCheckBoxDoml2Html.setNextFocusableComponent(jCheckBoxDoml2Pdf);
206         jCheckBoxDoml2Html.setSelected(DefaultDODSWizard.getGenerator().getHtml());
207         jCheckBoxDoml2Html.setText(" HTML");
208         jCheckBoxDoml2Pdf.setMaximumSize(new Dimension JavaDoc(100, 22));
209         jCheckBoxDoml2Pdf.setMinimumSize(new Dimension JavaDoc(100, 22));
210         jCheckBoxDoml2Pdf.setNextFocusableComponent(jCheckBoxDoml2Xmi);
211         jCheckBoxDoml2Pdf.setSelected(DefaultDODSWizard.getGenerator().getPdf());
212         jCheckBoxDoml2Pdf.setText(" PDF");
213         jCheckBoxDoml2Xmi.setMaximumSize(new Dimension JavaDoc(100, 22));
214         jCheckBoxDoml2Xmi.setMinimumSize(new Dimension JavaDoc(100, 22));
215         jCheckBoxDoml2Xmi.setNextFocusableComponent(jCheckBoxDoml2Ptl);
216         jCheckBoxDoml2Xmi.setSelected(DefaultDODSWizard.getGenerator().getXmi());
217         jCheckBoxDoml2Xmi.setText(" XMI");
218         jCheckBoxDoml2Ptl.setMaximumSize(new Dimension JavaDoc(100, 22));
219         jCheckBoxDoml2Ptl.setMinimumSize(new Dimension JavaDoc(100, 22));
220         jCheckBoxDoml2Ptl.setNextFocusableComponent(jComboBoxTemplateSet);
221         jCheckBoxDoml2Ptl.setSelected(DefaultDODSWizard.getGenerator().getPtl());
222         jCheckBoxDoml2Ptl.setText("PTL");
223         jCheckBoxForce.setMaximumSize(new Dimension JavaDoc(100, 22));
224         jCheckBoxForce.setMinimumSize(new Dimension JavaDoc(100, 22));
225         jCheckBoxForce.setNextFocusableComponent(jComboBoxVendors);
226         jCheckBoxForce.setSelected(true);
227         if (DefaultDODSWizard.getGenerator().getForce().equals("false")) {
228             jCheckBoxForce.setSelected(false);
229         }
230         jCheckBoxForce.setText("Overwrite");
231         jCheckBoxInvoke.setNextFocusableComponent(jOutputDirTextField);
232         jCheckBoxInvoke.setSelected(DefaultDODSWizard.getGenerator().getInvoke());
233         jCheckBoxInvoke.setText("Invoke DODS generator during project ant rebild");
234         jTemplateTypeLabel.setText("Template set :");
235         jTemplateTypeLabel.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 12));
236         jComboBoxTemplateSet.setNextFocusableComponent(jCheckBoxForce);
237         HashSet JavaDoc dirs = Common.getAllTemplateSets();
238           String JavaDoc item = null;
239           int i = 0;
240           int selIndex = 1;
241                 
242          if (dirs!=null){
243             for (Iterator JavaDoc iter = dirs.iterator(); iter.hasNext(); i++) {
244                 item = (String JavaDoc) iter.next();
245                 jComboBoxTemplateSet.addItem(" " + item);
246                 if (item.equals(DefaultDODSWizard.getGenerator().getTemplateSet())) {
247                     selIndex = i;
248                 }
249             }
250                         
251             jComboBoxTemplateSet.setSelectedIndex(selIndex);
252             jComboBoxTemplateSet.setMinimumSize(new Dimension JavaDoc(135, 20));
253             jVendorTypeLabel.setText("DB vendor :");
254             jVendorTypeLabel.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 12));
255             jJavaLabel.setText("Java code :");
256             jJavaLabel.setFont(new java.awt.Font JavaDoc("SansSerif", 0, 12));
257             Set JavaDoc vendors = Common.getDodsConfVendorNames();
258             String JavaDoc vendor = null;
259     
260             i = 0;
261             selIndex = 0;
262             jComboBoxVendors.addItem(" ");
263             for (Iterator JavaDoc iter = vendors.iterator(); iter.hasNext(); i++) {
264                 vendor = (String JavaDoc) iter.next();
265                 jComboBoxVendors.addItem(" " + vendor);
266                 if (vendor.equals(DefaultDODSWizard.getGenerator().getDatabase())) {
267                     selIndex = i;
268                 }
269             }
270          }else{
271              JOptionPane.showMessageDialog(null,"Error configuration folder not found.");
272              System.exit(1);
273          }
274         jComboBoxVendors.setSelectedIndex(selIndex);
275         jComboBoxVendors.setMinimumSize(new Dimension JavaDoc(121, 20));
276         jComboBoxVendors.setNextFocusableComponent(jCheckBoxSQL);
277         jSpaceButton.setEnabled(false);
278         jSpaceButton.setForeground(Color.lightGray);
279         jSpaceButton.setBorder(null);
280         jSpaceButton.setMaximumSize(new Dimension JavaDoc(20, 20));
281         jSpaceButton.setMinimumSize(new Dimension JavaDoc(20, 20));
282         jSpaceButton.setPreferredSize(new Dimension JavaDoc(30, 30));
283         jSpaceButton.setActionCommand("");
284         jSpaceButton.setFocusPainted(false);
285         jSpaceButton.setMargin(new Insets JavaDoc(3, 3, 3, 3));
286         jIconLabel.setIconTextGap(10);
287         jIconLabel.setIcon(enhydra);
288         jPictPanel.setLayout(flowLayout1);
289         flowLayout1.setHgap(0);
290         flowLayout1.setVgap(20);
291         jCheckBoxSQL.setMaximumSize(new Dimension JavaDoc(103, 22));
292         jCheckBoxSQL.setMinimumSize(new Dimension JavaDoc(103, 22));
293         jCheckBoxSQL.setNextFocusableComponent(jCheckBoxSQLSplitter);
294         jCheckBoxSQL.setSelected(false);
295         jCheckBoxSQL.setText("SQL generate");
296         jCheckBoxSQL.addActionListener(new java.awt.event.ActionListener JavaDoc() {
297             public void actionPerformed(ActionEvent JavaDoc e) {
298                 jCheckBoxSQL_actionPerformed(e);
299             }
300         });
301         jCheckBoxSQLSplitter.setMaximumSize(new Dimension JavaDoc(103, 22));
302         jCheckBoxSQLSplitter.setMinimumSize(new Dimension JavaDoc(103, 22));
303         jCheckBoxSQLSplitter.setNextFocusableComponent(jCheckBoxJava);
304         jCheckBoxSQLSplitter.setSelected(false);
305         jCheckBoxSQLSplitter.setText("SQL splitter");
306         jCheckBoxJava.setMaximumSize(new Dimension JavaDoc(104, 22));
307         jCheckBoxJava.setMinimumSize(new Dimension JavaDoc(104, 22));
308         jCheckBoxJava.setNextFocusableComponent(jCheckBoxCompile);
309         jCheckBoxJava.setSelected(false);
310         jCheckBoxJava.setText("Java generate");
311         jCheckBoxJava.addActionListener(new java.awt.event.ActionListener JavaDoc() {
312             public void actionPerformed(ActionEvent JavaDoc e) {
313                 jCheckBoxJava_actionPerformed(e);
314             }
315         });
316         jCheckBoxCompile.setMaximumSize(new Dimension JavaDoc(100, 22));
317         jCheckBoxCompile.setMinimumSize(new Dimension JavaDoc(100, 22));
318         jCheckBoxCompile.setNextFocusableComponent(jCancelButton);
319         jCheckBoxCompile.setText("Compile java");
320         jCheckBoxCompile.setSelected(false);
321         String JavaDoc action = DefaultDODSWizard.getGenerator().getAction();
322
323         if (action.equals("dods:build_all") || action.equals("dods:sql")
324                 || action.equals("dods:noCompile")
325                 || action.equals("build_all_split")
326                 || action.equals("dods:sqlsplit")
327                 || action.equals("dods:noCompileSplit")) {
328             jCheckBoxSQL.setSelected(true);
329         }
330         if (action.equals("build_all_split") || action.equals("dods:sqlsplit")
331                 || action.equals("dods:noCompileSplit")) {
332             jCheckBoxSQLSplitter.setSelected(true);
333         }
334         if (action.equals("dods:build_all") || action.equals("dods:java")
335                 || action.equals("dods:noCompile")
336                 || action.equals("build_all_split")
337                 || action.equals("dods:javaNoCompile")
338                 || action.equals("dods:noCompileSplit")) {
339             jCheckBoxJava.setSelected(true);
340         }
341         if (action.equals("dods:build_all") || action.equals("dods:java")
342                 || action.equals("build_all_split")) {
343             if (!DefaultDODSWizard.getGenerator().getKelp()) {
344                 jCheckBoxCompile.setSelected(true);
345             }
346         }
347         int kelp = 0;
348
349         if (DefaultDODSWizard.getGenerator().getKelp()) {
350             jContentPanel.add(jCheckBoxInvoke, new XYConstraints(32, 0, -1, -1));
351             jContentPanel.add(jTitleLabel, new XYConstraints(35, 35, -1, -1));
352             kelp = 10;
353         } else {
354             jContentPanel.add(jTitleLabel, new XYConstraints(35, 15, -1, -1));
355         }
356         jContentPanel.add(jConfigDirLabel,
357                 new XYConstraints(35, 60 + kelp, -1, -1));
358         jContentPanel.add(jConfigDirTextField,
359                 new XYConstraints(130, 60 + kelp, 290, 20));
360         jContentPanel.add(jConfigDirButton,
361                 new XYConstraints(430, 60 + kelp, 65, 20));
362         jContentPanel.add(jOutputDirLabel,
363                 new XYConstraints(35, 95 + kelp, -1, -1));
364         jContentPanel.add(jOutputDirTextField,
365                 new XYConstraints(130, 95 + kelp, 290, 20));
366         jContentPanel.add(jOutputDirButton,
367                 new XYConstraints(430, 95 + kelp, 65, 20));
368         jContentPanel.add(jDomlRootLabel,
369                 new XYConstraints(35, 130 + kelp, -1, -1));
370         jContentPanel.add(jDomlTextField,
371                 new XYConstraints(130, 130 + kelp, 290, 20));
372         jContentPanel.add(jDomlButton,
373                 new XYConstraints(430, 130 + kelp, 65, 20));
374         jContentPanel.add(jDocLabel, new XYConstraints(35, 165 + kelp, -1, -1));
375         jContentPanel.add(jCheckBoxDoml2Html,
376                 new XYConstraints(132, 165 + kelp, -1, 20));
377         jContentPanel.add(jCheckBoxDoml2Pdf,
378                 new XYConstraints(212, 165 + kelp, -1, 20));
379         jContentPanel.add(jCheckBoxDoml2Xmi,
380                 new XYConstraints(292, 165 + kelp, -1, 20));
381         jContentPanel.add(jCheckBoxDoml2Ptl,
382                 new XYConstraints(372, 165 + kelp, -1, 20));
383         jContentPanel.add(jTemplateTypeLabel,
384                 new XYConstraints(35, 205 + kelp, -1, -1));
385         jContentPanel.add(jComboBoxTemplateSet,
386                 new XYConstraints(135, 205 + kelp, 165, 20));
387         jContentPanel.add(jCheckBoxForce,
388                 new XYConstraints(372, 205 + kelp, -1, 20));
389         jContentPanel.add(jVendorTypeLabel,
390                 new XYConstraints(35, 240 + kelp, -1, 20));
391         jContentPanel.add(jComboBoxVendors,
392                 new XYConstraints(135, 240 + kelp, -1, 20));
393         jContentPanel.add(jCheckBoxSQL,
394                 new XYConstraints(265, 240 + kelp, -1, 20));
395         jContentPanel.add(jCheckBoxSQLSplitter,
396                 new XYConstraints(372, 240 + kelp, -1, 20));
397         jContentPanel.add(jJavaLabel, new XYConstraints(35, 275 + kelp, -1, 20));
398         jContentPanel.add(jCheckBoxJava,
399                 new XYConstraints(135, 275 + kelp, -1, 20));
400         if (!DefaultDODSWizard.getGenerator().getKelp()) {
401             jContentPanel.add(jCheckBoxCompile,
402                     new XYConstraints(265, 275 + kelp, -1, 20));
403         }
404         jButtonPanel.add(jGenerateButton, null);
405         jButtonPanel.add(jSpace, null);
406         if (DefaultDODSWizard.getGenerator().getKelp()) {
407             jButtonPanel.add(jCloseButton, null);
408             jButtonPanel.add(jSpace1, null);
409         }
410         jButtonPanel.add(jCancelButton, null);
411         contentPane.add(jPictPanel, BorderLayout.NORTH);
412         contentPane.add(jButtonPanel, BorderLayout.SOUTH);
413         jPictPanel.add(jIconLabel, null);
414         contentPane.add(jContentPanel, BorderLayout.CENTER);
415     }
416
417     public void setDefaultFocus() {
418         jGenerateButton.requestFocus();
419     }
420
421     // Overridden so we can exit when window is closed
422
protected void processWindowEvent(WindowEvent JavaDoc e) {
423         super.processWindowEvent(e);
424         if (e.getID() == WindowEvent.WINDOW_CLOSING) {
425             DefaultDODSWizard.getGenerator().preCancel();
426             if (DefaultDODSWizard.getGenerator().getKelp()) {
427                 this.dispose();
428             } else {
429                 System.exit(0);
430             }
431         }
432     }
433
434     void jCancelButton_actionPerformed(ActionEvent JavaDoc e) {
435         DefaultDODSWizard.getGenerator().preCancel();
436         if (DefaultDODSWizard.getGenerator().getKelp()) {
437             this.dispose();
438         } else {
439             System.exit(0);
440         }
441     }
442
443     void jCloseButton_actionPerformed(ActionEvent JavaDoc e) {
444         saveParameters();
445         DefaultDODSWizard.getGenerator().preClose();
446         this.dispose();
447     }
448
449     void jOutputDirButton_actionPerformed(ActionEvent JavaDoc e) {
450         JFileChooser JavaDoc chooser = null;
451         File JavaDoc choice = null;
452
453         chooser = new JFileChooser JavaDoc();
454         chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
455         chooser.setFileFilter((javax.swing.filechooser.FileFilter JavaDoc) new DirectoryFilter());
456         chooser.setDialogTitle("Select Project Root");
457         chooser.setApproveButtonText("OK");
458         String JavaDoc strFieldText = jDomlTextField.getText();
459
460         if ((strFieldText == null) || strFieldText.equals("")) {
461             strFieldText = System.getProperty("user.dir");
462         }
463         chooser.setCurrentDirectory(new File JavaDoc(strFieldText));
464         int v = chooser.showOpenDialog(this);
465
466         this.requestFocus();
467         switch (v) {
468         case JFileChooser.APPROVE_OPTION:
469             if (chooser.getSelectedFile() != null) {
470                 if (chooser.getSelectedFile().exists()) {
471                     choice = chooser.getSelectedFile();
472                 } else {
473                     File JavaDoc parentFile = new File JavaDoc(chooser.getSelectedFile().getParent());
474
475                     choice = parentFile;
476                 }
477                 jOutputDirTextField.setText(choice.getPath());
478             }
479             break;
480
481         case JFileChooser.CANCEL_OPTION:
482         case JFileChooser.ERROR_OPTION:
483         }
484         chooser.removeAll();
485         chooser = null;
486     }
487
488     void jDomlButton_actionPerformed(ActionEvent JavaDoc e) {
489         JFileChooser JavaDoc chooser = null;
490         File JavaDoc choice = null;
491
492         chooser = new JFileChooser JavaDoc();
493         chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
494         chooser.setFileFilter((javax.swing.filechooser.FileFilter JavaDoc) new DomlFilter());
495         chooser.setDialogTitle("Select .doml file");
496         chooser.setAcceptAllFileFilterUsed(false);
497         String JavaDoc strFieldText = jDomlTextField.getText();
498
499         if ((strFieldText == null) || strFieldText.equals("")) {
500             strFieldText = System.getProperty("user.dir");
501         }
502         chooser.setCurrentDirectory(new File JavaDoc(strFieldText));
503         chooser.setApproveButtonText("OK");
504         int v = chooser.showOpenDialog(this);
505
506         this.requestFocus();
507         switch (v) {
508         case JFileChooser.APPROVE_OPTION:
509             if (chooser.getSelectedFile() != null) {
510                 if (chooser.getSelectedFile().exists()) {
511                     choice = chooser.getSelectedFile();
512                 } else {
513                     File JavaDoc parentFile = new File JavaDoc(chooser.getSelectedFile().getParent());
514
515                     choice = parentFile;
516                 }
517                 jDomlTextField.setText(choice.getPath());
518                 String JavaDoc tempSet = null;
519                 String JavaDoc vendor = null;
520
521                 try {
522                     if (choice.isFile()) {
523                         tempSet = XmlUtil.getSingleAttribute(choice.getPath(),
524                                 "/doml/database@templateset", null);
525                         vendor = XmlUtil.getSingleAttribute(choice.getPath(),
526                                 "/doml/database@database", null);
527                     }
528                 } catch (Exception JavaDoc ex) {}
529                 if (tempSet != null) {
530                     tempSet = " " + tempSet;
531                     for (int i = 0; i < jComboBoxTemplateSet.getItemCount(); i++) {
532                         if (((String JavaDoc) jComboBoxTemplateSet.getItemAt(i)).equals(tempSet)) {
533                             jComboBoxTemplateSet.setSelectedIndex(i);
534                             break;
535                         }
536                     }
537                 }
538                 if (vendor != null) {
539                     vendor = " " + vendor;
540                     for (int i = 0; i < jComboBoxVendors.getItemCount(); i++) {
541                         if (((String JavaDoc) jComboBoxVendors.getItemAt(i)).equals(vendor)) {
542                             jComboBoxVendors.setSelectedIndex(i);
543                             break;
544                         }
545                     }
546                 }
547             }
548             break;
549
550         case JFileChooser.CANCEL_OPTION:
551         case JFileChooser.ERROR_OPTION:
552         }
553         chooser.removeAll();
554         chooser = null;
555     }
556
557     void jGenerateButton_actionPerformed(ActionEvent JavaDoc e) {
558         try {
559             File JavaDoc outDir = new File JavaDoc(jOutputDirTextField.getText());
560             File JavaDoc dfile = new File JavaDoc(jDomlTextField.getText());
561
562             if (dfile.isFile()) {
563                 if (!outDir.mkdirs() && !outDir.isDirectory()) { // making directory
564
MessageDialog message = new MessageDialog(" Please enter or choose valid project root directory file ",
565                             this, " Invalid project root directory ");
566                     Dimension JavaDoc dimension = Toolkit.getDefaultToolkit().getScreenSize();
567
568                     message.setLocation((dimension.width
569                                     - message.getSize().width)
570                             / 2,
571                             (dimension.height - message.getSize().height) / 2);
572                     message.setVisible(true);
573                     return;
574                 }
575                 saveParameters();
576                 DefaultDODSWizard.getGenerator().preGenerate();
577                 // Creating properties file
578
Common.setDomlFile(DefaultDODSWizard.getGenerator().getDoml());
579                 Common.setProjectRoot(DefaultDODSWizard.getGenerator().getOutputDir());
580                 Common.setConfigDir(DefaultDODSWizard.getGenerator().getConfigDir());
581                 // Execute action
582
ExecThread runEjen = new ExecThread();
583
584                 runEjen.start();
585             } else {
586                 MessageDialog message = new MessageDialog(" Please enter or choose valid .doml file ",
587                         this, " Invalid .doml file ");
588                 Dimension JavaDoc dimension = Toolkit.getDefaultToolkit().getScreenSize();
589
590                 message.setLocation((dimension.width - message.getSize().width)
591                         / 2,
592                         (dimension.height - message.getSize().height) / 2);
593                 message.setVisible(true);
594             }
595         } catch (Exception JavaDoc ex) {
596             ex.printStackTrace();
597         }
598     }
599
600     void saveParameters() {
601         DefaultDODSWizard.getGenerator().setOutputDir(jOutputDirTextField.getText());
602         DefaultDODSWizard.getGenerator().setDoml(jDomlTextField.getText());
603         DefaultDODSWizard.getGenerator().setConfigDir(jConfigDirTextField.getText());
604         DefaultDODSWizard.getGenerator().setAction("dods:build_all"); // default
605
if (jCheckBoxSQL.isSelected() && !jCheckBoxSQLSplitter.isSelected()
606                 && !jCheckBoxJava.isSelected()) {
607             DefaultDODSWizard.getGenerator().setAction("dods:sql");
608         }
609         if (jCheckBoxSQL.isSelected() && jCheckBoxSQLSplitter.isSelected()
610                 && !jCheckBoxJava.isSelected()) {
611             DefaultDODSWizard.getGenerator().setAction("dods:sqlsplit");
612         }
613         if (!jCheckBoxSQL.isSelected() && jCheckBoxJava.isSelected()) {
614             if (jCheckBoxCompile.isSelected()) {
615                 DefaultDODSWizard.getGenerator().setAction("dods:java");
616             } else {
617                 DefaultDODSWizard.getGenerator().setAction("dods:javaNoCompile");
618             }
619         }
620         if (jCheckBoxSQL.isSelected() && jCheckBoxJava.isSelected()) {
621             if (jCheckBoxCompile.isSelected()
622                     && !jCheckBoxSQLSplitter.isSelected()) {
623                 DefaultDODSWizard.getGenerator().setAction("dods:build_all");
624             } // default
625
else if (jCheckBoxCompile.isSelected()
626                     && jCheckBoxSQLSplitter.isSelected()) {
627                 DefaultDODSWizard.getGenerator().setAction("dods:build_all_split");
628             } else if (!jCheckBoxCompile.isSelected()
629                     && !jCheckBoxSQLSplitter.isSelected()) {
630                 DefaultDODSWizard.getGenerator().setAction("dods:noCompile");
631             } else {
632                 DefaultDODSWizard.getGenerator().setAction("dods:noCompileSplit");
633             }
634         }
635         if (jCheckBoxDoml2Html.isSelected()) {
636             DefaultDODSWizard.getGenerator().setHtml(true);
637         } else {
638             DefaultDODSWizard.getGenerator().setHtml(false);
639         }
640         if (jCheckBoxDoml2Pdf.isSelected()) {
641             DefaultDODSWizard.getGenerator().setPdf(true);
642         } else {
643             DefaultDODSWizard.getGenerator().setPdf(false);
644         }
645         if (jCheckBoxDoml2Xmi.isSelected()) {
646             DefaultDODSWizard.getGenerator().setXmi(true);
647         } else {
648             DefaultDODSWizard.getGenerator().setXmi(false);
649         }
650         if (jCheckBoxDoml2Ptl.isSelected()) {
651             DefaultDODSWizard.getGenerator().setPtl(true);
652         } else {
653             DefaultDODSWizard.getGenerator().setPtl(false);
654         }
655         if (jCheckBoxForce.isSelected()) {
656             DefaultDODSWizard.getGenerator().setForce("true");
657         } else {
658             DefaultDODSWizard.getGenerator().setForce("false");
659         }
660         DefaultDODSWizard.getGenerator().setTemplateSet(((String JavaDoc) jComboBoxTemplateSet.getSelectedItem()).substring(1));
661         if (!((String JavaDoc) jComboBoxVendors.getSelectedItem()).equals(" ")) {
662             DefaultDODSWizard.getGenerator().setDatabase(((String JavaDoc) jComboBoxVendors.getSelectedItem()).substring(1));
663         }
664         if (DefaultDODSWizard.getGenerator().getKelp()) {
665             if (jCheckBoxInvoke.isSelected()) {
666                 DefaultDODSWizard.getGenerator().setInvoke(true);
667             } else {
668                 DefaultDODSWizard.getGenerator().setInvoke(false);
669             }
670         }
671     }
672
673     void jCheckBoxSQL_actionPerformed(ActionEvent JavaDoc e) {
674         if (jCheckBoxSQL.isSelected()) {
675             jCheckBoxSQLSplitter.setSelected(true);
676             jCheckBoxSQLSplitter.setEnabled(true);
677         } else {
678             jCheckBoxSQLSplitter.setSelected(true);
679             jCheckBoxSQLSplitter.setSelected(false);
680             jCheckBoxSQLSplitter.setEnabled(false);
681             jCheckBoxJava.setSelected(true);
682             if (!DefaultDODSWizard.getGenerator().getKelp()) {
683                 jCheckBoxCompile.setSelected(true);
684             }
685             jCheckBoxCompile.setEnabled(true);
686         }
687     }
688     
689     void jConfigDirButton_actionPerformed(ActionEvent JavaDoc e) {
690         JFileChooser JavaDoc chooser = null;
691         File JavaDoc choice = null;
692
693         chooser = new JFileChooser JavaDoc();
694         chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
695         chooser.setFileFilter((javax.swing.filechooser.FileFilter JavaDoc) new DirectoryFilter());
696         chooser.setDialogTitle("Select Config Dir");
697         chooser.setApproveButtonText("OK");
698         String JavaDoc strFieldText = Common.getConfigDir();
699
700         if ((strFieldText == null) || strFieldText.equals("")) {
701             strFieldText = System.getProperty("user.dir");
702         }
703         chooser.setCurrentDirectory(new File JavaDoc(strFieldText));
704         int v = chooser.showOpenDialog(this);
705
706         this.requestFocus();
707         switch (v) {
708         case JFileChooser.APPROVE_OPTION:
709             if (chooser.getSelectedFile() != null) {
710                 if (chooser.getSelectedFile().exists()) {
711                     File JavaDoc confFile = new File JavaDoc(chooser.getSelectedFile().getAbsolutePath()
712                             + File.separator + "dodsConf.xml");
713
714                     if (confFile.exists() || confFile.isFile()) {
715                         choice = chooser.getSelectedFile();
716                     } else {
717                         choice = new File JavaDoc(Common.getConfigDir());
718                     }
719                 } else {
720                     choice = new File JavaDoc(Common.getConfigDir());
721                 }
722                 jConfigDirTextField.setText(choice.getPath());
723                 Common.setConfigDir(choice.getPath());
724             }
725             break;
726
727         case JFileChooser.CANCEL_OPTION:
728         case JFileChooser.ERROR_OPTION:
729         }
730         chooser.removeAll();
731         chooser = null;
732             
733         Set JavaDoc vendors = Common.getDodsConfVendorNames();
734         String JavaDoc vendor = null;
735         int i = 0;
736         int selIndex = 0;
737
738         jComboBoxVendors.removeAllItems();
739         jComboBoxVendors.addItem(" ");
740         for (Iterator JavaDoc iter = vendors.iterator(); iter.hasNext(); i++) {
741             vendor = (String JavaDoc) iter.next();
742             jComboBoxVendors.addItem(" " + vendor);
743             if (vendor.equals(DefaultDODSWizard.getGenerator().getDatabase())) {
744                 selIndex = i;
745             }
746         }
747         jComboBoxVendors.setSelectedIndex(selIndex);
748     }
749
750     void jCheckBoxJava_actionPerformed(ActionEvent JavaDoc e) {
751         if (jCheckBoxJava.isSelected()) {
752             if (!DefaultDODSWizard.getGenerator().getKelp()) {
753                 jCheckBoxCompile.setSelected(true);
754             }
755             jCheckBoxCompile.setEnabled(true);
756             jCheckBoxSQLSplitter.setEnabled(true);
757         } else {
758             jCheckBoxSQL.setSelected(true);
759             jCheckBoxSQLSplitter.setEnabled(true);
760             if (!DefaultDODSWizard.getGenerator().getKelp()) {
761                 jCheckBoxCompile.setSelected(false);
762             }
763             jCheckBoxCompile.setEnabled(false);
764         }
765     }
766 }
767
Popular Tags