View Javadoc

1   package org.devaki.nextobjects.workspace.models.objects;
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  
22  import java.io.Serializable;
23  import java.util.Vector;
24  import org.devaki.nextobjects.ui.components.CustomTreeNode;
25  import org.devaki.nextobjects.workspace.models.BaseModel;
26  import org.devaki.nextobjects.workspace.models.graphics.ObjectView;
27  /***
28   * Objects of the models.
29   * @author <a href="mailto:eflorent@devaki.org">Emmanuel Florent</a>
30   */
31  public abstract class BaseObject implements Serializable
32  {
33      /***
34      * The name
35      */
36      private String name = "";
37      /***
38      * The code
39      */
40      private String code = "";
41      /***
42      * The description
43      */
44      private String description = "";
45      /***
46      * Notes
47      */
48      private String notes = "";
49      /***
50      * Coumns associated
51      */
52      private Vector columns = new Vector(1);
53      /***
54        * Model associated
55        */
56      private BaseModel myModel;
57      /***
58      *Nodel associated
59      */
60      private transient CustomTreeNode customTreeNode;
61      /***
62      * Has the data of the object been modified
63      */
64      private boolean dataChanged = false;
65      /***
66       * Construct a standard nextGraphicsObject
67       */
68      public BaseObject()
69      {
70      }
71      /***
72       * Construct an object with a pre-defined model
73       * @param pModel the context model
74       */
75      public BaseObject(final BaseModel pModel)
76      {
77          this.myModel = pModel;
78      }
79      /***
80       * Construct a (next)Object by copying another nextGraphicsObject
81       * @param pObject the object to clone
82       */
83      public BaseObject(final BaseObject pObject)
84      {
85          this.setName(pObject.getName());
86          this.setCode(pObject.getCode());
87          this.setDescription(pObject.getDescription());
88          this.setNotes(pObject.getNotes());
89      }
90      /***
91       * Get the object view
92       * @return the objectview
93       */
94      public abstract ObjectView getObjectView();
95      /***
96       * Returns a String representation of the object
97       * Really usefull in the treeview ow/ would avoid.
98       * @return the name
99       */
100     public final String toString()
101     {
102         return this.name;
103     }
104     /***
105      * Set notes for the object
106      * @param pNotes the notes
107      */
108     public final void setNotes(final String pNotes)
109     {
110         this.notes = pNotes;
111     }
112     /***
113      * Changes the name
114      * @param pName the name
115      */
116     public final void setName(final String pName)
117     {
118         this.name = pName;
119         if (this.myModel != null)
120         {
121             this.resetModelStatus();
122         }
123     }
124     /***
125      * Changes the code
126      * @param pCode the code
127      */
128     public final void setCode(final String pCode)
129     {
130         this.code = pCode;
131         if (this.myModel != null)
132         {
133             this.resetModelStatus();
134         }
135     }
136     /***
137      * Changes the description
138      * @param pDescription the description
139      */
140     public final void setDescription(final String pDescription)
141     {
142         this.description = pDescription;
143         if (this.myModel != null)
144         {
145             this.resetModelStatus();
146         }
147     }
148     /***
149      * Set if the data has changed or not
150      * @param pDataChanged is the data changed
151      */
152     public final void setDataChanged(final boolean pDataChanged)
153     {
154         this.dataChanged = pDataChanged;
155     }
156     /***
157      * Changes the model
158      * @param pModel the context model
159      */
160     public final void setMyModel(final BaseModel pModel)
161     {
162         this.myModel = pModel;
163         this.resetModelStatus();
164     }
165     /***
166      * Defines the CustomTreeNode associated to the current object
167      * @param pNode the node
168      */
169     public final void setDynamicTreeNode(final CustomTreeNode pNode)
170     {
171         this.customTreeNode = pNode;
172     }
173     /***
174      * Get notes for the object
175      * @return the notes
176      */
177     public final String getNotes()
178     {
179         return this.notes;
180     }
181     /***
182      * Get the name
183      * @return the name
184      */
185     public final String getName()
186     {
187         return this.name;
188     }
189     /***
190      * Get the code
191      * @return the code
192      */
193     public final String getCode()
194     {
195         return this.code;
196     }
197     /***
198      * Get the description
199      * @return the description
200      */
201     public final String getDescription()
202     {
203         return this.description;
204     }
205     /***
206      * Return the list of fields
207      * @return the columns
208      */
209     public final Vector getData()
210     {
211         return this.columns;
212     }
213     /***
214      * Return if the data has changed or not
215      * @return is data changed
216      */
217     public final boolean getDataChanged()
218     {
219         return this.dataChanged;
220     }
221     /***
222      * Get the model
223      * @return the model
224      */
225     public final BaseModel getMyModel()
226     {
227         return this.myModel;
228     }
229     /***
230      * Get the CustomTreeNode object associated
231      * @return the tree node
232      */
233     public final CustomTreeNode getDynamicTreeNode()
234     {
235         return this.customTreeNode;
236     }
237     /***
238      * Reset the status of the model because it has been changed
239      */
240     public final void resetModelStatus()
241     {
242         this.myModel.setSaved(false);
243         this.myModel.setVerified(false);
244     }
245     /***
246      * Get the columns of the object
247      * @return the columns
248      */
249     public final Vector getColumns()
250     {
251         return columns;
252     }
253 
254     /***
255      * Set the columns of the object
256      * @param vector a set of columns
257      */
258     public final void setColumns(final Vector vector)
259     {
260         columns = vector;
261     }
262 
263 } // End of class