root / branches / v10 / extensions / extPublish / src / org / gvsig / publish / PublishExtension.java @ 13962
History | View | Annotate | Download (3.51 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 |
/**
|
42 |
* @author Jos? Vicente Hig?n (josevicente.higon@iver.es)
|
43 |
*/
|
44 |
package org.gvsig.publish; |
45 |
|
46 |
import java.util.ArrayList; |
47 |
import java.util.Iterator; |
48 |
|
49 |
import org.gvsig.publish.gui.publish.PublishWindow; |
50 |
import org.gvsig.publish.serversModel.Publication; |
51 |
|
52 |
import com.iver.andami.PluginServices; |
53 |
import com.iver.andami.plugins.Extension; |
54 |
import com.iver.andami.ui.mdiManager.IWindow; |
55 |
import com.iver.cit.gvsig.ProjectExtension; |
56 |
import com.iver.cit.gvsig.project.Project; |
57 |
|
58 |
public class PublishExtension extends Extension { |
59 |
/**
|
60 |
*
|
61 |
* To get the "add resource controller" in order to show the window "addResourceWindow",
|
62 |
* I need to know the active publication:
|
63 |
* I must get the active window (PublishWindow) and get the controller
|
64 |
*
|
65 |
*/
|
66 |
public void execute(String actionCommand) { |
67 |
if (actionCommand.compareTo("ADD_RESOURCE")==0){ |
68 |
|
69 |
//gets all the "ProjectPublish"
|
70 |
ProjectExtension projectExtension = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class); |
71 |
Project project = projectExtension.getProject(); |
72 |
ArrayList allPrjPub = project.getDocumentsByType(PublicationFactory.registerName);
|
73 |
|
74 |
//gets the active window
|
75 |
PublishWindow activeWindow = (PublishWindow) PluginServices.getMDIManager().getActiveWindow(); |
76 |
Publication active = activeWindow.getActivePublication(); |
77 |
|
78 |
//gets the pubication document active
|
79 |
Iterator i = allPrjPub.iterator();
|
80 |
while (i.hasNext()){
|
81 |
ProjectPublication prjPub = (ProjectPublication) i.next(); |
82 |
if (prjPub.getPublication().equals(active)){
|
83 |
prjPub.getAddResourceController().showWindow(); |
84 |
} |
85 |
} |
86 |
|
87 |
//allPrjPub.get(0)
|
88 |
//ProjectPublication projectPublication = project.getDocumentsByType(PublicationFactory.registerName);
|
89 |
//AddResourceController controller = new AddResourceController();
|
90 |
//controller.showWindow();
|
91 |
} |
92 |
} |
93 |
/**
|
94 |
* Registers the publication factory
|
95 |
*/
|
96 |
public void initialize() { |
97 |
PublicationFactory.register(); |
98 |
} |
99 |
/**
|
100 |
* Returns if the extension is enabled
|
101 |
*/
|
102 |
public boolean isEnabled() { |
103 |
return true; |
104 |
} |
105 |
/**
|
106 |
* Only is visible when a publication is selected
|
107 |
*/
|
108 |
public boolean isVisible() { |
109 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
110 |
if (f == null) { |
111 |
return false; |
112 |
} |
113 |
boolean isPublication = f instanceof PublishWindow; |
114 |
return (isPublication);
|
115 |
} |
116 |
|
117 |
} |