activators.add(new GridActivator());
}
@Override
protected void initAcceptBehaviours( List<Behaviour> acceptBehaviours ) {
MutualExclusiveBehavior mutualExclusive = new MutualExclusiveBehavior();
acceptBehaviours.add(mutualExclusive);
mutualExclusive.getBehaviours().add(new AcceptChangesBehaviour(Polygon.class, false){
@Override
public boolean isValid( EditToolHandler handler ) {
SimpleFeature feature = handler.getContext().getEditManager().getEditFeature();
if (feature == null)
return false;
Geometry geometry = (Geometry) feature.getDefaultGeometry();
Class< ? extends Geometry> class1 = geometry == null? null : geometry.getClass();
return super.isValid(handler) && feature != null
&& (class1 == Polygon.class || class1 == MultiPolygon.class);
}
});
mutualExclusive.getBehaviours().add(new AcceptChangesBehaviour(LineString.class, false){
@Override
public boolean isValid( EditToolHandler handler ) {
SimpleFeature feature = handler.getContext().getEditManager().getEditFeature();
if (feature == null)
return false;
Class< ? extends Geometry> class1 = ((Geometry) feature.getDefaultGeometry())
.getClass();
return super.isValid(handler) && feature != null
&& (class1 == LineString.class || class1 == MultiLineString.class);
}
});
mutualExclusive.getBehaviours().add(new AcceptChangesBehaviour(Point.class, false){
@Override
public boolean isValid( EditToolHandler handler ) {
SimpleFeature feature = handler.getContext().getEditManager().getEditFeature();
if (feature == null)
return false;