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();
}
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.
}
}
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;
}
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()));
}
}
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();
}
Aggregations