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