View Javadoc

1   package org.devaki.nextobjects.ui.workspace.models.objects;
2   /*
3    *  nextobjects Copyright (C) 2001-2005 Laurent Thevenet, Emmanuel Florent
4    *  This program is free software; you can redistribute it and/or modify
5    *  it under the terms of the GNU General Public License as published by the
6    *  Free Software Foundation; either version 2 of the License, or (at your
7    *  option) any later version.
8    *  This program is distributed in the hope that it will
9    *  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
10   *  of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11   *  PURPOSE. See the GNU General Public License for more details.
12   *  You should have received a copy of the GNU General Public License along
13   *  with this program; if not, write to the Free Software Foundation, Inc., 59
14   *  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
15   */
16  import java.awt.GridBagConstraints;
17  import java.awt.GridBagLayout;
18  import java.awt.Insets;
19  import java.awt.Dimension;
20  import java.awt.event.ActionEvent;
21  import java.awt.event.ActionListener;
22  import java.awt.event.FocusAdapter;
23  import java.awt.event.FocusEvent;
24  import javax.swing.BorderFactory;
25  import javax.swing.JCheckBox;
26  import javax.swing.JDialog;
27  import javax.swing.JLabel;
28  import javax.swing.JPanel;
29  import javax.swing.JScrollPane;
30  import javax.swing.JTabbedPane;
31  import javax.swing.SwingConstants;
32  import javax.swing.WindowConstants;
33  import javax.swing.event.DocumentEvent;
34  import javax.swing.event.DocumentListener;
35  import javax.swing.text.BadLocationException;
36  import org.devaki.nextobjects.NextObjects;
37  import org.devaki.nextobjects.workspace.models.objects.Table;
38  import org.devaki.nextobjects.ui.components.CustomButton;
39  import org.devaki.nextobjects.ui.components.CustomComboBox;
40  import org.devaki.nextobjects.ui.components.CustomTextArea;
41  import org.devaki.nextobjects.ui.components.CustomTextField;
42  import org.devaki.nextobjects.ui.main.NOTreeView;
43  /***
44   *  This is the editor window
45   *
46   * @author     <a href="mailto:eflorent@devaki.org">Emmanuel Florent</a>
47   */
48  public class TableEdit extends JDialog
49  {
50      /***  Local reference of the edited object */
51      private Table myTable;
52      /***  jLabel */
53      private JLabel jLabelName = new JLabel("Name");
54      /***  jLabel */
55      private JLabel jLabelCode = new JLabel("Code");
56      /***  jLabel */
57      private JLabel jLabelDescription = new JLabel("Description");
58      /***  jLabel */
59      private JLabel jLabelAlias = new JLabel("Alias");
60      /***  jLabel */
61      private JLabel jLabelIdMethod = new JLabel("ID Creation");
62      /***  jLabel */
63      private JLabel jLabelJavaName = new JLabel("Java Name");
64      /***  jLabel */
65      private JLabel jLabelBaseClass = new JLabel("Base Class");
66      /***  jLabel */
67      private JLabel jLabelBasePeer = new JLabel("Base Peer");
68      /***  jLabel */
69      private JLabel jLabelJavaNamingMethod = new JLabel("Java Naming Method");
70      /***  jTextField */
71      private CustomTextField jTextFieldName =
72          new CustomTextField("", "Name of the table in the schema", true);
73      /***  jTextField */
74      private CustomTextField jTextFieldCode =
75          new CustomTextField("", "Name of the table in the database", true);
76      /***  jTextField */
77      private CustomTextField jTextFieldAlias =
78          new CustomTextField("", "The table alias", true);
79      /***  jTextField */
80      private CustomTextArea jTextAreaDescription =
81          new CustomTextArea("", "Description of the table", true, true);
82      /***  jTextField */
83      private CustomTextArea jTextAreaNotes =
84          new CustomTextArea("", "Notes about the table", true, true);
85      /***  jTextField */
86      private CustomTextField jTextFieldJavaName =
87          new CustomTextField(
88              "",
89              "How this table will be referenced in Java. If you leave it empty, "
90                  + "Torque use DefaultJavaNamigMethod",
91              true);
92      /***  jTextField */
93      private CustomTextField jTextFieldBaseClass =
94          new CustomTextField("", "Used for OM Peer generation", true);
95      /***  jTextField */
96      private CustomTextField jTextFieldBasePeer =
97          new CustomTextField("", "Used for OM Peer generation", true);
98      /***  jComboBox */
99      private CustomComboBox jComboBoxIdMethod;
100     /***  jComboBox */
101     private CustomComboBox jComboBoxJavaNamingMethod;
102     /***  jComboBox */
103     private CustomComboBox jComboBoxJavaType;
104     /***  jComboBox */
105     private CustomComboBox jComboBoxInheritance;
106     /***  jComboBox */
107     private CustomComboBox jComboBoxColumnJavaNamingMethod;
108     /***  jCheckBox */
109     private JCheckBox jCheckBoxGenerateSQL = new JCheckBox("Generate SQL");
110     /***  jCheckBox */
111     private JCheckBox jCheckBoxHeavyIndexing = new JCheckBox("Heavy Indexing");
112     /***  jCheckBox */
113     private JCheckBox jCheckBoxAbstract = new JCheckBox("Abstract");
114     /***  datadictionary */
115     private DataDictionaryEdit dataDict = new DataDictionaryEdit();
116     /***  jButton */
117     private CustomButton jButtonEqual =
118         new CustomButton("=", "Automatic table code", true, true);
119     /***  jButton */
120     private CustomButton jButtonOK = new CustomButton("OK", "", true, false);
121     /***  jButton */
122     private CustomButton jButtonCancel =
123         new CustomButton("Cancel", "", true, false);
124     /***  jTabbedPane */
125     private JTabbedPane jTabbedPane = new JTabbedPane(SwingConstants.TOP);
126     /***  jPanel */
127     private JPanel jPanelGeneral = new JPanel(new GridBagLayout());
128     /***  jPanel */
129     private JPanel jPanelGeneralProperties = new JPanel(new GridBagLayout());
130     /***  jPanel */
131     private JPanel jPanelGeneralFields = new JPanel(new GridBagLayout());
132     /***  jPanel */
133     private JPanel jPanelSql = new JPanel(new GridBagLayout());
134     /***  jPanel */
135     private JPanel jPanelSqlProperties = new JPanel(new GridBagLayout());
136     /***  jPanel */
137     private JPanel jPanelObjectModel = new JPanel(new GridBagLayout());
138     /***  jPanel */
139     private JPanel jPanelNotes = new JPanel(new GridBagLayout());
140     /***  Construct a new 'TableEdit' object */
141     public TableEdit()
142     {
143         super(NextObjects.getReference());
144         // Define the size of the window
145         this.setSize(new Dimension(475, 500));
146         // Center the window
147         this.setLocationRelativeTo(null);
148         // Specify that the window is modal
149         this.setModal(true);
150         // Specify that the window is not resizable
151         this.setResizable(false);
152         // Define what to do when closing this window using the cross button
153         this.setDefaultCloseOperation(WindowConstants.HIDE_ON_CLOSE);
154         // PANELS
155         // Set a GridBagLayout for the content panel
156         this.getContentPane().setLayout(new GridBagLayout());
157         // Create titled borders for some panels
158         this.jPanelGeneralProperties.setBorder(
159             BorderFactory.createTitledBorder("Properties"));
160         this.jPanelGeneralFields.setBorder(
161             BorderFactory.createTitledBorder("Fields"));
162         this.jPanelSqlProperties.setBorder(
163             BorderFactory.createTitledBorder("Properties"));
164         // COMBO BOXES
165         // Create an array of Strings and initialize the ID Method combo box
166         String[] temp1 = { "none", "idBrooker", "native" };
167         this.jComboBoxIdMethod = new CustomComboBox(temp1, -1, "", true);
168         // Create an array of Strings and initialize the Java Naming Method
169         // combo boxes
170         String[] temp2 = { "underscore", "javaname", "nochange", };
171         this.jComboBoxJavaNamingMethod =
172             new CustomComboBox(temp2, -1, "", true);
173         this.jComboBoxColumnJavaNamingMethod =
174             new CustomComboBox(temp2, -1, "", true);
175         // Create an array of Strings and initialize the Java Type combo box
176         String[] temp3 = { "object", "primitive" };
177         this.jComboBoxJavaType = new CustomComboBox(temp3, -1, "", true);
178         // Create an array of Strings and initialize the Inheritance combo box
179         String[] temp4 = { "single", "false" };
180         this.jComboBoxInheritance = new CustomComboBox(temp4, -1, "", true);
181         // TABLES
182         /***  Listeners * */
183         // FOCUS
184         this.jTextFieldName.addFocusListener(new FocusAdapter()
185         {
186             // Select the content of 'jTextFieldName' when it gained focus
187             public final void focusGained(final FocusEvent e)
188             {
189                 jTextFieldName.selectAll();
190             }
191         });
192         this.jTextFieldCode.addFocusListener(new FocusAdapter()
193         {
194             // Select the content of 'jTextFieldCode' when it gained focus
195             public final void focusGained(final FocusEvent e)
196             {
197                 jTextFieldCode.selectAll();
198             }
199         });
200         this.jTextFieldAlias.addFocusListener(new FocusAdapter()
201         {
202             // Select the content of 'jTextFieldAlias' when it gained focus
203             public final void focusGained(final FocusEvent e)
204             {
205                 jTextFieldAlias.selectAll();
206             }
207         });
208         this.jTextFieldJavaName.addFocusListener(new FocusAdapter()
209         {
210             // Select the content of 'jTextFieldJavaName' when it own focus
211             public final void focusGained(final FocusEvent e)
212             {
213                 jTextFieldJavaName.selectAll();
214             }
215         });
216         this.jTextFieldBaseClass.addFocusListener(new FocusAdapter()
217         {
218             //Select the content of 'jTextFieldBaseClass' when it own focus
219             public final void focusGained(final FocusEvent e)
220             {
221                 jTextFieldBaseClass.selectAll();
222             }
223         });
224         this.jTextFieldBasePeer.addFocusListener(new FocusAdapter()
225         {
226             // Select the content of 'jTextFieldBasePeer' when it own focus
227             public final void focusGained(final FocusEvent e)
228             {
229                 jTextFieldBasePeer.selectAll();
230             }
231         });
232         // DOCUMENT
233         this
234             .jTextFieldName
235             .getDocument()
236             .addDocumentListener(new DocumentListener()
237         {
238             // Not implemented
239             public final void changedUpdate(final DocumentEvent e)
240             {
241             }
242             // When inserting text, call 'enablingOKButton'
243             public final void insertUpdate(final DocumentEvent e)
244             {
245                 enablingOKButton();
246             }
247             // When removing text, call 'enablingOKButton'
248             public final void removeUpdate(final DocumentEvent e)
249             {
250                 enablingOKButton();
251             }
252         });
253         this
254             .jTextFieldCode
255             .getDocument()
256             .addDocumentListener(new DocumentListener()
257         {
258             // Not implemented
259             public final void changedUpdate(final DocumentEvent e)
260             {
261             }
262             // When inserting text, call 'enablingOKButton'
263             public final void insertUpdate(final DocumentEvent e)
264             {
265                 // Cancel insertion if user types the <SPACE> key
266                 try
267                 {
268                     if (e
269                         .getDocument()
270                         .getText(e.getOffset(), 1)
271                         .startsWith(" "))
272                     {
273                         e.getDocument().remove(e.getOffset(), 1);
274                     }
275                 }
276                 catch (BadLocationException exc)
277                 {
278                 }
279                 enablingOKButton();
280             }
281             // When removing text, call 'enablingOKButton'
282             public final void removeUpdate(final DocumentEvent e)
283             {
284                 enablingOKButton();
285             }
286         });
287         // ACTION
288         this.jCheckBoxGenerateSQL.addActionListener(new ActionListener()
289         {
290             // Disable or enable components inside 'jPanelSqlProperties'
291             // depending on 'jCheckBoxGenerateSQL' is checked or not
292             public final void actionPerformed(final ActionEvent e)
293             {
294                 boolean tmpBool = jCheckBoxGenerateSQL.isSelected();
295                 for (int i = 0;
296                     i < jPanelSqlProperties.getComponentCount();
297                     i++)
298                 {
299                     jPanelSqlProperties.getComponent(i).setEnabled(tmpBool);
300                 }
301             }
302         });
303         this.jButtonEqual.addActionListener(new ActionListener()
304         {
305             // When clicking on 'jButtonEqual', set the text of
306             // 'jTextFieldCode with' a formatted content of 'jTextFieldName'
307             public final void actionPerformed(final ActionEvent e)
308             {
309                 jTextFieldCode.setText(
310                     jTextFieldName.getText().toLowerCase().replace(' ', '_'));
311             }
312         });
313         this.jButtonOK.addActionListener(new ActionListener()
314         {
315             // When calling 'jButtonOK', save data and close the window
316             public final void actionPerformed(final ActionEvent e)
317             {
318                 closingWindow(true);
319             }
320         });
321         this.jButtonCancel.addActionListener(new ActionListener()
322         {
323             // When calling 'jButtonCancel', close the dialog without saving
324             public final void actionPerformed(final ActionEvent e)
325             {
326                 dataDict.getModel().resetColumns();
327                 myTable.setData(dataDict.getModel().getColumns());
328                 closingWindow(false);
329             }
330         });
331         /***  Assembling components * */
332         // 'jPanelGeneralProperties'
333         this.jPanelGeneralProperties.add(
334             this.jLabelName,
335             new GridBagConstraints(
336                 0,
337                 0,
338                 1,
339                 1,
340                 0.0,
341                 0.0,
342                 GridBagConstraints.WEST,
343                 GridBagConstraints.NONE,
344                 new Insets(5, 5, 0, 5),
345                 0,
346                 0));
347         this.jPanelGeneralProperties.add(
348             this.jTextFieldName,
349             new GridBagConstraints(
350                 1,
351                 0,
352                 1,
353                 1,
354                 1.0,
355                 0.0,
356                 GridBagConstraints.CENTER,
357                 GridBagConstraints.HORIZONTAL,
358                 new Insets(5, 0, 0, 5),
359                 0,
360                 0));
361         this.jPanelGeneralProperties.add(
362             this.jLabelCode,
363             new GridBagConstraints(
364                 2,
365                 0,
366                 1,
367                 1,
368                 0.0,
369                 0.0,
370                 GridBagConstraints.WEST,
371                 GridBagConstraints.NONE,
372                 new Insets(5, 0, 0, 5),
373                 0,
374                 0));
375         this.jPanelGeneralProperties.add(
376             this.jButtonEqual,
377             new GridBagConstraints(
378                 3,
379                 0,
380                 1,
381                 1,
382                 0.0,
383                 0.0,
384                 GridBagConstraints.WEST,
385                 GridBagConstraints.NONE,
386                 new Insets(5, 0, 0, 0),
387                 0,
388                 0));
389         this.jPanelGeneralProperties.add(
390             this.jTextFieldCode,
391             new GridBagConstraints(
392                 4,
393                 0,
394                 1,
395                 1,
396                 1.0,
397                 0.0,
398                 GridBagConstraints.CENTER,
399                 GridBagConstraints.HORIZONTAL,
400                 new Insets(5, 0, 0, 5),
401                 0,
402                 0));
403         this.jPanelGeneralProperties.add(
404             this.jLabelDescription,
405             new GridBagConstraints(
406                 0,
407                 1,
408                 1,
409                 1,
410                 0.0,
411                 0.0,
412                 GridBagConstraints.NORTHWEST,
413                 GridBagConstraints.NONE,
414                 new Insets(5, 5, 0, 5),
415                 0,
416                 0));
417         this.jPanelGeneralProperties.add(
418             new JScrollPane(this.jTextAreaDescription),
419             new GridBagConstraints(
420                 1,
421                 1,
422                 4,
423                 1,
424                 1.0,
425                 1.0,
426                 GridBagConstraints.CENTER,
427                 GridBagConstraints.BOTH,
428                 new Insets(5, 0, 5, 5),
429                 0,
430                 0));
431         // 'jPanelGeneral'
432         this.jPanelGeneral.add(
433             this.jPanelGeneralProperties,
434             new GridBagConstraints(
435                 0,
436                 0,
437                 1,
438                 1,
439                 1.0,
440                 0.3,
441                 GridBagConstraints.CENTER,
442                 GridBagConstraints.BOTH,
443                 new Insets(5, 5, 0, 5),
444                 0,
445                 0));
446         this.jPanelGeneral.add(
447             this.dataDict,
448             new GridBagConstraints(
449                 0,
450                 1,
451                 1,
452                 1,
453                 1.0,
454                 1.7,
455                 GridBagConstraints.CENTER,
456                 GridBagConstraints.BOTH,
457                 new Insets(5, 5, 5, 5),
458                 0,
459                 0));
460         // 'jPanelSqlProperties'
461         this.jPanelSqlProperties.add(
462             this.jLabelIdMethod,
463             new GridBagConstraints(
464                 0,
465                 0,
466                 1,
467                 1,
468                 0.0,
469                 0.0,
470                 GridBagConstraints.WEST,
471                 GridBagConstraints.NONE,
472                 new Insets(5, 5, 0, 5),
473                 0,
474                 0));
475         this.jPanelSqlProperties.add(
476             this.jComboBoxIdMethod,
477             new GridBagConstraints(
478                 1,
479                 0,
480                 1,
481                 1,
482                 1.0,
483                 0.0,
484                 GridBagConstraints.CENTER,
485                 GridBagConstraints.HORIZONTAL,
486                 new Insets(5, 0, 0, 5),
487                 0,
488                 0));
489         this.jPanelSqlProperties.add(
490             this.jCheckBoxHeavyIndexing,
491             new GridBagConstraints(
492                 2,
493                 0,
494                 1,
495                 1,
496                 0.0,
497                 0.0,
498                 GridBagConstraints.CENTER,
499                 GridBagConstraints.NONE,
500                 new Insets(5, 0, 0, 5),
501                 0,
502                 0));
503         this.jPanelSqlProperties.add(
504             this.jLabelAlias,
505             new GridBagConstraints(
506                 0,
507                 1,
508                 1,
509                 1,
510                 0.0,
511                 0.0,
512                 GridBagConstraints.WEST,
513                 GridBagConstraints.NONE,
514                 new Insets(5, 5, 0, 5),
515                 0,
516                 0));
517         this.jPanelSqlProperties.add(
518             this.jTextFieldAlias,
519             new GridBagConstraints(
520                 1,
521                 1,
522                 2,
523                 1,
524                 1.0,
525                 0.0,
526                 GridBagConstraints.CENTER,
527                 GridBagConstraints.HORIZONTAL,
528                 new Insets(5, 0, 0, 5),
529                 0,
530                 0));
531         this.jPanelSqlProperties.add(
532             new JLabel("More things soon here"),
533             new GridBagConstraints(
534                 0,
535                 2,
536                 3,
537                 1,
538                 1.0,
539                 1.0,
540                 GridBagConstraints.CENTER,
541                 GridBagConstraints.BOTH,
542                 new Insets(5, 5, 5, 5),
543                 0,
544                 0));
545         // 'jPanelSQL'
546         this.jPanelSql.add(
547             this.jCheckBoxGenerateSQL,
548             new GridBagConstraints(
549                 0,
550                 0,
551                 1,
552                 1,
553                 0.0,
554                 0.0,
555                 GridBagConstraints.WEST,
556                 GridBagConstraints.NONE,
557                 new Insets(5, 5, 0, 5),
558                 0,
559                 0));
560         this.jPanelSql.add(
561             this.jPanelSqlProperties,
562             new GridBagConstraints(
563                 0,
564                 1,
565                 1,
566                 1,
567                 1.0,
568                 1.0,
569                 GridBagConstraints.CENTER,
570                 GridBagConstraints.BOTH,
571                 new Insets(5, 5, 5, 5),
572                 0,
573                 0));
574         // 'jPanelObjectModel'
575         this.jPanelObjectModel.add(
576             this.jLabelJavaName,
577             new GridBagConstraints(
578                 0,
579                 0,
580                 1,
581                 1,
582                 0.0,
583                 0.0,
584                 GridBagConstraints.WEST,
585                 GridBagConstraints.NONE,
586                 new Insets(5, 5, 0, 5),
587                 0,
588                 0));
589         this.jPanelObjectModel.add(
590             this.jTextFieldJavaName,
591             new GridBagConstraints(
592                 1,
593                 0,
594                 1,
595                 1,
596                 1.0,
597                 0.0,
598                 GridBagConstraints.CENTER,
599                 GridBagConstraints.HORIZONTAL,
600                 new Insets(5, 0, 0, 5),
601                 0,
602                 0));
603         this.jPanelObjectModel.add(
604             this.jCheckBoxAbstract,
605             new GridBagConstraints(
606                 2,
607                 0,
608                 1,
609                 1,
610                 0.0,
611                 0.0,
612                 GridBagConstraints.CENTER,
613                 GridBagConstraints.NONE,
614                 new Insets(5, 0, 0, 5),
615                 0,
616                 0));
617         this.jPanelObjectModel.add(
618             this.jLabelBaseClass,
619             new GridBagConstraints(
620                 0,
621                 1,
622                 1,
623                 1,
624                 0.0,
625                 0.0,
626                 GridBagConstraints.WEST,
627                 GridBagConstraints.NONE,
628                 new Insets(5, 5, 0, 5),
629                 0,
630                 0));
631         this.jPanelObjectModel.add(
632             this.jTextFieldBaseClass,
633             new GridBagConstraints(
634                 1,
635                 1,
636                 2,
637                 1,
638                 1.0,
639                 0.0,
640                 GridBagConstraints.CENTER,
641                 GridBagConstraints.HORIZONTAL,
642                 new Insets(5, 0, 0, 5),
643                 0,
644                 0));
645         this.jPanelObjectModel.add(
646             this.jLabelBasePeer,
647             new GridBagConstraints(
648                 0,
649                 2,
650                 1,
651                 1,
652                 0.0,
653                 0.0,
654                 GridBagConstraints.WEST,
655                 GridBagConstraints.NONE,
656                 new Insets(5, 5, 0, 5),
657                 0,
658                 0));
659         this.jPanelObjectModel.add(
660             this.jTextFieldBasePeer,
661             new GridBagConstraints(
662                 1,
663                 2,
664                 2,
665                 1,
666                 1.0,
667                 0.0,
668                 GridBagConstraints.CENTER,
669                 GridBagConstraints.HORIZONTAL,
670                 new Insets(5, 0, 0, 5),
671                 0,
672                 0));
673         this.jPanelObjectModel.add(
674             this.jLabelJavaNamingMethod,
675             new GridBagConstraints(
676                 0,
677                 3,
678                 1,
679                 1,
680                 0.0,
681                 0.0,
682                 GridBagConstraints.WEST,
683                 GridBagConstraints.NONE,
684                 new Insets(5, 5, 0, 5),
685                 0,
686                 0));
687         this.jPanelObjectModel.add(
688             this.jComboBoxJavaNamingMethod,
689             new GridBagConstraints(
690                 1,
691                 3,
692                 2,
693                 1,
694                 1.0,
695                 0.0,
696                 GridBagConstraints.CENTER,
697                 GridBagConstraints.HORIZONTAL,
698                 new Insets(5, 0, 0, 5),
699                 0,
700                 0));
701         this.jPanelObjectModel.add(
702             new JLabel("More things here soon"),
703             new GridBagConstraints(
704                 0,
705                 4,
706                 3,
707                 1,
708                 1.0,
709                 1.0,
710                 GridBagConstraints.CENTER,
711                 GridBagConstraints.BOTH,
712                 new Insets(5, 5, 5, 5),
713                 0,
714                 0));
715         // 'jPanelNotes'
716         this.jPanelNotes.add(
717             new JScrollPane(this.jTextAreaNotes),
718             new GridBagConstraints(
719                 0,
720                 0,
721                 1,
722                 1,
723                 1.0,
724                 1.0,
725                 GridBagConstraints.CENTER,
726                 GridBagConstraints.BOTH,
727                 new Insets(5, 5, 5, 5),
728                 0,
729                 0));
730         // 'jTabbedPane'
731         this.jTabbedPane.add(this.jPanelGeneral, "General");
732         this.jTabbedPane.add(this.jPanelSql, "SQL");
733         this.jTabbedPane.add(this.jPanelObjectModel, "Object-Model");
734         this.jTabbedPane.add(this.jPanelNotes, "Notes");
735         // Content Panel
736         this.getContentPane().add(
737             this.jTabbedPane,
738             new GridBagConstraints(
739                 0,
740                 0,
741                 2,
742                 1,
743                 1.0,
744                 1.0,
745                 GridBagConstraints.CENTER,
746                 GridBagConstraints.BOTH,
747                 new Insets(5, 5, 0, 5),
748                 0,
749                 0));
750         this.getContentPane().add(
751             this.jButtonOK,
752             new GridBagConstraints(
753                 0,
754                 1,
755                 1,
756                 1,
757                 1.0,
758                 0.0,
759                 GridBagConstraints.EAST,
760                 GridBagConstraints.NONE,
761                 new Insets(5, 5, 5, 5),
762                 0,
763                 0));
764         this.getContentPane().add(
765             this.jButtonCancel,
766             new GridBagConstraints(
767                 1,
768                 1,
769                 1,
770                 1,
771                 0.0,
772                 0.0,
773                 GridBagConstraints.CENTER,
774                 GridBagConstraints.NONE,
775                 new Insets(5, 0, 5, 5),
776                 0,
777                 0));
778     }
779     // End of 'TableEdit()'
780     /***
781      *  What to do before closing the window
782      *
783      * @param  isOK  save data
784      */
785     private void closingWindow(final boolean isOK)
786     {
787         // Save data if this method follows an action on 'jButtonOK'
788         if (isOK)
789         {
790             this.saveData();
791         }
792         // Dispose window (unallocate resources) - show() must be call to set
793         // window visible again
794         this.dispose();
795     }
796     /***
797      *  Enable or disable the 'OK' button depending on the length of
798      *  'jTextFieldName' and 'jTextFieldCode'
799      */
800     private void enablingOKButton()
801     {
802         if ((this.jTextFieldName.getText().length() != 0)
803             && (this.jTextFieldCode.getText().length() != 0))
804         {
805             //Both text  length are different from zero, so enable 'jButtonOK'
806             this.jButtonOK.setEnabled(true);
807         }
808         // One or both text length are equal to zero, so disable 'jButtonOK'
809         else
810         {
811             this.jButtonOK.setEnabled(false);
812         }
813     }
814     /***
815      *  Initialize the editor with a <code>Table</code> object
816      *
817      * @param  pTable  the table to set
818      */
819     public final void setData(final Table pTable)
820     {
821         // Define title of the window
822         this.setTitle(
823             new StringBuffer()
824                 .append("Properties of '")
825                 .append(pTable.getName())
826                 .append("' - nextObjects")
827                 .toString());
828         // Initialize the local reference of the edited object
829         this.myTable = pTable;
830         // Initialize components values
831         this.jTextFieldName.setText(this.myTable.getName());
832         this.jTextFieldCode.setText(this.myTable.getCode());
833         this.jTextFieldAlias.setText(this.myTable.getAlias());
834         this.jTextAreaDescription.setText(this.myTable.getDescription());
835         this.dataDict.getModel().setColumns(this.myTable.getData());
836         this.jTextAreaNotes.setText(this.myTable.getNotes());
837         this.jCheckBoxGenerateSQL.setSelected(!this.myTable.getSkipSql());
838         this.jComboBoxIdMethod.setSelectedItem(this.myTable.getIdMethod());
839         this.jCheckBoxHeavyIndexing.setSelected(
840             this.myTable.getHeavyIndexing());
841         this.jTextFieldJavaName.setText(this.myTable.getJavaName());
842         this.jCheckBoxAbstract.setSelected(this.myTable.getAbstractClass());
843         this.jTextFieldBaseClass.setText(this.myTable.getBaseClass());
844         this.jTextFieldBasePeer.setText(this.myTable.getBasePeer());
845         this.jComboBoxJavaNamingMethod.setSelectedItem(
846             this.myTable.getJavaNamingMethod());
847         // Enable/Disable components inside 'jPanelSqlProperites'
848         // according to the 'jCheckBoxGenerateSQL' value
849         boolean tmpBool = this.jCheckBoxGenerateSQL.isSelected();
850         for (int i = 0; i < this.jPanelSqlProperties.getComponentCount(); i++)
851         {
852             this.jPanelSqlProperties.getComponent(i).setEnabled(tmpBool);
853         }
854         // Set 'General', the active tab when opening the dialog box
855         this.jTabbedPane.setSelectedIndex(0);
856         // Set 'jButtonOK' as the default button
857         this.getRootPane().setDefaultButton(this.jButtonOK);
858         // Make the window visible
859         this.show();
860     }
861     /***  Save the informations into the edited object */
862     private void saveData()
863     {
864         this.myTable.setName(this.jTextFieldName.getText());
865         this.myTable.setCode(this.jTextFieldCode.getText());
866         this.myTable.setAlias(this.jTextFieldAlias.getText());
867         this.myTable.setData(this.dataDict.getModel().getColumns());
868         this.myTable.setNotes(this.jTextAreaNotes.getText());
869         this.myTable.setSkipSql(!this.jCheckBoxGenerateSQL.isSelected());
870         if (this.jComboBoxIdMethod.getSelectedItem() != null)
871         {
872             this.myTable.setIdMethod(
873                 this.jComboBoxIdMethod.getSelectedItem().toString());
874         }
875         this.myTable.setHeavyIndexing(this.jCheckBoxHeavyIndexing.isSelected());
876         this.myTable.setJavaName(this.jTextFieldJavaName.getText());
877         this.myTable.setAbstractClass(this.jCheckBoxAbstract.isSelected());
878         this.myTable.setBaseClass(this.jTextFieldBaseClass.getText());
879         this.myTable.setBasePeer(this.jTextFieldBasePeer.getText());
880         if (this.jComboBoxJavaNamingMethod.getSelectedItem() != null)
881         {
882             this.myTable.setJavaNamingMethod(
883                 this.jComboBoxJavaNamingMethod.getSelectedItem().toString());
884         }
885         // Reload the columns in the tree
886         NOTreeView.reloadBaseClassChildrens(this.myTable.getDynamicTreeNode());
887         //repaint
888         myTable.getMyModel().getModelView().setFullRefresh(true);
889         myTable.getMyModel().getModelView().drawingArea.repaint();
890     }
891 }