FeatureTypeStyle featureTypeStyle = this.build.createFeatureTypeStyle(
SLDs.GENERIC_FEATURE_TYPENAME, rule);
featureTypeStyle.setName("simple"); //$NON-NLS-1$
featureTypeStyle.setSemanticTypeIdentifiers(new String[]{"generic:geometry", "simple"}); //$NON-NLS-1$ //$NON-NLS-2$
Style style = (Style) getStyleBlackboard().get(SLDContent.ID);
style.setDefault(true);
if (replace.getSelection()) {
// if repalce was hit we are going to completly redfine the style
// based on what the user has here
//
style.featureTypeStyles().clear();
style.featureTypeStyles().add(featureTypeStyle);
} else {
// if we are just responding to what is going on we will try and update the existing
// style in place (leaving any other content alone)
//
List<FeatureTypeStyle> fts = style.featureTypeStyles();
boolean match = false;
for( int i = fts.size() - 1; i > -1; i-- ) {
if (SLDs.isSemanticTypeMatch(fts.get(i), "simple")) { //$NON-NLS-1$
fts.set(i, featureTypeStyle);
match = true;
break;
}
}
if (match) {
style.featureTypeStyles().clear();
style.featureTypeStyles().addAll(fts);
} else {
// add the new entry to the array
List<FeatureTypeStyle> fts2 = new ArrayList<FeatureTypeStyle>(fts);
Collections.copy(fts2, fts);
fts2.add(featureTypeStyle);
style.featureTypeStyles().clear();
style.featureTypeStyles().addAll(fts2);
}
}
// put style on blackboard
getStyleBlackboard().put(SLDContent.ID, style);
((StyleBlackboard) getStyleBlackboard()).setSelected(new String[]{SLDContent.ID});