root / trunk / extensions / extPublish / src / org / gvsig / publish / ProjectPublication.java @ 29308
History | View | Annotate | Download (6.36 KB)
1 |
/* gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
|
---|---|
2 |
*
|
3 |
* Copyright (C) 2004-2006 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 Iba?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.publish; |
42 |
|
43 |
import java.util.Iterator; |
44 |
|
45 |
import org.gvsig.exceptions.DriverException; |
46 |
import org.gvsig.publish.gui.properties.PublicationPropertiesController; |
47 |
import org.gvsig.publish.gui.publish.PublishController; |
48 |
import org.gvsig.publish.gui.selectServer.SelectServerController; |
49 |
import org.gvsig.publish.infoproject.IProjectInfo; |
50 |
import org.gvsig.publish.infoproject.factory.ProjectInfoFactory; |
51 |
import org.gvsig.publish.serversmodel.Publication; |
52 |
|
53 |
import com.hardcode.gdbms.driver.exceptions.ReadDriverException; |
54 |
import com.iver.andami.PluginServices; |
55 |
import com.iver.andami.ui.mdiManager.IWindow; |
56 |
|
57 |
import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
58 |
import com.iver.cit.gvsig.fmap.layers.XMLException; |
59 |
import com.iver.cit.gvsig.project.Project; |
60 |
import com.iver.cit.gvsig.project.documents.ProjectDocument; |
61 |
import com.iver.cit.gvsig.project.documents.exceptions.OpenException; |
62 |
import com.iver.cit.gvsig.project.documents.exceptions.SaveException; |
63 |
import com.iver.cit.gvsig.project.documents.table.ProjectTableFactory; |
64 |
import com.iver.utiles.XMLEntity; |
65 |
|
66 |
public class ProjectPublication extends ProjectDocument { |
67 |
/**
|
68 |
*
|
69 |
*/
|
70 |
private static final long serialVersionUID = 5784873591226633893L; |
71 |
/*
|
72 |
* Dependences
|
73 |
* xxx
|
74 |
*/
|
75 |
private Publication publication = null; |
76 |
private PublishController publishCtrl = null; |
77 |
//private AddResourceController addResourceCtrl = null;
|
78 |
private SelectServerController slcSrvCtrl = null; |
79 |
private PublicationPropertiesController ppc = null; |
80 |
|
81 |
/**
|
82 |
* Creates all the controllers and sets the relations.
|
83 |
* It's invoked when a new publication is created (new button)
|
84 |
* @see ProjectDocument#setProject(Project, int)
|
85 |
*/
|
86 |
public void setProject(Project project, int index) { |
87 |
super.setProject(project, index);
|
88 |
} |
89 |
/**
|
90 |
*
|
91 |
* @return the publication of the document
|
92 |
*/
|
93 |
private Publication getPublication(){
|
94 |
if (publication == null){ |
95 |
publication = new Publication();
|
96 |
} |
97 |
return publication;
|
98 |
} |
99 |
|
100 |
/**
|
101 |
* @see ProjectDocument#afterAdd()
|
102 |
*/
|
103 |
public void afterAdd() { |
104 |
|
105 |
} |
106 |
/**
|
107 |
* @see ProjectDocument#afterRemove()
|
108 |
*/
|
109 |
public void afterRemove() { |
110 |
// TODO Auto-generated method stub
|
111 |
|
112 |
} |
113 |
/**
|
114 |
* This method is called when I open the document
|
115 |
* @return
|
116 |
* @see {@linkProjectDocument#createWindow()}
|
117 |
*/
|
118 |
public IWindow createWindow() {
|
119 |
|
120 |
IProjectInfo projectInfo = ProjectInfoFactory.getProjectInfo(getProject()); |
121 |
Iterator it= getPublication().setProjectInfo(projectInfo).iterator();
|
122 |
String message=""; |
123 |
while (it.hasNext()){
|
124 |
message=message +" " +it.next().toString();
|
125 |
} |
126 |
//create controllers
|
127 |
publishCtrl = new PublishController();
|
128 |
slcSrvCtrl = new SelectServerController();
|
129 |
//initial message
|
130 |
if (!message.equals("")){ |
131 |
String aux = PluginServices.getText(this, "publish_layerinfo_not_available"); |
132 |
message = aux + message; |
133 |
publishCtrl.setInitialMessage(message); |
134 |
} |
135 |
|
136 |
//Add observers
|
137 |
getPublication().addObserver(publishCtrl); |
138 |
|
139 |
//sets the publication in the controllers
|
140 |
//addResourceCtrl.setPublication(publication);
|
141 |
publishCtrl.setPublication(getPublication()); |
142 |
slcSrvCtrl.setPublication(getPublication()); |
143 |
|
144 |
|
145 |
|
146 |
//If the publication is new, I must select the server
|
147 |
if (getPublication().getServer() == null){ |
148 |
publishCtrl.showWindow(); |
149 |
return slcSrvCtrl.getWindow();
|
150 |
} |
151 |
return publishCtrl.getWindow();
|
152 |
//return null;
|
153 |
} |
154 |
/**
|
155 |
*
|
156 |
* @param root
|
157 |
* @param project
|
158 |
* @throws SaveException
|
159 |
* @see {@link ProjectDocument#exportToXML(XMLEntity, Project)}
|
160 |
*/
|
161 |
public void exportToXML(XMLEntity root, Project project) |
162 |
throws SaveException {
|
163 |
XMLEntity tableRoot = project.getExportXMLTypeRootNode(root,ProjectTableFactory.registerName); |
164 |
tableRoot.addChild(this.getXMLEntity());
|
165 |
} |
166 |
/**
|
167 |
* This method is invoked when the properties button is pressed
|
168 |
*
|
169 |
* @return
|
170 |
* @see {@link ProjectDocument#getProperties()}
|
171 |
*/
|
172 |
public IWindow getProperties() {
|
173 |
if (ppc == null){ |
174 |
ppc = new PublicationPropertiesController(getPublication());
|
175 |
} |
176 |
return ppc.getWindow();
|
177 |
} |
178 |
/**
|
179 |
*
|
180 |
* @param root
|
181 |
* @param typeRoot
|
182 |
* @param elementIndex
|
183 |
* @param project
|
184 |
* @param removeDocumentsFromRoot
|
185 |
* @throws XMLException
|
186 |
* @throws OpenException
|
187 |
* @throws
|
188 |
* @see {@link ProjectDocument#importFromXML(XMLEntity, XMLEntity, int, Project, boolean)}
|
189 |
*/
|
190 |
public void importFromXML(XMLEntity root, XMLEntity typeRoot, |
191 |
int elementIndex, Project project, boolean removeDocumentsFromRoot) |
192 |
throws XMLException, OpenException {
|
193 |
XMLEntity element = typeRoot.getChild(elementIndex); |
194 |
|
195 |
try {
|
196 |
this.setXMLEntity(element);
|
197 |
} catch (ReadDriverException e) {
|
198 |
PublishLogger.getLog().error("ERROR ProjectPublication: importXML", e);
|
199 |
} |
200 |
|
201 |
if (removeDocumentsFromRoot) {
|
202 |
typeRoot.removeChild(elementIndex); |
203 |
} |
204 |
project.addDocument(this);
|
205 |
|
206 |
} |
207 |
/**
|
208 |
* @see ProjectDocument#getXMLEntity()
|
209 |
*/
|
210 |
public XMLEntity getXMLEntity() throws SaveException { |
211 |
XMLEntity xml= super.getXMLEntity();
|
212 |
xml.addChild(getPublication().getXMLEntity()); |
213 |
return xml;
|
214 |
} |
215 |
/**
|
216 |
* @throws ReadDriverException
|
217 |
* @see ProjectDocument#getXMLEntity()
|
218 |
*/
|
219 |
public void setXMLEntity(XMLEntity xml) throws XMLException, |
220 |
OpenException, ReadDriverException { |
221 |
super.setXMLEntity(xml);
|
222 |
getPublication().setXMLEntity(xml.getChild(0));
|
223 |
} |
224 |
|
225 |
|
226 |
} |