1 package org.enhydra.dods.wizard; 2 3 import java.awt.AWTEvent ; 4 import java.awt.BorderLayout ; 5 import java.awt.Color ; 6 import java.awt.Dimension ; 7 import java.awt.FlowLayout ; 8 import java.awt.GridBagLayout ; 9 import java.awt.Image ; 10 import java.awt.Insets ; 11 import java.awt.Toolkit ; 12 import java.awt.event.ActionEvent ; 13 import java.awt.event.WindowEvent ; 14 import java.io.File ; 15 import java.util.HashSet ; 16 import java.util.Iterator ; 17 import java.util.ResourceBundle ; 18 import java.util.Set ; 19 20 import javax.swing.DebugGraphics ; 21 import javax.swing.ImageIcon ; 22 import javax.swing.JButton ; 23 import javax.swing.JCheckBox ; 24 import javax.swing.JComboBox ; 25 import javax.swing.JFileChooser ; 26 import javax.swing.JFrame ; 27 import javax.swing.JLabel ; 28 import javax.swing.JOptionPane ; 29 import javax.swing.JPanel ; 30 import javax.swing.JTextField ; 31 32 import org.enhydra.dods.Common; 33 import org.enhydra.dods.xml.XmlUtil; 34 35 40 public class WizardFrame1 extends JFrame { 41 JPanel contentPane; 42 JPanel jButtonPanel = new JPanel (); 43 JPanel jPictPanel = new JPanel (); 44 JPanel jContentPanel = new JPanel (); 45 BorderLayout borderLayout1 = new BorderLayout (); 46 FlowLayout flowLayout1 = new FlowLayout (); 47 GridBagLayout gridBagLayout1 = new GridBagLayout (); 48 XYLayout xyLayout = new XYLayout(); 49 JLabel jIconLabel = new JLabel (); 50 JLabel jTitleLabel = new JLabel (); 51 JLabel jOutputDirLabel = new JLabel (); 52 JLabel jDomlRootLabel = new JLabel (); 53 JLabel jTemplateTypeLabel = new JLabel (); 54 JLabel jDocLabel = new JLabel (); 55 JLabel jVendorTypeLabel = new JLabel (); 56 JLabel jJavaLabel = new JLabel (); 57 JLabel jConfigDirLabel = new JLabel (); 58 JTextField jOutputDirTextField = new JTextField (); 59 JTextField jDomlTextField = new JTextField (); 60 JTextField jConfigDirTextField = new JTextField (); 61 JButton jDomlButton = new JButton (); 62 JButton jSpaceButton = new JButton (); 63 JButton jGenerateButton = new JButton (); 64 JButton jCancelButton = new JButton (); 65 JButton jOutputDirButton = new JButton (); 66 JButton jSpace = new JButton (); 67 JButton jCloseButton = new JButton (); 68 JButton jSpace1 = new JButton (); 69 JButton jConfigDirButton = new JButton (); 70 Image appImage = Toolkit.getDefaultToolkit().getImage(getClass().getResource("smallicon.gif")); 71 ImageIcon enhydra = new ImageIcon (Toolkit.getDefaultToolkit().getImage(getClass().getResource("Enhydra.gif"))); 72 ResourceBundle rb; 73 JCheckBox jCheckBoxSQL = new JCheckBox (); 74 JCheckBox jCheckBoxSQLSplitter = new JCheckBox (); 75 JCheckBox jCheckBoxJava = new JCheckBox (); 76 JCheckBox jCheckBoxCompile = new JCheckBox (); 77 JCheckBox jCheckBoxDoml2Html = new JCheckBox (); 78 JCheckBox jCheckBoxDoml2Pdf = new JCheckBox (); 79 JCheckBox jCheckBoxDoml2Xmi = new JCheckBox (); 80 JCheckBox jCheckBoxDoml2Ptl = new JCheckBox (); 81 JCheckBox jCheckBoxForce = new JCheckBox (); 82 JCheckBox jCheckBoxInvoke = new JCheckBox (); 83 JComboBox jComboBoxTemplateSet = new JComboBox (); 84 JComboBox jComboBoxVendors = new JComboBox (); 85 public WizardFrame1() { 87 enableEvents(AWTEvent.WINDOW_EVENT_MASK); 88 try { 89 jbInit(); 90 } catch (Exception e) { 91 e.printStackTrace(); 92 } 93 } 94 95 private void jbInit() throws Exception { 97 setIconImage(appImage); 98 this.setResizable(false); 99 contentPane = (JPanel ) this.getContentPane(); 100 contentPane.setLayout(borderLayout1); 101 this.setSize(new Dimension (570, 550)); 102 this.setTitle("DODS Generator Wizard"); 103 jButtonPanel.setDebugGraphicsOptions(DebugGraphics.NONE_OPTION); 104 jButtonPanel.setMinimumSize(new Dimension (233, 50)); 105 jButtonPanel.setPreferredSize(new Dimension (500, 50)); 106 jContentPanel.setLayout(xyLayout); 107 jGenerateButton.setFont(new java.awt.Font ("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 () { 117 public void actionPerformed(ActionEvent e) { 118 jGenerateButton_actionPerformed(e); 119 } 120 }); 121 jCancelButton.setFont(new java.awt.Font ("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 () { 129 public void actionPerformed(ActionEvent e) { 130 jCancelButton_actionPerformed(e); 131 } 132 }); 133 jCloseButton.setFont(new java.awt.Font ("SansSerif", 0, 11)); 134 jCloseButton.setNextFocusableComponent(jGenerateButton); 135 jCloseButton.setText(" Close "); 136 jCloseButton.addActionListener(new java.awt.event.ActionListener () { 137 public void actionPerformed(ActionEvent e) { 138 jCloseButton_actionPerformed(e); 139 } 140 }); 141 jConfigDirTextField.setNextFocusableComponent(jConfigDirButton); 142 jConfigDirTextField.setText(Common.getConfigDir()); 143 jConfigDirLabel.setFont(new java.awt.Font ("SansSerif", 0, 12)); 144 jConfigDirLabel.setText("Config directory :"); 145 jConfigDirButton.setFont(new java.awt.Font ("SansSerif", 0, 12)); 146 jConfigDirButton.setMaximumSize(new Dimension (55, 25)); 147 jConfigDirButton.setMinimumSize(new Dimension (55, 25)); 148 jConfigDirButton.setNextFocusableComponent(jOutputDirTextField); 149 jConfigDirButton.setPreferredSize(new Dimension (55, 25)); 150 jConfigDirButton.setMargin(new Insets (2, 14, 3, 14)); 151 jConfigDirButton.setText("Set ..."); 152 jConfigDirButton.addActionListener(new java.awt.event.ActionListener () { 153 public void actionPerformed(ActionEvent e) { 154 jConfigDirButton_actionPerformed(e); 155 } 156 }); 157 jSpace.setEnabled(false); 158 jSpace.setBorder(null); 159 jSpace.setPreferredSize(new Dimension (30, 20)); 160 jSpace.setFocusPainted(false); 161 jSpace.setMargin(new Insets (2, 50, 2, 14)); 162 jSpace1.setEnabled(false); 163 jSpace1.setBorder(null); 164 jSpace1.setPreferredSize(new Dimension (30, 20)); 165 jSpace1.setFocusPainted(false); 166 jSpace1.setMargin(new Insets (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 ("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 ("SansSerif", 0, 12)); 174 jOutputDirLabel.setText("Output directory :"); 175 jOutputDirButton.setFont(new java.awt.Font ("SansSerif", 0, 12)); 176 jOutputDirButton.setMaximumSize(new Dimension (55, 25)); 177 jOutputDirButton.setMinimumSize(new Dimension (55, 25)); 178 jOutputDirButton.setNextFocusableComponent(jDomlTextField); 179 jOutputDirButton.setPreferredSize(new Dimension (55, 25)); 180 jOutputDirButton.setMargin(new Insets (2, 14, 3, 14)); 181 jOutputDirButton.setText("Set ..."); 182 jOutputDirButton.addActionListener(new java.awt.event.ActionListener () { 183 public void actionPerformed(ActionEvent e) { 184 jOutputDirButton_actionPerformed(e); 185 } 186 }); 187 jDomlRootLabel.setText("Doml file :"); 188 jDomlRootLabel.setFont(new java.awt.Font ("SansSerif", 0, 12)); 189 jDomlButton.setFont(new java.awt.Font ("SansSerif", 0, 12)); 190 jDomlButton.setMaximumSize(new Dimension (50, 25)); 191 jDomlButton.setMinimumSize(new Dimension (55, 25)); 192 jDomlButton.setNextFocusableComponent(jCheckBoxDoml2Html); 193 jDomlButton.setPreferredSize(new Dimension (55, 25)); 194 jDomlButton.setMargin(new Insets (2, 14, 3, 14)); 195 jDomlButton.setText("Set ..."); 196 jDomlButton.addActionListener(new java.awt.event.ActionListener () { 197 public void actionPerformed(ActionEvent e) { 198 jDomlButton_actionPerformed(e); 199 } 200 }); 201 jDocLabel.setText("Documentation :"); 202 jDocLabel.setFont(new java.awt.Font ("SansSerif", 0, 12)); 203 jCheckBoxDoml2Html.setMaximumSize(new Dimension (100, 22)); 204 jCheckBoxDoml2Html.setMinimumSize(new Dimension (100, 22)); 205 jCheckBoxDoml2Html.setNextFocusableComponent(jCheckBoxDoml2Pdf); 206 jCheckBoxDoml2Html.setSelected(DefaultDODSWizard.getGenerator().getHtml()); 207 jCheckBoxDoml2Html.setText(" HTML"); 208 jCheckBoxDoml2Pdf.setMaximumSize(new Dimension (100, 22)); 209 jCheckBoxDoml2Pdf.setMinimumSize(new Dimension (100, 22)); 210 jCheckBoxDoml2Pdf.setNextFocusableComponent(jCheckBoxDoml2Xmi); 211 jCheckBoxDoml2Pdf.setSelected(DefaultDODSWizard.getGenerator().getPdf()); 212 jCheckBoxDoml2Pdf.setText(" PDF"); 213 jCheckBoxDoml2Xmi.setMaximumSize(new Dimension (100, 22)); 214 jCheckBoxDoml2Xmi.setMinimumSize(new Dimension (100, 22)); 215 jCheckBoxDoml2Xmi.setNextFocusableComponent(jCheckBoxDoml2Ptl); 216 jCheckBoxDoml2Xmi.setSelected(DefaultDODSWizard.getGenerator().getXmi()); 217 jCheckBoxDoml2Xmi.setText(" XMI"); 218 jCheckBoxDoml2Ptl.setMaximumSize(new Dimension (100, 22)); 219 jCheckBoxDoml2Ptl.setMinimumSize(new Dimension (100, 22)); 220 jCheckBoxDoml2Ptl.setNextFocusableComponent(jComboBoxTemplateSet); 221 jCheckBoxDoml2Ptl.setSelected(DefaultDODSWizard.getGenerator().getPtl()); 222 jCheckBoxDoml2Ptl.setText("PTL"); 223 jCheckBoxForce.setMaximumSize(new Dimension (100, 22)); 224 jCheckBoxForce.setMinimumSize(new Dimension (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 ("SansSerif", 0, 12)); 236 jComboBoxTemplateSet.setNextFocusableComponent(jCheckBoxForce); 237 HashSet dirs = Common.getAllTemplateSets(); 238 String item = null; 239 int i = 0; 240 int selIndex = 1; 241 242 if (dirs!=null){ 243 for (Iterator iter = dirs.iterator(); iter.hasNext(); i++) { 244 item = (String ) 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 (135, 20)); 253 jVendorTypeLabel.setText("DB vendor :"); 254 jVendorTypeLabel.setFont(new java.awt.Font ("SansSerif", 0, 12)); 255 jJavaLabel.setText("Java code :"); 256 jJavaLabel.setFont(new java.awt.Font ("SansSerif", 0, 12)); 257 Set vendors = Common.getDodsConfVendorNames(); 258 String vendor = null; 259 260 i = 0; 261 selIndex = 0; 262 jComboBoxVendors.addItem(" "); 263 for (Iterator iter = vendors.iterator(); iter.hasNext(); i++) { 264 vendor = (String ) 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 (121, 20)); 276 jComboBoxVendors.setNextFocusableComponent(jCheckBoxSQL); 277 jSpaceButton.setEnabled(false); 278 jSpaceButton.setForeground(Color.lightGray); 279 jSpaceButton.setBorder(null); 280 jSpaceButton.setMaximumSize(new Dimension (20, 20)); 281 jSpaceButton.setMinimumSize(new Dimension (20, 20)); 282 jSpaceButton.setPreferredSize(new Dimension (30, 30)); 283 jSpaceButton.setActionCommand(""); 284 jSpaceButton.setFocusPainted(false); 285 jSpaceButton.setMargin(new Insets (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 (103, 22)); 292 jCheckBoxSQL.setMinimumSize(new Dimension (103, 22)); 293 jCheckBoxSQL.setNextFocusableComponent(jCheckBoxSQLSplitter); 294 jCheckBoxSQL.setSelected(false); 295 jCheckBoxSQL.setText("SQL generate"); 296 jCheckBoxSQL.addActionListener(new java.awt.event.ActionListener () { 297 public void actionPerformed(ActionEvent e) { 298 jCheckBoxSQL_actionPerformed(e); 299 } 300 }); 301 jCheckBoxSQLSplitter.setMaximumSize(new Dimension (103, 22)); 302 jCheckBoxSQLSplitter.setMinimumSize(new Dimension (103, 22)); 303 jCheckBoxSQLSplitter.setNextFocusableComponent(jCheckBoxJava); 304 jCheckBoxSQLSplitter.setSelected(false); 305 jCheckBoxSQLSplitter.setText("SQL splitter"); 306 jCheckBoxJava.setMaximumSize(new Dimension (104, 22)); 307 jCheckBoxJava.setMinimumSize(new Dimension (104, 22)); 308 jCheckBoxJava.setNextFocusableComponent(jCheckBoxCompile); 309 jCheckBoxJava.setSelected(false); 310 jCheckBoxJava.setText("Java generate"); 311 jCheckBoxJava.addActionListener(new java.awt.event.ActionListener () { 312 public void actionPerformed(ActionEvent e) { 313 jCheckBoxJava_actionPerformed(e); 314 } 315 }); 316 jCheckBoxCompile.setMaximumSize(new Dimension (100, 22)); 317 jCheckBoxCompile.setMinimumSize(new Dimension (100, 22)); 318 jCheckBoxCompile.setNextFocusableComponent(jCancelButton); 319 jCheckBoxCompile.setText("Compile java"); 320 jCheckBoxCompile.setSelected(false); 321 String 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 protected void processWindowEvent(WindowEvent 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 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 e) { 444 saveParameters(); 445 DefaultDODSWizard.getGenerator().preClose(); 446 this.dispose(); 447 } 448 449 void jOutputDirButton_actionPerformed(ActionEvent e) { 450 JFileChooser chooser = null; 451 File choice = null; 452 453 chooser = new JFileChooser (); 454 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 455 chooser.setFileFilter((javax.swing.filechooser.FileFilter ) new DirectoryFilter()); 456 chooser.setDialogTitle("Select Project Root"); 457 chooser.setApproveButtonText("OK"); 458 String strFieldText = jDomlTextField.getText(); 459 460 if ((strFieldText == null) || strFieldText.equals("")) { 461 strFieldText = System.getProperty("user.dir"); 462 } 463 chooser.setCurrentDirectory(new File (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 parentFile = new File (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 e) { 489 JFileChooser chooser = null; 490 File choice = null; 491 492 chooser = new JFileChooser (); 493 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); 494 chooser.setFileFilter((javax.swing.filechooser.FileFilter ) new DomlFilter()); 495 chooser.setDialogTitle("Select .doml file"); 496 chooser.setAcceptAllFileFilterUsed(false); 497 String strFieldText = jDomlTextField.getText(); 498 499 if ((strFieldText == null) || strFieldText.equals("")) { 500 strFieldText = System.getProperty("user.dir"); 501 } 502 chooser.setCurrentDirectory(new File (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 parentFile = new File (chooser.getSelectedFile().getParent()); 514 515 choice = parentFile; 516 } 517 jDomlTextField.setText(choice.getPath()); 518 String tempSet = null; 519 String 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 ex) {} 529 if (tempSet != null) { 530 tempSet = " " + tempSet; 531 for (int i = 0; i < jComboBoxTemplateSet.getItemCount(); i++) { 532 if (((String ) 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 ) 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 e) { 558 try { 559 File outDir = new File (jOutputDirTextField.getText()); 560 File dfile = new File (jDomlTextField.getText()); 561 562 if (dfile.isFile()) { 563 if (!outDir.mkdirs() && !outDir.isDirectory()) { MessageDialog message = new MessageDialog(" Please enter or choose valid project root directory file ", 565 this, " Invalid project root directory "); 566 Dimension 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 Common.setDomlFile(DefaultDODSWizard.getGenerator().getDoml()); 579 Common.setProjectRoot(DefaultDODSWizard.getGenerator().getOutputDir()); 580 Common.setConfigDir(DefaultDODSWizard.getGenerator().getConfigDir()); 581 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 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 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"); 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 } 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 ) jComboBoxTemplateSet.getSelectedItem()).substring(1)); 661 if (!((String ) jComboBoxVendors.getSelectedItem()).equals(" ")) { 662 DefaultDODSWizard.getGenerator().setDatabase(((String ) 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 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 e) { 690 JFileChooser chooser = null; 691 File choice = null; 692 693 chooser = new JFileChooser (); 694 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 695 chooser.setFileFilter((javax.swing.filechooser.FileFilter ) new DirectoryFilter()); 696 chooser.setDialogTitle("Select Config Dir"); 697 chooser.setApproveButtonText("OK"); 698 String strFieldText = Common.getConfigDir(); 699 700 if ((strFieldText == null) || strFieldText.equals("")) { 701 strFieldText = System.getProperty("user.dir"); 702 } 703 chooser.setCurrentDirectory(new File (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 confFile = new File (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 (Common.getConfigDir()); 718 } 719 } else { 720 choice = new File (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 vendors = Common.getDodsConfVendorNames(); 734 String vendor = null; 735 int i = 0; 736 int selIndex = 0; 737 738 jComboBoxVendors.removeAllItems(); 739 jComboBoxVendors.addItem(" "); 740 for (Iterator iter = vendors.iterator(); iter.hasNext(); i++) { 741 vendor = (String ) 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 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 |