Statistics
| Revision:

root / branches / v10 / extensions / extPublish / src / org / gvsig / publish / PublishExtension.java @ 16212

History | View | Annotate | Download (3.88 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.About;
56
import com.iver.cit.gvsig.ProjectExtension;
57
import com.iver.cit.gvsig.gui.panels.FPanelAbout;
58
import com.iver.cit.gvsig.project.Project;
59

    
60
public class PublishExtension extends Extension {
61
        /**
62
         * 
63
         * To get the "add resource controller" in order to show the window "addResourceWindow",
64
         * I need to know the active publication:
65
         * I must get the active window (PublishWindow) and get the controller
66
         *  
67
         */
68
        public void execute(String actionCommand) {                
69
                if (actionCommand.compareTo("ADD_RESOURCE")==0){
70

    
71
                        //gets all the "ProjectPublish"                
72
                        ProjectExtension projectExtension = (ProjectExtension) PluginServices.getExtension(ProjectExtension.class);
73
                        Project project = projectExtension.getProject();
74
                        ArrayList allPrjPub = project.getDocumentsByType(PublicationFactory.registerName);
75

    
76
                        //gets the active window
77
                        PublishWindow activeWindow = (PublishWindow) PluginServices.getMDIManager().getActiveWindow();
78
                        Publication active = activeWindow.getActivePublication();
79

    
80
                        //gets the pubication document active
81
                        Iterator i = allPrjPub.iterator();
82
                        while (i.hasNext()){
83
                                ProjectPublication prjPub = (ProjectPublication) i.next();
84
                                if (prjPub.getPublication().equals(active)){
85
                                        prjPub.getAddResourceController().showWindow();
86
                                }
87
                        }
88

    
89
                        //allPrjPub.get(0)
90
                        //ProjectPublication projectPublication = project.getDocumentsByType(PublicationFactory.registerName);
91
                        //AddResourceController controller = new AddResourceController();
92
                        //controller.showWindow();
93
                }                         
94
        }
95
        /**
96
         * Registers the publication factory 
97
         */
98
        public void initialize() {
99
                PublicationFactory.register();
100
        }
101
        /**
102
         * Returns if the extension is enabled
103
         */
104
        public boolean isEnabled() {
105
                return true;
106
        }
107
        /**
108
         * Only is visible when a publication is selected
109
         */
110
        public boolean isVisible() {
111
                IWindow f = PluginServices.getMDIManager().getActiveWindow();
112
                if (f == null) {
113
                        return false;
114
                }
115
                boolean isPublication = f instanceof PublishWindow; 
116
                return (isPublication);        
117
        }
118
        public void postInitialize() {
119
                super.postInitialize();
120
                About about=(About)PluginServices.getExtension(About.class);
121
                FPanelAbout panelAbout=about.getAboutPanel();
122
                java.net.URL aboutURL = this.getClass().getResource("/about.htm");
123
                panelAbout.addAboutUrl(PluginServices.getText(this,"extension_de_publicacion"),aboutURL);
124
         
125
        }
126

    
127
}