Map<String,StyleImpl> nameMap = new HashMap<String, StyleImpl>();
// calculate display names for all styles
// If there are duplicate titles then a combo title(name) is displayed
for (Object s : allStyles) {
StyleImpl wmsStyle =
(StyleImpl) s;
String name = getDisplayName(wmsStyle);
if( nameMap.containsKey(name) ){
// rename the old one and mark it as deleted
StyleImpl oldStyle = nameMap.get(name);
if( oldStyle!=null){
nameMap.put(name, null);
String oldStyleName = name + " ("+oldStyle.getName()+")"; //$NON-NLS-1$ //$NON-NLS-2$
nameMap.put(oldStyleName, oldStyle);
}
name = name + " ("+wmsStyle.getName()+")"; //$NON-NLS-1$ //$NON-NLS-2$
}
// if the key is still used then we will use the first instance only. If
// there are two definitions of the same name and title then there isn't any
// more we can be expected to do
if( !nameMap.containsKey(name) ){
nameMap.put(name, wmsStyle);
}
}
for( Entry<String, StyleImpl> entry : nameMap.entrySet() ) {
if( entry.getValue()!=null) {
styleCombo.add(entry.getKey());
styles.add(entry.getValue());
}
}
//look for a value to set the combo to on the blackboard
StyleImpl style =
(StyleImpl) layer.getStyleBlackboard().get(WMSStyleContent.WMSSTYLE);
boolean set=false;
if (style != null) {
for( int i=0; i<styles.size(); i++) {
StyleImpl wmsStyle = (StyleImpl) styles.get(i);
if( style.equals(wmsStyle) ){
set=true;
styleCombo.select(i);
setDetails(wmsStyle);
break;