root / branches / v10 / extensions / extPublish / src / org / gvsig / publish / ProjectPublication.java @ 16215
History | View | Annotate | Download (6.07 KB)
1 | 13962 | jvhigon | /* 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 org.gvsig.publish.gui.addResource.AddResourceController; |
||
44 | import org.gvsig.publish.gui.publish.PublishController; |
||
45 | 14376 | jvhigon | import org.gvsig.publish.gui.selectServer.SelectServerController; |
46 | 16212 | jvhigon | import org.gvsig.publish.infoproject.IProjectInfo; |
47 | import org.gvsig.publish.infoproject.ProjectInfoFactory; |
||
48 | import org.gvsig.publish.serversmodel.Publication; |
||
49 | 13962 | jvhigon | |
50 | import com.iver.andami.ui.mdiManager.IWindow; |
||
51 | import com.iver.cit.gvsig.fmap.DriverException; |
||
52 | 14376 | jvhigon | import com.iver.cit.gvsig.fmap.drivers.DriverIOException; |
53 | 13962 | jvhigon | import com.iver.cit.gvsig.fmap.layers.XMLException; |
54 | import com.iver.cit.gvsig.project.Project; |
||
55 | import com.iver.cit.gvsig.project.documents.ProjectDocument; |
||
56 | import com.iver.cit.gvsig.project.documents.exceptions.OpenException; |
||
57 | import com.iver.cit.gvsig.project.documents.exceptions.SaveException; |
||
58 | 14376 | jvhigon | import com.iver.cit.gvsig.project.documents.table.ProjectTableFactory; |
59 | 13962 | jvhigon | import com.iver.utiles.XMLEntity; |
60 | |||
61 | 14227 | jvhigon | public class ProjectPublication extends ProjectDocument { |
62 | 13962 | jvhigon | /*
|
63 | * Dependences
|
||
64 | */
|
||
65 | private Publication publication = null; |
||
66 | private PublishController publishCtrl = null; |
||
67 | private AddResourceController addResourceCtrl = null; |
||
68 | 14376 | jvhigon | private SelectServerController slcSrvCtrl = null; |
69 | |||
70 | 13962 | jvhigon | /**
|
71 | 14376 | jvhigon | * Creates all the controllers and sets the relations
|
72 | * @see ProjectDocument#setProject(Project, int)
|
||
73 | 13962 | jvhigon | */
|
74 | 14376 | jvhigon | public void setProject(Project project, int index) { |
75 | super.setProject(project, index);
|
||
76 | 14546 | jvhigon | //super.setName("publication");
|
77 | 14376 | jvhigon | //creates the publication an sets the project info
|
78 | publication = new Publication();
|
||
79 | IProjectInfo projectInfo = ProjectInfoFactory.getProjectInfo(project); |
||
80 | publication.setProjectInfo(projectInfo); |
||
81 | |||
82 | 13962 | jvhigon | //Creates the controllers
|
83 | addResourceCtrl = new AddResourceController();
|
||
84 | publishCtrl = new PublishController();
|
||
85 | 14376 | jvhigon | slcSrvCtrl = new SelectServerController();
|
86 | 13962 | jvhigon | |
87 | //Add observers
|
||
88 | publication.addObserver(publishCtrl); |
||
89 | |||
90 | //sets the publication in the controllers
|
||
91 | addResourceCtrl.setPublication(publication); |
||
92 | publishCtrl.setPublication(publication); |
||
93 | 14376 | jvhigon | slcSrvCtrl.setPublication(publication); |
94 | |||
95 | } |
||
96 | /**
|
||
97 | * @see ProjectDocument#getXMLEntity()
|
||
98 | */
|
||
99 | public XMLEntity getXMLEntity() throws SaveException { |
||
100 | XMLEntity xml= super.getXMLEntity();
|
||
101 | xml.addChild(publication.getXMLEntity()); |
||
102 | return xml;
|
||
103 | } |
||
104 | /**
|
||
105 | * @see ProjectDocument#getXMLEntity()
|
||
106 | */
|
||
107 | public void setXMLEntity(XMLEntity xml) throws XMLException, |
||
108 | DriverException, DriverIOException, OpenException { |
||
109 | super.setXMLEntity(xml);
|
||
110 | // publication=new Publication();
|
||
111 | publication.setXMLEntity(xml.getChild(0));
|
||
112 | 13962 | jvhigon | |
113 | 14376 | jvhigon | // if(publication.getServer() == null){
|
114 | // addSrvCtrl.showWindow();
|
||
115 | // }
|
||
116 | 13962 | jvhigon | } |
117 | 14376 | jvhigon | |
118 | 13962 | jvhigon | /**
|
119 | *
|
||
120 | * @return the publication of the document
|
||
121 | */
|
||
122 | public Publication getPublication(){
|
||
123 | return publication;
|
||
124 | } |
||
125 | 14376 | jvhigon | |
126 | 13962 | jvhigon | /**
|
127 | * The purpose of this method is provide an entry to controller
|
||
128 | * through Extension object
|
||
129 | * @see PublishExtension#execute(String)
|
||
130 | *
|
||
131 | * @return the "addServeController's publicaction document
|
||
132 | */
|
||
133 | public AddResourceController getAddResourceController(){
|
||
134 | return addResourceCtrl;
|
||
135 | } |
||
136 | /**
|
||
137 | * When you add a publication you must select a server
|
||
138 | * @see ProjectDocument#afterAdd()
|
||
139 | */
|
||
140 | public void afterAdd() { |
||
141 | 14376 | jvhigon | |
142 | 13962 | jvhigon | } |
143 | /**
|
||
144 | * @see ProjectDocument#afterRemove()
|
||
145 | */
|
||
146 | public void afterRemove() { |
||
147 | // TODO Auto-generated method stub
|
||
148 | |||
149 | } |
||
150 | /**
|
||
151 | 14376 | jvhigon | * This method is called when I open the document
|
152 | 13962 | jvhigon | * @return
|
153 | * @see {@linkProjectDocument#createWindow()}
|
||
154 | */
|
||
155 | public IWindow createWindow() {
|
||
156 | 14376 | jvhigon | //If the publication is new, I must select the server
|
157 | if (publication.getServer() == null){ |
||
158 | return slcSrvCtrl.getWindow();
|
||
159 | } |
||
160 | 13962 | jvhigon | return publishCtrl.getWindow();
|
161 | } |
||
162 | /**
|
||
163 | *
|
||
164 | * @param root
|
||
165 | * @param project
|
||
166 | * @throws SaveException
|
||
167 | * @see {@link ProjectDocument#exportToXML(XMLEntity, Project)}
|
||
168 | */
|
||
169 | public void exportToXML(XMLEntity root, Project project) |
||
170 | throws SaveException {
|
||
171 | 14376 | jvhigon | XMLEntity tableRoot = project.getExportXMLTypeRootNode(root,ProjectTableFactory.registerName); |
172 | tableRoot.addChild(this.getXMLEntity());
|
||
173 | 13962 | jvhigon | } |
174 | /**
|
||
175 | *
|
||
176 | * @return
|
||
177 | * @see {@link ProjectDocument#getProperties()}
|
||
178 | */
|
||
179 | public IWindow getProperties() {
|
||
180 | // TODO Auto-generated method stub
|
||
181 | return null; |
||
182 | } |
||
183 | /**
|
||
184 | *
|
||
185 | * @param root
|
||
186 | * @param typeRoot
|
||
187 | * @param elementIndex
|
||
188 | * @param project
|
||
189 | * @param removeDocumentsFromRoot
|
||
190 | * @throws XMLException
|
||
191 | * @throws DriverException
|
||
192 | * @throws OpenException
|
||
193 | * @see {@link ProjectDocument#importFromXML(XMLEntity, XMLEntity, int, Project, boolean)}
|
||
194 | */
|
||
195 | public void importFromXML(XMLEntity root, XMLEntity typeRoot, |
||
196 | int elementIndex, Project project, boolean removeDocumentsFromRoot) |
||
197 | throws XMLException, DriverException, OpenException {
|
||
198 | 14376 | jvhigon | XMLEntity element = typeRoot.getChild(elementIndex); |
199 | try {
|
||
200 | this.setXMLEntity(element);
|
||
201 | } catch (DriverIOException e) {
|
||
202 | PublishLogger.getLog().error("ERROR ProjectPublication: importXML", e);
|
||
203 | } |
||
204 | if (removeDocumentsFromRoot) {
|
||
205 | typeRoot.removeChild(elementIndex); |
||
206 | } |
||
207 | project.addDocument(this);
|
||
208 | 13962 | jvhigon | |
209 | } |
||
210 | } |