1 package org.webdocwf.util.loader.wizard; 2 3 import java.awt.*; 4 import java.awt.event.*; 5 import javax.swing.*; 6 import javax.swing.event.*; 7 import javax.swing.border.*; 8 import java.io.*; 9 import java.util.*; 10 11 public class OctopusGeneratorFrame 12 extends JInternalFrame { 13 14 private static final String SOURCE_TYPE = "Source database type", 15 TARGET_TYPE = "Target database type", 16 SOURCE_DATABASE = "Source database URL", 17 TARGET_DATABASE ="Target database URL", 18 SOURCE_USER = "Source database user", 19 SOURCE_PASSWORD = "Source database password", 20 TARGET_USER = "Target database user", 21 TARGET_PASSWORD = "Target database password", 22 VALUE_MODE = "Value mode", 23 GENERATOR_OUTPUT ="Generator output directory", 24 DOML_PATH = "Doml URL( when use Doml as input )", 25 PACKAGE_NAME = "Package name", 26 SOURCE_DRIVER_NAME = "Source database driver name", 27 TARGET_DRIVER_NAME ="Target database driver name", 28 ADDITIONAL_PATHS = "Additional classpaths", 29 DROP_TABLE = "Drop Tables", 30 CREATE_TABLE = "Create Tables", 31 CREATE_PRIMARY_KEYS = "Create Primary Keys", 32 DROP_FOREIGN_KEYS = "Drop Foreign Keys", 33 CREATE_FOREIGN_KEYS ="Create Foreign Keys", 34 CREATE_INDEXES = "Create Indexes", 35 CREATE_SQL_FOR_ALL_VENDORS ="Create SQL Statements for All Vendors", 36 GENERATE_DOML = "Generate Doml file", 37 GENERATE_XML = "Generate Xml files", 38 GENERATE_SQL = "Generate Sql files", 39 OPTIMIZED_MODE ="Optimized mode for all tables", 40 FULL_MODE = "Full mode for all tables", 41 INCLUDE_TABLE_LIST = "Include Table List (e.g. table1;table2)", 42 PATH_TO_CONF_IN_JAR = "Path to conf files in jar"; 43 44 private static Dimension bigButton = new Dimension(100, 20); 46 private static Dimension smallComponent = new Dimension(150, 20); 47 private static Dimension bigComponent = new Dimension(400, 20); 48 private static Dimension bigPlusButton = new Dimension(380, 20); 49 private static Dimension veryBigComponent = new Dimension(650, 20); 50 private static Dimension veryBigPlusButton = new Dimension(630, 20); 51 private static Dimension panelComponenet = new Dimension(720, 40); 52 53 JSplitPane main; 54 55 Border loweredBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED); 56 Border raisedBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED); 57 Border bevelBorder = BorderFactory.createLoweredBevelBorder(); 58 59 private JCheckBox sqlFiles, xmlFiles, domlFile, 60 createTables, createPK, createFK, createIn, 61 dropTables, createSQLForAll, dropFK; 62 private JRadioButton optimizedMode, fullMode; 63 private JTextField packageField, generatorOutput, addPaths; 64 private JDesktopPane desktop; 65 private OctopusGeneratorData initData; 66 private HashMap fields; 67 private JTextArea traceArea; 68 69 public OctopusGeneratorFrame(JDesktopPane desktop) { 70 super("Octopus Generator Application", true, true, true, true); 71 setFrameIcon( new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/"+ 72 "wizard/images/Enhydra16.gif"))); 73 74 this.desktop = desktop; 75 fields = new HashMap(); 76 JPanel generatorOptionsUp = new JPanel(); 78 JPanel generatorOptionsDown = new JPanel(); 79 80 JTabbedPane octopusGeneratorData = new JTabbedPane(); 82 JPanel commonPanel = new JPanel(); 83 JPanel advancedPanel = new JPanel(); 84 JPanel outputOptions = new JPanel(); 85 octopusGeneratorData.addTab("JDBC as source data", commonPanel); 86 octopusGeneratorData.addTab("Output options", outputOptions); 87 octopusGeneratorData.addTab("Advanced", advancedPanel); 88 89 generatorOptionsUp.setLayout(new BoxLayout(generatorOptionsUp, BoxLayout.Y_AXIS)); 91 generatorOptionsUp.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); 92 JButton gotoOct = createOctopusButton("Loader", bigButton); 93 gotoOct.setAction(new StartOctopusLoader()); 94 JButton help = createOctopusButton("Help", bigButton); 95 help.setAction(new OctopusHelpAction()); 96 generatorOptionsUp.add(gotoOct); 97 generatorOptionsUp.add(help); 98 99 generatorOptionsDown.setLayout(new BoxLayout(generatorOptionsDown, BoxLayout.Y_AXIS)); 101 generatorOptionsDown.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); 102 JButton start = createOctopusButton("Start", bigButton); 103 start.setAction(new StartOctopusGenerator()); 104 JButton stop = createOctopusButton("Stop", bigButton); 105 stop.setAction(new StopOctopusGenerator()); 106 generatorOptionsDown.add(start); 107 generatorOptionsDown.add(stop); 108 109 JSplitPane generatorOptions = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, 111 generatorOptionsUp, generatorOptionsDown); 112 generatorOptions.setOneTouchExpandable(true); 113 generatorOptions.setDividerLocation(560); 114 115 JSplitPane generatorInputData = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true, 116 generatorOptions, octopusGeneratorData); 117 118 JPanel pathToConfPanel = new JPanel(); 120 pathToConfPanel.setLayout(new BoxLayout(pathToConfPanel, BoxLayout.X_AXIS)); 121 pathToConfPanel.setBorder(setTitleOfBorder("Advanced Options", loweredBorder)); 122 JLabel strPathToConf = createOctopusLabel(PATH_TO_CONF_IN_JAR, smallComponent); 123 JTextField pathToConf = createOctopusTextField(PATH_TO_CONF_IN_JAR, veryBigComponent); 124 pathToConfPanel.add(strPathToConf); 125 pathToConfPanel.add(pathToConf); 126 127 JPanel mainPathToConfPanel = new JPanel(); 128 mainPathToConfPanel.setLayout(new BoxLayout(mainPathToConfPanel, BoxLayout.X_AXIS)); 129 mainPathToConfPanel.add(pathToConfPanel); 130 mainPathToConfPanel.add(Box.createHorizontalGlue()); 131 132 advancedPanel.setLayout(new BoxLayout(advancedPanel, BoxLayout.Y_AXIS)); 133 advancedPanel.add(Box.createRigidArea(new Dimension(0, 15))); 134 advancedPanel.add(mainPathToConfPanel); 135 136 JPanel sourcePanel = new JPanel(); 138 sourcePanel.setLayout(new BoxLayout(sourcePanel, BoxLayout.Y_AXIS)); 139 JLabel strSourceType = createOctopusLabel(SOURCE_TYPE, bigComponent); 141 JComboBox sourceType = createOctopusCombobox(SOURCE_TYPE, bigComponent); 142 JLabel strSourceUrl = createOctopusLabel(SOURCE_DATABASE, bigComponent); 144 JTextField sourceUrl = createOctopusTextField(SOURCE_DATABASE, bigComponent); 145 JLabel strSourceDriverName = createOctopusLabel(SOURCE_DRIVER_NAME, bigComponent); 147 JComboBox sourceDriverName = createOctopusCombobox(SOURCE_DRIVER_NAME, bigComponent); 148 JLabel strSourceUser = createOctopusLabel(SOURCE_USER, bigComponent); 150 JTextField sourceUser = createOctopusTextField(SOURCE_USER, bigComponent); 151 JLabel strSourcePassword = createOctopusLabel(SOURCE_PASSWORD, bigComponent); 153 JTextField sourcePassword = createOctopusTextField(SOURCE_PASSWORD, bigComponent); 154 JLabel strDomlUrl = createOctopusLabel(DOML_PATH, bigComponent); 156 JTextField domlUrl = createOctopusTextField(DOML_PATH, bigPlusButton); 157 JButton domlButton=createOctopusButton("doml url button",new Dimension(20,20)); 158 domlButton.setAction(new BrowseAction_DOML()); 159 160 ImageIcon icon = new ImageIcon(getClass().getClassLoader().getResource( 161 "org/webdocwf/util/loader/" + 162 "wizard/images/database.gif")); 163 JLabel sourceLabel = new JLabel("JDBC Source Database", icon, SwingConstants.RIGHT); 164 165 sourcePanel.add(createJDBCRow(sourceLabel,null)); 166 sourcePanel.add(Box.createRigidArea(new Dimension(0, 10))); 167 sourcePanel.add(createJDBCRow(strSourceType,null)); 168 sourcePanel.add(createJDBCRow(sourceType,null)); 169 sourcePanel.add(createJDBCRow(strSourceUrl,null)); 170 sourcePanel.add(createJDBCRow(sourceUrl,null)); 171 sourcePanel.add(createJDBCRow(strDomlUrl,null)); 172 sourcePanel.add(createJDBCRow(domlUrl,domlButton)); 173 sourcePanel.add(createJDBCRow(strSourceDriverName,null)); 174 sourcePanel.add(createJDBCRow(sourceDriverName,null)); 175 sourcePanel.add(createJDBCRow(strSourceUser,null)); 176 sourcePanel.add(createJDBCRow(sourceUser,null)); 177 sourcePanel.add(createJDBCRow(strSourcePassword,null)); 178 sourcePanel.add(createJDBCRow(sourcePassword,null)); 179 180 sourcePanel.setBorder(setTitleOfBorder("", bevelBorder)); 181 182 JPanel targetPanel = new JPanel(); 184 targetPanel.setLayout(new BoxLayout(targetPanel, BoxLayout.Y_AXIS)); 185 JLabel strTargetType = createOctopusLabel(TARGET_TYPE, bigComponent); 187 JComboBox targetType = createOctopusCombobox(TARGET_TYPE, bigComponent); 188 JLabel strTargetUrl = createOctopusLabel(TARGET_DATABASE, bigComponent); 190 JTextField targetUrl = createOctopusTextField(TARGET_DATABASE, bigComponent); 191 JLabel strTargetDriverName = createOctopusLabel(TARGET_DRIVER_NAME, bigComponent); 193 JComboBox targetDriverName = createOctopusCombobox(TARGET_DRIVER_NAME, bigComponent); 194 JLabel strTargetUser = createOctopusLabel(TARGET_USER, bigComponent); 196 JTextField targetUser = createOctopusTextField(TARGET_USER, bigComponent); 197 JLabel strTargetPassword = createOctopusLabel(TARGET_PASSWORD, bigComponent); 199 JTextField targetPassword = createOctopusTextField(TARGET_PASSWORD, bigComponent); 200 201 JLabel strTargetDoml = createOctopusLabel("Doml URL", bigComponent); 202 String msg = "Doml file will be placed in output directory"; 203 JTextField targetDoml = createOctopusTextField("Doml URL target", bigComponent); 204 targetDoml.setText(msg); 205 targetDoml.setEditable(false); 206 207 ImageIcon icon2 = new ImageIcon(getClass().getClassLoader().getResource( 208 "org/webdocwf/util/loader/" + 209 "wizard/images/database2.gif")); 210 JLabel targetLabel = new JLabel("JDBC Target Database", icon2, SwingConstants.RIGHT); 211 212 targetPanel.add(createJDBCRow(targetLabel,null)); 213 targetPanel.add(Box.createRigidArea(new Dimension(0, 10))); 214 targetPanel.add(createJDBCRow(strTargetType,null)); 215 targetPanel.add(createJDBCRow(targetType,null)); 216 targetPanel.add(createJDBCRow(strTargetUrl,null)); 217 targetPanel.add(createJDBCRow(targetUrl,null)); 218 targetPanel.add(createJDBCRow(strTargetDoml,null)); 219 targetPanel.add(createJDBCRow(targetDoml,null)); 220 targetPanel.add(createJDBCRow(strTargetDriverName,null)); 221 targetPanel.add(createJDBCRow(targetDriverName,null)); 222 targetPanel.add(createJDBCRow(strTargetUser,null)); 223 targetPanel.add(createJDBCRow(targetUser,null)); 224 targetPanel.add(createJDBCRow(strTargetPassword,null)); 225 targetPanel.add(createJDBCRow(targetPassword,null)); 226 227 targetPanel.setBorder(setTitleOfBorder("", bevelBorder)); 228 229 JPanel JDBCPanel = new JPanel(); 230 JDBCPanel.setLayout(new BoxLayout(JDBCPanel, BoxLayout.X_AXIS)); 231 JDBCPanel.add(sourcePanel); 232 JDBCPanel.add(targetPanel); 233 234 JPanel JDBCMainPanel = new JPanel(); 235 JDBCMainPanel.setLayout(new BoxLayout(JDBCMainPanel, BoxLayout.X_AXIS)); 236 JDBCMainPanel.add(JDBCPanel); 237 JDBCMainPanel.add(Box.createHorizontalGlue()); 238 239 JPanel valuModePanel = new JPanel(); 241 valuModePanel.setLayout(new BoxLayout(valuModePanel, BoxLayout.X_AXIS)); 242 valuModePanel.setBorder(setTitleOfBorder("Value mode", loweredBorder)); 243 JLabel strValueMode = createOctopusLabel(VALUE_MODE, smallComponent); 244 JComboBox valueMode = createOctopusCombobox(VALUE_MODE, veryBigComponent); 245 valuModePanel.add(strValueMode); 246 valuModePanel.add(valueMode); 247 248 JPanel mainValueModePanel = new JPanel(); 249 mainValueModePanel.setLayout(new BoxLayout(mainValueModePanel, BoxLayout.X_AXIS)); 250 mainValueModePanel.add(valuModePanel); 251 mainValueModePanel.add(Box.createHorizontalGlue()); 252 253 JPanel generatorOutputPanel = new JPanel(); 255 generatorOutputPanel.setLayout(new BoxLayout(generatorOutputPanel, BoxLayout.X_AXIS)); 256 JPanel generatorOutputInnerPanel = new JPanel(); 257 JButton browseGeneratorOutput = createOctopusButton("O", new Dimension(20, 20)); 258 browseGeneratorOutput.setAction(new BrowseAction_GO()); 259 260 generatorOutputInnerPanel.setLayout(new BoxLayout(generatorOutputInnerPanel, BoxLayout.X_AXIS)); 261 generatorOutputInnerPanel.setBorder(setTitleOfBorder("Generator Output", loweredBorder)); 262 JLabel strGeneratorOutput = createOctopusLabel(GENERATOR_OUTPUT, smallComponent); 263 generatorOutput = createOctopusTextField(GENERATOR_OUTPUT, veryBigPlusButton); 264 generatorOutputInnerPanel.add(strGeneratorOutput); 265 generatorOutputInnerPanel.add(generatorOutput); 266 generatorOutputInnerPanel.add(browseGeneratorOutput); 267 268 generatorOutputPanel.add(generatorOutputInnerPanel); 269 generatorOutputPanel.add(Box.createHorizontalGlue()); 270 271 JPanel includeTableListPanel = new JPanel(); 273 includeTableListPanel.setLayout(new BoxLayout(includeTableListPanel, BoxLayout.X_AXIS)); 274 JPanel includeTableListInnerPanel = new JPanel(); 275 includeTableListInnerPanel.setLayout(new BoxLayout(includeTableListInnerPanel, BoxLayout.X_AXIS)); 276 includeTableListInnerPanel.setBorder(setTitleOfBorder("Tables List", loweredBorder)); 277 JLabel strIncludeTableList = createOctopusLabel(INCLUDE_TABLE_LIST, smallComponent); 278 JTextField includeTableList = createOctopusTextField(INCLUDE_TABLE_LIST, veryBigComponent); 279 includeTableListInnerPanel.add(strIncludeTableList); 280 includeTableListInnerPanel.add(includeTableList); 281 282 includeTableListPanel.add(includeTableListInnerPanel); 283 includeTableListPanel.add(Box.createHorizontalGlue()); 284 285 JPanel addPathsPanel = new JPanel(); 287 addPathsPanel.setLayout(new BoxLayout(addPathsPanel, BoxLayout.X_AXIS)); 288 JPanel addPathsInnerPanel = new JPanel(); 289 JButton browseAdditionalClass = createOctopusButton("O", new Dimension(20, 20)); 290 browseAdditionalClass.setAction(new BrowseAction_AC()); 291 addPathsInnerPanel.setLayout(new BoxLayout(addPathsInnerPanel, BoxLayout.X_AXIS)); 292 addPathsInnerPanel.setBorder(setTitleOfBorder("Add new drivers", loweredBorder)); 293 JLabel strAddPaths = createOctopusLabel(ADDITIONAL_PATHS, smallComponent); 294 addPaths = createOctopusTextField(ADDITIONAL_PATHS, veryBigPlusButton); 295 addPathsInnerPanel.add(strAddPaths); 296 addPathsInnerPanel.add(addPaths); 297 addPathsInnerPanel.add(browseAdditionalClass); 298 299 addPathsPanel.add(addPathsInnerPanel); 300 addPathsPanel.add(Box.createHorizontalGlue()); 301 302 JPanel commonOptionsPanel = new JPanel(); 303 JPanel commonOptionsMainPanel = new JPanel(); 304 commonOptionsPanel.setLayout(new BoxLayout(commonOptionsPanel, BoxLayout.Y_AXIS)); 305 commonOptionsMainPanel.setLayout(new BoxLayout(commonOptionsMainPanel, BoxLayout.X_AXIS)); 306 commonOptionsPanel.add(mainValueModePanel); 307 commonOptionsPanel.add(generatorOutputPanel); 308 commonOptionsPanel.add(includeTableListPanel); 309 commonOptionsPanel.add(addPathsPanel); 310 311 commonOptionsMainPanel.add(commonOptionsPanel); 312 commonOptionsMainPanel.add(Box.createHorizontalGlue()); 313 314 commonPanel.setLayout(new BoxLayout(commonPanel, BoxLayout.Y_AXIS)); 315 commonPanel.add(JDBCMainPanel); 316 commonPanel.add(commonOptionsMainPanel); 317 commonPanel.add(Box.createVerticalGlue()); 318 319 JPanel outputMode = new JPanel(); 320 outputMode.setLayout(new BoxLayout(outputMode, BoxLayout.X_AXIS)); 321 outputMode.setBorder(setTitleOfBorder("Output Mode", loweredBorder)); 322 sqlFiles = new JCheckBox(GENERATE_SQL); 323 sqlFiles.setSelected(true); 324 xmlFiles = new JCheckBox(GENERATE_XML); 325 xmlFiles.setSelected(true); 326 domlFile = new JCheckBox(GENERATE_DOML); 327 outputMode.add(sqlFiles); 328 outputMode.add(xmlFiles); 329 outputMode.add(domlFile); 330 331 sqlFiles.addActionListener(new ActionListener() { 332 public void actionPerformed(ActionEvent e) { 333 if(sqlFiles.isSelected()) { 334 createTables.setEnabled(true); 335 createTables.setSelected(true); 336 dropTables.setEnabled(true); 337 dropTables.setSelected(true); 338 createPK.setEnabled(true); 339 createPK.setSelected(true); 340 createFK.setEnabled(true); 341 createFK.setSelected(true); 342 dropFK.setEnabled(true); 343 dropFK.setSelected(true); 344 createIn.setEnabled(true); 345 createIn.setSelected(true); 346 createSQLForAll.setEnabled(true); 347 createSQLForAll.setSelected(false); 348 } else { 349 createTables.setSelected(false); 350 createTables.setEnabled(false); 351 dropTables.setEnabled(false); 352 dropTables.setSelected(false); 353 createPK.setEnabled(false); 354 createPK.setSelected(false); 355 createFK.setEnabled(false); 356 createFK.setSelected(false); 357 dropFK.setEnabled(false); 358 dropFK.setSelected(false); 359 createIn.setEnabled(false); 360 createIn.setSelected(false); 361 createSQLForAll.setEnabled(false); 362 createSQLForAll.setSelected(false); 363 } 364 } 365 }); 366 367 xmlFiles.addActionListener(new ActionListener() { 368 public void actionPerformed(ActionEvent e) { 369 if(xmlFiles.isSelected()) { 370 optimizedMode.setEnabled(true); 371 optimizedMode.setSelected(false); 372 fullMode.setEnabled(true); 373 fullMode.setSelected(true); 374 } else { 375 optimizedMode.setEnabled(false); 376 optimizedMode.setSelected(false); 377 fullMode.setEnabled(false); 378 fullMode.setSelected(false); 379 } 380 } 381 }); 382 383 domlFile.addActionListener(new ActionListener() { 384 public void actionPerformed(ActionEvent e) { 385 if(domlFile.isSelected()) { 386 packageField.setEditable(true); 387 packageField.setText(""); 388 } else { 389 packageField.setText(""); 390 packageField.setEditable(false); 391 392 } 393 } 394 }); 395 396 JPanel mainOutputMode = new JPanel(); 397 mainOutputMode.setLayout(new BoxLayout(mainOutputMode, BoxLayout.X_AXIS)); 398 mainOutputMode.add(outputMode); 399 mainOutputMode.add(Box.createHorizontalGlue()); 400 401 createTables = new JCheckBox(CREATE_TABLE); 402 createTables.setSelected(true); 403 createPK = new JCheckBox(CREATE_PRIMARY_KEYS); 404 createPK.setSelected(true); 405 createFK = new JCheckBox(CREATE_FOREIGN_KEYS); 406 createFK.setSelected(true); 407 createIn = new JCheckBox(CREATE_INDEXES); 408 createIn.setSelected(true); 409 dropTables = new JCheckBox(DROP_TABLE); 410 dropTables.setSelected(true); 411 dropFK = new JCheckBox(DROP_FOREIGN_KEYS); 412 dropFK.setSelected(true); 413 createSQLForAll = new JCheckBox(CREATE_SQL_FOR_ALL_VENDORS); 414 415 JPanel sqlOptionsPanel1 = new JPanel(); 416 sqlOptionsPanel1.setLayout(new BoxLayout(sqlOptionsPanel1, BoxLayout.Y_AXIS)); 417 sqlOptionsPanel1.add(dropTables); 418 sqlOptionsPanel1.add(createTables); 419 sqlOptionsPanel1.add(createPK); 420 421 JPanel sqlOptionsPanel2 = new JPanel(); 422 sqlOptionsPanel2.setLayout(new BoxLayout(sqlOptionsPanel2, BoxLayout.Y_AXIS)); 423 sqlOptionsPanel2.add(dropFK); 424 sqlOptionsPanel2.add(createFK); 425 sqlOptionsPanel2.add(createIn); 426 427 JPanel sqlOptionsPanel3 = new JPanel(); 428 sqlOptionsPanel3.setLayout(new BoxLayout(sqlOptionsPanel3, BoxLayout.Y_AXIS)); 429 sqlOptionsPanel3.add(createSQLForAll); 430 431 JPanel sqlOptionsPanel = new JPanel(); 432 sqlOptionsPanel.setLayout(new BoxLayout(sqlOptionsPanel, BoxLayout.X_AXIS)); 433 sqlOptionsPanel.setBorder(setTitleOfBorder("SQL Options", loweredBorder)); 434 sqlOptionsPanel.add(sqlOptionsPanel1); 435 sqlOptionsPanel.add(sqlOptionsPanel2); 436 sqlOptionsPanel.add(sqlOptionsPanel3); 437 438 JPanel mainSqlOptionsPanel = new JPanel(); 439 mainSqlOptionsPanel.setLayout(new BoxLayout(mainSqlOptionsPanel, BoxLayout.X_AXIS)); 440 mainSqlOptionsPanel.add(sqlOptionsPanel); 441 mainSqlOptionsPanel.add(Box.createHorizontalGlue()); 442 443 JPanel xmlOptionsPanel = new JPanel(); 444 xmlOptionsPanel.setLayout(new BoxLayout(xmlOptionsPanel, BoxLayout.X_AXIS)); 445 optimizedMode = new JRadioButton(OPTIMIZED_MODE); 446 fullMode = new JRadioButton(FULL_MODE); 447 fullMode.setSelected(true); 448 449 optimizedMode.addActionListener(new ActionListener() { 450 public void actionPerformed(ActionEvent e) { 451 if(optimizedMode.isSelected()) { 452 fullMode.setSelected(false); 453 } else { 454 fullMode.setSelected(true); 455 } 456 } 457 }); 458 459 fullMode.addActionListener(new ActionListener() { 460 public void actionPerformed(ActionEvent e) { 461 if(fullMode.isSelected()) { 462 optimizedMode.setSelected(false); 463 } else { 464 optimizedMode.setSelected(true); 465 } 466 } 467 }); 468 469 xmlOptionsPanel.setBorder(setTitleOfBorder("XML Options", loweredBorder)); 470 xmlOptionsPanel.add(optimizedMode); 471 xmlOptionsPanel.add(fullMode); 472 473 JPanel mainXmlOptionsPanel = new JPanel(); 474 mainXmlOptionsPanel.setLayout(new BoxLayout(mainXmlOptionsPanel, BoxLayout.X_AXIS)); 475 mainXmlOptionsPanel.add(xmlOptionsPanel); 476 mainXmlOptionsPanel.add(Box.createHorizontalGlue()); 477 478 JPanel packagePanel = new JPanel(); 479 packagePanel.setLayout(new BoxLayout(packagePanel, BoxLayout.X_AXIS)); 480 packagePanel.setBorder(setTitleOfBorder("Package name for doml file", loweredBorder)); 481 packageField = createOctopusTextField(PACKAGE_NAME, veryBigComponent); 482 packageField.setEditable(false); 483 JLabel strPackageField = createOctopusLabel(PACKAGE_NAME, smallComponent); 484 packagePanel.add(strPackageField); 485 packagePanel.add(packageField); 486 487 JPanel mainPackagePanel = new JPanel(); 488 mainPackagePanel.setLayout(new BoxLayout(mainPackagePanel, BoxLayout.X_AXIS)); 489 mainPackagePanel.add(packagePanel); 490 mainPackagePanel.add(Box.createHorizontalGlue()); 491 492 outputOptions.setLayout(new BoxLayout(outputOptions, BoxLayout.Y_AXIS)); 494 495 outputOptions.add(Box.createRigidArea(new Dimension(0, 10))); 496 outputOptions.add(mainOutputMode); 497 outputOptions.add(Box.createRigidArea(new Dimension(0, 10))); 498 outputOptions.add(mainSqlOptionsPanel); 499 outputOptions.add(Box.createRigidArea(new Dimension(0, 10))); 500 outputOptions.add(mainXmlOptionsPanel); 501 outputOptions.add(Box.createRigidArea(new Dimension(0, 10))); 502 outputOptions.add(mainPackagePanel); 503 504 JPanel textAreaPanel = new JPanel(); 506 textAreaPanel.setLayout(new BoxLayout(textAreaPanel, BoxLayout.X_AXIS)); 507 JPanel areaOptionPanel = new JPanel(); 508 areaOptionPanel.setLayout(new BoxLayout(areaOptionPanel, BoxLayout.Y_AXIS)); 509 traceArea = new JTextArea(18, 130); 510 traceArea.setLineWrap(true); 511 traceArea.setEditable(false); 512 traceArea.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED)); 513 JScrollPane scrollPane = new JScrollPane(traceArea, 514 ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS, 515 ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); 516 517 scrollPane.setBorder(setTitleOfBorder("Log Octopus Generator output ... ", loweredBorder)); 518 JButton fullScreen = createOctopusButton("Full Screen", new Dimension(25, 25)); 519 fullScreen.setAction(new FullScreenAction()); 520 JButton normalScreen = createOctopusButton("Normal Screen", new Dimension(25, 25)); 521 normalScreen.setAction(new NormalScreenAction()); 522 JButton saveScreen = createOctopusButton("Save Trace", new Dimension(25, 25)); 523 saveScreen.setAction(new SaveTraceAction()); 524 JButton clearTrace = createOctopusButton("Clear Trace", new Dimension(25, 25)); 525 clearTrace.setAction(new ClearTraceAction()); 526 527 areaOptionPanel.add(fullScreen); 528 areaOptionPanel.add(normalScreen); 529 areaOptionPanel.add(saveScreen); 530 areaOptionPanel.add(clearTrace); 531 areaOptionPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED)); 532 533 JPanel areaOptionMainPanel = new JPanel(new BorderLayout()); 534 areaOptionMainPanel.add(areaOptionPanel, BorderLayout.PAGE_START); 535 536 textAreaPanel.add(areaOptionMainPanel); 537 textAreaPanel.add(scrollPane); 538 main = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, generatorInputData, 539 textAreaPanel); 540 main.setOneTouchExpandable(true); 541 main.setDividerLocation(650); 542 543 fields.put(SOURCE_TYPE, sourceType); 546 fields.put(SOURCE_DATABASE, sourceUrl); 547 fields.put(DOML_PATH, domlUrl); 548 fields.put(SOURCE_DRIVER_NAME, sourceDriverName); 549 fields.put(SOURCE_USER, sourceUser); 550 fields.put(SOURCE_PASSWORD, sourcePassword); 551 fields.put(TARGET_TYPE, targetType); 553 fields.put(TARGET_DATABASE, targetUrl); 554 fields.put(TARGET_DRIVER_NAME, targetDriverName); 555 fields.put(TARGET_USER, targetUser); 556 fields.put(TARGET_PASSWORD, targetPassword); 557 558 fields.put(VALUE_MODE, valueMode); 560 561 fields.put(GENERATOR_OUTPUT, generatorOutput); 562 fields.put(ADDITIONAL_PATHS, addPaths); 563 fields.put(INCLUDE_TABLE_LIST, includeTableList); 564 565 fields.put(GENERATE_SQL, sqlFiles); 567 fields.put(CREATE_TABLE, createTables); 568 fields.put(CREATE_PRIMARY_KEYS, createPK); 569 fields.put(CREATE_FOREIGN_KEYS, createFK); 570 fields.put(CREATE_INDEXES, createIn); 571 fields.put(DROP_TABLE, dropTables); 572 fields.put(DROP_FOREIGN_KEYS, dropFK); 573 fields.put(CREATE_SQL_FOR_ALL_VENDORS, createSQLForAll); 574 575 fields.put(GENERATE_XML, xmlFiles); 577 fields.put(FULL_MODE, fullMode); 578 fields.put(OPTIMIZED_MODE, optimizedMode); 579 580 fields.put(GENERATE_DOML, domlFile); 582 fields.put(PACKAGE_NAME, packageField); 583 584 fields.put(PATH_TO_CONF_IN_JAR, pathToConf); 586 587 Container container = getContentPane(); 588 container.setLayout(new BoxLayout(container, BoxLayout.X_AXIS)); 589 container.add(main); 590 setBounds(0, 0, 970, 680); 591 } 592 593 private JPanel createJDBCRow(JComponent jc1, JComponent jc2){ 594 JPanel jp = new JPanel(); 595 jp.setLayout(new BoxLayout(jp, BoxLayout.X_AXIS)); 596 jp.add(jc1); 597 if(jc2!=null) 598 jp.add(jc2); 599 600 jp.add(Box.createHorizontalGlue()); 601 return jp; 602 } 603 604 private Border setTitleOfBorder(String title, Border border) { 605 Border inb = BorderFactory.createTitledBorder(border, title); 606 return inb; 607 } 608 609 private JButton createOctopusButton(String componentName, Dimension dimension) { 610 611 JButton button = new JButton(); 612 if(!componentName.equalsIgnoreCase("")) 613 button.setText(componentName); 614 615 button.setAlignmentX(Component.LEFT_ALIGNMENT); 616 button.setAlignmentY(Component.CENTER_ALIGNMENT); 617 button.setMinimumSize(new Dimension(dimension)); 618 button.setMaximumSize(new Dimension(dimension)); 619 button.setPreferredSize(new Dimension(dimension)); 620 621 return button; 622 } 623 624 private JComboBox createOctopusCombobox(String componentName, Dimension dimension) { 625 626 JComboBox comboBox = new JComboBox(); 627 comboBox.setName(componentName); 628 comboBox.setAlignmentX(Component.LEFT_ALIGNMENT); 629 comboBox.setAlignmentY(Component.CENTER_ALIGNMENT); 630 comboBox.setMinimumSize(new Dimension(dimension)); 631 comboBox.setMaximumSize(new Dimension(dimension)); 632 comboBox.setPreferredSize(new Dimension(dimension)); 633 634 return comboBox; 635 } 636 637 private JLabel createOctopusLabel(String componentName, Dimension dimension) { 638 639 JLabel label = new JLabel(); 640 label.setText(componentName); 641 label.setAlignmentX(Component.LEFT_ALIGNMENT); 642 label.setAlignmentY(Component.CENTER_ALIGNMENT); 643 label.setMinimumSize(new Dimension(dimension)); 644 label.setMaximumSize(new Dimension(dimension)); 645 label.setPreferredSize(new Dimension(dimension)); 646 647 return label; 648 } 649 650 private JTextField createOctopusTextField(String componentName, Dimension dimension) { 651 652 JTextField textField = new JTextField(); 653 textField.setName(componentName); 654 textField.setAlignmentX(Component.LEFT_ALIGNMENT); 655 textField.setAlignmentY(Component.CENTER_ALIGNMENT); 656 textField.setMinimumSize(new Dimension(dimension)); 657 textField.setMaximumSize(new Dimension(dimension)); 658 textField.setPreferredSize(new Dimension(dimension)); 659 660 return textField; 661 } 662 663 public void setOctopusGeneratorInit(OctopusGeneratorData initData, String confJarStructure) { 664 this.initData = initData; 665 setField(SOURCE_TYPE, initData.getSourceType(), "box"); 666 setField(SOURCE_DRIVER_NAME, initData.getSourceDriverName(), "box"); 667 setField(SOURCE_DATABASE, initData.getSourceDatabase(), "label"); 668 669 setField(TARGET_TYPE, initData.getTargetType(), "box"); 670 setField(TARGET_DRIVER_NAME, initData.getTargetDriverName(), "box"); 671 setField(TARGET_DATABASE, initData.getTargetDatabase(), "label"); 672 673 setField(VALUE_MODE, initData.getValueMode(), "box"); 674 675 } 676 677 public OctopusGeneratorData getOctopusGeneratorInit() throws Exception { 678 679 initData.setSourceType(getField(SOURCE_TYPE, "box")); 680 initData.setTargetType(getField(TARGET_TYPE, "box")); 681 initData.setSourceDatabase(getField(SOURCE_DATABASE, "label")); 682 initData.setTargetDatabase(getField(TARGET_DATABASE, "label")); 683 initData.setSourceUser(getField(SOURCE_USER, "label")); 684 initData.setSourcePassword(getField(SOURCE_PASSWORD, "label")); 685 initData.setTargetUser(getField(TARGET_USER, "label")); 686 initData.setTargetPassword(getField(TARGET_PASSWORD, "label")); 687 initData.setValueMode(getField(VALUE_MODE, "box")); 688 initData.setGeneratorOutput(getField(GENERATOR_OUTPUT, "label")); 689 initData.setDomlPath(getField(DOML_PATH, "label")); 690 initData.setPackageName(getField(PACKAGE_NAME, "label")); 691 initData.setSourceDriverName(getField(SOURCE_DRIVER_NAME, "box")); 692 initData.setTargetDriverName(getField(TARGET_DRIVER_NAME, "box")); 693 initData.setAdditionalPaths(getField(ADDITIONAL_PATHS, "label")); 694 initData.setSqlStmtDropTable(getField(DROP_TABLE, "checkBox")); 695 initData.setSqlStmtDropIntegrity(getField(DROP_FOREIGN_KEYS, "checkBox")); 696 initData.setSqlStmtCreateTable(getField(CREATE_TABLE, "checkBox")); 697 initData.setSqlStmtCreatePK(getField(CREATE_PRIMARY_KEYS, "checkBox")); 698 initData.setSqlStmtCreateFK(getField(CREATE_FOREIGN_KEYS, "checkBox")); 699 initData.setSqlStmtCreateIndex(getField(CREATE_INDEXES, "checkBox")); 700 initData.setSqlStmtForAllVendors(getField(CREATE_SQL_FOR_ALL_VENDORS, "checkBox")); 701 initData.setSqlGenerate(getField(GENERATE_SQL, "checkBox")); 702 initData.setXmlGenerate(getField(GENERATE_XML, "checkBox")); 703 initData.setDomlGenerate(getField(GENERATE_DOML, "checkBox")); 704 if(getField(FULL_MODE, "radioButton").equalsIgnoreCase("true")) 705 initData.setFullMode("true"); 706 else 707 initData.setFullMode("false"); 708 initData.setIncludeTableList(getField(INCLUDE_TABLE_LIST, "label")); 709 initData.setConfJarStructure(getField(PATH_TO_CONF_IN_JAR, "label")); 710 return initData; 711 } 712 713 private String getField(String fieldName, String type) { 714 if(type.equalsIgnoreCase("label")) { 715 JTextField field = (JTextField)fields.get(fieldName); 716 return field.getText().trim(); 717 } else if(type.startsWith("checkBox")) { 718 JCheckBox field = (JCheckBox)fields.get(fieldName); 719 if(field.isSelected() == true) 720 return "true"; 721 else 722 return "false"; 723 } else if(type.startsWith("radioButton")) { 724 JRadioButton field = (JRadioButton)fields.get(fieldName); 725 if(field.isSelected() == true) 726 return "true"; 727 else 728 return "false"; 729 } else { 730 JComboBox field = (JComboBox)fields.get(fieldName); 731 return field.getSelectedItem().toString(); 732 733 } 734 } 735 736 private void setField(String fieldName, String value, String type) { 737 if(!type.equalsIgnoreCase("box")) { 738 JTextField field = (JTextField)fields.get(fieldName); 739 field.setText(value); 740 } else { 741 JComboBox field = (JComboBox)fields.get(fieldName); 742 if(fieldName.equalsIgnoreCase(SOURCE_TYPE)) { 743 for(int i = 0; i < OctopusGeneratorData.getSourceDatabaseTypes().length; i++) { 744 field.addItem(OctopusGeneratorData.getSourceDatabaseTypes()[i]); 745 } 746 } else if(fieldName.equalsIgnoreCase(TARGET_TYPE)) { 747 for(int i = 0; i < OctopusGeneratorData.getTargetDatabaseTypes().length; i++) { 748 field.addItem(OctopusGeneratorData.getTargetDatabaseTypes()[i]); 749 } 750 } else if(fieldName.equalsIgnoreCase(SOURCE_DRIVER_NAME)) { 751 for(int i = 0; i < OctopusGeneratorData.getSourceDriverNames().length; i++) { 752 field.addItem(OctopusGeneratorData.getSourceDriverNames()[i]); 753 } 754 } else if(fieldName.equalsIgnoreCase(TARGET_DRIVER_NAME)) { 755 for(int i = 0; i < OctopusGeneratorData.getTargetDriverNames().length; i++) { 756 field.addItem(OctopusGeneratorData.getTargetDriverNames()[i]); 757 } 758 } else if(fieldName.equalsIgnoreCase(VALUE_MODE)) { 759 for(int i = 0; i < OctopusGeneratorData.getValueModes().length; i++) { 760 field.addItem(OctopusGeneratorData.getValueModes()[i]); 761 } 762 } 763 } 764 } 765 766 private class FullScreenAction 767 extends AbstractAction { 768 769 772 public FullScreenAction() { 773 774 putValue(SMALL_ICON, 775 new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" + 776 "wizard/images/Host16.gif"))); 777 putValue(SHORT_DESCRIPTION, "Full Screen"); 778 putValue(LONG_DESCRIPTION, "Set Trace to Full Screen"); 779 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('F', 780 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); 781 putValue(MNEMONIC_KEY, new Integer ('F')); 782 } 783 784 788 public void actionPerformed(ActionEvent e) { 789 main.setDividerLocation(0); 790 } 791 } 792 793 private class NormalScreenAction 794 extends AbstractAction { 795 796 799 public NormalScreenAction() { 800 801 putValue(SMALL_ICON, 802 new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" + 803 "wizard/images/Unhost16.gif"))); 804 putValue(SHORT_DESCRIPTION, "Normal Screen"); 805 putValue(LONG_DESCRIPTION, "Back to normal screen"); 806 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('N', 807 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); 808 putValue(MNEMONIC_KEY, new Integer ('N')); 809 } 810 811 815 public void actionPerformed(ActionEvent e) { 816 main.setDividerLocation(510); 817 } 818 } 819 820 private class SaveTraceAction 821 extends AbstractAction { 822 823 826 public SaveTraceAction() { 827 828 putValue(SMALL_ICON, 829 new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" + 830 "wizard/images/Save16.gif"))); 831 putValue(SHORT_DESCRIPTION, "Save Trace"); 832 putValue(LONG_DESCRIPTION, "Save Trace to file"); 833 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('S', 834 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); 835 putValue(MNEMONIC_KEY, new Integer ('S')); 836 } 837 838 842 public void actionPerformed(ActionEvent e) { 843 JFileChooser fc = new JFileChooser(); 844 fc.setDialogTitle("Save Octopus log ..."); 845 int returnVal = fc.showSaveDialog(null); 846 if(returnVal == JFileChooser.APPROVE_OPTION) { 847 File file = fc.getSelectedFile(); 848 String text = traceArea.getText(); 849 try { 850 Writer out = new BufferedWriter(new FileWriter(file, false)); 851 out.write(text); 852 out.close(); 853 } 854 catch(Exception ex) { 855 ex.printStackTrace(); 856 } 857 858 } else { 859 } 861 } 862 } 863 864 private class ClearTraceAction 865 extends AbstractAction { 866 867 870 public ClearTraceAction() { 871 872 putValue(SMALL_ICON, 873 new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" + 874 "wizard/images/Delete16.gif"))); 875 putValue(SHORT_DESCRIPTION, "Clear Trace"); 876 putValue(LONG_DESCRIPTION, "Clear Trace"); 877 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('L', 878 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); 879 putValue(MNEMONIC_KEY, new Integer ('L')); 880 } 881 882 886 public void actionPerformed(ActionEvent e) { 887 traceArea.setText(""); 888 } 889 } 890 891 private class BrowseAction_GO 892 extends AbstractAction { 893 894 897 public BrowseAction_GO() { 898 putValue(SMALL_ICON, 899 new ImageIcon(getClass().getClassLoader(). 900 getResource("org/webdocwf/util/loader/" + 901 "wizard/images/Open16.gif"))); 902 putValue(SHORT_DESCRIPTION, "Browse for Generator output directory"); 903 putValue(LONG_DESCRIPTION, "Browse for Generator output directory"); 904 putValue(MNEMONIC_KEY, new Integer ('B')); 905 } 906 907 911 public void actionPerformed(ActionEvent e) { 912 JFileChooser chooser = null; 913 File choice = null; 914 File current = new File(System.getProperty("user.dir")); 915 chooser = new JFileChooser(current); 916 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); 917 chooser.setFileFilter((javax.swing.filechooser.FileFilter )new DirectoryFilter()); 918 chooser.setDialogTitle("Select Generator Output Directory"); 919 chooser.setApproveButtonText("OK"); 920 String strFieldText = ""; 921 922 chooser.setCurrentDirectory(new File(strFieldText)); 923 int v = chooser.showOpenDialog(desktop); 924 desktop.requestFocus(); 925 926 switch(v) { 927 case JFileChooser.APPROVE_OPTION: 928 if(chooser.getSelectedFile() != null) { 929 if(chooser.getSelectedFile().exists()) { 930 choice = chooser.getSelectedFile(); 931 } else { 932 File parentFile = new File(chooser.getSelectedFile().getParent()); 933 choice = parentFile; 934 } 935 generatorOutput.setText(choice.getPath()); 936 } 937 break; 938 939 case JFileChooser.CANCEL_OPTION: 940 case JFileChooser.ERROR_OPTION: 941 942 } 943 } 944 } 945 946 private class BrowseAction_AC 948 extends AbstractAction { 949 950 953 public BrowseAction_AC() { 954 putValue(SMALL_ICON, 955 new ImageIcon(getClass().getClassLoader(). 956 getResource("org/webdocwf/util/loader/" + 957 "wizard/images/Open16.gif"))); 958 putValue(SHORT_DESCRIPTION, "Add .jar files"); 959 putValue(LONG_DESCRIPTION, "Add .jar (jdbc) files to system classpath"); 960 putValue(MNEMONIC_KEY, new Integer ('B')); 961 } 962 963 967 public void actionPerformed(ActionEvent e) { 968 JFileChooser chooser = null; 969 File choice = null; 970 File current = new File(System.getProperty("user.dir")); 971 chooser = new JFileChooser(current); 972 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); 973 chooser.setFileFilter((javax.swing.filechooser.FileFilter )new JarFilter()); 974 chooser.setDialogTitle("Select .jar file"); 975 chooser.setAcceptAllFileFilterUsed(false); 976 String strFieldText = addPaths.getText(); 977 978 if(!strFieldText.equalsIgnoreCase("")) 979 strFieldText = strFieldText + ";"; 980 981 chooser.setCurrentDirectory(new File(strFieldText)); 982 chooser.setApproveButtonText("OK"); 983 int v = chooser.showOpenDialog(desktop); 984 985 desktop.requestFocus(); 986 switch(v) { 987 case JFileChooser.APPROVE_OPTION: 988 if(chooser.getSelectedFile() != null) { 989 if(chooser.getSelectedFile().exists()) { 990 choice = chooser.getSelectedFile(); 991 } else { 992 File parentFile = new File(chooser.getSelectedFile().getParent()); 993 choice = parentFile; 994 } 995 addPaths.setText(strFieldText + choice.getPath()); 996 } 997 break; 998 999 case JFileChooser.CANCEL_OPTION: 1000 case JFileChooser.ERROR_OPTION: 1001 1002 chooser.removeAll(); 1003 chooser = null; 1004 current = null; 1005 1006 } 1007 } 1008 } 1009 1010 private class StartOctopusGenerator 1011 extends AbstractAction { 1012 1013 1016 public StartOctopusGenerator() { 1017 1018 putValue(NAME, "Start"); 1019 putValue(SMALL_ICON, 1020 new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" + 1021 "wizard/images/Play16.gif"))); 1022 putValue(SHORT_DESCRIPTION, "Start the OctopusGenerator application"); 1023 putValue(LONG_DESCRIPTION, "Start the OctopusGenerator application"); 1024 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('R', 1025 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); 1026 putValue(MNEMONIC_KEY, new Integer ('R')); 1027 } 1028 1029 1033 public void actionPerformed(ActionEvent e) { 1034 OctopusGeneratorData initData = null; 1035 String errorMsg = null; 1036 main.setDividerLocation(520); 1037 try { 1038 initData = getOctopusGeneratorInit(); 1039 traceArea.setText(""); 1040 OctopusGeneratorThread runGenerator = new OctopusGeneratorThread(desktop, 1041 initData, errorMsg, traceArea); 1042 runGenerator.start(); 1043 } 1044 catch(Exception ex) { 1045 errorMsg = ex.getMessage(); 1046 } 1047 } 1048 } 1049 1050 private class StopOctopusGenerator 1051 extends AbstractAction { 1052 1053 1056 public StopOctopusGenerator() { 1057 1058 putValue(NAME, "Close"); 1059 putValue(SMALL_ICON, 1060 new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" + 1061 "wizard/images/Stop16.gif"))); 1062 putValue(SHORT_DESCRIPTION, "Stop the OctopusGenerator application"); 1063 putValue(LONG_DESCRIPTION, "Stop the OctopusGenerator application"); 1064 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('T', 1065 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); 1066 putValue(MNEMONIC_KEY, new Integer ('T')); 1067 } 1068 1069 1073 public void actionPerformed(ActionEvent e) { 1074 dispose(); 1075 1076 } 1077 } 1078 1079 private class OctopusHelpAction 1080 extends AbstractAction { 1081 1082 1085 public OctopusHelpAction() { 1086 putValue(NAME, "Help"); 1087 putValue(SMALL_ICON, 1088 new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" + 1089 "wizard/images/Help16.gif"))); 1090 putValue(SHORT_DESCRIPTION, "Help for running the program"); 1091 putValue(LONG_DESCRIPTION, "Help for running the program"); 1092 putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke('H', 1093 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask())); 1094 putValue(MNEMONIC_KEY, new Integer ('H')); 1095 } 1096 1097 1101 public void actionPerformed(ActionEvent e) { 1102 try { 1103 OctopusGeneratorHelpFrame helpFrame = new OctopusGeneratorHelpFrame(); 1104 helpFrame.setIconImage(new ImageIcon(getClass().getClassLoader().getResource( 1105 "org/webdocwf/util/loader/" + 1106 "wizard/images/Enhydra16.gif")).getImage()); 1107 helpFrame.setVisible(true); 1108 } 1109 catch(Exception ex) { 1110 String message = ex.getMessage(); 1111 String message2 = "Check the OCTOPUS_HOME variable!"; 1112 JOptionPane error = new JOptionPane(); 1113 error.showMessageDialog(desktop, message + "\n" + message2, "Error", 0); 1114 error.setVisible(true); 1115 System.exit(0); 1116 } 1117 } 1118 } 1119 1120 private class StartOctopusLoader 1121 extends AbstractAction { 1122 1123 1126 public StartOctopusLoader() { 1127 1128 putValue(NAME, "Loader"); 1129 putValue(SMALL_ICON, 1130 new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/" + 1131 "wizard/images/Goto16.gif"))); 1132 putValue(SHORT_DESCRIPTION, "Start the OctopusLoader application"); 1133 putValue(LONG_DESCRIPTION, "Start the OctopusLoader application"); 1134 } 1138 1139 1143 public void actionPerformed(ActionEvent e) { 1144 OctopusLoaderFrame octopusLoader = new OctopusLoaderFrame(desktop); 1145 setDefaultCloseOperation(DISPOSE_ON_CLOSE); 1146 String confJarStructure = ""; 1147 try { 1148 octopusLoader.setOctopusLoaderInit(new OctopusLoaderData(), null, confJarStructure); 1149 desktop.add(octopusLoader); 1150 octopusLoader.setVisible(true); 1151 } 1152 catch(Exception ex) { 1153 String message = ex.getMessage(); 1154 String message2 = "Check the OCTOPUS_HOME variable!"; 1155 JOptionPane error = new JOptionPane(); 1156 error.showMessageDialog(desktop, message + "\n" + message2, "Error", 0); 1157 error.setVisible(true); 1158 System.exit(0); 1159 } 1160 dispose(); 1162 } 1163 } 1164 1165 private class BrowseAction_DOML extends AbstractAction{ 1167 1168 1171 public BrowseAction_DOML() { 1172 putValue(SMALL_ICON, 1174 new ImageIcon(getClass().getClassLoader(). 1175 getResource("org/webdocwf/util/loader/" + 1176 "wizard/images/Open16.gif"))); 1177 putValue(SHORT_DESCRIPTION, "Browse for .doml file"); 1178 putValue(LONG_DESCRIPTION, "Browse for .doml file"); 1179 putValue(MNEMONIC_KEY, new Integer ('B')); 1180 } 1181 1182 1186 public void actionPerformed(ActionEvent e) { 1187 JFileChooser chooser = null; 1188 File choice = null; 1189 File current=new File(System.getProperty("user.dir")); 1190 chooser = new JFileChooser(current); 1191 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES); 1192 chooser.setFileFilter( (javax.swing.filechooser.FileFilter )new DomlFilter()); 1193 chooser.setDialogTitle("Select .doml file"); 1194 chooser.setAcceptAllFileFilterUsed(false); 1195 String strFieldText = ""; 1196 1197 chooser.setCurrentDirectory(new File(strFieldText)); 1198 chooser.setApproveButtonText("OK"); 1199 int v = chooser.showOpenDialog(desktop); 1200 1201 desktop.requestFocus(); 1202 switch (v) { 1203 case JFileChooser.APPROVE_OPTION: 1204 if (chooser.getSelectedFile() != null) { 1205 if (chooser.getSelectedFile().exists()) { 1206 choice = chooser.getSelectedFile(); 1207 } 1208 else { 1209 File parentFile = new File(chooser.getSelectedFile().getParent()); 1210 choice = parentFile; 1211 } 1212 setField(DOML_PATH, choice.getPath(), "label"); 1213 } 1214 break; 1215 1216 case JFileChooser.CANCEL_OPTION: 1217 case JFileChooser.ERROR_OPTION: 1218 1219 chooser.removeAll(); 1220 chooser = null; 1221 1222 } 1223 } 1224 } 1225 1226 1227 1228} 1229 | Popular Tags |