Revision 16 org.gvsig.lrs/trunk/org.gvsig.lrs/org.gvsig.lrs.app/org.gvsig.lrs.app.mainplugin/src/main/java/org/gvsig/lrs/app/showmeasures/ShowMeasuresExtension.java
ShowMeasuresExtension.java | ||
---|---|---|
65 | 65 |
import org.gvsig.lrs.swing.api.LrsAlgorithmsSwingManager; |
66 | 66 |
import org.gvsig.lrs.swing.impl.JLrsCalibrateRouteParamsController; |
67 | 67 |
import org.gvsig.lrs.swing.impl.JLrsShowMeasuresParamsController; |
68 |
import org.gvsig.lrs.swing.impl.JLrsUtilsController; |
|
68 | 69 |
import org.gvsig.tools.ToolsLocator; |
69 | 70 |
import org.gvsig.tools.dispose.DisposeUtils; |
70 | 71 |
import org.gvsig.tools.exception.BaseException; |
... | ... | |
193 | 194 |
IView view = getActiveView(); |
194 | 195 |
FLyrVect activeLayer = getActiveLayer(view); |
195 | 196 |
if (activeLayer != null) { |
196 |
return correctLayerFound(activeLayer);
|
|
197 |
return JLrsUtilsController.hasMLayersWithSelectedFeatures(activeLayer);
|
|
197 | 198 |
} |
198 | 199 |
return false; |
199 | 200 |
} |
... | ... | |
227 | 228 |
} |
228 | 229 |
return null; |
229 | 230 |
} |
230 |
|
|
231 |
//TODO Extract validations to a common class |
|
232 |
/** |
|
233 |
* Tries to find one curve M-layer with selected Features |
|
234 |
* |
|
235 |
* @param FLayer |
|
236 |
* @return |
|
237 |
* @throws ReadException |
|
238 |
*/ |
|
239 |
private static boolean correctLayerFound(FLayer layer) { |
|
240 |
boolean correctLayerFound = false; |
|
241 |
// Validates is FLyrVect |
|
242 |
FLyrVect lyrVect = null; |
|
243 |
if (layer instanceof FLyrVect) { |
|
244 |
lyrVect = (FLyrVect) layer; |
|
245 |
} else |
|
246 |
return false; |
|
247 |
|
|
248 |
try { |
|
249 |
if (lyrVect != null && (lyrVect.getGeometryType() |
|
250 |
.isTypeOf(Geometry.TYPES.CURVE) |
|
251 |
|| lyrVect.getGeometryType().isTypeOf(Geometry.TYPES.MULTICURVE))) { |
|
252 |
//TODO M-geometry commented to test button |
|
253 |
// if (lyrVect.getGeometryType() |
|
254 |
// .isSubTypeOf(Geometry.SUBTYPES.GEOM2DM) || |
|
255 |
// lyrVect.getGeometryType() |
|
256 |
// .isSubTypeOf(Geometry.SUBTYPES.GEOM3DM)) { |
|
257 |
|
|
258 |
//At least a feature must be selected |
|
259 |
return hasSelectedFeatures(lyrVect); |
|
260 |
|
|
261 |
//} |
|
262 |
} |
|
263 |
} catch (Exception e) { |
|
264 |
logger.error("Can't get linear vector layers", e); |
|
265 |
} |
|
266 |
return correctLayerFound; |
|
267 |
} |
|
268 |
|
|
269 |
private static boolean hasSelectedFeatures(FLyrVect layer) { |
|
270 |
FeatureStore featureStore=layer.getFeatureStore(); |
|
271 |
if(featureStore!=null){ |
|
272 |
try { |
|
273 |
FeatureSelection selectedFeatures= featureStore.getFeatureSelection(); |
|
274 |
if ((selectedFeatures.getSize() >0)) { |
|
275 |
return true; |
|
276 |
} |
|
277 |
} catch (DataException e) { |
|
278 |
logger.warn("Can't get selected feature", e); |
|
279 |
} |
|
280 |
} |
|
281 |
return false; |
|
282 |
} |
|
283 |
|
|
284 | 231 |
} |
Also available in: Unified diff