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