1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 package org.dbforms.devgui;
25
26 import java.awt.*;
27 import java.awt.event.*;
28
29 import java.io.*;
30
31 import java.sql.*;
32
33 import java.util.Vector;
34
35 import javax.swing.*;
36
37
38
39 /***
40 * DOCUMENT ME!
41 *
42 * @author $author$
43 * @version $Revision: 1.13 $
44 */
45 public class ConfigFilePanel extends AbstractPropertyPanel implements ActionListener {
46 private javax.swing.ButtonGroup catalogButtonGroup;
47 private javax.swing.ButtonGroup forkeyButtonGroup;
48 private javax.swing.ButtonGroup schemaButtonGroup;
49 private javax.swing.ButtonGroup tableButtonGroup;
50
51
52
53
54
55
56
57
58
59
60
61
62 private DevGui parent;
63 private EditorPanel panel_editor;
64 private javax.swing.JButton b_browse;
65 private javax.swing.JButton b_generate;
66 private javax.swing.JButton b_loadLists;
67 private javax.swing.JCheckBox cb_autocommit;
68 private javax.swing.JCheckBox cb_examine_systabs;
69 private javax.swing.JCheckBox cb_examine_tables;
70 private javax.swing.JCheckBox cb_examine_views;
71 private javax.swing.JCheckBox cb_include_catalogname;
72 private javax.swing.JCheckBox cb_include_schemaname;
73 private javax.swing.JCheckBox cb_stdTypeNames;
74 private javax.swing.JComboBox catalogList;
75 private javax.swing.JComboBox dateFormat;
76 private javax.swing.JComboBox schemaList;
77 private javax.swing.JLabel jLabel1;
78 private javax.swing.JLabel jLabel2;
79 private javax.swing.JLabel jLabel3;
80 private javax.swing.JLabel jLabel4;
81 private javax.swing.JLabel jLabel5;
82 private javax.swing.JLabel jLabel6;
83 private javax.swing.JLabel jLabel7;
84 private javax.swing.JPanel jPanel1;
85 private javax.swing.JPanel jPanel2;
86 private javax.swing.JPanel jPanel3;
87 private javax.swing.JPanel jPanel4;
88 private javax.swing.JPanel jPanel5;
89 private javax.swing.JPanel jPanel6;
90 private javax.swing.JPanel panel_top;
91 private javax.swing.JRadioButton rb_catalog_all;
92 private javax.swing.JRadioButton rb_catalog_combobox;
93 private javax.swing.JRadioButton rb_forkey_deactivated;
94 private javax.swing.JRadioButton rb_forkey_getCrossReferences;
95 private javax.swing.JRadioButton rb_forkey_getImportedKeys;
96 private javax.swing.JRadioButton rb_schema_all;
97 private javax.swing.JRadioButton rb_schema_combobox;
98 private javax.swing.JRadioButton rb_table_all;
99 private javax.swing.JRadioButton rb_table_textfield;
100 private javax.swing.JSeparator jSeparator1;
101
102
103 private javax.swing.JSeparator jSeparator2;
104 private javax.swing.JSeparator jSeparator3;
105 private javax.swing.JSeparator jSeparator4;
106 private javax.swing.JSeparator jSeparator5;
107 private javax.swing.JSeparator jSeparator6;
108 private javax.swing.JSeparator jSeparator7;
109 private javax.swing.JSeparator jSeparator8;
110 private javax.swing.JTextField tf_configFile;
111 private javax.swing.JTextField tf_tableNamePattern;
112 private String[] dateFormats = {
113 "",
114 "yyyy-MM-dd",
115 "yyyy_MM_dd",
116 "yyyy/MM/dd",
117 "yyyy.MM.dd",
118 "dd-MMM-yyyy",
119 "dd.MM.yyyy",
120 "dd/MM/yyyyy",
121 "MM-dd-yyyy"
122 };
123
124 /***
125 * Creates new form WebAppPanel
126 *
127 * @param parent DOCUMENT ME!
128 */
129 public ConfigFilePanel(DevGui parent) {
130 super(parent.getProjectData());
131 this.parent = parent;
132 initComponents();
133
134
135 initComponents2();
136 doLayout();
137 }
138
139
140
141 /***
142 * DOCUMENT ME!
143 *
144 * @param projectData DOCUMENT ME!
145 */
146 public void setNewProjectData(ProjectData projectData) {
147 this.projectData = projectData;
148
149 String webAppRoot = projectData.getProperty("webAppRoot");
150 String configFile = projectData.getProperty(CONFIG_FILE);
151
152 tf_configFile.setText("");
153
154 if (!"".equals(configFile)) {
155 tf_configFile.setText(configFile);
156
157 File f = new File(configFile);
158
159 if (f.exists() && f.isFile()) {
160 panel_editor.setFile(f);
161 }
162 } else {
163 if (!"".equals(webAppRoot)) {
164 tf_configFile.setText(FileNameTool.normalize(webAppRoot)
165 + "WEB-INF" + parent.getFileSeparator());
166 }
167 }
168
169 initializeCatalogAndSchemaList();
170
171
172 String forKeyDetection = projectData.getProperty(FOREIGNKEY_DETECTION);
173
174 if (DEACTIVATED.equalsIgnoreCase(forKeyDetection)) {
175 rb_forkey_deactivated.setSelected(true);
176 } else if (USE_GETCROSSREFERENCES.equalsIgnoreCase(forKeyDetection)) {
177 rb_forkey_getCrossReferences.setSelected(true);
178 } else {
179 rb_forkey_getImportedKeys.setSelected(true);
180 }
181
182
183 if (ALL.equalsIgnoreCase(projectData.getProperty(CATALOG_SELECTION))) {
184 rb_catalog_all.setSelected(true);
185 } else {
186 rb_catalog_combobox.setSelected(true);
187 }
188
189 if (ALL.equalsIgnoreCase(projectData.getProperty(SCHEMA_SELECTION))) {
190 rb_schema_all.setSelected(true);
191 } else {
192 rb_schema_combobox.setSelected(true);
193 }
194
195 if (ALL.equalsIgnoreCase(projectData.getProperty(TABLE_SELECTION))) {
196 rb_table_all.setSelected(true);
197 } else {
198 rb_table_textfield.setSelected(true);
199 }
200
201
202
203 cb_include_catalogname.setSelected(TRUESTRING.equalsIgnoreCase(projectData
204 .getProperty(INCLUDE_CATALOGNAME)));
205 cb_include_schemaname.setSelected(TRUESTRING.equalsIgnoreCase(projectData
206 .getProperty(INCLUDE_SCHEMANAME)));
207 cb_autocommit.setSelected(TRUESTRING.equalsIgnoreCase(projectData
208 .getProperty(AUTOCOMMIT_MODE)));
209
210 cb_stdTypeNames.setSelected(TRUESTRING.equalsIgnoreCase(projectData
211 .getProperty(WRITE_STD_TYPENAMES)));
212
213
214 cb_examine_tables.setSelected(TRUESTRING.equalsIgnoreCase(projectData
215 .getProperty(EXAMINE_TABLES)));
216 cb_examine_views.setSelected(TRUESTRING.equalsIgnoreCase(projectData
217 .getProperty(EXAMINE_VIEWS)));
218 cb_examine_systabs.setSelected(TRUESTRING.equalsIgnoreCase(projectData
219 .getProperty(EXAMINE_SYSTABS)));
220
221
222 catalogList.setSelectedItem(projectData.getProperty(CATALOG));
223 schemaList.setSelectedItem(projectData.getProperty(SCHEMA));
224
225
226 tf_tableNamePattern.setText(projectData.getProperty(TABLE_NAME_PATTERN));
227
228
229 if (projectData.getProperty(DATE_FORMAT) != null) {
230 dateFormat.setSelectedItem(projectData.getProperty(DATE_FORMAT));
231 }
232 }
233
234
235 /***
236 * DOCUMENT ME!
237 *
238 * @param ev DOCUMENT ME!
239 */
240 public void actionPerformed(ActionEvent ev) {
241 if (ev.getSource() == b_generate) {
242 String configFile = projectData.getProperty(CONFIG_FILE);
243
244 if (!"".equals(configFile)) {
245 File f = new File(configFile);
246
247 try {
248 String result = XMLConfigGenerator.createXMLOutput(projectData,
249 true);
250
251 FileOutputStream os = new FileOutputStream(f);
252 ByteArrayInputStream is = new ByteArrayInputStream(result.getBytes());
253
254 byte[] b = new byte[1024];
255 int read;
256
257 while ((read = is.read(b)) != -1) {
258 os.write(b, 0, read);
259 }
260
261 panel_editor.setFile(f);
262 } catch (IOException ioe) {
263 showExceptionDialog(ioe);
264 } catch (Exception e) {
265 showExceptionDialog(e);
266 }
267 } else {
268 JOptionPane.showMessageDialog(this,
269 "Please enter name of config file");
270 }
271 } else if (ev.getSource() == b_browse) {
272 String configFile = projectData.getProperty(CONFIG_FILE);
273
274 System.out.println("configFile=" + configFile + "!");
275
276 File dlgFile;
277
278 System.out.println("ps2");
279
280 if (!"".equals(configFile)) {
281 System.out.println("ps3");
282 dlgFile = new File(configFile);
283 System.out.println("ps4");
284 } else {
285 System.out.println("ps5");
286
287 String webAppRoot = projectData.getProperty("webAppRoot");
288 System.out.println("ps6");
289
290 if (!"".equals(webAppRoot)) {
291 System.out.println("ps7");
292 dlgFile = new File(webAppRoot);
293 System.out.println("ps8");
294 } else {
295 System.out.println("ps9");
296 dlgFile = null;
297 System.out.println("ps10");
298 }
299 }
300
301 if ((dlgFile != null) && dlgFile.exists()) {
302 dlgFile = null;
303 }
304
305 JFileChooser dlg_fileChooser = new JFileChooser(dlgFile);
306 dlg_fileChooser.setVisible(true);
307
308 int returnVal = dlg_fileChooser.showOpenDialog(this);
309
310 if (returnVal == JFileChooser.APPROVE_OPTION) {
311 File selectedFile = dlg_fileChooser.getSelectedFile();
312 tf_configFile.setText(selectedFile.getAbsolutePath());
313 tf_configFile.grabFocus();
314 panel_editor.setFile(selectedFile);
315 }
316 }
317 }
318
319
320 /***
321 * DOCUMENT ME!
322 *
323 * @param cb DOCUMENT ME!
324 * @param propertyName DOCUMENT ME!
325 */
326 protected void addCheckBoxItemListener(final JCheckBox cb,
327 final String propertyName) {
328 cb.addItemListener(new java.awt.event.ItemListener() {
329 public void itemStateChanged(java.awt.event.ItemEvent e) {
330 projectData.setProperty(propertyName,
331 cb.isSelected() ? TRUESTRING
332 : FALSESTRING);
333 }
334 });
335 }
336
337
338 /***
339 * DOCUMENT ME!
340 *
341 * @param cb DOCUMENT ME!
342 * @param p DOCUMENT ME!
343 */
344 protected void addComboBoxItemListener(final JComboBox cb,
345 final String p) {
346 cb.addItemListener(new java.awt.event.ItemListener() {
347 public void itemStateChanged(java.awt.event.ItemEvent e) {
348 projectData.setProperty(p, (String) cb.getSelectedItem());
349 }
350 });
351 }
352
353
354 /***
355 * DOCUMENT ME!
356 *
357 * @param rb DOCUMENT ME!
358 * @param propertyName DOCUMENT ME!
359 * @param propertyValue DOCUMENT ME!
360 */
361 protected void addJRadioButtonActionListener(final JRadioButton rb,
362 final String propertyName,
363 final String propertyValue) {
364 rb.addActionListener(new java.awt.event.ActionListener() {
365 public void actionPerformed(java.awt.event.ActionEvent e) {
366 projectData.setProperty(propertyName, propertyValue);
367 }
368 });
369 }
370
371
372 /***
373 * This method is called from within the constructor to initialize the form.
374 * WARNING: Do NOT modify this code. The content of this method is always
375 * regenerated by the Form Editor.
376 */
377 private void initComponents() {
378
379 java.awt.GridBagConstraints gridBagConstraints;
380
381 catalogButtonGroup = new javax.swing.ButtonGroup();
382 schemaButtonGroup = new javax.swing.ButtonGroup();
383 tableButtonGroup = new javax.swing.ButtonGroup();
384 forkeyButtonGroup = new javax.swing.ButtonGroup();
385 panel_top = new javax.swing.JPanel();
386 tf_tableNamePattern = new javax.swing.JTextField();
387 jPanel2 = new javax.swing.JPanel();
388 jLabel1 = new javax.swing.JLabel();
389 tf_configFile = new javax.swing.JTextField();
390 b_browse = new javax.swing.JButton();
391 rb_catalog_all = new javax.swing.JRadioButton();
392 rb_schema_all = new javax.swing.JRadioButton();
393 rb_table_all = new javax.swing.JRadioButton();
394 rb_table_textfield = new javax.swing.JRadioButton();
395 jSeparator1 = new javax.swing.JSeparator();
396 jSeparator2 = new javax.swing.JSeparator();
397 jSeparator3 = new javax.swing.JSeparator();
398 jSeparator4 = new javax.swing.JSeparator();
399 rb_catalog_combobox = new javax.swing.JRadioButton();
400 jPanel1 = new javax.swing.JPanel();
401 b_generate = new javax.swing.JButton();
402 rb_schema_combobox = new javax.swing.JRadioButton();
403 cb_autocommit = new javax.swing.JCheckBox();
404 jPanel3 = new javax.swing.JPanel();
405 jLabel3 = new javax.swing.JLabel();
406 cb_include_catalogname = new javax.swing.JCheckBox();
407 jLabel4 = new javax.swing.JLabel();
408 cb_include_schemaname = new javax.swing.JCheckBox();
409 jLabel5 = new javax.swing.JLabel();
410 jPanel4 = new javax.swing.JPanel();
411 jLabel6 = new javax.swing.JLabel();
412 cb_examine_tables = new javax.swing.JCheckBox();
413 cb_examine_views = new javax.swing.JCheckBox();
414 cb_examine_systabs = new javax.swing.JCheckBox();
415 jSeparator5 = new javax.swing.JSeparator();
416 catalogList = new javax.swing.JComboBox();
417 schemaList = new javax.swing.JComboBox();
418 b_loadLists = new javax.swing.JButton();
419 cb_stdTypeNames = new javax.swing.JCheckBox();
420 jSeparator6 = new javax.swing.JSeparator();
421 jPanel5 = new javax.swing.JPanel();
422 jLabel2 = new javax.swing.JLabel();
423 dateFormat = new javax.swing.JComboBox();
424 jSeparator7 = new javax.swing.JSeparator();
425 jPanel6 = new javax.swing.JPanel();
426 jLabel7 = new javax.swing.JLabel();
427 rb_forkey_getImportedKeys = new javax.swing.JRadioButton();
428 rb_forkey_getCrossReferences = new javax.swing.JRadioButton();
429 rb_forkey_deactivated = new javax.swing.JRadioButton();
430 jSeparator8 = new javax.swing.JSeparator();
431
432 setLayout(new java.awt.BorderLayout());
433
434 panel_top.setLayout(new java.awt.GridBagLayout());
435
436 gridBagConstraints = new java.awt.GridBagConstraints();
437 gridBagConstraints.gridx = 2;
438 gridBagConstraints.gridy = 7;
439 gridBagConstraints.gridwidth = 2;
440 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
441 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
442 gridBagConstraints.weightx = 1.0;
443 panel_top.add(tf_tableNamePattern, gridBagConstraints);
444
445 jPanel2.setLayout(new java.awt.GridBagLayout());
446
447 jLabel1.setText("DbForms-Config File: ");
448 jPanel2.add(jLabel1, new java.awt.GridBagConstraints());
449
450 tf_configFile.setMinimumSize(new java.awt.Dimension(50, 24));
451 gridBagConstraints = new java.awt.GridBagConstraints();
452 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
453 gridBagConstraints.weightx = 1.0;
454 jPanel2.add(tf_configFile, gridBagConstraints);
455
456 b_browse.setText("browse...");
457 jPanel2.add(b_browse, new java.awt.GridBagConstraints());
458
459 gridBagConstraints = new java.awt.GridBagConstraints();
460 gridBagConstraints.gridwidth = 4;
461 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
462 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
463 gridBagConstraints.weightx = 1.0;
464 panel_top.add(jPanel2, gridBagConstraints);
465
466 rb_catalog_all.setSelected(true);
467 rb_catalog_all.setText("in all catalogs");
468 catalogButtonGroup.add(rb_catalog_all);
469 gridBagConstraints = new java.awt.GridBagConstraints();
470 gridBagConstraints.gridx = 0;
471 gridBagConstraints.gridy = 5;
472 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
473 panel_top.add(rb_catalog_all, gridBagConstraints);
474
475 rb_schema_all.setSelected(true);
476 rb_schema_all.setText("in all schemas");
477 schemaButtonGroup.add(rb_schema_all);
478 gridBagConstraints = new java.awt.GridBagConstraints();
479 gridBagConstraints.gridx = 0;
480 gridBagConstraints.gridy = 6;
481 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
482 panel_top.add(rb_schema_all, gridBagConstraints);
483
484 rb_table_all.setSelected(true);
485 rb_table_all.setText("with arbitrary names");
486 tableButtonGroup.add(rb_table_all);
487 gridBagConstraints = new java.awt.GridBagConstraints();
488 gridBagConstraints.gridx = 0;
489 gridBagConstraints.gridy = 7;
490 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
491 panel_top.add(rb_table_all, gridBagConstraints);
492
493 rb_table_textfield.setText("with table name pattern:");
494 tableButtonGroup.add(rb_table_textfield);
495 gridBagConstraints = new java.awt.GridBagConstraints();
496 gridBagConstraints.gridx = 1;
497 gridBagConstraints.gridy = 7;
498 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
499 panel_top.add(rb_table_textfield, gridBagConstraints);
500
501 gridBagConstraints = new java.awt.GridBagConstraints();
502 gridBagConstraints.gridx = 0;
503 gridBagConstraints.gridy = 1;
504 gridBagConstraints.gridwidth = 4;
505 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
506 panel_top.add(jSeparator1, gridBagConstraints);
507
508 gridBagConstraints = new java.awt.GridBagConstraints();
509 gridBagConstraints.gridx = 0;
510 gridBagConstraints.gridy = 16;
511 gridBagConstraints.gridwidth = 4;
512 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
513 panel_top.add(jSeparator2, gridBagConstraints);
514
515 gridBagConstraints = new java.awt.GridBagConstraints();
516 gridBagConstraints.gridx = 0;
517 gridBagConstraints.gridy = 8;
518 gridBagConstraints.gridwidth = 4;
519 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
520 panel_top.add(jSeparator3, gridBagConstraints);
521
522 gridBagConstraints = new java.awt.GridBagConstraints();
523 gridBagConstraints.gridx = 0;
524 gridBagConstraints.gridy = 10;
525 gridBagConstraints.gridwidth = 4;
526 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
527 panel_top.add(jSeparator4, gridBagConstraints);
528
529 rb_catalog_combobox.setText("in catalog with name:");
530 catalogButtonGroup.add(rb_catalog_combobox);
531 rb_catalog_combobox.addActionListener(new java.awt.event.ActionListener() {
532 public void actionPerformed(java.awt.event.ActionEvent evt) {
533 rb_catalog_comboboxActionPerformed(evt);
534 }
535 });
536
537 gridBagConstraints = new java.awt.GridBagConstraints();
538 gridBagConstraints.gridx = 1;
539 gridBagConstraints.gridy = 5;
540 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
541 panel_top.add(rb_catalog_combobox, gridBagConstraints);
542
543 b_generate.setText("Generate XML!");
544 jPanel1.add(b_generate);
545
546 gridBagConstraints = new java.awt.GridBagConstraints();
547 gridBagConstraints.gridx = 0;
548 gridBagConstraints.gridy = 19;
549 gridBagConstraints.gridwidth = 4;
550 panel_top.add(jPanel1, gridBagConstraints);
551
552 rb_schema_combobox.setText("in schema with name pattern:");
553 schemaButtonGroup.add(rb_schema_combobox);
554 gridBagConstraints = new java.awt.GridBagConstraints();
555 gridBagConstraints.gridx = 1;
556 gridBagConstraints.gridy = 6;
557 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
558 panel_top.add(rb_schema_combobox, gridBagConstraints);
559
560 cb_autocommit.setSelected(true);
561 cb_autocommit.setText("Use autocommit mode while reading metadata (recommended).");
562 gridBagConstraints = new java.awt.GridBagConstraints();
563 gridBagConstraints.gridx = 0;
564 gridBagConstraints.gridy = 9;
565 gridBagConstraints.gridwidth = 4;
566 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
567 panel_top.add(cb_autocommit, gridBagConstraints);
568
569 jLabel3.setText("Include");
570 jPanel3.add(jLabel3);
571
572 cb_include_catalogname.setText("catalog name");
573 jPanel3.add(cb_include_catalogname);
574
575 jLabel4.setText(" ");
576 jPanel3.add(jLabel4);
577
578 cb_include_schemaname.setText("schema name");
579 jPanel3.add(cb_include_schemaname);
580
581 jLabel5.setText("in table name.");
582 jPanel3.add(jLabel5);
583
584 gridBagConstraints = new java.awt.GridBagConstraints();
585 gridBagConstraints.gridx = 0;
586 gridBagConstraints.gridy = 15;
587 gridBagConstraints.gridwidth = 4;
588 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
589 panel_top.add(jPanel3, gridBagConstraints);
590
591 jPanel4.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
592
593 jLabel6.setText("Examine");
594 jPanel4.add(jLabel6);
595
596 cb_examine_tables.setSelected(true);
597 cb_examine_tables.setText("Tables");
598 jPanel4.add(cb_examine_tables);
599
600 cb_examine_views.setSelected(true);
601 cb_examine_views.setText("Views");
602 jPanel4.add(cb_examine_views);
603
604 cb_examine_systabs.setText("System Tables");
605 jPanel4.add(cb_examine_systabs);
606
607 gridBagConstraints = new java.awt.GridBagConstraints();
608 gridBagConstraints.gridx = 0;
609 gridBagConstraints.gridy = 3;
610 gridBagConstraints.gridwidth = 4;
611 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
612 panel_top.add(jPanel4, gridBagConstraints);
613
614 gridBagConstraints = new java.awt.GridBagConstraints();
615 gridBagConstraints.gridx = 0;
616 gridBagConstraints.gridy = 4;
617 gridBagConstraints.gridwidth = 4;
618 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
619 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
620 panel_top.add(jSeparator5, gridBagConstraints);
621
622 catalogList.setEditable(true);
623 catalogList.setMinimumSize(new java.awt.Dimension(124, 24));
624 catalogList.setPreferredSize(new java.awt.Dimension(128, 24));
625 gridBagConstraints = new java.awt.GridBagConstraints();
626 gridBagConstraints.gridx = 2;
627 gridBagConstraints.gridy = 5;
628 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
629 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
630 gridBagConstraints.weightx = 1.0;
631 panel_top.add(catalogList, gridBagConstraints);
632
633 schemaList.setEditable(true);
634 schemaList.setMinimumSize(new java.awt.Dimension(124, 24));
635 schemaList.setPreferredSize(new java.awt.Dimension(128, 24));
636 gridBagConstraints = new java.awt.GridBagConstraints();
637 gridBagConstraints.gridx = 2;
638 gridBagConstraints.gridy = 6;
639 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
640 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
641 gridBagConstraints.weightx = 1.0;
642 panel_top.add(schemaList, gridBagConstraints);
643
644 b_loadLists.setText("Load");
645 b_loadLists.setToolTipText("Load catalog and schema names from database");
646 b_loadLists.addActionListener(new java.awt.event.ActionListener() {
647 public void actionPerformed(java.awt.event.ActionEvent evt) {
648 loadCatalogAndSchemaNames(evt);
649 }
650 });
651
652 gridBagConstraints = new java.awt.GridBagConstraints();
653 gridBagConstraints.gridx = 3;
654 gridBagConstraints.gridy = 5;
655 gridBagConstraints.gridheight = 2;
656 gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
657 gridBagConstraints.weighty = 0.5;
658 panel_top.add(b_loadLists, gridBagConstraints);
659
660 cb_stdTypeNames.setText("Try to write standard type names for unknown field types into xml config file.");
661 gridBagConstraints = new java.awt.GridBagConstraints();
662 gridBagConstraints.gridx = 0;
663 gridBagConstraints.gridy = 11;
664 gridBagConstraints.gridwidth = 4;
665 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
666 panel_top.add(cb_stdTypeNames, gridBagConstraints);
667
668 gridBagConstraints = new java.awt.GridBagConstraints();
669 gridBagConstraints.gridx = 0;
670 gridBagConstraints.gridy = 14;
671 gridBagConstraints.gridwidth = 4;
672 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
673 gridBagConstraints.weightx = 1.0;
674 panel_top.add(jSeparator6, gridBagConstraints);
675
676 jLabel2.setText("Set date format to: ");
677 jPanel5.add(jLabel2);
678
679 dateFormat.setEditable(true);
680 jPanel5.add(dateFormat);
681
682 gridBagConstraints = new java.awt.GridBagConstraints();
683 gridBagConstraints.gridx = 0;
684 gridBagConstraints.gridy = 17;
685 gridBagConstraints.gridwidth = 4;
686 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
687 panel_top.add(jPanel5, gridBagConstraints);
688
689 gridBagConstraints = new java.awt.GridBagConstraints();
690 gridBagConstraints.gridx = 0;
691 gridBagConstraints.gridy = 18;
692 gridBagConstraints.gridwidth = 4;
693 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
694 panel_top.add(jSeparator7, gridBagConstraints);
695
696 jPanel6.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT));
697
698 jLabel7.setText("Foreign Key Detection:");
699 jPanel6.add(jLabel7);
700
701 rb_forkey_getImportedKeys.setSelected(true);
702 rb_forkey_getImportedKeys.setText("getImportedKeys( )");
703 forkeyButtonGroup.add(rb_forkey_getImportedKeys);
704 jPanel6.add(rb_forkey_getImportedKeys);
705
706 rb_forkey_getCrossReferences.setText("getCrossReferences( )");
707 rb_forkey_getCrossReferences.setToolTipText("null");
708 forkeyButtonGroup.add(rb_forkey_getCrossReferences);
709 jPanel6.add(rb_forkey_getCrossReferences);
710
711 rb_forkey_deactivated.setText("deactivated");
712 forkeyButtonGroup.add(rb_forkey_deactivated);
713 jPanel6.add(rb_forkey_deactivated);
714
715 gridBagConstraints = new java.awt.GridBagConstraints();
716 gridBagConstraints.gridx = 0;
717 gridBagConstraints.gridy = 13;
718 gridBagConstraints.gridwidth = 4;
719 gridBagConstraints.insets = new java.awt.Insets(0, 1, 0, 1);
720 gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
721 panel_top.add(jPanel6, gridBagConstraints);
722
723 gridBagConstraints = new java.awt.GridBagConstraints();
724 gridBagConstraints.gridx = 0;
725 gridBagConstraints.gridy = 12;
726 gridBagConstraints.gridwidth = 4;
727 gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
728 gridBagConstraints.weightx = 1.0;
729 panel_top.add(jSeparator8, gridBagConstraints);
730
731 add(panel_top, java.awt.BorderLayout.NORTH);
732 }
733
734
735 private void initComponents2() {
736 b_browse.addActionListener(this);
737
738
739 addAFocusListener(tf_configFile, CONFIG_FILE);
740
741
742 tf_configFile.addFocusListener(new java.awt.event.FocusAdapter() {
743 public void focusLost(java.awt.event.FocusEvent e) {
744 File f = new File(tf_configFile.getText());
745
746 if (f.exists() && f.isFile() && f.canRead()) {
747 panel_editor.setFile(f);
748 }
749 }
750 });
751
752 b_browse.setToolTipText("default: webAppRoot" + parent.getFileSeparator()
753 + "WEB-INF" + parent.getFileSeparator()
754 + "dbforms-config.xml\nNon-default values must be configured in web.xml!");
755
756 b_generate.addActionListener(this);
757 b_generate.setToolTipText("Generate raw content of config-file by quering the database you defined in tab \"Database properties\".");
758
759 panel_editor = new EditorPanel();
760 add(BorderLayout.CENTER, panel_editor);
761
762
763
764
765
766
767 addAFocusListener(tf_tableNamePattern, TABLE_NAME_PATTERN);
768
769
770
771
772 addJRadioButtonActionListener(rb_catalog_all, CATALOG_SELECTION, ALL);
773 addJRadioButtonActionListener(rb_catalog_combobox, CATALOG_SELECTION,
774 SELECTION);
775
776 addJRadioButtonActionListener(rb_schema_all, SCHEMA_SELECTION, ALL);
777 addJRadioButtonActionListener(rb_schema_combobox, SCHEMA_SELECTION,
778 SELECTION);
779
780 addJRadioButtonActionListener(rb_table_all, TABLE_SELECTION, ALL);
781 addJRadioButtonActionListener(rb_table_textfield, TABLE_SELECTION,
782 SELECTION);
783
784 addJRadioButtonActionListener(rb_forkey_getImportedKeys,
785 FOREIGNKEY_DETECTION, USE_GETIMPORTEDKEYS);
786 addJRadioButtonActionListener(rb_forkey_getCrossReferences,
787 FOREIGNKEY_DETECTION, USE_GETCROSSREFERENCES);
788 addJRadioButtonActionListener(rb_forkey_deactivated,
789 FOREIGNKEY_DETECTION, DEACTIVATED);
790
791
792
793
794 addCheckBoxItemListener(cb_include_catalogname, INCLUDE_CATALOGNAME);
795 addCheckBoxItemListener(cb_include_schemaname, INCLUDE_SCHEMANAME);
796 addCheckBoxItemListener(cb_autocommit, AUTOCOMMIT_MODE);
797 addCheckBoxItemListener(cb_examine_tables, EXAMINE_TABLES);
798 addCheckBoxItemListener(cb_examine_views, EXAMINE_VIEWS);
799 addCheckBoxItemListener(cb_examine_systabs, EXAMINE_SYSTABS);
800 addCheckBoxItemListener(cb_stdTypeNames, WRITE_STD_TYPENAMES);
801
802 initializeCatalogAndSchemaList();
803
804
805
806 addComboBoxItemListener(catalogList, CATALOG);
807 addComboBoxItemListener(schemaList, SCHEMA);
808
809
810 for (int i = 0; i < dateFormats.length; i++) {
811 dateFormat.addItem(dateFormats[i]);
812 }
813
814
815 addComboBoxItemListener(dateFormat, DATE_FORMAT);
816 }
817
818
819 private void initializeCatalogAndSchemaList() {
820
821
822 Vector catalogs = new Vector();
823 catalogs.add("--- no catalogs loaded ---");
824 catalogList.setModel(new DefaultComboBoxModel(catalogs));
825
826
827
828 Vector schemas = new Vector();
829 schemas.add("--- no schemas loaded ---");
830 schemaList.setModel(new DefaultComboBoxModel(schemas));
831
832
833
834 }
835
836
837
838
839
840
841
842 private void loadCatalogAndSchemaNames(java.awt.event.ActionEvent evt) {
843
844 String jdbcDriver = projectData.getProperty("jdbcDriver");
845 String jdbcURL = projectData.getProperty("jdbcURL");
846 String username = projectData.getProperty("username");
847 String password = projectData.getProperty("password");
848
849 try {
850 try {
851 Class.forName(jdbcDriver)
852 .newInstance();
853 } catch (ClassNotFoundException ex) {
854 String message = "Could not find JDBC driver class " + jdbcDriver
855 + "\n"
856 + "Please check database properties and classpath!";
857
858 if (jdbcDriver.equalsIgnoreCase("")) {
859 message = "JDBC driver class in database properties not set!\n"
860 + "Please check database properties!";
861 }
862
863 JOptionPane.showMessageDialog(this, message);
864
865 return;
866 }
867
868 Connection con = DriverManager.getConnection(jdbcURL, username,
869 password);
870
871 DatabaseMetaData dbmd = con.getMetaData();
872
873
874
875 Vector catalogs = new Vector();
876
877 try {
878 ResultSet catalogRs = dbmd.getCatalogs();
879
880 while (catalogRs.next()) {
881 catalogs.add(catalogRs.getString(1));
882 }
883 } catch (SQLException ignored) {
884 ;
885 }
886
887 if (catalogs.size() == 0) {
888 catalogs.add(" --- no catalogs found ---");
889 }
890
891 catalogList.setModel(new DefaultComboBoxModel(catalogs));
892 catalogList.setSelectedIndex(0);
893 projectData.setProperty(CATALOG, (String) catalogList.getItemAt(0));
894
895
896 Vector schemas = new Vector();
897 ResultSet schemaRs = dbmd.getSchemas();
898
899 while (schemaRs.next()) {
900 schemas.add(schemaRs.getString(1));
901 }
902
903 if (schemas.size() == 0) {
904 schemas.add("--- no schemas found ---");
905 }
906
907 schemaList.setModel(new DefaultComboBoxModel(schemas));
908 schemaList.setSelectedIndex(0);
909 projectData.setProperty(SCHEMA, (String) schemaList.getItemAt(0));
910 } catch (Exception ex) {
911 showExceptionDialog(ex);
912 }
913 }
914
915
916
917 private void rb_catalog_comboboxActionPerformed(java.awt.event.ActionEvent evt) {
918
919
920 }
921
922
923 }