svn-gvsig-desktop / branches / v2_0_0_prep / applications / appgvSIG / src / org / gvsig / app / project / documents / layout / LayoutDocument.java @ 33275
History | View | Annotate | Download (3.51 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
|
4 |
*
|
5 |
* This program is free software; you can redistribute it and/or
|
6 |
* modify it under the terms of the GNU General Public License
|
7 |
* as published by the Free Software Foundation; either version 2
|
8 |
* of the License, or (at your option) any later version.
|
9 |
*
|
10 |
* This program is distributed in the hope that it will be useful,
|
11 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13 |
* GNU General Public License for more details.
|
14 |
*
|
15 |
* You should have received a copy of the GNU General Public License
|
16 |
* along with this program; if not, write to the Free Software
|
17 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,USA.
|
18 |
*
|
19 |
* For more information, contact:
|
20 |
*
|
21 |
* Generalitat Valenciana
|
22 |
* Conselleria d'Infraestructures i Transport
|
23 |
* Av. Blasco Ib??ez, 50
|
24 |
* 46010 VALENCIA
|
25 |
* SPAIN
|
26 |
*
|
27 |
* +34 963862235
|
28 |
* gvsig@gva.es
|
29 |
* www.gvsig.gva.es
|
30 |
*
|
31 |
* or
|
32 |
*
|
33 |
* IVER T.I. S.A
|
34 |
* Salamanca 50
|
35 |
* 46005 Valencia
|
36 |
* Spain
|
37 |
*
|
38 |
* +34 963163400
|
39 |
* dac@iver.es
|
40 |
*/
|
41 |
package org.gvsig.app.project.documents.layout; |
42 |
|
43 |
import org.gvsig.app.project.documents.AbstractDocument; |
44 |
import org.gvsig.app.project.documents.DocumentManager; |
45 |
import org.gvsig.app.project.documents.layout.gui.LayoutPanel; |
46 |
import org.gvsig.app.project.documents.view.BaseViewDocument; |
47 |
import org.gvsig.tools.ToolsLocator; |
48 |
import org.gvsig.tools.dynobject.DynStruct; |
49 |
import org.gvsig.tools.persistence.PersistenceManager; |
50 |
import org.gvsig.tools.persistence.PersistentState; |
51 |
import org.gvsig.tools.persistence.exception.PersistenceException; |
52 |
|
53 |
|
54 |
|
55 |
/**
|
56 |
* Modelo del Layout.
|
57 |
*
|
58 |
* @author Fernando Gonz?lez Cort?s
|
59 |
*/
|
60 |
public class LayoutDocument extends AbstractDocument { |
61 |
/**
|
62 |
*
|
63 |
*/
|
64 |
private static final long serialVersionUID = 7320640550072493414L; |
65 |
|
66 |
public static final String PERSISTENCE_DEFINITION_NAME = "LayoutDocument"; |
67 |
|
68 |
private LayoutPanel model;
|
69 |
|
70 |
public LayoutDocument(DocumentManager factory) {
|
71 |
super(factory);
|
72 |
this.model = null; |
73 |
} |
74 |
|
75 |
public LayoutDocument() {
|
76 |
this(null); |
77 |
} |
78 |
|
79 |
|
80 |
/**
|
81 |
* @see org.gvsig.app.project.documents.layout.LayoutDocument#getModel()
|
82 |
*/
|
83 |
public LayoutPanel getModel() {
|
84 |
return model;
|
85 |
} |
86 |
|
87 |
/**
|
88 |
* @see org.gvsig.app.project.documents.layout.LayoutDocument#setMapContext(com.iver.cit.gvsig.project.castor.XMLEntity)
|
89 |
*/
|
90 |
public void setModel(LayoutPanel layout) { |
91 |
model = layout; |
92 |
layout.setName(getName()); |
93 |
} |
94 |
|
95 |
/**
|
96 |
* @see org.gvsig.app.project.documents.AbstractDocument#setName(java.lang.String)
|
97 |
*/
|
98 |
public void setName(String string) { |
99 |
super.setName(string);
|
100 |
|
101 |
LayoutPanel m = getModel(); |
102 |
|
103 |
if (m != null) { |
104 |
m.setName(string); |
105 |
} |
106 |
} |
107 |
|
108 |
public void loadFromState(PersistentState state) |
109 |
throws PersistenceException {
|
110 |
this.model = (LayoutPanel) state.get("layout"); |
111 |
} |
112 |
|
113 |
public void saveToState(PersistentState state) throws PersistenceException { |
114 |
state.set("layout", model);
|
115 |
} |
116 |
|
117 |
public static void registerPersistent() { |
118 |
LayoutPanel.registerPersistent(); |
119 |
|
120 |
PersistenceManager manager = ToolsLocator.getPersistenceManager(); |
121 |
DynStruct definition = manager.addDefinition( |
122 |
BaseViewDocument.class, |
123 |
PERSISTENCE_DEFINITION_NAME, |
124 |
"Layout document persistence definition",
|
125 |
null,
|
126 |
null
|
127 |
); |
128 |
definition.extend(manager.getDefinition(AbstractDocument.PERSISTENCE_DEFINITION_NAME));
|
129 |
|
130 |
definition.addDynFieldObject("layout").setClassOfValue(LayoutPanel.class).setMandatory(true); |
131 |
} |
132 |
|
133 |
} |