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