Search in sources :

Example 6 with PortalSession

use of au.org.emii.portal.session.PortalSession in project spatial-portal by AtlasOfLivingAustralia.

the class MapComposer method load.

/**
 * Initial building of the tree menu and active layers list based on the
 * values obtained from the current session.
 * <p/>
 * JavaScript for loading default map layers and setting the default zoombox
 * is in SessionInit.java
 */
public void load() {
    LOGGER.debug("entering loadMapLayers");
    PortalSession portalSession = getPortalSession();
    List<MapLayer> activeLayers = portalSession.getActiveLayers();
    // model and renderer for active layers list
    ListModelList activeLayerModel = new ListModelList(activeLayers, true);
    // tell the list about them...
    if (activeLayers.isEmpty()) {
        MapLayer ml = remoteMap.createLocalLayer(LayerUtilitiesImpl.MAP, "Map options");
        ml.setRemoveable(false);
        activeLayers.add(ml);
    }
    activeLayersList.setModel(activeLayerModel);
    activeLayersList.setItemRenderer(activeLayerRenderer);
    activeLayersList.setSelectedIndex(activeLayerModel.size() - 1);
    updateLayerControls();
    refreshContextualMenu();
}
Also used : PortalSession(au.org.emii.portal.session.PortalSession) HasMapLayer(au.org.emii.portal.menu.HasMapLayer) MapLayer(au.org.emii.portal.menu.MapLayer)

Example 7 with PortalSession

use of au.org.emii.portal.session.PortalSession in project spatial-portal by AtlasOfLivingAustralia.

the class VisibilityToggleEventListener method onEvent.

@Override
public void onEvent(Event event) throws Exception {
    LOGGER.debug("VisibilityToggleEventListener.onEvent() fired ");
    Checkbox checkbox = (Checkbox) event.getTarget();
    try {
        MapComposer mapComposer = (MapComposer) event.getPage().getFellow(StringConstants.MAPPORTALPAGE);
        if (mapComposer.safeToPerformMapAction()) {
            Listitem listitem = (Listitem) checkbox.getParent().getParent();
            MapLayer layer = listitem.getValue();
            boolean checked = checkbox.isChecked();
            /* checkbox state will be saved automatically in MapLayer instances
                 * with calls to activate/remove in OpenLayersJavascript
                 */
            if (checked) {
                PortalSession portalSession = (PortalSession) Executions.getCurrent().getDesktop().getSession().getAttribute(StringConstants.PORTAL_SESSION);
                openLayersJavascript.execute(openLayersJavascript.getIFrameReferences() + openLayersJavascript.activateMapLayer(layer, false, true) + openLayersJavascript.updateMapLayerIndexes(portalSession.getActiveLayers()));
                checkbox.setTooltiptext("Hide");
                mapComposer.refreshContextualMenu();
            } else {
                openLayersJavascript.removeMapLayerNow(layer);
                checkbox.setTooltiptext("Show");
                mapComposer.refreshContextualMenu();
            }
        } else {
            /* there was a problem performing the action - 'undo'
                 * the user's click on the checkbox
                 */
            checkbox.setChecked(!checkbox.isChecked());
        }
    } catch (Exception e) {
    // toogle won't work if page not completely loaded.
    }
}
Also used : MapComposer(au.org.emii.portal.composer.MapComposer) Checkbox(org.zkoss.zul.Checkbox) MapLayer(au.org.emii.portal.menu.MapLayer) PortalSession(au.org.emii.portal.session.PortalSession) Listitem(org.zkoss.zul.Listitem)

Example 8 with PortalSession

use of au.org.emii.portal.session.PortalSession in project spatial-portal by AtlasOfLivingAustralia.

the class ConfigurationLoaderStage1Impl method load.

