svn-gvsig-desktop / tags / v1_1_Build_1008 / extensions / extGeoProcessing / src / com / iver / cit / gvsig / geoprocess / manager / GeoprocessManagerExtension.java @ 12520
History | View | Annotate | Download (6.32 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 | 8765 | jjdelcerro | * Revision 1.7.2.1 2006-11-15 00:08:17 jjdelcerro
|
49 | * *** empty log message ***
|
||
50 | *
|
||
51 | * Revision 1.9 2006/09/20 13:40:47 caballero
|
||
52 | * IProjectView
|
||
53 | *
|
||
54 | * Revision 1.8 2006/09/15 10:42:54 caballero
|
||
55 | * extensibilidad de documentos
|
||
56 | *
|
||
57 | * Revision 1.7 2006/09/07 19:02:27 azabala
|
||
58 | 7120 | azabala | * cached Geoprocess Manager, to remember folder status
|
59 | *
|
||
60 | * Revision 1.6 2006/09/07 18:54:11 azabala
|
||
61 | 7119 | azabala | * added comments
|
62 | *
|
||
63 | * Revision 1.5 2006/08/29 07:56:30 cesar
|
||
64 | 6880 | cesar | * Rename the *View* family of classes to *Window* (ie: SingletonView to SingletonWindow, ViewInfo to WindowInfo, etc)
|
65 | *
|
||
66 | * Revision 1.4 2006/08/29 07:13:56 cesar
|
||
67 | 6877 | cesar | * Rename class com.iver.andami.ui.mdiManager.View to com.iver.andami.ui.mdiManager.IWindow
|
68 | *
|
||
69 | * Revision 1.3 2006/08/18 08:40:05 jmvivo
|
||
70 | 6779 | jmvivo | * Actualizado para que el isEnabled tenga en cuenta que las capas esten 'avialable'
|
71 | *
|
||
72 | * Revision 1.2 2006/06/27 16:12:38 azabala
|
||
73 | 6056 | azabala | * registration of all core geoprocesses (wizard's)
|
74 | *
|
||
75 | * Revision 1.1 2006/06/23 19:03:52 azabala
|
||
76 | 6018 | azabala | * first version in cvs
|
77 | *
|
||
78 | *
|
||
79 | */
|
||
80 | package com.iver.cit.gvsig.geoprocess.manager; |
||
81 | |||
82 | import com.iver.andami.PluginServices; |
||
83 | import com.iver.andami.plugins.Extension; |
||
84 | import com.iver.cit.gvsig.fmap.layers.FLayer; |
||
85 | import com.iver.cit.gvsig.fmap.layers.FLayers; |
||
86 | import com.iver.cit.gvsig.fmap.layers.FLyrVect; |
||
87 | import com.iver.cit.gvsig.geoprocess.impl.buffer.BufferGeoprocessPlugin; |
||
88 | import com.iver.cit.gvsig.geoprocess.impl.clip.ClipGeoprocessPlugin; |
||
89 | import com.iver.cit.gvsig.geoprocess.impl.convexhull.ConvexHullGeoprocessPlugin; |
||
90 | 6056 | azabala | import com.iver.cit.gvsig.geoprocess.impl.difference.DifferenceGeoprocessPlugin; |
91 | import com.iver.cit.gvsig.geoprocess.impl.dissolve.DissolveGeoprocessPlugin; |
||
92 | import com.iver.cit.gvsig.geoprocess.impl.intersection.IntersectionGeoprocessPlugin; |
||
93 | import com.iver.cit.gvsig.geoprocess.impl.merge.MergeGeoprocessPlugin; |
||
94 | import com.iver.cit.gvsig.geoprocess.impl.spatialjoin.SpatialJoinGeoprocessPlugin; |
||
95 | import com.iver.cit.gvsig.geoprocess.impl.union.UnionGeoprocessPlugin; |
||
96 | 8765 | jjdelcerro | import com.iver.cit.gvsig.project.documents.view.IProjectView; |
97 | import com.iver.cit.gvsig.project.documents.view.gui.View; |
||
98 | 6018 | azabala | import com.iver.utiles.extensionPoints.ExtensionPoints; |
99 | import com.iver.utiles.extensionPoints.ExtensionPointsSingleton; |
||
100 | 7119 | azabala | /**
|
101 | * This andami extension shows a GUI component (GeoprocessManager)
|
||
102 | * that allows user to launch geoprocesses, and developers to register
|
||
103 | * new geoprocesses in a dynamic linkage manner.
|
||
104 | * <br>
|
||
105 | * In its initialize() method it registers the basis geoprocesses
|
||
106 | * (buffer, clip, etc.)
|
||
107 | 8765 | jjdelcerro | *
|
108 | 7119 | azabala | * @author azabala
|
109 | *
|
||
110 | */
|
||
111 | 6018 | azabala | public class GeoprocessManagerExtension extends Extension { |
112 | |||
113 | 7119 | azabala | /**
|
114 | 7120 | azabala | * Cached instance of geoprocess manager
|
115 | */
|
||
116 | private GeoprocessManager gpManagerDialog = null; |
||
117 | /**
|
||
118 | 7119 | azabala | * Register basis geoprocesses during extension initialization
|
119 | */
|
||
120 | 6018 | azabala | public void initialize() { |
121 | 8765 | jjdelcerro | ExtensionPoints extensionPoints = |
122 | 6018 | azabala | ExtensionPointsSingleton.getInstance(); |
123 | extensionPoints.add("GeoprocessManager",
|
||
124 | 8765 | jjdelcerro | "BUFFER",
|
125 | 6018 | azabala | BufferGeoprocessPlugin.class); |
126 | extensionPoints.add("GeoprocessManager",
|
||
127 | 8765 | jjdelcerro | "CLIP",
|
128 | 6018 | azabala | ClipGeoprocessPlugin.class); |
129 | extensionPoints.add("GeoprocessManager",
|
||
130 | 8765 | jjdelcerro | "CONVEX HULL",
|
131 | 6018 | azabala | ConvexHullGeoprocessPlugin.class); |
132 | 6056 | azabala | extensionPoints.add("GeoprocessManager",
|
133 | 8765 | jjdelcerro | "DIFFERENCE",
|
134 | 6056 | azabala | DifferenceGeoprocessPlugin.class); |
135 | extensionPoints.add("GeoprocessManager",
|
||
136 | 8765 | jjdelcerro | "DISSOLVE",
|
137 | 6056 | azabala | DissolveGeoprocessPlugin.class); |
138 | extensionPoints.add("GeoprocessManager",
|
||
139 | 8765 | jjdelcerro | "INTERSECTION",
|
140 | 6056 | azabala | IntersectionGeoprocessPlugin.class); |
141 | extensionPoints.add("GeoprocessManager",
|
||
142 | 8765 | jjdelcerro | "MERGE",
|
143 | 6056 | azabala | MergeGeoprocessPlugin.class); |
144 | extensionPoints.add("GeoprocessManager",
|
||
145 | 8765 | jjdelcerro | "SPATIAL JOIN",
|
146 | 6056 | azabala | SpatialJoinGeoprocessPlugin.class); |
147 | extensionPoints.add("GeoprocessManager",
|
||
148 | 8765 | jjdelcerro | "UNION",
|
149 | 6056 | azabala | UnionGeoprocessPlugin.class); |
150 | 8765 | jjdelcerro | |
151 | 6018 | azabala | } |
152 | |||
153 | public void execute(String actionCommand) { |
||
154 | if(actionCommand.equalsIgnoreCase("GEOPROCESSING_MANAGER")){ |
||
155 | 7120 | azabala | if(gpManagerDialog == null) |
156 | gpManagerDialog = new GeoprocessManager();
|
||
157 | 6018 | azabala | PluginServices.getMDIManager(). |
158 | 7120 | azabala | addWindow(gpManagerDialog); |
159 | 6018 | azabala | } |
160 | |||
161 | } |
||
162 | |||
163 | public boolean isEnabled() { |
||
164 | 6877 | cesar | com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
165 | 6880 | cesar | .getActiveWindow(); |
166 | 6779 | jmvivo | if (f == null) { |
167 | return false; |
||
168 | } |
||
169 | if (f instanceof View) { |
||
170 | View vista = (View) f; |
||
171 | 8765 | jjdelcerro | IProjectView model = vista.getModel(); |
172 | 6779 | jmvivo | FLayers layers = model.getMapContext().getLayers(); |
173 | int numLayers = layers.getLayersCount();
|
||
174 | for(int i = 0; i < numLayers; i++){ |
||
175 | FLayer layer = layers.getLayer(i); |
||
176 | if(layer instanceof FLyrVect && layer.isAvailable()) |
||
177 | return true; |
||
178 | } |
||
179 | } |
||
180 | return false; |
||
181 | 6018 | azabala | } |
182 | 8765 | jjdelcerro | |
183 | 6018 | azabala | public boolean isVisible() { |
184 | //Meter en un geoprocessutil para todas las extensiones
|
||
185 | //de geoprocessing
|
||
186 | 6877 | cesar | com.iver.andami.ui.mdiManager.IWindow f = PluginServices.getMDIManager() |
187 | 6880 | cesar | .getActiveWindow(); |
188 | 6018 | azabala | if (f == null) { |
189 | return false; |
||
190 | } |
||
191 | if (f instanceof View) { |
||
192 | View vista = (View) f; |
||
193 | 8765 | jjdelcerro | IProjectView model = vista.getModel(); |
194 | 6018 | azabala | FLayers layers = model.getMapContext().getLayers(); |
195 | int numLayers = layers.getLayersCount();
|
||
196 | for(int i = 0; i < numLayers; i++){ |
||
197 | FLayer layer = layers.getLayer(i); |
||
198 | if(layer instanceof FLyrVect) |
||
199 | return true; |
||
200 | } |
||
201 | return false; |
||
202 | } |
||
203 | 8765 | jjdelcerro | return false; |
204 | 6018 | azabala | } |
205 | |||
206 | } |