Revision 1830 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/ProjectElement.java
ProjectElement.java | ||
---|---|---|
40 | 40 |
*/ |
41 | 41 |
package com.iver.cit.gvsig.project; |
42 | 42 |
|
43 |
import java.beans.PropertyChangeListener; |
|
44 |
import java.beans.PropertyChangeSupport; |
|
45 |
import java.io.Serializable; |
|
46 |
import java.text.DateFormat; |
|
47 |
import java.util.Date; |
|
43 |
import com.hardcode.driverManager.DriverLoadException; |
|
48 | 44 |
|
49 |
import com.hardcode.driverManager.DriverLoadException; |
|
50 | 45 |
import com.iver.andami.messages.NotificationManager; |
46 |
|
|
51 | 47 |
import com.iver.cit.gvsig.fmap.DriverException; |
52 | 48 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
53 | 49 |
import com.iver.cit.gvsig.fmap.layers.CancelationException; |
54 | 50 |
import com.iver.cit.gvsig.fmap.layers.DifferentVersionException; |
55 | 51 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
52 |
|
|
56 | 53 |
import com.iver.utiles.XMLEntity; |
57 | 54 |
|
55 |
import java.beans.PropertyChangeListener; |
|
56 |
import java.beans.PropertyChangeSupport; |
|
58 | 57 |
|
58 |
import java.io.Serializable; |
|
59 |
|
|
60 |
import java.text.DateFormat; |
|
61 |
|
|
62 |
import java.util.Date; |
|
63 |
|
|
64 |
|
|
59 | 65 |
/** |
60 | 66 |
* Clase base de los elementos del proyecto (mapas, tablas y vistas) |
61 | 67 |
* |
62 | 68 |
* @author Fernando Gonz?lez Cort?s |
63 | 69 |
*/ |
64 | 70 |
public abstract class ProjectElement implements Serializable { |
65 |
protected PropertyChangeSupport change; |
|
66 |
protected Project project; |
|
67 |
protected String name; |
|
68 |
protected String creationDate; |
|
69 |
protected String owner; |
|
70 |
protected String comment; |
|
71 |
protected PropertyChangeSupport change; |
|
72 |
protected Project project; |
|
73 |
protected int index; |
|
74 |
protected String name; |
|
75 |
protected String creationDate; |
|
76 |
protected String owner; |
|
77 |
protected String comment; |
|
71 | 78 |
|
72 |
/**
|
|
73 |
* Creates a new ProjectElement object.
|
|
74 |
*/
|
|
75 |
public ProjectElement() {
|
|
76 |
creationDate = DateFormat.getDateInstance().format(new Date());
|
|
77 |
change = new PropertyChangeSupport(this);
|
|
78 |
}
|
|
79 |
/**
|
|
80 |
* Creates a new ProjectElement object.
|
|
81 |
*/
|
|
82 |
public ProjectElement() {
|
|
83 |
creationDate = DateFormat.getDateInstance().format(new Date());
|
|
84 |
change = new PropertyChangeSupport(this);
|
|
85 |
}
|
|
79 | 86 |
|
80 |
/**
|
|
81 |
* @see java.lang.Object#toString()
|
|
82 |
*/
|
|
83 |
public String toString() {
|
|
84 |
return name;
|
|
85 |
}
|
|
87 |
/**
|
|
88 |
* @see java.lang.Object#toString()
|
|
89 |
*/
|
|
90 |
public String toString() {
|
|
91 |
return name;
|
|
92 |
}
|
|
86 | 93 |
|
87 |
/**
|
|
88 |
* Obtiene el nombre del elemento
|
|
89 |
*
|
|
90 |
* @return
|
|
91 |
*/
|
|
92 |
public String getName() {
|
|
93 |
return name;
|
|
94 |
}
|
|
94 |
/**
|
|
95 |
* Obtiene el nombre del elemento
|
|
96 |
*
|
|
97 |
* @return
|
|
98 |
*/
|
|
99 |
public String getName() {
|
|
100 |
return name;
|
|
101 |
}
|
|
95 | 102 |
|
96 |
/**
|
|
97 |
* Establece el nombre del elemento
|
|
98 |
*
|
|
99 |
* @param string
|
|
100 |
*/
|
|
101 |
public void setName(String string) {
|
|
102 |
String oldValue = name;
|
|
103 |
name = string;
|
|
104 |
change.firePropertyChange("name", oldValue, name);
|
|
105 |
}
|
|
103 |
/**
|
|
104 |
* Establece el nombre del elemento
|
|
105 |
*
|
|
106 |
* @param string
|
|
107 |
*/
|
|
108 |
public void setName(String string) {
|
|
109 |
String oldValue = name;
|
|
110 |
name = string;
|
|
111 |
change.firePropertyChange("name", oldValue, name);
|
|
112 |
}
|
|
106 | 113 |
|
107 |
/**
|
|
108 |
* Obtiene la fecha de creaci?n del elemento
|
|
109 |
*
|
|
110 |
* @return
|
|
111 |
*/
|
|
112 |
public String getCreationDate() {
|
|
113 |
return creationDate;
|
|
114 |
}
|
|
114 |
/**
|
|
115 |
* Obtiene la fecha de creaci?n del elemento
|
|
116 |
*
|
|
117 |
* @return
|
|
118 |
*/
|
|
119 |
public String getCreationDate() {
|
|
120 |
return creationDate;
|
|
121 |
}
|
|
115 | 122 |
|
116 |
/**
|
|
117 |
* Obtiene el propietario del elemento
|
|
118 |
*
|
|
119 |
* @return
|
|
120 |
*/
|
|
121 |
public String getOwner() {
|
|
122 |
return owner;
|
|
123 |
}
|
|
123 |
/**
|
|
124 |
* Obtiene el propietario del elemento
|
|
125 |
*
|
|
126 |
* @return
|
|
127 |
*/
|
|
128 |
public String getOwner() {
|
|
129 |
return owner;
|
|
130 |
}
|
|
124 | 131 |
|
125 |
/**
|
|
126 |
* Establece la fecha de creaci?n del elemento.
|
|
127 |
*
|
|
128 |
* @param string
|
|
129 |
*/
|
|
130 |
public void setCreationDate(String string) {
|
|
131 |
creationDate = string;
|
|
132 |
change.firePropertyChange("creationDate", creationDate, creationDate);
|
|
133 |
}
|
|
132 |
/**
|
|
133 |
* Establece la fecha de creaci?n del elemento.
|
|
134 |
*
|
|
135 |
* @param string
|
|
136 |
*/
|
|
137 |
public void setCreationDate(String string) {
|
|
138 |
creationDate = string;
|
|
139 |
change.firePropertyChange("creationDate", creationDate, creationDate);
|
|
140 |
}
|
|
134 | 141 |
|
135 |
/**
|
|
136 |
* Establece el propietario del elemento
|
|
137 |
*
|
|
138 |
* @param string
|
|
139 |
*/
|
|
140 |
public void setOwner(String string) {
|
|
141 |
owner = string;
|
|
142 |
change.firePropertyChange("owner", owner, owner);
|
|
143 |
}
|
|
142 |
/**
|
|
143 |
* Establece el propietario del elemento
|
|
144 |
*
|
|
145 |
* @param string
|
|
146 |
*/
|
|
147 |
public void setOwner(String string) {
|
|
148 |
owner = string;
|
|
149 |
change.firePropertyChange("owner", owner, owner);
|
|
150 |
}
|
|
144 | 151 |
|
145 |
/**
|
|
146 |
* Obtiene los comentarios del proyecto
|
|
147 |
*
|
|
148 |
* @return
|
|
149 |
*/
|
|
150 |
public String getComment() {
|
|
151 |
return comment;
|
|
152 |
}
|
|
152 |
/**
|
|
153 |
* Obtiene los comentarios del proyecto
|
|
154 |
*
|
|
155 |
* @return
|
|
156 |
*/
|
|
157 |
public String getComment() {
|
|
158 |
return comment;
|
|
159 |
}
|
|
153 | 160 |
|
154 |
/**
|
|
155 |
* Establece los comentarios del proyecto
|
|
156 |
*
|
|
157 |
* @param string
|
|
158 |
*/
|
|
159 |
public void setComment(String string) {
|
|
160 |
comment = string;
|
|
161 |
change.firePropertyChange("comment", comment, comment);
|
|
162 |
}
|
|
161 |
/**
|
|
162 |
* Establece los comentarios del proyecto
|
|
163 |
*
|
|
164 |
* @param string
|
|
165 |
*/
|
|
166 |
public void setComment(String string) {
|
|
167 |
comment = string;
|
|
168 |
change.firePropertyChange("comment", comment, comment);
|
|
169 |
}
|
|
163 | 170 |
|
164 |
/**
|
|
165 |
* A?ade un listener para los cambios en las bounded properties
|
|
166 |
*
|
|
167 |
* @param listener
|
|
168 |
*/
|
|
169 |
public synchronized void addPropertyChangeListener(
|
|
170 |
PropertyChangeListener listener) {
|
|
171 |
change.addPropertyChangeListener(listener);
|
|
172 |
}
|
|
171 |
/**
|
|
172 |
* A?ade un listener para los cambios en las bounded properties
|
|
173 |
*
|
|
174 |
* @param listener
|
|
175 |
*/
|
|
176 |
public synchronized void addPropertyChangeListener(
|
|
177 |
PropertyChangeListener listener) {
|
|
178 |
change.addPropertyChangeListener(listener);
|
|
179 |
}
|
|
173 | 180 |
|
174 |
/**
|
|
175 |
* DOCUMENT ME!
|
|
176 |
*
|
|
177 |
* @return DOCUMENT ME!
|
|
178 |
* @throws DriverException
|
|
179 |
*/
|
|
180 |
public XMLEntity getXMLEntity() {
|
|
181 |
XMLEntity xml = new XMLEntity();
|
|
182 |
xml.putProperty("className",this.getClass().getName());
|
|
183 |
xml.putProperty("comment", comment);
|
|
184 |
xml.putProperty("creationDate", creationDate);
|
|
185 |
xml.putProperty("name", name);
|
|
186 |
xml.putProperty("owner", owner);
|
|
181 |
/**
|
|
182 |
* DOCUMENT ME!
|
|
183 |
*
|
|
184 |
* @return DOCUMENT ME!
|
|
185 |
* @throws XMLException
|
|
186 |
*/
|
|
187 |
public XMLEntity getXMLEntity() throws XMLException {
|
|
188 |
XMLEntity xml = new XMLEntity();
|
|
189 |
xml.putProperty("className", this.getClass().getName());
|
|
190 |
xml.putProperty("comment", comment);
|
|
191 |
xml.putProperty("creationDate", creationDate);
|
|
192 |
xml.putProperty("name", name);
|
|
193 |
xml.putProperty("owner", owner);
|
|
187 | 194 |
|
188 |
//xml.addChild(mapContext.getXMLEntity);
|
|
189 |
return xml;
|
|
190 |
}
|
|
195 |
//xml.addChild(mapContext.getXMLEntity);
|
|
196 |
return xml;
|
|
197 |
}
|
|
191 | 198 |
|
192 |
/** |
|
193 |
* DOCUMENT ME! |
|
194 |
* |
|
195 |
* @param xml DOCUMENT ME! |
|
196 |
* @param p DOCUMENT ME! |
|
197 |
* |
|
198 |
* @return DOCUMENT ME! |
|
199 |
* @throws XMLException |
|
200 |
* @throws DriverException |
|
201 |
* @throws DriverIOException |
|
202 |
* @throws DifferentVersionException |
|
203 |
* @throws CancelationException |
|
204 |
* @throws DifferentVersionException |
|
205 |
* @throws ClassNotFoundException |
|
206 |
* @throws InstantiationException |
|
207 |
* @throws IllegalAccessException |
|
208 |
* @throws DriverIOException |
|
209 |
* @throws DriverLoadException |
|
210 |
*/ |
|
211 |
public static ProjectElement createFromXML(XMLEntity xml, Project p) throws XMLException, DriverException, DriverIOException{ |
|
212 |
ProjectElement pe = null; |
|
199 |
/** |
|
200 |
* DOCUMENT ME! |
|
201 |
* |
|
202 |
* @param xml DOCUMENT ME! |
|
203 |
* @param p DOCUMENT ME! |
|
204 |
* |
|
205 |
* @return DOCUMENT ME! |
|
206 |
* |
|
207 |
* @throws XMLException |
|
208 |
* @throws DriverException |
|
209 |
* @throws DriverIOException |
|
210 |
*/ |
|
211 |
public static ProjectElement createFromXML(XMLEntity xml, Project p) |
|
212 |
throws XMLException, DriverException, DriverIOException { |
|
213 |
ProjectElement pe = null; |
|
213 | 214 |
|
214 |
Class clase; |
|
215 |
try { |
|
216 |
clase = Class.forName(xml.getStringProperty("className")); |
|
215 |
Class clase; |
|
216 |
|
|
217 |
try { |
|
218 |
clase = Class.forName(xml.getStringProperty("className")); |
|
217 | 219 |
pe = (ProjectElement) clase.newInstance(); |
218 |
} catch (ClassNotFoundException e) {
|
|
219 |
NotificationManager.addError("Clase de ProjectElement no reconocida",
|
|
220 |
e);
|
|
221 |
} catch (InstantiationException e) {
|
|
222 |
NotificationManager.addError("Clase de ProjectElement no reconocida",
|
|
223 |
e);
|
|
224 |
} catch (IllegalAccessException e) {
|
|
225 |
NotificationManager.addError("Clase de ProjectElement no reconocida",
|
|
226 |
e);
|
|
227 |
}
|
|
220 |
} catch (ClassNotFoundException e) { |
|
221 |
NotificationManager.addError("Clase de ProjectElement no reconocida",
|
|
222 |
e);
|
|
223 |
} catch (InstantiationException e) { |
|
224 |
NotificationManager.addError("Clase de ProjectElement no reconocida",
|
|
225 |
e);
|
|
226 |
} catch (IllegalAccessException e) { |
|
227 |
NotificationManager.addError("Clase de ProjectElement no reconocida",
|
|
228 |
e);
|
|
229 |
} |
|
228 | 230 |
|
229 |
pe.setComment(xml.getStringProperty("comment"));
|
|
230 |
pe.setCreationDate(xml.getStringProperty("creationDate"));
|
|
231 |
pe.setName(xml.getStringProperty("name"));
|
|
232 |
pe.setOwner(xml.getStringProperty("owner"));
|
|
233 |
pe.project = p;
|
|
231 |
pe.setComment(xml.getStringProperty("comment"));
|
|
232 |
pe.setCreationDate(xml.getStringProperty("creationDate"));
|
|
233 |
pe.setName(xml.getStringProperty("name"));
|
|
234 |
pe.setOwner(xml.getStringProperty("owner"));
|
|
235 |
pe.project = p;
|
|
234 | 236 |
|
235 |
pe.setXMLEntity(xml,p); |
|
237 |
pe.setXMLEntity(xml, p);
|
|
236 | 238 |
|
237 |
return pe;
|
|
238 |
}
|
|
239 |
return pe;
|
|
240 |
}
|
|
239 | 241 |
|
240 |
/** |
|
241 |
* DOCUMENT ME! |
|
242 |
* |
|
243 |
* @param xml DOCUMENT ME! |
|
244 |
* @throws IllegalAccessException |
|
245 |
* @throws InstantiationException |
|
246 |
* @throws ClassNotFoundException |
|
247 |
* @throws DriverIOException |
|
248 |
* @throws DriverLoadException |
|
249 |
* @throws XMLException |
|
250 |
* @throws DriverIOException |
|
251 |
*/ |
|
252 |
public abstract void setXMLEntity(XMLEntity xml,Project p)throws XMLException, DriverException, DriverIOException; |
|
242 |
/** |
|
243 |
* DOCUMENT ME! |
|
244 |
* |
|
245 |
* @param xml DOCUMENT ME! |
|
246 |
* @param p DOCUMENT ME! |
|
247 |
* |
|
248 |
* @throws XMLException |
|
249 |
* @throws DriverException |
|
250 |
* @throws DriverIOException |
|
251 |
*/ |
|
252 |
public abstract void setXMLEntity(XMLEntity xml, Project p) |
|
253 |
throws XMLException, DriverException, DriverIOException; |
|
254 |
|
|
255 |
/** |
|
256 |
* DOCUMENT ME! |
|
257 |
* |
|
258 |
* @return DOCUMENT ME! |
|
259 |
*/ |
|
253 | 260 |
public Project getProject() { |
254 | 261 |
return project; |
255 | 262 |
} |
256 |
public void setProject(Project project) { |
|
263 |
|
|
264 |
/** |
|
265 |
* DOCUMENT ME! |
|
266 |
* |
|
267 |
* @param project DOCUMENT ME! |
|
268 |
*/ |
|
269 |
public void setProject(Project project, int index) { |
|
257 | 270 |
this.project = project; |
271 |
this.index = index; |
|
258 | 272 |
} |
273 |
public int getIndex() { |
|
274 |
return index; |
|
275 |
} |
|
259 | 276 |
} |
Also available in: Unified diff