private void load() {
    // protect against sticky error flag (remember we're a singleton)
    error = false;
    reloading = true;
    Properties portalDocument = portalDocumentFactory.createPortalDocumentInstance();
    if (portalDocument == null) {
        LOGGER.debug("Configuration file missing or invalid - cannot load portal.  See previous message for cause");
    } else {
        stage2.setProperties(portalDocument);
        // Ask stage2 to load the portal from the PortalDocument instance and
        // pass us back the master session that gets created
        PortalSession masterPortalSession = stage2.load();
        // how this could happen!
        if (stage2.isError()) {
            error = true;
        }
        /* Now we need to store an application scope variable storing the
             * relevant details from the config file
             *
             *  Because its stored as method scope variables and published, we
             *  don't need to worry about concurrent modification.
             *
             *  Also give a copy of servlet context to PortalSessionAccessor
             *  so that it can be accessed via spring
             */
        servletContext.setAttribute(ApplicationInit.PORTAL_MASTER_SESSION_ATTRIBUTE, masterPortalSession);
        LOGGER.debug("finished building master portalSession");
    }
    reloading = false;
}
Also used : PortalSession(au.org.emii.portal.session.PortalSession) Properties(java.util.Properties)

Example 9 with PortalSession

use of au.org.emii.portal.session.PortalSession in project spatial-portal by AtlasOfLivingAustralia.

the class MapComposer method reloadMapLayerNowAndIndexes.

public void reloadMapLayerNowAndIndexes(MapLayer selectedLayer) {
    if (safeToPerformMapAction()) {
        PortalSession portalSession = (PortalSession) Executions.getCurrent().getDesktop().getSession().getAttribute(StringConstants.PORTAL_SESSION);
        openLayersJavascript.execute(openLayersJavascript.getIFrameReferences() + openLayersJavascript.reloadMapLayer(selectedLayer) + openLayersJavascript.updateMapLayerIndexes(portalSession.getActiveLayers()));
    }
}
Also used : PortalSession(au.org.emii.portal.session.PortalSession)

Example 10 with PortalSession

use of au.org.emii.portal.session.PortalSession in project spatial-portal by AtlasOfLivingAustralia.

the class MapComposer method setLayersVisible.

public void setLayersVisible(boolean show) {
    PortalSession portalSession = (PortalSession) Executions.getCurrent().getDesktop().getSession().getAttribute(StringConstants.PORTAL_SESSION);
    for (Listitem li : activeLayersList.getItems()) {
        if (li.getValue() == null || !"Map options".equals(((MapLayer) li.getValue()).getName())) {
            Checkbox cb = (Checkbox) li.getFirstChild().getFirstChild();
            if (show && !cb.isChecked()) {
                openLayersJavascript.execute(openLayersJavascript.getIFrameReferences() + openLayersJavascript.activateMapLayer((MapLayer) li.getValue(), false, true) + openLayersJavascript.updateMapLayerIndexes(portalSession.getActiveLayers()));
            } else if (!show && cb.isChecked()) {
                openLayersJavascript.removeMapLayerNow((MapLayer) li.getValue());
            }
            cb.setChecked(show);
            cb.setTooltiptext(show ? "Hide" : "Show");
        }
    }
    refreshContextualMenu();
}
Also used : Checkbox(org.zkoss.zul.Checkbox) PortalSession(au.org.emii.portal.session.PortalSession) HasMapLayer(au.org.emii.portal.menu.HasMapLayer) MapLayer(au.org.emii.portal.menu.MapLayer)

Aggregations

PortalSession (au.org.emii.portal.session.PortalSession)10 MapLayer (au.org.emii.portal.menu.MapLayer)4 HasMapLayer (au.org.emii.portal.menu.HasMapLayer)2 Checkbox (org.zkoss.zul.Checkbox)2 MapComposer (au.org.emii.portal.composer.MapComposer)1 ConfigurationLoaderStage1Impl (au.org.emii.portal.config.ConfigurationLoaderStage1Impl)1 OpenLayersJavascript (au.org.emii.portal.javascript.OpenLayersJavascript)1 PortalSessionCloner (au.org.emii.portal.util.PortalSessionCloner)1 PortalSessionUtilities (au.org.emii.portal.util.PortalSessionUtilities)1 SessionInitImpl (au.org.emii.portal.web.SessionInitImpl)1 Properties (java.util.Properties)1 HttpSession (javax.servlet.http.HttpSession)1 ParseException (org.json.simple.parser.ParseException)1 Session (org.zkoss.zk.ui.Session)1 SessionInit (org.zkoss.zk.ui.util.SessionInit)1 Listitem (org.zkoss.zul.Listitem)1