View Javadoc

1   package org.devaki.nextobjects.ui.workspace.models;
2   /*
3   
4   nextobjects Copyright (C) 2001-2005 Emmanuel Florent
5   
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by the
8   Free Software Foundation; either version 2 of the License, or (at your
9   option) any later version.
10  
11  This program is distributed in the hope that it will
12  be useful, but WITHOUT ANY WARRANTY; without even the implied warranty
13  of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14  PURPOSE. See the GNU General Public License for more details.
15  
16  You should have received a copy of the GNU General Public License along
17  with this program; if not, write to the Free Software Foundation, Inc., 59
18  Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19  
20  */
21  import org.devaki.nextobjects.ui.workspace.models.objects.AssociationEdit;
22  import org
23      .devaki
24      .nextobjects
25      .ui
26      .workspace
27      .models
28      .objects
29      .AssociationLinkEdit;
30  import org.devaki.nextobjects.ui.workspace.models.objects.ConstraintEdit;
31  import org.devaki.nextobjects.ui.workspace.models.objects.EntityEdit;
32  import org.devaki.nextobjects.ui.workspace.models.objects.LabelEdit;
33  import org
34      .devaki
35      .nextobjects
36      .ui
37      .workspace
38      .models
39      .objects
40      .InheritanceLinkEdit;
41  import org.devaki.nextobjects.ui.workspace.models.objects.TableEdit;
42  import org.devaki.nextobjects.ui.workspace.models.styles.ClassStyleEdit;
43  import org.devaki.nextobjects.ui.workspace.models.styles.LineStyleEdit;
44  import org.devaki.nextobjects.workspace.models.objects.Association;
45  import org.devaki.nextobjects.workspace.models.objects.AssociationLink;
46  import org.devaki.nextobjects.workspace.models.objects.BaseObject;
47  import org.devaki.nextobjects.workspace.models.objects.Constraint;
48  import org.devaki.nextobjects.workspace.models.objects.Entity;
49  import org.devaki.nextobjects.workspace.models.objects.Label;
50  import org.devaki.nextobjects.workspace.models.objects.InheritanceLink;
51  import org.devaki.nextobjects.workspace.models.objects.Table;
52  import org.devaki.nextobjects.workspace.models.graphics.ObjectView;
53  import org.devaki.nextobjects.workspace.models.graphics.ClassView;
54  import org.devaki.nextobjects.workspace.models.graphics.LineView;
55  import org.devaki.nextobjects.ui.menus.ModelPopupMenu;
56  import org.devaki.nextobjects.util.ModelMan;
57  /***
58   * This class calls the properties et styles editors for each object
59   */
60  public final class EditorFactory
61  {
62      /*** model editor */
63      private static ModelEdit modelEdit = new ModelEdit();
64      /*** entity editor */
65      private static EntityEdit entityEdit = new EntityEdit();
66      /*** association editor */
67      private static AssociationEdit associationEdit = new AssociationEdit();
68      /*** table editor */
69      private static TableEdit tableEdit = new TableEdit();
70      /*** association link editor */
71      private static AssociationLinkEdit associationLinkEdit =
72          new AssociationLinkEdit();
73      /*** inheritance link editor */
74      private static InheritanceLinkEdit inheritanceLinkEdit =
75          new InheritanceLinkEdit();
76      /*** constraint editor */
77      private static ConstraintEdit constraintEdit = new ConstraintEdit();
78      /*** label editor */
79      private static LabelEdit labelEdit = new LabelEdit();
80      /*** style editor for classes */
81      private static ClassStyleEdit classStyleEdit;
82      /*** style editor for lines */
83      private static LineStyleEdit lineStyleEdit;
84      /*** model popup menu */
85      private static ModelPopupMenu modelPopupMenu = new ModelPopupMenu();
86      /***
87       * Constructor forbid instanciation
88       */
89      private EditorFactory()
90      {
91      }
92      /***
93       * Call current object editing window
94       * If no current object call current model object editing window
95       * @param pObject the object to show the editor
96       */
97      public static void getObjectEdit(final BaseObject pObject)
98      {
99          if (pObject == null)
100         {
101             EditorFactory.getModelEdit();
102         }
103         else if (pObject instanceof Association)
104         {
105             EditorFactory.getAssociationEdit((Association) pObject);
106         }
107         else if (pObject instanceof AssociationLink)
108         {
109             EditorFactory.getAssociationLinkEdit((AssociationLink) pObject);
110         }
111         else if (pObject instanceof Constraint)
112         {
113             EditorFactory.getConstraintEdit((Constraint) pObject);
114         }
115         else if (pObject instanceof Entity)
116         {
117             EditorFactory.getEntityEdit((Entity) pObject);
118         }
119         else if (pObject instanceof InheritanceLink)
120         {
121             EditorFactory.getInheritanceEdit((InheritanceLink) pObject);
122         }
123         else if (pObject instanceof Label)
124         {
125             EditorFactory.getLabelEdit((Label) pObject);
126         }
127         else if (pObject instanceof Table)
128         {
129             EditorFactory.getTableEdit((Table) pObject);
130         }
131     }
132     /***
133      * Call the 'ProjectPreferences' window
134      */
135     public static void getModelEdit()
136     {
137         modelEdit.setData(ModelMan.getCurrentModel());
138     }
139     /***
140      * Call the 'AssociationEdit' window
141      * @param pAssociation the context Association
142      */
143     public static void getAssociationEdit(final Association pAssociation)
144     {
145         associationEdit.setData(pAssociation);
146     }
147     /***
148      * Call the 'AssociationLinkEdit' window
149      * @param pLink the context AssociationLink
150      */
151     public static void getAssociationLinkEdit(final AssociationLink pLink)
152     {
153         associationLinkEdit.setData(pLink);
154     }
155     /***
156      * Call the 'ContraintEdit' window
157      * @param pConstraint the context Constraint
158      */
159     public static void getConstraintEdit(final Constraint pConstraint)
160     {
161         constraintEdit.setData(pConstraint);
162     }
163     /***
164      * Call the 'EntityEdit' window
165      * @param pEntity the context Entity
166      */
167     public static void getEntityEdit(final Entity pEntity)
168     {
169         entityEdit.setData(pEntity);
170     }
171     /***
172      * Call the 'InheritanceLinkEdit' window
173      * @param pLink the context InheritanceLink
174      */
175     public static void getInheritanceEdit(final InheritanceLink pLink)
176     {
177         inheritanceLinkEdit.setData(pLink);
178     }
179     /***
180      * Call the 'LabelEdit' window
181      * @param pLabel the context Label
182      */
183     public static void getLabelEdit(final Label pLabel)
184     {
185         labelEdit.setData(pLabel);
186     }
187     /***
188      * Call the 'TableEdit' window
189      * @param pTable the context Table
190      */
191     public static void getTableEdit(final Table pTable)
192     {
193         tableEdit.setData(pTable);
194     }
195     /***
196      * Get an object style window
197      * @param pObjectView the context object view
198      */
199     public static void getObjectStyle(final ObjectView pObjectView)
200     {
201         if (pObjectView instanceof ClassView)
202         {
203             classStyleEdit = new ClassStyleEdit(pObjectView);
204             classStyleEdit.setData(((ClassView) pObjectView).getStyle());
205         }
206         else if (pObjectView instanceof LineView)
207         {
208             lineStyleEdit = new LineStyleEdit(pObjectView);
209             lineStyleEdit.setData(((LineView) pObjectView).getStyle());
210         }
211     }
212 }