Statistics
| Revision:

root / trunk / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / manager / GeoprocessManagerExtension.java @ 6877

History | View | Annotate | Download (5.21 KB)

1 6018 azabala
/*
2
 * Created on 23-jun-2006
3
 *
4
 * gvSIG. Sistema de Informaci?n Geogr?fica de la Generalitat Valenciana
5
 *
6
 * Copyright (C) 2004 IVER T.I. and Generalitat Valenciana.
7
 *
8
 * This program is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, write to the Free Software
20
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307,USA.
21
 *
22
 * For more information, contact:
23
 *
24
 *  Generalitat Valenciana
25
 *   Conselleria d'Infraestructures i Transport
26
 *   Av. Blasco Ib??ez, 50
27
 *   46010 VALENCIA
28
 *   SPAIN
29
 *
30
 *      +34 963862235
31
 *   gvsig@gva.es
32
 *      www.gvsig.gva.es
33
 *
34
 *    or
35
 *
36
 *   IVER T.I. S.A
37
 *   Salamanca 50
38
 *   46005 Valencia
39
 *   Spain
40
 *
41
 *   +34 963163400
42
 *   dac@iver.es
43
 */
44
/* CVS MESSAGES:
45
*
46
* $Id$
47
* $Log$
48 6877 cesar
* Revision 1.4  2006-08-29 07:13:56  cesar
49
* Rename class com.iver.andami.ui.mdiManager.View to com.iver.andami.ui.mdiManager.IWindow
50
*
51
* Revision 1.3  2006/08/18 08:40:05  jmvivo
52 6779 jmvivo
* Actualizado para que el isEnabled tenga en cuenta que las capas esten 'avialable'
53
*
54
* Revision 1.2  2006/06/27 16:12:38  azabala
55 6056 azabala
* registration of all core geoprocesses (wizard's)
56
*
57
* Revision 1.1  2006/06/23 19:03:52  azabala
58 6018 azabala
* first version in cvs
59
*
60
*
61
*/
62
package com.iver.cit.gvsig.geoprocess.manager;
63
64
import com.iver.andami.PluginServices;
65
import com.iver.andami.plugins.Extension;
66
import com.iver.cit.gvsig.fmap.layers.FLayer;
67
import com.iver.cit.gvsig.fmap.layers.FLayers;
68
import com.iver.cit.gvsig.fmap.layers.FLyrVect;
69
import com.iver.cit.gvsig.geoprocess.impl.buffer.BufferGeoprocessPlugin;
70
import com.iver.cit.gvsig.geoprocess.impl.clip.ClipGeoprocessPlugin;
71
import com.iver.cit.gvsig.geoprocess.impl.convexhull.ConvexHullGeoprocessPlugin;
72 6056 azabala
import com.iver.cit.gvsig.geoprocess.impl.difference.DifferenceGeoprocessPlugin;
73
import com.iver.cit.gvsig.geoprocess.impl.dissolve.DissolveGeoprocessPlugin;
74
import com.iver.cit.gvsig.geoprocess.impl.intersection.IntersectionGeoprocessPlugin;
75
import com.iver.cit.gvsig.geoprocess.impl.merge.MergeGeoprocessPlugin;
76
import com.iver.cit.gvsig.geoprocess.impl.spatialjoin.SpatialJoinGeoprocessPlugin;
77
import com.iver.cit.gvsig.geoprocess.impl.union.UnionGeoprocessPlugin;
78 6018 azabala
import com.iver.cit.gvsig.gui.View;
79
import com.iver.cit.gvsig.project.ProjectView;
80
import com.iver.utiles.extensionPoints.ExtensionPoints;
81
import com.iver.utiles.extensionPoints.ExtensionPointsSingleton;
82
83
public class GeoprocessManagerExtension extends Extension {
84
85
        public void initialize() {
86
                ExtensionPoints extensionPoints =
87
                        ExtensionPointsSingleton.getInstance();
88
                extensionPoints.add("GeoprocessManager",
89
                                "BUFFER",
90
                                BufferGeoprocessPlugin.class);
91
                extensionPoints.add("GeoprocessManager",
92
                                "CLIP",
93
                                ClipGeoprocessPlugin.class);
94
                extensionPoints.add("GeoprocessManager",
95
                                "CONVEX HULL",
96
                                ConvexHullGeoprocessPlugin.class);
97 6056 azabala
                extensionPoints.add("GeoprocessManager",
98
                                "DIFFERENCE",
99
                                DifferenceGeoprocessPlugin.class);
100
                extensionPoints.add("GeoprocessManager",
101
                                "DISSOLVE",
102
                                DissolveGeoprocessPlugin.class);
103
                extensionPoints.add("GeoprocessManager",
104
                                "INTERSECTION",
105
                                IntersectionGeoprocessPlugin.class);
106
                extensionPoints.add("GeoprocessManager",
107
                                "MERGE",
108
                                MergeGeoprocessPlugin.class);
109
                extensionPoints.add("GeoprocessManager",
110
                                "SPATIAL JOIN",
111
                                SpatialJoinGeoprocessPlugin.class);
112
                extensionPoints.add("GeoprocessManager",
113
                                "UNION",
114
                                UnionGeoprocessPlugin.class);
115
116 6018 azabala
        }
117
118
        public void execute(String actionCommand) {
119
                if(actionCommand.equalsIgnoreCase("GEOPROCESSING_MANAGER")){
120
                        PluginServices.getMDIManager().
121
                                addView(new GeoprocessManager());
122
                }
123
124
        }
125
126
        public boolean isEnabled() {
127 6877 cesar
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
128 6779 jmvivo
                .getActiveView();
129
                if (f == null) {
130
                        return false;
131
                }
132
                if (f instanceof View) {
133
                        View vista = (View) f;
134
                        ProjectView model = vista.getModel();
135
                        FLayers layers =  model.getMapContext().getLayers();
136
                        int numLayers = layers.getLayersCount();
137
                        for(int i = 0; i < numLayers; i++){
138
                                FLayer layer = layers.getLayer(i);
139
                                if(layer instanceof FLyrVect && layer.isAvailable())
140
                                        return true;
141
                        }
142
                }
143
                return false;
144 6018 azabala
        }
145 6779 jmvivo
146 6018 azabala
        public boolean isVisible() {
147
                //Meter en un geoprocessutil para todas las extensiones
148
                //de geoprocessing
149 6877 cesar
                com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager()
150 6018 azabala
                 .getActiveView();
151
                if (f == null) {
152
                    return false;
153
                }
154
                if (f instanceof View) {
155
                    View vista = (View) f;
156
                    ProjectView model = vista.getModel();
157
                    FLayers layers =  model.getMapContext().getLayers();
158
                    int numLayers = layers.getLayersCount();
159
                    for(int i = 0; i < numLayers; i++){
160
                            FLayer layer = layers.getLayer(i);
161
                            if(layer instanceof FLyrVect)
162
                                    return true;
163
                    }
164
                    return false;
165
                } else {
166
                    return false;
167
                }
168
        }
169
170
}