Search in sources :

Example 1 with HasMapLayer

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);
    }
}
Also used : Window(org.zkoss.zul.Window) HasMapLayer(au.org.emii.portal.menu.HasMapLayer) MapLayer(au.org.emii.portal.menu.MapLayer) HasMapLayer(au.org.emii.portal.menu.HasMapLayer) SpeciesAutoCompleteComponent(au.org.ala.spatial.composer.species.SpeciesAutoCompleteComponent) Component(org.zkoss.zk.ui.Component) RemoteMap(au.org.emii.portal.util.RemoteMap) ParseException(org.json.simple.parser.ParseException)

Aggregations

SpeciesAutoCompleteComponent (au.org.ala.spatial.composer.species.SpeciesAutoCompleteComponent)1 HasMapLayer (au.org.emii.portal.menu.HasMapLayer)1 MapLayer (au.org.emii.portal.menu.MapLayer)1 RemoteMap (au.org.emii.portal.util.RemoteMap)1 ParseException (org.json.simple.parser.ParseException)1 Component (org.zkoss.zk.ui.Component)1 Window (org.zkoss.zul.Window)1