private void replaceLayer(IGeoResource resource,
Collection<IGeoResource> exported) {
List<Layer> layers = MapPaletteSaveStrategy.this.editor.getMap()
.getLayersInternal();
Layer found;
do {
found = null;
for (Layer layer : layers) {
if (URLUtils.urlEquals(layer.getID(), resource
.getIdentifier(), false)) {
found = layer;
break;
}
}
if (found != null) {
layers.addAll(layers.indexOf(found), toLayers(found,
exported));
layers.remove(found);
}
} while (found != null);
}
private Collection<Layer> toLayers(Layer found,
Collection<IGeoResource> exported) {
LayerFactory layerFactory = MapPaletteSaveStrategy.this.editor
.getMap().getLayerFactory();
Collection<Layer> newLayers = new ArrayList<Layer>();
for (IGeoResource exportedResource : exported) {
try {
Layer createLayer = layerFactory
.createLayer(exportedResource);
StyleBlackboard clone = (StyleBlackboard) found
.getStyleBlackboard().clone();
createLayer.setStyleBlackboard(clone);
newLayers.add(createLayer);
} catch (IOException e) {
throw (RuntimeException) new RuntimeException()
.initCause(e);
}