use of au.org.emii.portal.menu.HasMapLayer in project spatial-portal by AtlasOfLivingAustralia.
the class MapComposer method updateLayerControls.
public void updateLayerControls() {
adjustActiveLayersList();
//remove any scatterplot legend
Component c = getFellowIfAny("scatterplotlayerlegend");
if (c != null) {
c.detach();
}
//remove children
for (int i = layerControls.getChildren().size() - 1; i >= 0; i--) {
layerControls.getChildren().get(i).detach();
}
MapLayer selectedLayer = this.getActiveLayersSelection(false);
if (selectedLayer == null) {
if (activeLayersList.getItemCount() > 0) {
activeLayersList.setSelectedIndex(0);
selectedLayer = (MapLayer) activeLayersList.getModel().getElementAt(0);
} else {
return;
}
}
lblSelectedLayer.setValue(selectedLayer.getDisplayName());
String page;
Window window;
if (selectedLayer.getType() == LayerUtilitiesImpl.SCATTERPLOT) {
page = "WEB-INF/zul/legend/LayerLegendScatterplot.zul";
} else if (selectedLayer.getType() == LayerUtilitiesImpl.MAP) {
page = "WEB-INF/zul/legend/MapOptions.zul";
} else {
Map params = new HashMap();
llc2MapLayer = selectedLayer;
params.put("map_layer", llc2MapLayer);
window = (Window) Executions.createComponents("WEB-INF/zul/legend/LayerLegendGeneral.zul", layerControls, params);
try {
window.doEmbedded();
} catch (Exception e) {
LOGGER.error("error setting up layer legend", e);
}
return;
}
window = (Window) Executions.createComponents(page, layerControls, null);
try {
if (window instanceof HasMapLayer) {
((HasMapLayer) window).setMapLayer(selectedLayer);
}
} catch (Exception e) {
LOGGER.error("failed to set map layer to window: " + (window != null ? window.getId() : "window is null"), e);
}
try {
window.doEmbedded();
} catch (Exception e) {
LOGGER.error("error setting layer legend", e);
}
}
Aggregations