1 package org/webdocwf/util/loader/wizard/package-summary.html">> org.webdocwf.util.loader.wizard;
2
3 import java.awt.Dimension;
4 import java.awt.Toolkit;
5 import java.awt.event.ActionEvent;
6 import java.awt.event.ActionListener;
7 import java.io.BufferedWriter;
8 import java.io.File;
9 import java.io.FileWriter;
10 import java.io.Writer;
11 import java.util.HashMap;
12
13 import javax.swing.AbstractAction;
14 import javax.swing.BorderFactory;
15 import javax.swing.Box;
16 import javax.swing.BoxLayout;
17 import javax.swing.ImageIcon;
18 import javax.swing.JButton;
19 import javax.swing.JCheckBox;
20 import javax.swing.JComboBox;
21 import javax.swing.JComponent;
22 import javax.swing.JFileChooser;
23 import javax.swing.JLabel;
24 import javax.swing.JPanel;
25 import javax.swing.JRadioButton;
26 import javax.swing.JScrollPane;
27 import javax.swing.JSplitPane;
28 import javax.swing.JTabbedPane;
29 import javax.swing.JTextArea;
30 import javax.swing.JTextField;
31 import javax.swing.KeyStroke;
32 import javax.swing.ScrollPaneConstants;
33 import javax.swing.SwingConstants;
34 import javax.swing.border.Border;
35 import javax.swing.border.EtchedBorder;
36
37 public class OctopusGeneratorPanel extends JPanel {
38
39 private static final String SOURCE_TYPE = "Source database type",
40 TARGET_TYPE = "Target database type",
41 SOURCE_DATABASE = "Source database URL",
42 TARGET_DATABASE = "Target database URL",
43 SOURCE_USER = "Source database user",
44 SOURCE_PASSWORD = "Source database password",
45 TARGET_USER = "Target database user",
46 TARGET_PASSWORD = "Target database password",
47 VALUE_MODE = "Value mode",
48 GENERATOR_OUTPUT = "Generator output directory",
49 DOML_PATH = "Doml URL( when use Doml as input )",
50 PACKAGE_NAME = "Package name",
51 SOURCE_DRIVER_NAME = "Source database driver name",
52 TARGET_DRIVER_NAME = "Target database driver name",
53 ADDITIONAL_PATHS = "Additional classpath",
54 DROP_TABLE = "Drop Tables",
55 CREATE_TABLE = "Create Tables",
56 CREATE_PRIMARY_KEYS = "Create Primary Keys",
57 DROP_FOREIGN_KEYS = "Drop Foreign Keys",
58 CREATE_FOREIGN_KEYS = "Create Foreign Keys",
59 CREATE_INDEXES = "Create Indexes",
60 CREATE_SQL_FOR_ALL_VENDORS = "Create SQL Statements for All Vendors",
61 GENERATE_DOML = "Generate Doml file",
62 GENERATE_XML = "Generate Xml files",
63 GENERATE_SQL = "Generate Sql files",
64 OPTIMIZED_MODE = "Optimized mode for all tables",
65 FULL_MODE = "Full mode for all tables",
66 INCLUDE_TABLE_LIST = "Include Table List (e.g. table1;table2)",
67 PATH_TO_CONF_IN_JAR = "Path to conf files in jar",
68 LOG_MODE = "Log mode",
69 LOG_FILE_NAME ="Log file name",
70 LOG_FILE_DIRECTORY = "Log file directory";
71
72 //dimensions
73 public static Dimension bigButton = new Dimension(140, 25);
74 public static Dimension toolBarButton = new Dimension(30, 30);
75 public static Dimension smallComponent = new Dimension(150, 20);
76 public static Dimension bigComponent = new Dimension(400, 20);
77 public static Dimension bigPlusButton = new Dimension(380, 20);
78 public static Dimension veryBigComponent = new Dimension(650, 20);
79 public static Dimension veryBigPlusButton = new Dimension(630, 20);
80 public static Dimension panelComponenet = new Dimension(720, 40);
81
82 JSplitPane main;
83
84 Border loweredBorder = BorderFactory.createEtchedBorder(EtchedBorder.LOWERED);
85 Border raisedBorder = BorderFactory.createEtchedBorder(EtchedBorder.RAISED);
86 Border bevelBorder = BorderFactory.createLoweredBevelBorder();
87
88 private JCheckBox sqlFiles,
89 xmlFiles,
90 domlFile,
91 createTables,
92 createPK,
93 createFK,
94 createIn,
95 dropTables,
96 createSQLForAll,
97 dropFK;
98 private JRadioButton optimizedMode, fullMode;
99 privateb> JTextField packageField, generatorOutput, addPaths;
100 // private OctopusProjectFrame parent;
101 private OctopusGeneratorData initData;
102 private HashMap fields;
103 private JTextArea traceArea;
104
105 public OctopusGeneratorPanel() {
106 // super("TDT Generator Application", true, true, true, true);
107 // setFrameIcon( new ImageIcon(getClass().getClassLoader().getResource("org/webdocwf/util/loader/"+
108 // "wizard/images/Enhydra16.gif")));
109
110 // this.parent = parent;
111 fields = new HashMap();
112 //generatorOptions
113 // JPanel generatorOptionsUp = new JPanel();
114 // JPanel generatorOptionsDown = new JPanel();
115
116 //generator input data
117 JTabbedPane octopusGeneratorData = new JTabbedPane();
118 JPanel commonPanel = new JPanel();
119 JPanel advancedPanel = new JPanel();
120 JPanel outputOptions = new JPanel();
121 octopusGeneratorData.addTab("JDBC", commonPanel);
122 octopusGeneratorData.addTab("Output options", outputOptions);
123 octopusGeneratorData.addTab("Advanced", advancedPanel);
124
125 //generatotOptionsUp panel
126 // generatorOptionsUp.setLayout(new BoxLayout(generatorOptionsUp, BoxLayout.Y_AXIS));
127 // generatorOptionsUp.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
128 // JButton help = createOctopusButton("Help", bigButton);
129 // help.setAction(new OctopusHelpAction());
130 // generatorOptionsUp.add(help);
131
132 //generatotOptionsDown panel
133 // generatorOptionsDown.setLayout(new BoxLayout(generatorOptionsDown, BoxLayout.Y_AXIS));
134 // generatorOptionsDown.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
135 // JButton start = createOctopusButton("Start", bigButton);
136 // start.setAction(new StartOctopusGenerator());
137 // JButton stop = createOctopusButton("Stop", bigButton);
138 // stop.setAction(new StopOctopusGenerator());
139 // JButton save = createOctopusButton("Save", bigButton);
140 // save.setAction(new SaveProjectAction());
141 // generatorOptionsDown.add(Box.createRigidArea(new Dimension(0, 5)));
142 // generatorOptionsDown.add(start);
143 // generatorOptionsDown.add(Box.createRigidArea(new Dimension(0, 5)));
144 // generatorOptionsDown.add(stop);
145 // generatorOptionsDown.add(Box.createRigidArea(new Dimension(0, 5)));
146 // generatorOptionsDown.add(save);
147 // generatorOptionsDown.add(Box.createRigidArea(new Dimension(0, 15)));
148 // generatorOptionsDown.add(help);
149
150 //generatorOptions
151 // JSplitPane generatorOptions = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true,
152 // generatorOptionsUp, generatorOptionsDown);
153 // generatorOptions.setOneTouchExpandable(true);
154 // generatorOptions.setDividerLocation(560);
155
156 // JSplitPane generatorInputData = new JSplitPane(JSplitPane.HORIZONTAL_SPLIT, true,
157 // generatorOptions, octopusGeneratorData);
158 // JSplitPane generatorInputData =
159 // new JSplitPane(
160 // JSplitPane.HORIZONTAL_SPLIT,
161 // true,
162 // new JPanel(),
163 // octopusGeneratorData);
164
165 //advanced panel
166 JPanel pathToConfPanel = new JPanel();
167 pathToConfPanel.setLayout(new BoxLayout(pathToConfPanel, BoxLayout.X_AXIS));
168 pathToConfPanel.setBorder(setTitleOfBorder("Advanced Options", loweredBorder));
169 JLabel strPathToConf = OctopusProjectFrame.createOctopusLabel(PATH_TO_CONF_IN_JAR, smallComponent);
170 JTextField pathToConf = OctopusProjectFrame.createOctopusTextField(PATH_TO_CONF_IN_JAR, veryBigComponent);
171 pathToConfPanel.add(strPathToConf);
172 pathToConfPanel.add(pathToConf);
173
174 JPanel mainPathToConfPanel = new JPanel();
175 mainPathToConfPanel.setLayout(new BoxLayout(mainPathToConfPanel, BoxLayout.X_AXIS));
176 mainPathToConfPanel.add(pathToConfPanel);
177 mainPathToConfPanel.add(Box.createHorizontalGlue());
178
179 advancedPanel.setLayout(new BoxLayout(advancedPanel, BoxLayout.Y_AXIS));
180 advancedPanel.add(Box.createRigidArea(new Dimension(0, 15)));
181 advancedPanel.add(mainPathToConfPanel);
182
183 //sourcePanel
184 JPanel sourcePanel = new JPanel();
185 sourcePanel.setLayout(new BoxLayout(sourcePanel, BoxLayout.Y_AXIS));
186 //sourceType
187 JLabel strSourceType = OctopusProjectFrame.createOctopusLabel(SOURCE_TYPE, bigComponent);
188 JComboBox sourceType = OctopusProjectFrame.createOctopusCombobox(SOURCE_TYPE, bigComponent);
189 //sourceUrl
190 JLabel strSourceUrl = OctopusProjectFrame.createOctopusLabel(SOURCE_DATABASE, bigComponent);
191 JTextField sourceUrl = OctopusProjectFrame.createOctopusTextField(SOURCE_DATABASE, bigComponent);
192 //sourceDriverName
193 JLabel strSourceDriverName = OctopusProjectFrame.createOctopusLabel(SOURCE_DRIVER_NAME, bigComponent);
194 JComboBox sourceDriverName = OctopusProjectFrame.createOctopusCombobox(SOURCE_DRIVER_NAME, bigComponent);
195 //sourceUser
196 JLabel strSourceUser = OctopusProjectFrame.createOctopusLabel(SOURCE_USER, bigComponent);
197 JTextField sourceUser = OctopusProjectFrame.createOctopusTextField(SOURCE_USER, bigComponent);
198 //sourcePassword
199 JLabel strSourcePassword = OctopusProjectFrame.createOctopusLabel(SOURCE_PASSWORD, bigComponent);
200 JTextField sourcePassword = OctopusProjectFrame.createOctopusTextField(SOURCE_PASSWORD, bigComponent);
201 //doml
202 JLabel strDomlUrl = OctopusProjectFrame.createOctopusLabel(DOML_PATH, bigComponent);
203 JTextField domlUrl = OctopusProjectFrame.createOctopusTextField(DOML_PATH, bigPlusButton);
204 JButton domlButton = OctopusProjectFrame.createOctopusButton("doml url button", new Dimension(20, 20));
205 domlButton.setAction(new BrowseAction_DOML());
206
207 ImageIcon icon =
208 new ImageIcon(
209 getClass().getClassLoader().getResource(
210 "org/webdocwf/util/loader/" + "wizard/images/database.gif"));
211 JLabel sourceLabel = new JLabel("JDBC Source Database", icon, SwingConstants.RIGHT);
212
213 sourcePanel.add(createJDBCRow(sourceLabel, null));
214 sourcePanel.add(Box.createRigidArea(new Dimension(0, 10)));
215 sourcePanel.add(createJDBCRow(strSourceType, null));
216 sourcePanel.add(createJDBCRow(sourceType, null));
217 sourcePanel.add(createJDBCRow(strSourceUrl, null));
218 sourcePanel.add(createJDBCRow(sourceUrl, null));
219 sourcePanel.add(createJDBCRow(strDomlUrl, null));
220 sourcePanel.add(createJDBCRow(domlUrl, domlButton));
221 sourcePanel.add(createJDBCRow(strSourceDriverName, null));
222 sourcePanel.add(createJDBCRow(sourceDriverName, null));
223 sourcePanel.add(createJDBCRow(strSourceUser, null));
224 sourcePanel.add(createJDBCRow(sourceUser, null));
225 sourcePanel.add(createJDBCRow(strSourcePassword, null));
226 sourcePanel.add(createJDBCRow(sourcePassword, null));
227
228 sourcePanel.setBorder(setTitleOfBorder("", bevelBorder));
229
230 //targetPanel
231 JPanel targetPanel = new JPanel();
232 targetPanel.setLayout(new BoxLayout(targetPanel, BoxLayout.Y_AXIS));
233 //targetType
234 JLabel strTargetType = OctopusProjectFrame.createOctopusLabel(TARGET_TYPE, bigComponent);
235 JComboBox targetType = OctopusProjectFrame.createOctopusCombobox(TARGET_TYPE, bigComponent);
236 //targetUrl
237 JLabel strTargetUrl =OctopusProjectFrame.createOctopusLabel(TARGET_DATABASE, bigComponent);
238 JTextField targetUrl = OctopusProjectFrame.createOctopusTextField(TARGET_DATABASE, bigComponent);
239 //targetDriverName
240 JLabel strTargetDriverName = OctopusProjectFrame.createOctopusLabel(TARGET_DRIVER_NAME, bigComponent);
241 JComboBox targetDriverName = OctopusProjectFrame.createOctopusCombobox(TARGET_DRIVER_NAME, bigComponent);
242 //targetUser
243 JLabel strTargetUser = OctopusProjectFrame.createOctopusLabel(TARGET_USER, bigComponent);
244 JTextField targetUser = OctopusProjectFrame.createOctopusTextField(TARGET_USER, bigComponent);
245 //targetPassword
246 JLabel strTargetPassword = OctopusProjectFrame.createOctopusLabel(TARGET_PASSWORD, bigComponent);
247 JTextField targetPassword = OctopusProjectFrame.createOctopusTextField(TARGET_PASSWORD, bigComponent);
248
249 JLabel strTargetDoml = OctopusProjectFrame.createOctopusLabel("Doml URL", bigComponent);
250 String msg = "Doml file will be placed in output directory";
251 JTextField targetDoml = OctopusProjectFrame.createOctopusTextField("Doml URL target", bigComponent);
252 targetDoml.setText(msg);
253 targetDoml.setEditable(false);
254
255 ImageIcon icon2 =
256 new ImageIcon(
257 getClass().getClassLoader().getResource(
258 "org/webdocwf/util/loader/" + "wizard/images/database2.gif"));
259 JLabel targetLabel = new JLabel("JDBC Target Database", icon2, SwingConstants.RIGHT);
260
261 targetPanel.add(createJDBCRow(targetLabel, null));
262 targetPanel.add(Box.createRigidArea(new Dimension(0, 10)));
263 targetPanel.add(createJDBCRow(strTargetType, null));
264 targetPanel.add(createJDBCRow(targetType, null));
265 targetPanel.add(createJDBCRow(strTargetUrl, null));
266 targetPanel.add(createJDBCRow(targetUrl, null));
267 targetPanel.add(createJDBCRow(strTargetDoml, null));
268 targetPanel.add(createJDBCRow(targetDoml, null));
269 targetPanel.add(createJDBCRow(strTargetDriverName, null));
270 targetPanel.add(createJDBCRow(targetDriverName, null));
271 targetPanel.add(createJDBCRow(strTargetUser, null));
272 targetPanel.add(createJDBCRow(targetUser, null));
273 targetPanel.add(createJDBCRow(strTargetPassword, null));
274 targetPanel.add(createJDBCRow(targetPassword, null));
275
276 targetPanel.setBorder(setTitleOfBorder("", bevelBorder));
277
278 JPanel JDBCPanel = new JPanel();
279 JDBCPanel.setLayout(new BoxLayout(JDBCPanel, BoxLayout.X_AXIS));
280 JDBCPanel.add(sourcePanel);
281 JDBCPanel.add(targetPanel);
282
283 JPanel JDBCMainPanel = new JPanel();
284 JDBCMainPanel.setLayout(new BoxLayout(JDBCMainPanel, BoxLayout.X_AXIS));
285 JDBCMainPanel.add(JDBCPanel);
286 JDBCMainPanel.add(Box.createHorizontalGlue());
287
288 //value mode panel
289 JPanel valuModePanel = new JPanel();
290 valuModePanel.setLayout(new BoxLayout(valuModePanel, BoxLayout.X_AXIS));
291 valuModePanel.setBorder(setTitleOfBorder("Value mode", loweredBorder));
292 JLabel strValueMode = OctopusProjectFrame.createOctopusLabel(VALUE_MODE, smallComponent);
293 JComboBox valueMode = OctopusProjectFrame.createOctopusCombobox(VALUE_MODE, veryBigComponent);
294 valuModePanel.add(strValueMode);
295 valuModePanel.add(valueMode);
296
297 JPanel mainValueModePanel = new JPanel();
298 mainValueModePanel.setLayout(new BoxLayout(mainValueModePanel, BoxLayout.X_AXIS));
299 mainValueModePanel.add(valuModePanel);
300 mainValueModePanel.add(Box.createHorizontalGlue());
301
302 //generatorOutput panel
303 JPanel generatorOutputPanel = new JPanel();
304 generatorOutputPanel.setLayout(new BoxLayout(generatorOutputPanel, BoxLayout.X_AXIS));
305 JPanel generatorOutputInnerPanel = new JPanel();
306 JButton browseGeneratorOutput = OctopusProjectFrame.createOctopusButton("O", new Dimension(20, 20));
307 browseGeneratorOutput.setAction(new BrowseAction_GO());
308
309 generatorOutputInnerPanel.setLayout(
310 new BoxLayout(generatorOutputInnerPanel, BoxLayout.X_AXIS));
311 generatorOutputInnerPanel.setBorder(
312 setTitleOfBorder("Generator Output", loweredBorder));
313 JLabel strGeneratorOutput = OctopusProjectFrame.createOctopusLabel(GENERATOR_OUTPUT, smallComponent);
314 generatorOutput = OctopusProjectFrame.createOctopusTextField(GENERATOR_OUTPUT, veryBigPlusButton);
315 generatorOutputInnerPanel.add(strGeneratorOutput);
316 generatorOutputInnerPanel.add(generatorOutput);
317 generatorOutputInnerPanel.add(browseGeneratorOutput);
318
319 generatorOutputPanel.add(generatorOutputInnerPanel);
320 generatorOutputPanel.add(Box.createHorizontalGlue());
321
322 //includetablelist panel
323 JPanel includeTableListPanel = new JPanel();
324 includeTableListPanel.setLayout(new BoxLayout(includeTableListPanel, BoxLayout.X_AXIS));
325 JPanel includeTableListInnerPanel = new JPanel();
326 includeTableListInnerPanel.setLayout(
327 new BoxLayout(includeTableListInnerPanel, BoxLayout.X_AXIS));
328 includeTableListInnerPanel.setBorder(setTitleOfBorder("Tables List", loweredBorder));
329 JLabel strIncludeTableList = OctopusProjectFrame.createOctopusLabel(INCLUDE_TABLE_LIST, smallComponent);
330 JTextField includeTableList =
331 OctopusProjectFrame.createOctopusTextField(INCLUDE_TABLE_LIST, veryBigComponent);
332 includeTableListInnerPanel.add(strIncludeTableList);
333 includeTableListInnerPanel.add(includeTableList);
334
335 includeTableListPanel.add(includeTableListInnerPanel);
336 includeTableListPanel.add(Box.createHorizontalGlue());
337
338 //additinal classpaths panel
339 JPanel addPathsPanel = new JPanel();
340 addPathsPanel.setLayout(new BoxLayout(addPathsPanel, BoxLayout.X_AXIS));
341 JPanel addPathsInnerPanel = new JPanel();
342 JButton browseAdditionalClass = OctopusProjectFrame.createOctopusButton("O", new Dimension(20, 20));
343 browseAdditionalClass.setAction(new BrowseAction_AC());
344 addPathsInnerPanel.setLayout(new BoxLayout(addPathsInnerPanel, BoxLayout.X_AXIS));
345 addPathsInnerPanel.setBorder(setTitleOfBorder("Add new drivers", loweredBorder));
346 JLabel strAddPaths = OctopusProjectFrame.createOctopusLabel(ADDITIONAL_PATHS, smallComponent);
347 addPaths = OctopusProjectFrame.createOctopusTextField(ADDITIONAL_PATHS, veryBigPlusButton);
348 addPathsInnerPanel.add(strAddPaths);
349 addPathsInnerPanel.add(addPaths);
350 addPathsInnerPanel.add(browseAdditionalClass);
351
352 addPathsPanel.add(addPathsInnerPanel);
353 addPathsPanel.add(Box.createHorizontalGlue());
354
355 JPanel commonOptionsPanel = new JPanel();
356 JPanel commonOptionsMainPanel = new JPanel();
357 commonOptionsPanel.setLayout(new BoxLayout(commonOptionsPanel, BoxLayout.Y_AXIS));
358 commonOptionsMainPanel.setLayout(
359 new BoxLayout(commonOptionsMainPanel, BoxLayout.X_AXIS));
360 commonOptionsPanel.add(mainValueModePanel);
361 commonOptionsPanel.add(generatorOutputPanel);
362 commonOptionsPanel.add(includeTableListPanel);
363 commonOptionsPanel.add(addPathsPanel);
364
365 commonOptionsMainPanel.add(commonOptionsPanel);
366 commonOptionsMainPanel.add(Box.createHorizontalGlue());
367
368 commonPanel.setLayout(new BoxLayout(commonPanel, BoxLayout.Y_AXIS));
369 commonPanel.add(JDBCMainPanel);
370 commonPanel.add(commonOptionsMainPanel);
371 commonPanel.add(Box.createVerticalGlue());
372
373 JPanel outputMode = new JPanel();
374 outputMode.setLayout(new BoxLayout(outputMode, BoxLayout.X_AXIS));
375 outputMode.setBorder(setTitleOfBorder("Output Mode", loweredBorder));
376 sqlFiles = new JCheckBox(GENERATE_SQL);
377 sqlFiles.setSelected(true);
378 xmlFiles = new JCheckBox(GENERATE_XML);
379 xmlFiles.setSelected(true);
380 domlFile = new JCheckBox(GENERATE_DOML);
381 outputMode.add(sqlFiles);
382 outputMode.add(xmlFiles);
383 outputMode.add(domlFile);
384
385 sqlFiles.addActionListener(new ActionListener() {
386 public void actionPerformed(ActionEvent e) {
387 if (sqlFiles.isSelected()) {
388 createTables.setEnabled(true);
389 createTables.setSelected(true);
390 dropTables.setEnabled(true);
391 dropTables.setSelected(true);
392 createPK.setEnabled(true);
393 createPK.setSelected(true);
394 createFK.setEnabled(true);
395 createFK.setSelected(true);
396 dropFK.setEnabled(true);
397 dropFK.setSelected(true);
398 createIn.setEnabled(true);
399 createIn.setSelected(true);
400 createSQLForAll.setEnabled(true);
401 createSQLForAll.setSelected(false);
402 } else {
403 createTables.setSelected(false);
404 createTables.setEnabled(false);
405 dropTables.setEnabled(false);
406 dropTables.setSelected(false);
407 createPK.setEnabled(false);
408 createPK.setSelected(false);
409 createFK.setEnabled(false);
410 createFK.setSelected(false);
411 dropFK.setEnabled(false);
412 dropFK.setSelected(false);
413 createIn.setEnabled(false);
414 createIn.setSelected(false);
415 createSQLForAll.setEnabled(false);
416 createSQLForAll.setSelected(false);
417 }
418 }
419 });
420
421 xmlFiles.addActionListener(new ActionListener() {
422 public void actionPerformed(ActionEvent e) {
423 if (xmlFiles.isSelected()) {
424 optimizedMode.setEnabled(true);
425 optimizedMode.setSelected(false);
426 fullMode.setEnabled(true);
427 fullMode.setSelected(true);
428 } else {
429 optimizedMode.setEnabled(false);
430 optimizedMode.setSelected(false);
431 fullMode.setEnabled(false);
432 fullMode.setSelected(false);
433 }
434 }
435 });
436
437 domlFile.addActionListener(new ActionListener() {
438 public void actionPerformed(ActionEvent e) {
439 if (domlFile.isSelected()) {
440 packageField.setEditable(true);
441 packageField.setText("");
442 } else {
443 packageField.setText("");
444 packageField.setEditable(false);
445
446 }
447 }
448 });
449
450 JPanel mainOutputMode = new JPanel();
451 mainOutputMode.setLayout(new BoxLayout(mainOutputMode, BoxLayout.X_AXIS));
452 mainOutputMode.add(outputMode);
453 mainOutputMode.add(Box.createHorizontalGlue());
454
455 createTables = new JCheckBox(CREATE_TABLE);
456 createTables.setSelected(true);
457 createPK = new JCheckBox(CREATE_PRIMARY_KEYS);
458 createPK.setSelected(true);
459 createFK = new JCheckBox(CREATE_FOREIGN_KEYS);
460 createFK.setSelected(true);
461 createIn = new JCheckBox(CREATE_INDEXES);
462 createIn.setSelected(true);
463 dropTables = new JCheckBox(DROP_TABLE);
464 dropTables.setSelected(true);
465 dropFK = new JCheckBox(DROP_FOREIGN_KEYS);
466 dropFK.setSelected(true);
467 createSQLForAll = new JCheckBox(CREATE_SQL_FOR_ALL_VENDORS);
468
469 JPanel sqlOptionsPanel1 = new JPanel();
470 sqlOptionsPanel1.setLayout(new BoxLayout(sqlOptionsPanel1, BoxLayout.Y_AXIS));
471 sqlOptionsPanel1.add(dropTables);
472 sqlOptionsPanel1.add(createTables);
473 sqlOptionsPanel1.add(createPK);
474
475 JPanel sqlOptionsPanel2 = new JPanel();
476 sqlOptionsPanel2.setLayout(new BoxLayout(sqlOptionsPanel2, BoxLayout.Y_AXIS));
477 sqlOptionsPanel2.add(dropFK);
478 sqlOptionsPanel2.add(createFK);
479 sqlOptionsPanel2.add(createIn);
480
481 JPanel sqlOptionsPanel3 = new JPanel();
482 sqlOptionsPanel3.setLayout(new BoxLayout(sqlOptionsPanel3, BoxLayout.Y_AXIS));
483 sqlOptionsPanel3.add(createSQLForAll);
484
485 JPanel sqlOptionsPanel = new JPanel();
486 sqlOptionsPanel.setLayout(new BoxLayout(sqlOptionsPanel, BoxLayout.X_AXIS));
487 sqlOptionsPanel.setBorder(setTitleOfBorder("SQL Options", loweredBorder));
488 sqlOptionsPanel.add(sqlOptionsPanel1);
489 sqlOptionsPanel.add(sqlOptionsPanel2);
490 sqlOptionsPanel.add(sqlOptionsPanel3);
491
492 JPanel mainSqlOptionsPanel = new JPanel();
493 mainSqlOptionsPanel.setLayout(new BoxLayout(mainSqlOptionsPanel, BoxLayout.X_AXIS));
494 mainSqlOptionsPanel.add(sqlOptionsPanel);
495 mainSqlOptionsPanel.add(Box.createHorizontalGlue());
496
497 JPanel xmlOptionsPanel = new JPanel();
498 xmlOptionsPanel.setLayout(new BoxLayout(xmlOptionsPanel, BoxLayout.X_AXIS));
499 optimizedMode = new JRadioButton(OPTIMIZED_MODE);
500 fullMode = new JRadioButton(FULL_MODE);
501 // fullMode.setSelected(true);
502
503 optimizedMode.addActionListener(new ActionListener() {
504 public void actionPerformed(ActionEvent e) {
505 if (optimizedMode.isSelected()) {
506 fullMode.setSelected(false);
507 } else {
508 fullMode.setSelected(true);
509 }
510 }
511 });
512
513 fullMode.addActionListener(new ActionListener() {
514 public void actionPerformed(ActionEvent e) {
515 if (fullMode.isSelected()) {
516 optimizedMode.setSelected(false);
517 } else {
518 optimizedMode.setSelected(true);
519 }
520 }
521 });
522
523 xmlOptionsPanel.setBorder(setTitleOfBorder("XML Options", loweredBorder));
524 xmlOptionsPanel.add(optimizedMode);
525 xmlOptionsPanel.add(fullMode);
526
527 JPanel mainXmlOptionsPanel = new JPanel();
528 mainXmlOptionsPanel.setLayout(new BoxLayout(mainXmlOptionsPanel, BoxLayout.X_AXIS));
529 mainXmlOptionsPanel.add(xmlOptionsPanel);
530 mainXmlOptionsPanel.add(Box.createHorizontalGlue());
531
532 JPanel packagePanel = new JPanel();
533 packagePanel.setLayout(new</b> BoxLayout(packagePanel, BoxLayout.X_AXIS));
534 packagePanel.setBorder(setTitleOfBorder("Package name for doml file", loweredBorder));
535 packageField = OctopusProjectFrame.createOctopusTextField(PACKAGE_NAME, veryBigComponent);
536 packageField.setEditable(false);
537 JLabel strPackageField = OctopusProjectFrame.createOctopusLabel(PACKAGE_NAME, smallComponent);
538 packagePanel.add(strPackageField);
539 packagePanel.add(packageField);
540
541 JPanel mainPackagePanel = new JPanel();
542 mainPackagePanel.setLayout(new BoxLayout(mainPackagePanel, BoxLayout.X_AXIS));
543 mainPackagePanel.add(packagePanel);
544 mainPackagePanel.add(Box.createHorizontalGlue());
545
546
547 //zk added this for logging
548 JPanel loggingModePanel = new JPanel();
549 loggingModePanel.setLayout(new BoxLayout(loggingModePanel, BoxLayout.X_AXIS));
550
551
552 //log mode
553 JLabel strLogMode = OctopusProjectFrame.createOctopusLabel(LOG_MODE, smallComponent);
554 JComboBox logMode = OctopusProjectFrame.createOctopusCombobox(LOG_MODE, veryBigComponent);
555
556 loggingModePanel.add(strLogMode);
557 loggingModePanel.add(logMode);
558 //loggingModePanel.add(Box.createHorizontalGlue());
559
560 //log file directory
561 JPanel loggingDirPanel = new JPanel();
562 loggingDirPanel.setLayout(new BoxLayout(loggingDirPanel, BoxLayout.X_AXIS));
563 JLabel strLogFileDir = OctopusProjectFrame.createOctopusLabel(LOG_FILE_DIRECTORY, smallComponent);
564 JTextField logFileDir = OctopusProjectFrame.createOctopusTextField(LOG_FILE_DIRECTORY, veryBigPlusButton);
565 JButton logDirButton = OctopusProjectFrame.createOctopusButton("", new Dimension(20, 20));
566
567 logDirButton.setAction(new BrowseAction_L());
568
569 loggingDirPanel.add(strLogFileDir);
570 loggingDirPanel.add(logFileDir);
571 loggingDirPanel.add(logDirButton);
572 //loggingDirPanel.add(Box.createHorizontalGlue());
573
574 //log file name
575 JPanel loggingFilePanel = new JPanel();
576 loggingFilePanel.setLayout(new BoxLayout(loggingFilePanel, BoxLayout.X_AXIS));
577 JLabel strLogFileName = OctopusProjectFrame.createOctopusLabel(LOG_FILE_NAME, smallComponent);
578 JTextField logFileName = OctopusProjectFrame.createOctopusTextField(LOG_FILE_NAME, veryBigComponent);
579
580 loggingFilePanel.add(strLogFileName);
581 loggingFilePanel.add(logFileName);
582 //loggingFilePanel.add(Box.createHorizontalGlue());
583
584
585 JPanel loggingPanel = new JPanel();
586 loggingPanel.setLayout(new BoxLayout(loggingPanel, BoxLayout.Y_AXIS));
587 loggingPanel.setBorder(setTitleOfBorder("Logging options", loweredBorder));
588 loggingPanel.add(loggingModePanel);
589 loggingPanel.add(loggingDirPanel);
590 loggingPanel.add(loggingFilePanel);
591 //loggingPanel.add(Box.createHorizontalGlue());
592
593 JPanel mainLoggingPanel = new JPanel();
594 mainLoggingPanel.setLayout(new BoxLayout(mainLoggingPanel, BoxLayout.X_AXIS));
595 mainLoggingPanel.add(loggingPanel);
596 //mainLoggingPanel.setAlignmentX(0);
597 mainLoggingPanel.add(Box.createHorizontalGlue());
598
599 //end
600
601
602
603 //output options panel
604 outputOptions.setLayout(new BoxLayout(outputOptions, BoxLayout.Y_AXIS));
605
606 outputOptions.add(Box.createRigidArea(new Dimension(0, 10)));
607 outputOptions.add(mainOutputMode);
608 outputOptions.add(Box.createRigidArea(new Dimension(0, 10)));
609 outputOptions.add(mainSqlOptionsPanel);
610 outputOptions.add(Box.createRigidArea(new Dimension(0, 10)));
611 outputOptions.add(mainXmlOptionsPanel);
612 outputOptions.add(Box.createRigidArea(new Dimension(0, 10)));
613 outputOptions.add(mainPackagePanel);
614 //zk added for logging
615 outputOptions.add(Box.createRigidArea(new Dimension(0, 10)));
616 outputOptions.add(mainLoggingPanel);
617
618 //
619
620
621 // output panel
622 JPanel textAreaPanel = new JPanel();
623 textAreaPanel.setLayout(new BoxLayout(textAreaPanel, BoxLayout.X_AXIS));
624 JPanel areaOptionPanel = new JPanel();
625 areaOptionPanel.setLayout(new BoxLayout(areaOptionPanel, BoxLayout.Y_AXIS));
626 traceArea = new JTextArea(18, 130);
627 traceArea.setLineWrap(true);
628 traceArea.setEditable(false);
629 traceArea.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.RAISED));
630 JScrollPane scrollPane =
631 new JScrollPane(
632 traceArea,
633 ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS,
634 ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
635
636 scrollPane.setBorder(
637 setTitleOfBorder("Log TDT Generator output ... ", loweredBorder));
638 JButton fullScreen = OctopusProjectFrame.createOctopusButton("Full Screen", new Dimension(25, 25));
639 fullScreen.setAction(new FullScreenAction());
640 JButton normalScreen = OctopusProjectFrame.createOctopusButton("Normal Screen", new Dimension(25, 25));
641 normalScreen.setAction(new NormalScreenAction());
642 JButton saveScreen = OctopusProjectFrame.createOctopusButton("Save Trace", new Dimension(25, 25));
643 saveScreen.setAction(new SaveTraceAction());
644 JButton clearTrace = OctopusProjectFrame.createOctopusButton("Clear Trace", new Dimension(25, 25));
645 clearTrace.setAction(new ClearTraceAction());
646
647 areaOptionPanel.add(fullScreen);
648 areaOptionPanel.add(normalScreen);
649 areaOptionPanel.add(saveScreen);
650 areaOptionPanel.add(clearTrace);
651 areaOptionPanel.add(Box.createVerticalGlue());
652 areaOptionPanel.setBorder(BorderFactory.createEtchedBorder(EtchedBorder.LOWERED));
653
654 // JPanel areaOptionMainPanel = new JPanel(new BorderLayout());
655 // areaOptionMainPanel.add(areaOptionPanel, BorderLayout.PAGE_START);
656
657 textAreaPanel.add(areaOptionPanel);
658 textAreaPanel.add(scrollPane);
659 // main =
660 // new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, generatorInputData, textAreaPanel);
661 main = new JSplitPane(JSplitPane.VERTICAL_SPLIT, true, octopusGeneratorData, textAreaPanel);
662 main.setOneTouchExpandable(true);
663 // main.setDividerLocation(650);
664
665 //setting all parameters into hash table
666 //source
667 fields.put(SOURCE_TYPE, sourceType);
668 fields.put(SOURCE_DATABASE, sourceUrl);
669 fields.put(DOML_PATH, domlUrl);
670 fields.put(SOURCE_DRIVER_NAME, sourceDriverName);
671 fields.put(SOURCE_USER, sourceUser);
672 fields.put(SOURCE_PASSWORD, sourcePassword);
673 //target
674 fields.put(TARGET_TYPE, targetType);
675 fields.put(TARGET_DATABASE, targetUrl);
676 fields.put(TARGET_DRIVER_NAME, targetDriverName);
677 fields.put(TARGET_USER, targetUser);
678 fields.put(TARGET_PASSWORD, targetPassword);
679
680 //copy mode
681 fields.put(VALUE_MODE, valueMode);
682
683 fields.put(GENERATOR_OUTPUT, generatorOutput);
684 fields.put(ADDITIONAL_PATHS, addPaths);
685 fields.put(INCLUDE_TABLE_LIST, includeTableList);
686
687 //sql statements
688 fields.put(GENERATE_SQL, sqlFiles);
689 fields.put(CREATE_TABLE, createTables);
690 fields.put(CREATE_PRIMARY_KEYS, createPK);
691 fields.put(CREATE_FOREIGN_KEYS, createFK);
692 fields.put(CREATE_INDEXES, createIn);
693 fields.put(DROP_TABLE, dropTables);
694 fields.put(DROP_FOREIGN_KEYS, dropFK);
695 fields.put(CREATE_SQL_FOR_ALL_VENDORS, createSQLForAll);
696
697 //xml options
698 fields.put(GENERATE_XML, xmlFiles);
699 fields.put(FULL_MODE, fullMode);
700 fields.put(OPTIMIZED_MODE, optimizedMode);
701
702 //ZK added for logging
703 fields.put(LOG_MODE, logMode);
704 fields.put(LOG_FILE_NAME, logFileName);
705 fields.put(LOG_FILE_DIRECTORY, logFileDir);
706 //end
707
708 //doml options
709 fields.put(GENERATE_DOML, domlFile);
710 fields.put(PACKAGE_NAME, packageField);
711
712 //advanced
713 fields.put(PATH_TO_CONF_IN_JAR, pathToConf);
714
715 // Container container = getContentPane();
716 setLayout(new BoxLayout(this, BoxLayout.X_AXIS));
717 add(main);
718 setBounds(0, 0, 970, 680);
719 }
720
721 private JPanel createJDBCRow(JComponent jc1, JComponent jc2) {
722 JPanel jp = new JPanel();
723 jp.setLayout(new BoxLayout(jp, BoxLayout.X_AXIS));
724 jp.add(jc1);
725 if (jc2 != null)
726 jp.add(jc2);
727
728 jp.add(Box.createHorizontalGlue());
729 return jp;
730 }
731
732 private Border setTitleOfBorder(String title, Border border) {
733 Border inb = BorderFactory.createTitledBorder(border, title);
734 return inb;
735 }
736
737 public JTextArea getTraceArea() {
738 return this.traceArea;
739 }
740
741 // private JButton createOctopusButton(String componentName, Dimension dimension) {
742 //
743 // JButton button = new JButton();
744 // if (!componentName.equalsIgnoreCase(""))
745 // button.setText(componentName);
746 //
747 // button.setAlignmentX(Component.LEFT_ALIGNMENT);
748 // button.setAlignmentY(Component.CENTER_ALIGNMENT);
749 // button.setMinimumSize(new Dimension(dimension));
750 // button.setMaximumSize(new Dimension(dimension));
751 // button.setPreferredSize(new Dimension(dimension));
752 //
753 // return button;
754 // }
755 //
756 // private JComboBox createOctopusCombobox(String componentName, Dimension dimension) {
757 //
758 // JComboBox comboBox = new JComboBox();
759 // comboBox.setName(componentName);
760 // comboBox.setAlignmentX(Component.LEFT_ALIGNMENT);
761 // comboBox.setAlignmentY(Component.CENTER_ALIGNMENT);
762 // comboBox.setMinimumSize(new Dimension(dimension));
763 // comboBox.setMaximumSize(new Dimension(dimension));
764 // comboBox.setPreferredSize(new Dimension(dimension));
765 //
766 // return comboBox;
767 // }
768 //
769 // private JLabel createOctopusLabel(String componentName, Dimension dimension) {
770 //
771 // JLabel label = new JLabel();
772 // label.setText(componentName);
773 // label.setAlignmentX(Component.LEFT_ALIGNMENT);
774 // label.setAlignmentY(Component.CENTER_ALIGNMENT);
775 // label.setMinimumSize(new Dimension(dimension));
776 // label.setMaximumSize(new Dimension(dimension));
777 // label.setPreferredSize(new Dimension(dimension));
778 //
779 // return label;
780 // }
781 //
782 // private JTextField createOctopusTextField(String componentName, Dimension dimension) {
783 //
784 // JTextField textField = new JTextField();
785 // textField.setName(componentName);
786 // textField.setAlignmentX(Component.LEFT_ALIGNMENT);
787 // textField.setAlignmentY(Component.CENTER_ALIGNMENT);
788 // textField.setMinimumSize(new Dimension(dimension));
789 // textField.setMaximumSize(new Dimension(dimension));
790 // textField.setPreferredSize(new Dimension(dimension));
791 //
792 // return textField;
793 // }
794
795 public void setOctopusGeneratorInit(
796 OctopusGeneratorData initData,
797 String confJarStructure) {
798 this.initData = initData;
799 setField(LOG_MODE, initData.getLogMode(), "box");
800 setField(LOG_FILE_DIRECTORY, initData.getLogFileDir(), "label");
801 setField(LOG_FILE_NAME, initData.getLogFileName(), "label");
802
803 setField(SOURCE_TYPE, initData.getSourceType(), "box");
804 setField(TARGET_TYPE, initData.getTargetType(), "box");
805 setField(SOURCE_DATABASE, initData.getSourceDatabase(), "label");
806 setField(TARGET_DATABASE, initData.getTargetDatabase(), "label");
807 setField(SOURCE_USER, initData.getSourceUser(), "label");
808 setField(SOURCE_PASSWORD, initData.getSourcePassword(), "label");
809 setField(TARGET_USER, initData.getTargetUser(), "label");
810 setField(TARGET_PASSWORD, initData.getTargetPassword(), "label");
811 setField(VALUE_MODE, initData.getValueMode(), "box");
812 setField(GENERATOR_OUTPUT, initData.getGeneratorOutput(), "label");
813 setField(DOML_PATH, initData.getDomlPath(), "label");
814 setField(PACKAGE_NAME, initData.getPackageName(), "label");
815 setField(SOURCE_DRIVER_NAME, initData.getSourceDriverName(), "box");
816 setField(TARGET_DRIVER_NAME, initData.getTargetDriverName(), "box");
817 setField(ADDITIONAL_PATHS, initData.getAdditionalPaths(), "label");
818 setField(DROP_TABLE, initData.getSqlStmtDropTable(), "checkBox");
819 setField(DROP_FOREIGN_KEYS, initData.getSqlStmtDropIntegrity(), "checkBox");
820 setField(DROP_FOREIGN_KEYS, initData.getSqlStmtDropIntegrity(), "checkBox");
821 setField(CREATE_TABLE, initData.getSqlStmtCreateTable(), "checkBox");
822 setField(CREATE_PRIMARY_KEYS, initData.getSqlStmtCreatePK(), "checkBox");
823 setField(CREATE_FOREIGN_KEYS, initData.getSqlStmtCreateFK(), "checkBox");
824 setField(CREATE_INDEXES, initData.getSqlStmtCreateIndex(), "checkBox");
825 setField(CREATE_SQL_FOR_ALL_VENDORS, initData.getSqlStmtForAllVendors(), "checkBox");
826 setField(GENERATE_SQL, initData.getSqlGenerate(), "checkBox");
827 setField(GENERATE_XML, initData.getXmlGenerate(), "checkBox");
828 setField(GENERATE_DOML, initData.getDomlGenerate(), "checkBox");
829 setField(FULL_MODE, initData.getFullMode(), "radioButton");
830 setField(OPTIMIZED_MODE, initData.getFullMode().equalsIgnoreCase("true") ? "false" : "true", "radioButton");
831 setField(INCLUDE_TABLE_LIST, initData.getIncludeTableList(), "label");
832 setField(PATH_TO_CONF_IN_JAR, initData.getConfJarStructure(), "label");
833
834 }
835
836 public OctopusGeneratorData getOctopusGeneratorInit() throws Exception {
837 initData.setLogMode(getField(LOG_MODE, "box"));
838 initData.setLogFileName(getField(LOG_FILE_NAME, "label"));
839 initData.setLogFileDir(getField(LOG_FILE_DIRECTORY, "label"));
840
841 initData.setSourceType(getField(SOURCE_TYPE, "box"));
842 initData.setTargetType(getField(TARGET_TYPE, "box"));
843 initData.setSourceDatabase(getField(SOURCE_DATABASE, "label"));
844 initData.setTargetDatabase(getField(TARGET_DATABASE, "label"));
845 initData.setSourceUser(getField(SOURCE_USER, "label"));
846 initData.setSourcePassword(getField(SOURCE_PASSWORD, "label"));
847 initData.setTargetUser(getField(TARGET_USER, "label"));
848 initData.setTargetPassword(getField(TARGET_PASSWORD, "label"));
849 initData.setValueMode(getField(VALUE_MODE, "box"));
850 initData.setGeneratorOutput(getField(GENERATOR_OUTPUT, "label"));
851 initData.setDomlPath(getField(DOML_PATH, "label"));
852 initData.setPackageName(getField(PACKAGE_NAME, "label"));
853 initData.setSourceDriverName(getField(SOURCE_DRIVER_NAME, "box"));
854 initData.setTargetDriverName(getField(TARGET_DRIVER_NAME, "box"));
855 initData.setAdditionalPaths(getField(ADDITIONAL_PATHS, "label"));
856 initData.setSqlStmtDropTable(getField(DROP_TABLE, "checkBox"));
857 initData.setSqlStmtDropIntegrity(getField(DROP_FOREIGN_KEYS, "checkBox"));
858 initData.setSqlStmtCreateTable(getField(CREATE_TABLE, "checkBox"));
859 initData.setSqlStmtCreatePK(getField(CREATE_PRIMARY_KEYS, "checkBox"));
860 initData.setSqlStmtCreateFK(getField(CREATE_FOREIGN_KEYS, "checkBox"));
861 initData.setSqlStmtCreateIndex(getField(CREATE_INDEXES, "checkBox"));
862 initData.setSqlStmtForAllVendors(getField(CREATE_SQL_FOR_ALL_VENDORS, "checkBox"));
863 initData.setSqlGenerate(getField(GENERATE_SQL, "checkBox"));
864 initData.setXmlGenerate(getField(GENERATE_XML, "checkBox"));
865 initData.setDomlGenerate(getField(GENERATE_DOML, "checkBox"));
866 if (getField(FULL_MODE, "radioButton").equalsIgnoreCase("true"))
867 initData.setFullMode("true");
868 else
869 initData.setFullMode("false");
870 initData.setIncludeTableList(getField(INCLUDE_TABLE_LIST, "label"));
871 initData.setConfJarStructure(getField(PATH_TO_CONF_IN_JAR, "label"));
872
873 return initData;
874 }
875
876 private String getField(String fieldName, String type) {
877 if (type.equalsIgnoreCase("textfield") || type.equalsIgnoreCase("label")) {
878 JTextField field = (JTextField) fields.get(fieldName);
879 return field.getText().trim();
880 }
881 else
882 if (type.startsWith("checkBox")) {
883 JCheckBox field = (JCheckBox) fields.get(fieldName);
884 if (field.isSelected() == true)
885 return "true";
886 else
887 return "false";
888 }else
889 if (type.startsWith("radioButton")) {
890 JRadioButton field = (JRadioButton) fields.get(fieldName);
891 if (field.isSelected() == true)
892 return "true";
893 else
894 return "false";
895 } else {
896 JComboBox field = (JComboBox) fields.get(fieldName);
897 return field.getSelectedItem().toString();
898
899 }
900 }
901
902 private void setField(String fieldName, String value, String type) {
903 if (type.equalsIgnoreCase("textfield") || type.equalsIgnoreCase("label")) {
904 JTextField field = (JTextField) fields.get(fieldName);
905 field.setText(value);
906 } else
907 if (type.equalsIgnoreCase("box")) {
908 JComboBox field = (JComboBox) fields.get(fieldName);
909 int itemCount = field.getItemCount();
910 if (fieldName.equalsIgnoreCase(SOURCE_TYPE)) {
911 for (int i = 0;
912 i < OctopusGeneratorData.getSourceDatabaseTypes().length;
913 i++) {
914 if( itemCount != OctopusGeneratorData.getSourceDatabaseTypes().length )
915 field.addItem(OctopusGeneratorData.getSourceDatabaseTypes()[i]);
916 if (value
917 .equalsIgnoreCase(OctopusGeneratorData.getSourceDatabaseTypes()[i]))
918 field.setSelectedIndex(i);
919 }
920 } else
921 if (fieldName.equalsIgnoreCase(TARGET_TYPE)) {
922 for (int i = 0;
923 i < OctopusGeneratorData.getTargetDatabaseTypes().length;
924 i++) {
925 if( itemCount != OctopusGeneratorData.getTargetDatabaseTypes().length )
926 field.addItem(OctopusGeneratorData.getTargetDatabaseTypes()[i]);
927 if (value
928 .equalsIgnoreCase(
929 OctopusGeneratorData.getTargetDatabaseTypes()[i]))
930 field.setSelectedIndex(i);
931 }
932 } else
933 if (fieldName.equalsIgnoreCase(SOURCE_DRIVER_NAME)) {
934 for (int i = 0;
935 i < OctopusGeneratorData.getSourceDriverNames().length;
936 i++) {
937 if( itemCount != OctopusGeneratorData.getSourceDriverNames().length )
938 field.addItem(OctopusGeneratorData.getSourceDriverNames()[i]);
939 if (value
940 .equalsIgnoreCase(
941 OctopusGeneratorData.getSourceDriverNames()[i]))
942 field.setSelectedIndex(i);
943 }
944 } else
945 if (fieldName.equalsIgnoreCase(TARGET_DRIVER_NAME)) {
946 for (int i = 0;
947 i < OctopusGeneratorData.getTargetDriverNames().length;
948 i++) {
949 if( itemCount != OctopusGeneratorData.getTargetDriverNames().length )
950 field.addItem(
951 OctopusGeneratorData.getTargetDriverNames()[i]);
952 if (value
953 .equalsIgnoreCase(
954 OctopusGeneratorData.getTargetDriverNames()[i]))
955 field.setSelectedIndex(i);
956 }
957 } else
958 if (fieldName.equalsIgnoreCase(VALUE_MODE)) {
959 for (int i = 0;
960 i < OctopusGeneratorData.getValueModes().length;
961 i++) {
962 if( itemCount != OctopusGeneratorData.getValueModes().length )
963 field.addItem(OctopusGeneratorData.getValueModes()[i]);
964 if (value
965 .equalsIgnoreCase(
966 OctopusGeneratorData.getValueModes()[i]))
967 field.setSelectedIndex(i);
968 }
969 }else
970 if (fieldName.equalsIgnoreCase(LOG_MODE)){
971 boolean setted = false;
972 for(int i = 0; i < OctopusLoaderData.getLogModes().length; i++) {
973 if( field.getItemCount() != OctopusGeneratorData.getLogModes().length )
974 field.addItem(OctopusGeneratorData.getLogModes()[i]);
975 if( value.equalsIgnoreCase(OctopusGeneratorData.getLogModes()[i])) {
976 field.setSelectedIndex(i);
977 setted = true;
978 }
979 }
980 if(!setted)
981 field.setSelectedIndex(1);
982 }
983 } else
984 if (type.equalsIgnoreCase("checkbox")) {
985 JCheckBox field = (JCheckBox) fields.get(fieldName);
986 if (fieldName.equalsIgnoreCase(DROP_TABLE)) {
987 if (value.equalsIgnoreCase("true"))
988 field.setSelected(true);
989 else
990 field.setSelected(false);
991 } else
992 if (fieldName.equalsIgnoreCase(DROP_FOREIGN_KEYS)) {
993 if (value.equalsIgnoreCase("true"))
994 field.setSelected(true);
995 else
996 field.setSelected(false);
997 } else
998 if (fieldName.equalsIgnoreCase(CREATE_TABLE)) {
999 if (value.equalsIgnoreCase("true"))
1000 field.setSelected(true);
1001 else
1002 field.setSelected(false);
1003 } else
1004 if (fieldName.equalsIgnoreCase(CREATE_PRIMARY_KEYS)) {
1005 if (value.equalsIgnoreCase("true"))
1006 field.setSelected(true);
1007 else
1008 field.setSelected(false);
1009 } else
1010 if (fieldName.equalsIgnoreCase(CREATE_FOREIGN_KEYS)) {
1011 if (value.equalsIgnoreCase("true"))
1012 field.setSelected(true);
1013 else
1014 field.setSelected(false);
1015 } else
1016 if (fieldName.equalsIgnoreCase(CREATE_INDEXES)) {
1017 if (value.equalsIgnoreCase("true"))
1018 field.setSelected(true);
1019 else
1020 field.setSelected(false);
1021 } else
1022 if (fieldName
1023 .equalsIgnoreCase(CREATE_SQL_FOR_ALL_VENDORS)) {
1024 if (value.equalsIgnoreCase("true"))
1025 field.setSelected(true);
1026 else
1027 field.setSelected(false);
1028 } else
1029 if (fieldName
1030 .equalsIgnoreCase(GENERATE_SQL)) {
1031 if (value.equalsIgnoreCase("true"))
1032 field.setSelected(true);
1033 else
1034 field.setSelected(false);
1035 } else
1036 if (fieldName
1037 .equalsIgnoreCase(GENERATE_XML)) {
1038 if (value.equalsIgnoreCase("true"))
1039 field.setSelected(true);
1040 else
1041 field.setSelected(false);
1042 } else
1043 if (fieldName
1044 .equalsIgnoreCase(GENERATE_DOML)) {
1045 if (value.equalsIgnoreCase("true"))
1046 field.setSelected(true);
1047 else
1048 field.setSelected(false);
1049 }
1050 } else
1051 if (type.equalsIgnoreCase("radioButton")) {
1052 JRadioButton field = (JRadioButton) fields.get(fieldName);
1053 if (value.equalsIgnoreCase("true"))
1054 field.setSelected(true);
1055 else
1056 field.setSelected(false);
1057 }
1058
1059 }
1060
1061 private class FullScreenAction extends AbstractAction {
1062
1063 /***
1064 * This method starts the LoaderGenerator application
1065 */
1066 public FullScreenAction() {
1067
1068 putValue(
1069 SMALL_ICON,
1070 new ImageIcon(
1071 getClass().getClassLoader().getResource(
1072 "org/webdocwf/util/loader/" + "wizard/images/Host16.gif")));
1073 putValue(SHORT_DESCRIPTION, "Full Screen");
1074 putValue(LONG_DESCRIPTION, "Set Trace to Full Screen");
1075 putValue(
1076 ACCELERATOR_KEY,
1077 KeyStroke.getKeyStroke(
1078 'F',
1079 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
1080 putValue(MNEMONIC_KEY, new Integer('F'));
1081 }
1082
1083 /***
1084 * This method check if the action is performed (event key pressed)
1085 * @param e is event
1086 */
1087 public void actionPerformed(ActionEvent e) {
1088 main.setDividerLocation(0);
1089 }
1090 }
1091
1092
1093
1094 private class NormalScreenAction extends AbstractAction {
1095
1096 /***
1097 * This method starts the LoaderGenerator application
1098 */
1099 public NormalScreenAction() {
1100
1101 putValue(
1102 SMALL_ICON,
1103 new ImageIcon(
1104 getClass().getClassLoader().getResource(
1105 "org/webdocwf/util/loader/" + "wizard/images/Unhost16.gif")));
1106 putValue(SHORT_DESCRIPTION, "Normal Screen");
1107 putValue(LONG_DESCRIPTION, "Back to normal screen");
1108 putValue(
1109 ACCELERATOR_KEY,
1110 KeyStroke.getKeyStroke(
1111 'N',
1112 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
1113 putValue(MNEMONIC_KEY, new Integer('N'));
1114 }
1115
1116 /***
1117 * This method check if the action is performed (event key pressed)
1118 * @param e is event
1119 */
1120 public void actionPerformed(ActionEvent e) {
1121 main.setDividerLocation(510);
1122 }
1123 }
1124
1125 private class SaveTraceAction extends AbstractAction {
1126
1127 /***
1128 * This method starts the LoaderGenerator application
1129 */
1130 public SaveTraceAction() {
1131
1132 putValue(
1133 SMALL_ICON,
1134 new ImageIcon(
1135 getClass().getClassLoader().getResource(
1136 "org/webdocwf/util/loader/" + "wizard/images/Save16.gif")));
1137 putValue(SHORT_DESCRIPTION, "Save Trace");
1138 putValue(LONG_DESCRIPTION, "Save Trace to file");
1139 putValue(
1140 ACCELERATOR_KEY,
1141 KeyStroke.getKeyStroke(
1142 'S',
1143 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
1144 putValue(MNEMONIC_KEY, new Integer('S'));
1145 }
1146
1147 /***
1148 * This method check if the action is performed (event key pressed)
1149 * @param e is event
1150 */
1151 public void actionPerformed(ActionEvent e) {
1152 JFileChooser fc = new JFileChooser();
1153 fc.setDialogTitle("Save Together Data Transformer log ...");
1154 int returnVal = fc.showSaveDialog(null);
1155 if (returnVal == JFileChooser.APPROVE_OPTION) {
1156 File file = fc.getSelectedFile();
1157 String text = traceArea.getText();
1158 try {
1159 Writer out = new BufferedWriter(new FileWriter(file));
1160 out.write(text);
1161 out.close();
1162 } catch (Exception ex) {
1163 ex.printStackTrace();
1164 }
1165
1166 } else {
1167 //do nothing
1168 }
1169 }
1170 }
1171
1172 private class ClearTraceAction extends AbstractAction {
1173
1174 /***
1175 * This method starts the LoaderGenerator application
1176 */
1177 public ClearTraceAction() {
1178
1179 putValue(
1180 SMALL_ICON,
1181 new ImageIcon(
1182 getClass().getClassLoader().getResource(
1183 "org/webdocwf/util/loader/" + "wizard/images/Delete16.gif")));
1184 putValue(SHORT_DESCRIPTION, "Clear Trace");
1185 putValue(LONG_DESCRIPTION, "Clear Trace");
1186 putValue(
1187 ACCELERATOR_KEY,
1188 KeyStroke.getKeyStroke(
1189 'L',
1190 Toolkit.getDefaultToolkit().getMenuShortcutKeyMask()));
1191 putValue(MNEMONIC_KEY, new Integer('L'));
1192 }
1193
1194 /***
1195 * This method check if the action is performed (event key pressed)
1196 * @param e is event
1197 */
1198 public void actionPerformed(ActionEvent e) {
1199 traceArea.setText("");
1200 }
1201 }
1202
1203 private class BrowseAction_GO extends AbstractAction {
1204
1205 /***
1206 * This method stop the LoaderGenerator application
1207 */
1208 public BrowseAction_GO() {
1209 putValue(
1210 SMALL_ICON,
1211 new ImageIcon(
1212 getClass().getClassLoader().getResource(
1213 "org/webdocwf/util/loader/" + "wizard/images/Open16.gif")));
1214 putValue(SHORT_DESCRIPTION, "Browse for Generator output directory");
1215 putValue(LONG_DESCRIPTION, "Browse for Generator output directory");
1216 putValue(MNEMONIC_KEY, new Integer('B'));
1217 }
1218
1219 /***
1220 * This method check if the action is performed (event key pressed)
1221 * @param e is event
1222 */
1223 public void actionPerformed(ActionEvent e) {
1224 JFileChooser chooser = null;
1225 File choice = null;
1226 File current = new File(System.getProperty("user.dir"));
1227 chooser = new JFileChooser(current);
1228 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
1229 chooser.setFileFilter((javax.swing.filechooser.FileFilter) new DirectoryFilter());
1230 chooser.setDialogTitle("Select Generator Output Directory");
1231 chooser.setApproveButtonText("Open");
1232 String strFieldText = "";
1233
1234 chooser.setCurrentDirectory(new File(strFieldText));
1235 int v = chooser.showOpenDialog(null);
1236 // desktop.requestFocus();
1237
1238 switch (v) {
1239 case JFileChooser.APPROVE_OPTION :
1240 if (chooser.getSelectedFile() != null) {
1241 if (chooser.getSelectedFile().exists()) {
1242 choice = chooser.getSelectedFile();
1243 } else {
1244 File parentFile = new File(chooser.getSelectedFile().getParent());
1245 choice = parentFile;
1246 }
1247 generatorOutput.setText(choice.getPath());
1248 }
1249 break;
1250
1251 case JFileChooser.CANCEL_OPTION :
1252 case JFileChooser.ERROR_OPTION :
1253
1254 }
1255 }
1256 }
1257
1258 //log dir
1259 private class BrowseAction_L
1260 extends AbstractAction {
1261
1262
1263 public BrowseAction_L() {
1264 // putValue(NAME, "browse");
1265 putValue(SMALL_ICON,
1266 new ImageIcon(getClass().getClassLoader().
1267 getResource("org/webdocwf/util/loader/" +
1268 "wizard/images/Open16.gif")));
1269 putValue(SHORT_DESCRIPTION, "Browse for Log file directory");
1270 putValue(LONG_DESCRIPTION, "Browse for Log file directory");
1271 putValue(MNEMONIC_KEY, new Integer('B'));
1272 }
1273
1274 /***
1275 * This method check if the action is performed (event key pressed)
1276 * @param e is event
1277 */
1278 public void actionPerformed(ActionEvent e) {
1279 JFileChooser chooser = null;
1280 File choice = null;
1281 File current = new File(System.getProperty("user.dir"));
1282 chooser = new JFileChooser(current);
1283 chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
1284 chooser.setFileFilter((javax.swing.filechooser.FileFilter)new DirectoryFilter());
1285 chooser.setDialogTitle("Select Log File Directory");
1286 chooser.setApproveButtonText("Open");
1287 String strFieldText = "";
1288
1289 chooser.setCurrentDirectory(new File(strFieldText));
1290 int v = chooser.showOpenDialog(null);
1291 // parent.requestFocus();
1292
1293 switch(v) {
1294 case JFileChooser.APPROVE_OPTION:
1295 if(chooser.getSelectedFile() != null) {
1296 if(chooser.getSelectedFile().exists()) {
1297 choice = chooser.getSelectedFile();
1298 } else {
1299 File parentFile = new File(chooser.getSelectedFile().getParent());
1300 choice = parentFile;
1301 }
1302 setField(LOG_FILE_DIRECTORY, choice.getPath(), "label");
1303 }
1304 break;
1305
1306 case JFileChooser.CANCEL_OPTION:
1307 case JFileChooser.ERROR_OPTION:
1308
1309 }
1310 }
1311 }
1312
1313 //additional paths
1314 private class BrowseAction_AC extends AbstractAction {
1315
1316 /***
1317 * This method stop the LoaderGenerator application
1318 */
1319 public BrowseAction_AC() {
1320 putValue(
1321 SMALL_ICON,
1322 new ImageIcon(
1323 getClass().getClassLoader().getResource(
1324 "org/webdocwf/util/loader/" + "wizard/images/Open16.gif")));
1325 putValue(SHORT_DESCRIPTION, "Add .jar files");
1326 putValue(LONG_DESCRIPTION, "Add .jar (jdbc) files to system classpath");
1327 putValue(MNEMONIC_KEY, new Integer('B'));
1328 }
1329
1330 /***
1331 * This method check if the action is performed (event key pressed)
1332 * @param e is event
1333 */
1334 public void actionPerformed(ActionEvent e) {
1335 JFileChooser chooser = null;
1336 File choice = null;
1337 File current = new File(System.getProperty("user.dir"));
1338 chooser = new JFileChooser(current);
1339 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
1340 chooser.setFileFilter((javax.swing.filechooser.FileFilter) new JarFilter());
1341 chooser.setDialogTitle("Select .jar file");
1342 chooser.setAcceptAllFileFilterUsed(false);
1343 String strFieldText = addPaths.getText();
1344
1345 if (!strFieldText.equalsIgnoreCase(""))
1346 strFieldText = strFieldText + ";";
1347
1348 chooser.setCurrentDirectory(new File(strFieldText));
1349 chooser.setApproveButtonText("Open");
1350 int v = chooser.showOpenDialog(null);
1351
1352 // desktop.requestFocus();
1353 switch (v) {
1354 case JFileChooser.APPROVE_OPTION :
1355 if (chooser.getSelectedFile() != null) {
1356 if (chooser.getSelectedFile().exists()) {
1357 choice = chooser.getSelectedFile();
1358 } else {
1359 File parentFile = new File(chooser.getSelectedFile().getParent());
1360 choice = parentFile;
1361 }
1362 addPaths.setText(strFieldText + choice.getPath());
1363 }
1364 break;
1365
1366 case JFileChooser.CANCEL_OPTION :
1367 case JFileChooser.ERROR_OPTION :
1368
1369 chooser.removeAll();
1370 chooser = null;
1371 current = null;
1372
1373 }
1374 }
1375 }
1376
1377
1378
1379 //doml file
1380 private class BrowseAction_DOML extends AbstractAction {
1381
1382 /***
1383 * This method stop the LoaderGenerator application
1384 */
1385 public BrowseAction_DOML() {
1386 // putValue(NAME, "browse");
1387 putValue(
1388 SMALL_ICON,
1389 new ImageIcon(
1390 getClass().getClassLoader().getResource(
1391 "org/webdocwf/util/loader/" + "wizard/images/Open16.gif")));
1392 putValue(SHORT_DESCRIPTION, "Browse for .doml file");
1393 putValue(LONG_DESCRIPTION, "Browse for .doml file");
1394 putValue(MNEMONIC_KEY, new Integer('B'));
1395 }
1396
1397 /***
1398 * This method check if the action is performed (event key pressed)
1399 * @param e is event
1400 */
1401 public void actionPerformed(ActionEvent e) {
1402 JFileChooser chooser = null;
1403 File choice = null;
1404 File current = new File(System.getProperty("user.dir"));
1405 chooser = new JFileChooser(current);
1406 chooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES);
1407 chooser.setFileFilter((javax.swing.filechooser.FileFilter) new DomlFilter());
1408 chooser.setDialogTitle("Select .doml file");
1409 chooser.setAcceptAllFileFilterUsed(false);
1410 String strFieldText = "";
1411
1412 chooser.setCurrentDirectory(new File(strFieldText));
1413 chooser.setApproveButtonText("Open");
1414 int v = chooser.showOpenDialog(null);
1415
1416 // parent.requestFocus();
1417 switch (v) {
1418 case JFileChooser.APPROVE_OPTION :
1419 if (chooser.getSelectedFile() != null) {
1420 if (chooser.getSelectedFile().exists()) {
1421 choice = chooser.getSelectedFile();
1422 } else {
1423 File parentFile = new File(chooser.getSelectedFile().getParent());
1424 choice = parentFile;
1425 }
1426 setField(DOML_PATH, choice.getPath(), "label");
1427 }
1428 break;
1429
1430 case JFileChooser.CANCEL_OPTION :
1431 case JFileChooser.ERROR_OPTION :
1432
1433 chooser.removeAll();
1434 chooser = null;
1435
1436 }
1437 }
1438 }
1439
1440 }
This page was automatically generated by Maven