Revision 9392 trunk/applications/appgvSIG/src/com/iver/cit/gvsig/project/documents/layout/ProjectMap.java
ProjectMap.java | ||
---|---|---|
51 | 51 |
import com.iver.cit.gvsig.fmap.DriverException; |
52 | 52 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
53 | 53 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
54 |
import com.iver.cit.gvsig.gui.layout.Layout; |
|
55 |
import com.iver.cit.gvsig.gui.layout.fframes.FFrameView; |
|
56 | 54 |
import com.iver.cit.gvsig.project.Project; |
57 | 55 |
import com.iver.cit.gvsig.project.documents.ProjectDocument; |
58 | 56 |
import com.iver.cit.gvsig.project.documents.ProjectDocumentFactory; |
59 | 57 |
import com.iver.cit.gvsig.project.documents.exceptions.OpenException; |
60 | 58 |
import com.iver.cit.gvsig.project.documents.exceptions.SaveException; |
59 |
import com.iver.cit.gvsig.project.documents.layout.fframes.FFrameView; |
|
61 | 60 |
import com.iver.cit.gvsig.project.documents.layout.fframes.IFFrame; |
61 |
import com.iver.cit.gvsig.project.documents.layout.gui.Layout; |
|
62 | 62 |
import com.iver.cit.gvsig.project.documents.layout.gui.MapProperties; |
63 | 63 |
import com.iver.cit.gvsig.project.documents.view.ProjectView; |
64 | 64 |
import com.iver.cit.gvsig.project.documents.view.ProjectViewFactory; |
... | ... | |
66 | 66 |
|
67 | 67 |
|
68 | 68 |
/** |
69 |
* DOCUMENT ME!
|
|
69 |
* Modelo del Layout.
|
|
70 | 70 |
* |
71 | 71 |
* @author Fernando Gonz?lez Cort?s |
72 | 72 |
*/ |
... | ... | |
135 | 135 |
{ |
136 | 136 |
XMLEntity child = xml.getChild(i); |
137 | 137 |
if (child.contains("className") |
138 |
&& child.getStringProperty("className").equals("com.iver.cit.gvsig.gui.layout.Layout")
|
|
138 |
&& (child.getStringProperty("className").equals("com.iver.cit.gvsig.gui.layout.Layout") || child.getStringProperty("className").equals(Layout.class.getName()))
|
|
139 | 139 |
&& child.contains("name") |
140 | 140 |
&& child.getStringProperty("name").equals("layout")) { |
141 | 141 |
setModel(Layout.createLayout(child,getProject())); |
... | ... | |
159 | 159 |
} |
160 | 160 |
|
161 | 161 |
|
162 |
|
|
163 | 162 |
public IWindow createWindow() { |
164 | 163 |
Layout l = getModel(); |
165 | 164 |
setName(l.getName()); |
166 | 165 |
l.setProjectMap(this); |
167 |
l.fullRect(); |
|
166 |
l.getLayoutControl().fullRect();
|
|
168 | 167 |
l.getWindowInfo().setTitle(PluginServices.getText(this, |
169 | 168 |
"Mapa") + " : " +l.getName()); |
170 | 169 |
return l; |
... | ... | |
184 | 183 |
} |
185 | 184 |
|
186 | 185 |
public void exportToXML(XMLEntity root, Project project) throws SaveException { |
187 |
XMLEntity mapsRoot = project.getExportXMLTypeRootNode(root,ProjectMapFactory.registerName);
|
|
186 |
XMLEntity mapsRoot = project.getExportXMLTypeRootNode(root,ProjectMapFactory.registerName); |
|
188 | 187 |
mapsRoot.addChild(this.getXMLEntity()); |
189 |
this.exportToXMLDependencies(root,project);
|
|
188 |
this.exportToXMLDependencies(root,project); |
|
190 | 189 |
} |
191 |
|
|
192 |
private void exportToXMLDependencies( XMLEntity root,Project project)
|
|
190 |
|
|
191 |
private void exportToXMLDependencies( XMLEntity root,Project project) |
|
193 | 192 |
throws SaveException { |
194 | 193 |
XMLEntity viewsRoot = project.getExportXMLTypeRootNode(root,ProjectViewFactory.registerName); |
195 |
IFFrame[] components = this.getModel().getFFrames(); |
|
194 |
IFFrame[] components = this.getModel().getLayoutContext().getFFrames();
|
|
196 | 195 |
for (int i=0; i < components.length; i++) { |
197 | 196 |
if (components[i] instanceof FFrameView) { |
198 | 197 |
ProjectView view = ((FFrameView)components[i]).getView(); |
... | ... | |
207 | 206 |
|
208 | 207 |
public void importFromXML(XMLEntity root, XMLEntity typeRoot, int elementIndex, Project project, boolean removeDocumentsFromRoot) throws XMLException, DriverException, OpenException { |
209 | 208 |
XMLEntity element = typeRoot.getChild(elementIndex); |
210 |
|
|
209 |
|
|
211 | 210 |
XMLEntity layout = element.getChild(0); |
212 | 211 |
//Cargamos las vistas vinculadas: |
213 |
|
|
212 |
|
|
214 | 213 |
//Recuperamos todos los nombres |
215 | 214 |
int childIndex; |
216 | 215 |
XMLEntity child; |
... | ... | |
221 | 220 |
if (child.contains("viewName")) { |
222 | 221 |
viewsName.put(child.getStringProperty("viewName"),child.getStringProperty("viewName")); |
223 | 222 |
} |
224 |
|
|
223 |
|
|
225 | 224 |
} |
226 | 225 |
|
227 |
|
|
226 |
|
|
228 | 227 |
XMLEntity viewsRoot = project.getExportXMLTypeRootNode(root,ProjectViewFactory.registerName); |
229 | 228 |
XMLEntity viewXML; |
230 |
|
|
229 |
|
|
231 | 230 |
// Construimos un diccionario ordenado inversamente por el indice |
232 | 231 |
// del elemento (por si se van eliminando elementos al importar) y |
233 | 232 |
// como valor el nombre de la vista |
234 | 233 |
TreeMap viewsToImport = new TreeMap( new Comparator() { |
235 | 234 |
|
236 | 235 |
public int compare(Object o1, Object o2) { |
237 |
|
|
236 |
|
|
238 | 237 |
if (((Integer)o1).intValue() > ((Integer)o2).intValue()) { |
239 | 238 |
return -1; //o1 first |
240 | 239 |
} else if (((Integer)o1).intValue() < ((Integer)o2).intValue()){ |
... | ... | |
242 | 241 |
} |
243 | 242 |
return 0; |
244 | 243 |
} |
245 |
|
|
244 |
|
|
246 | 245 |
}); |
247 | 246 |
Iterator iterViewsName = viewsName.keySet().iterator(); |
248 | 247 |
int viewIndex; |
... | ... | |
252 | 251 |
viewIndex = viewsRoot.firstIndexOfChild("name",viewName); |
253 | 252 |
viewsToImport.put(new Integer(viewIndex),viewName); |
254 | 253 |
} |
255 |
|
|
256 |
|
|
257 |
ProjectView view;
|
|
254 |
|
|
255 |
|
|
256 |
ProjectView view; |
|
258 | 257 |
ProjectDocumentFactory viewFactory = project.getProjectDocumentFactory(ProjectViewFactory.registerName); |
259 |
|
|
258 |
|
|
260 | 259 |
Iterator iterViewToImport = viewsToImport.entrySet().iterator(); |
261 | 260 |
Entry entry; |
262 | 261 |
// Nos recorremos las vistas a importar |
... | ... | |
268 | 267 |
view = (ProjectView)project.getProjectDocumentByName(viewName,ProjectViewFactory.registerName); |
269 | 268 |
if (view == null) { |
270 | 269 |
view = (ProjectView)viewFactory.create(project); |
271 |
view.importFromXML(root,viewsRoot,viewIndex,project,removeDocumentsFromRoot);
|
|
270 |
view.importFromXML(root,viewsRoot,viewIndex,project,removeDocumentsFromRoot); |
|
272 | 271 |
} |
273 |
|
|
272 |
|
|
274 | 273 |
} |
275 |
|
|
276 |
|
|
274 |
|
|
275 |
|
|
277 | 276 |
this.setXMLEntity(element); |
278 | 277 |
project.addDocument(this); |
279 | 278 |
if (removeDocumentsFromRoot) { |
280 | 279 |
typeRoot.removeChild(elementIndex); |
281 | 280 |
} |
282 | 281 |
|
283 |
|
|
282 |
|
|
284 | 283 |
} |
285 |
|
|
286 | 284 |
|
287 | 285 |
|
286 |
|
|
288 | 287 |
// public int computeSignature() { |
289 | 288 |
// int result = 17; |
290 | 289 |
// |
Also available in: Unified diff