Revision 40938 trunk/org.gvsig.desktop/org.gvsig.desktop.plugin/org.gvsig.selectiontools.app/org.gvsig.selectiontools.app.mainplugin/src/main/java/org/gvsig/selectiontools/app/extension/SelectByBufferExtension.java
SelectByBufferExtension.java | ||
---|---|---|
49 | 49 |
|
50 | 50 |
import javax.swing.JOptionPane; |
51 | 51 |
|
52 |
import org.slf4j.Logger; |
|
53 |
import org.slf4j.LoggerFactory; |
|
54 |
|
|
52 | 55 |
import org.gvsig.andami.IconThemeHelper; |
53 | 56 |
import org.gvsig.andami.PluginServices; |
54 | 57 |
import org.gvsig.andami.plugins.Extension; |
... | ... | |
56 | 59 |
import org.gvsig.app.project.documents.view.ViewDocument; |
57 | 60 |
import org.gvsig.app.project.documents.view.gui.IView; |
58 | 61 |
import org.gvsig.fmap.dal.exception.DataException; |
62 |
import org.gvsig.fmap.dal.feature.FeatureSelection; |
|
59 | 63 |
import org.gvsig.fmap.mapcontext.MapContext; |
60 | 64 |
import org.gvsig.fmap.mapcontext.layers.FLayer; |
61 | 65 |
import org.gvsig.fmap.mapcontext.layers.vectorial.FLyrVect; |
... | ... | |
72 | 76 |
*/ |
73 | 77 |
public class SelectByBufferExtension extends Extension { |
74 | 78 |
|
79 |
private static Logger logger = |
|
80 |
LoggerFactory.getLogger(SelectByBufferExtension.class); |
|
75 | 81 |
public static final String BUFFER_SELECTION_TOOL_NAME = "bufferSelection"; |
76 | 82 |
|
77 | 83 |
/* |
... | ... | |
98 | 104 |
/* |
99 | 105 |
* Unavaliable tool with views in geographic projections |
100 | 106 |
*/ |
107 |
/* |
|
108 |
* Removed restriction |
|
109 |
* |
|
101 | 110 |
if (!view.getMapControl().getProjection().isProjected()) { |
102 | 111 |
JOptionPane.showMessageDialog(null, |
103 | 112 |
PluginServices.getText(null, |
... | ... | |
106 | 115 |
JOptionPane.ERROR_MESSAGE); |
107 | 116 |
return; |
108 | 117 |
} |
118 |
*/ |
|
109 | 119 |
|
110 | 120 |
MapContext mapContext = model.getMapContext(); |
111 | 121 |
|
... | ... | |
123 | 133 |
|
124 | 134 |
if ((layer instanceof FLyrVect) && (layer.isAvailable()) |
125 | 135 |
&& (layer.isActive())) { |
136 |
|
|
126 | 137 |
usefulLayers.add((FLyrVect) layer); |
127 | 138 |
try { |
128 | 139 |
if (((FLyrVect) layer).getFeatureStore() |
... | ... | |
146 | 157 |
|| emptySelectionLayers == usefulLayers.size()) { |
147 | 158 |
JOptionPane.showMessageDialog(null, |
148 | 159 |
PluginServices.getText(null, |
149 |
"There_are_no_geometries_selected"), |
|
160 |
"_There_are_no_geometries_selected"),
|
|
150 | 161 |
PluginServices.getText(null, "Warning"), |
151 | 162 |
JOptionPane.WARNING_MESSAGE); |
152 | 163 |
|
... | ... | |
155 | 166 |
|
156 | 167 |
// Creates and displays the configuration panel |
157 | 168 |
PluginServices.getMDIManager() |
158 |
.addWindow(new BufferConfigurationPanel((FLyrVect[]) usefulLayers.toArray(new FLyrVect[0]), |
|
169 |
.addWindow(new BufferConfigurationPanel( |
|
170 |
(FLyrVect[]) usefulLayers.toArray(new FLyrVect[0]), |
|
159 | 171 |
view)); |
160 | 172 |
} |
161 | 173 |
} |
... | ... | |
166 | 178 |
*/ |
167 | 179 |
public boolean isVisible() { |
168 | 180 |
IWindow f = PluginServices.getMDIManager().getActiveWindow(); |
169 |
|
|
170 |
if (f == null) { |
|
171 |
return false; |
|
172 |
} |
|
173 |
|
|
174 |
if (f instanceof IView) { |
|
175 |
IView vista = (IView) f; |
|
176 |
ViewDocument model = vista.getViewDocument(); |
|
177 |
MapContext mapa = model.getMapContext(); |
|
178 |
|
|
179 |
return mapa.getLayers().getLayersCount() > 0; |
|
180 |
} |
|
181 |
|
|
182 |
return false; |
|
181 |
return (f instanceof IView); |
|
183 | 182 |
} |
184 | 183 |
|
185 | 184 |
/* |
... | ... | |
199 | 198 |
/* |
200 | 199 |
* Unavaliable tool with views in geographic projections |
201 | 200 |
*/ |
201 |
/* Restriction removed, also for EPSG:4326 etc |
|
202 | 202 |
if (!(vista.getMapControl().getProjection().isProjected())) { |
203 | 203 |
return false; |
204 | 204 |
} |
205 |
*/ |
|
205 | 206 |
|
206 | 207 |
MapContext mapa = model.getMapContext(); |
207 | 208 |
|
... | ... | |
212 | 213 |
layer = layers[i]; |
213 | 214 |
|
214 | 215 |
if ((layer instanceof FLyrVect) && (layer.isAvailable()) |
215 |
&& (layer.isActive())) |
|
216 |
return true; |
|
216 |
&& (layer.isActive())) { |
|
217 |
|
|
218 |
FLyrVect vect = (FLyrVect) layer; |
|
219 |
try { |
|
220 |
FeatureSelection selec = null; |
|
221 |
selec = (FeatureSelection) vect.getFeatureStore().getSelection(); |
|
222 |
if (selec.getSize() > 0) { |
|
223 |
return true; |
|
224 |
} |
|
225 |
} catch (DataException e) { |
|
226 |
logger.info("While getting layer selection.", e); |
|
227 |
} |
|
228 |
} |
|
217 | 229 |
} |
218 | 230 |
} |
219 | 231 |
|
Also available in: Unified diff