Revision 34114 branches/v2_0_0_prep/applications/appgvSIG/src/org/gvsig/app/project/documents/AbstractDocumentManager.java
AbstractDocumentManager.java | ||
---|---|---|
73 | 73 |
* @return Image. |
74 | 74 |
*/ |
75 | 75 |
public ImageIcon getIcon() { |
76 |
return PluginServices.getIconTheme().get("document-icon-sel");
|
|
76 |
return PluginServices.getIconTheme().get("document-icon-sel");
|
|
77 | 77 |
} |
78 | 78 |
|
79 | 79 |
/** |
... | ... | |
82 | 82 |
* @return Image. |
83 | 83 |
*/ |
84 | 84 |
public ImageIcon getIconSelected() { |
85 |
return PluginServices.getIconTheme().get("document-icon");
|
|
85 |
return PluginServices.getIconTheme().get("document-icon");
|
|
86 | 86 |
} |
87 | 87 |
|
88 | 88 |
/** |
... | ... | |
113 | 113 |
} |
114 | 114 |
|
115 | 115 |
/** |
116 |
* @see ExtensionBuilder |
|
117 |
*/ |
|
116 |
* @see ExtensionBuilder
|
|
117 |
*/
|
|
118 | 118 |
public Object create(Object[] args) { |
119 | 119 |
return this; |
120 | 120 |
} |
... | ... | |
122 | 122 |
/** |
123 | 123 |
* @see ExtensionBuilder |
124 | 124 |
*/ |
125 |
@SuppressWarnings("rawtypes")
|
|
125 |
@SuppressWarnings("rawtypes")
|
|
126 | 126 |
public Object create(Map args) { |
127 | 127 |
return this; |
128 | 128 |
} |
129 | 129 |
|
130 | 130 |
public IWindow getMainWindow(Document doc) { |
131 |
return getMainWindow(doc, null);
|
|
132 |
}
|
|
131 |
return getMainWindow(doc, null);
|
|
132 |
}
|
|
133 | 133 |
|
134 |
|
|
134 |
|
|
135 | 135 |
/** |
136 |
* Return true if the name exists to another document. |
|
137 |
* |
|
138 |
* @param project |
|
139 |
* @param documentName |
|
140 |
* |
|
141 |
* @return True if the name exists. |
|
142 |
* @deprecated use instead project.getProjectDocument |
|
143 |
*/ |
|
144 |
public boolean existName(Project project, String documentName) { |
|
145 |
return project.getDocument(documentName, getTypeName())!=null; |
|
146 |
} |
|
147 |
|
|
148 |
/** |
|
149 |
* Return the class or interface for the documents managed by this factory. |
|
150 |
* @return The document class; |
|
151 |
*/ |
|
152 |
@SuppressWarnings("rawtypes") |
|
153 |
abstract protected Class getDocumentClass(); |
|
154 |
|
|
155 |
public Object createFromState(PersistentState state) throws PersistenceException { |
|
156 |
Document doc = this.createDocument(); |
|
157 |
return doc; |
|
158 |
} |
|
136 |
* Return true if the name exists to another document. |
|
137 |
* |
|
138 |
* @param project |
|
139 |
* @param documentName |
|
140 |
* |
|
141 |
* @return True if the name exists. |
|
142 |
* @deprecated use instead project.getProjectDocument |
|
143 |
*/ |
|
144 |
public boolean existName(Project project, String documentName) { |
|
145 |
return project.getDocument(documentName, getTypeName())!=null; |
|
146 |
} |
|
159 | 147 |
|
160 |
public void loadFromState(PersistentState state, Object object) throws PersistenceException { |
|
161 |
Document doc = (Document) object; |
|
162 |
doc.loadFromState(state); |
|
163 |
} |
|
148 |
/** |
|
149 |
* Return the class or interface for the documents managed by this factory. |
|
150 |
* @return The document class; |
|
151 |
*/ |
|
152 |
@SuppressWarnings("rawtypes") |
|
153 |
abstract protected Class getDocumentClass(); |
|
164 | 154 |
|
165 |
public void saveToState(PersistentState state, Object obj) throws PersistenceException { |
|
166 |
Document doc = (Document) obj; |
|
167 |
doc.saveToState(state); |
|
168 |
|
|
169 |
} |
|
155 |
public Object createFromState(PersistentState state) throws PersistenceException { |
|
156 |
Document doc = this.createDocument(); |
|
157 |
return doc; |
|
158 |
} |
|
170 | 159 |
|
171 |
public boolean manages(Object object) { |
|
172 |
return object instanceof TableDocument; |
|
173 |
} |
|
160 |
public void loadFromState(PersistentState state, Object object) throws PersistenceException { |
|
161 |
Document doc = (Document) object; |
|
162 |
doc.loadFromState(state); |
|
163 |
} |
|
174 | 164 |
|
175 |
@SuppressWarnings({ "rawtypes", "unchecked" }) |
|
176 |
public boolean manages(Class theClass) { |
|
177 |
return this.getDocumentClass().isAssignableFrom(theClass); |
|
178 |
} |
|
165 |
public void saveToState(PersistentState state, Object obj) throws PersistenceException { |
|
166 |
Document doc = (Document) obj; |
|
167 |
doc.saveToState(state); |
|
179 | 168 |
|
180 |
@SuppressWarnings("rawtypes") |
|
181 |
public boolean manages(PersistentState state) { |
|
182 |
try { |
|
183 |
Class theClass; |
|
184 |
theClass = (Class) Class.forName(state.getTheClassName()); |
|
185 |
return manages(theClass); |
|
186 |
} catch (ClassNotFoundException e) { |
|
187 |
return false; |
|
188 |
} |
|
189 |
} |
|
169 |
} |
|
190 | 170 |
|
191 |
public List<DynStruct> getDefinitions() { |
|
192 |
DynStruct definition = this.getDefinition(this.getDocumentClass().getName()); |
|
193 |
List<DynStruct> definitions = new ArrayList<DynStruct>(); |
|
194 |
definitions.add(definition); |
|
195 |
return definitions; |
|
196 |
} |
|
171 |
public boolean manages(Object object) { |
|
172 |
return object instanceof TableDocument; |
|
173 |
} |
|
197 | 174 |
|
198 |
public String getDomainName() { |
|
199 |
return PersistenceManager.DEFAULT_DOMAIN_NAME; |
|
200 |
} |
|
175 |
@SuppressWarnings({ "rawtypes", "unchecked" }) |
|
176 |
public boolean manages(Class theClass) { |
|
177 |
return this.getDocumentClass().isAssignableFrom(theClass); |
|
178 |
} |
|
201 | 179 |
|
202 |
public String getDomainURL() { |
|
203 |
return PersistenceManager.DEFAULT_DOMAIN_URL; |
|
204 |
} |
|
180 |
@SuppressWarnings("rawtypes") |
|
181 |
public boolean manages(PersistentState state) { |
|
182 |
try { |
|
183 |
Class theClass; |
|
184 |
theClass = (Class) Class.forName(state.getTheClassName()); |
|
185 |
return manages(theClass); |
|
186 |
} catch (ClassNotFoundException e) { |
|
187 |
return false; |
|
188 |
} |
|
189 |
} |
|
205 | 190 |
|
206 |
@SuppressWarnings({ "unchecked", "rawtypes" })
|
|
207 |
public List getManagedClasses() {
|
|
208 |
List classes = new ArrayList();
|
|
209 |
classes.add(this.getDocumentClass());
|
|
210 |
return classes;
|
|
211 |
} |
|
191 |
public List<DynStruct> getDefinitions() {
|
|
192 |
DynStruct definition = this.getDefinition(this.getDocumentClass().getName());
|
|
193 |
List<DynStruct> definitions = new ArrayList<DynStruct>();
|
|
194 |
definitions.add(definition);
|
|
195 |
return definitions;
|
|
196 |
}
|
|
212 | 197 |
|
213 |
@SuppressWarnings("rawtypes") |
|
214 |
public Class getManagedClass(Object object) { |
|
215 |
return this.getDocumentClass(); |
|
216 |
} |
|
198 |
public String getDomainName() { |
|
199 |
return PersistenceManager.DEFAULT_DOMAIN_NAME; |
|
200 |
} |
|
217 | 201 |
|
218 |
@SuppressWarnings("rawtypes") |
|
219 |
public Class getManagedClass(PersistentState state) { |
|
220 |
return this.getDocumentClass(); |
|
221 |
} |
|
202 |
public String getDomainURL() { |
|
203 |
return PersistenceManager.DEFAULT_DOMAIN_URL; |
|
204 |
} |
|
222 | 205 |
|
223 |
@SuppressWarnings("rawtypes") |
|
224 |
public Class getManagedClass(String name) { |
|
225 |
return this.getDocumentClass(); |
|
226 |
} |
|
206 |
@SuppressWarnings({ "unchecked", "rawtypes" }) |
|
207 |
public List getManagedClasses() { |
|
208 |
List classes = new ArrayList(); |
|
209 |
classes.add(this.getDocumentClass()); |
|
210 |
return classes; |
|
211 |
} |
|
227 | 212 |
|
213 |
@SuppressWarnings("rawtypes") |
|
214 |
public Class getManagedClass(Object object) { |
|
215 |
return this.getDocumentClass(); |
|
216 |
} |
|
228 | 217 |
|
218 |
@SuppressWarnings("rawtypes") |
|
219 |
public Class getManagedClass(PersistentState state) { |
|
220 |
return this.getDocumentClass(); |
|
221 |
} |
|
222 |
|
|
223 |
@SuppressWarnings("rawtypes") |
|
224 |
public Class getManagedClass(String name) { |
|
225 |
return this.getDocumentClass(); |
|
226 |
} |
|
227 |
|
|
228 |
@SuppressWarnings("rawtypes") |
|
229 |
public String getManagedClassName(Object object) { |
|
230 |
Class clazz = this.getManagedClass(object); |
|
231 |
if (clazz != null){ |
|
232 |
return clazz.getName(); |
|
233 |
} |
|
234 |
return null; |
|
235 |
} |
|
236 |
|
|
237 |
|
|
229 | 238 |
} |
Also available in: Unified diff