Skip to content
Snippets Groups Projects
Commit c27f5588 authored by srosse's avatar srosse
Browse files

OO-594: hardened the window settings implementation, allow changes on the current window

parent c3cb1c85
No related branches found
No related tags found
No related merge requests found
......@@ -29,6 +29,7 @@ package org.olat.core.commons.chiefcontrollers;
import java.util.HashSet;
import java.util.Set;
import org.olat.core.dispatcher.Dispatcher;
import org.olat.core.dispatcher.mapper.GlobalMapperRegistry;
import org.olat.core.dispatcher.mapper.Mapper;
import org.olat.core.gui.UserRequest;
......@@ -62,7 +63,6 @@ import org.olat.core.util.Util;
import org.olat.core.util.i18n.I18nManager;
import org.olat.core.util.i18n.I18nModule;
import org.olat.core.util.prefs.Preferences;
import org.olat.dispatcher.AuthenticatedDispatcher;
/**
* Description: <br>
......@@ -145,7 +145,7 @@ public class BaseChiefController extends DefaultChiefController implements Conte
mainPanel.setContent(mainvc);
WindowManager winman = Windows.getWindows(ureq).getWindowManager();
String wSettings = (String)ureq.getUserSession().removeEntryFromNonClearedStore(AuthenticatedDispatcher.AUTHDISPATCHER_OPTIONS);
String wSettings = (String)ureq.getUserSession().removeEntryFromNonClearedStore(Dispatcher.WINDOW_SETTINGS);
WindowSettings settings = WindowSettings.parse(wSettings);
wbo = winman.createWindowBackOffice("basechiefwindow", this, settings);
Window w = wbo.getWindow();
......
......@@ -135,6 +135,7 @@ public class BaseFullWebappController extends BasicController implements Generic
private Panel initialPanel;
private DTabs myDTabsImpl;
private static Integer MAX_TAB;
private WindowSettings wSettings;
public BaseFullWebappController(UserRequest ureq, WindowControl ouisc_wControl,
BaseFullWebappControllerParts baseFullWebappControllerParts) {
......@@ -365,13 +366,10 @@ public class BaseFullWebappController extends BasicController implements Generic
}
}
WindowSettings wSettings = getWindowControl().getWindowBackOffice().getWindowSettings();
navVc.contextPut("sites", sites);
navVc.contextPut("dtabs", dtabs);
navVc.contextPut("dtabsLinkNames", dtabsLinkNames);
navVc.contextPut("tabhelper", this);
navVc.setVisible(!wSettings.isHideNavigation());
// header, optional (e.g. for logo, advertising )
headerCtr = baseFullWebappControllerParts.createHeaderController(ureq, getWindowControl());
......@@ -379,7 +377,6 @@ public class BaseFullWebappController extends BasicController implements Generic
listenTo(headerCtr); // cleanup on dispose
Component headerCmp = headerCtr.getInitialComponent();
mainVc.put("headerComponent", headerCmp);
headerCmp.setVisible(!wSettings.isHideHeader());
}
// topnav, optional (e.g. for imprint, logout)
......@@ -388,7 +385,6 @@ public class BaseFullWebappController extends BasicController implements Generic
listenTo(topnavCtr); // cleanup on dispose
Component topNavCmp = topnavCtr.getInitialComponent();
mainVc.put("topnavComponent", topNavCmp);
topNavCmp.setVisible(!wSettings.isHideHeader());
}
// panel for modal overlays, placed right after the olat-header-div
......@@ -405,7 +401,6 @@ public class BaseFullWebappController extends BasicController implements Generic
listenTo(footerCtr); // cleanup on dispose
Component footerCmp = footerCtr.getInitialComponent();
mainVc.put("footerComponent", footerCmp);
footerCmp.setVisible(!wSettings.isHideFooter());
}
......@@ -434,9 +429,26 @@ public class BaseFullWebappController extends BasicController implements Generic
String stickyMessage = GlobalStickyMessage.getGlobalStickyMessage();
mainVc.contextPut("hasStickyMessage", (stickyMessage == null ? Boolean.FALSE : Boolean.TRUE));
mainVc.contextPut("stickyMessage", stickyMessage);
setWindowSettings(getWindowControl().getWindowBackOffice().getWindowSettings());
addCustomThemeJS();
}
private void setWindowSettings(WindowSettings wSettings) {
if((this.wSettings == null && wSettings != null)
|| (this.wSettings != null && !this.wSettings.equals(wSettings))) {
this.wSettings = wSettings;
navVc.setVisible(wSettings == null || !wSettings.isHideNavigation());
if (topnavCtr != null) {
topnavCtr.getInitialComponent().setVisible(wSettings == null || !wSettings.isHideHeader());
}
if (footerCtr != null) {
footerCtr.getInitialComponent().setVisible(wSettings == null || !wSettings.isHideFooter());
}
mainVc.setDirty(true);
}
}
/**
* adds the custom js-code to the mainVc
......@@ -908,7 +920,9 @@ public class BaseFullWebappController extends BasicController implements Generic
* org.olat.core.gui.control.generic.dtabs.DTab, java.lang.String)
*/
public void activate(final UserRequest ureq, DTab dTab, final String viewIdentifier, final List<ContextEntry> entries) {
// FIXME:fj:c if viewIdentifier is DTABS.initialView -> activate to this
//update window settings if needed
setWindowSettings(getWindowControl().getWindowBackOffice().getWindowSettings());
// init view (e.g. kurs in run mode, repo-detail-edit...)
// jump here via external link or just open a new tab from e.g. repository
//fxdiff FXOLAT-113: business path in DMZ
......
......@@ -40,6 +40,11 @@ import javax.servlet.http.HttpServletResponse;
* @author Felix Jost
*/
public interface Dispatcher {
/**
* wsettings=hnf12 where
*/
public static final String WINDOW_SETTINGS = "wsettings";
/**
* @param request
......
......@@ -19,7 +19,6 @@
*/
package org.olat.core.gui;
import org.olat.core.util.StringHelper;
/**
*
......@@ -29,24 +28,35 @@ import org.olat.core.util.StringHelper;
*/
public class WindowSettings {
private boolean hideHeader = false;
private boolean hideNavigation = false;
private boolean hideFooter = false;
private boolean hideColumn1 = false;
private boolean hideColumn2 = false;
private final boolean hideHeader;
private final boolean hideNavigation;
private final boolean hideFooter;
private final boolean hideColumn1;
private final boolean hideColumn2;
public WindowSettings() {
//
this(false, false, false, false, false);
}
public WindowSettings(boolean hideHeader, boolean hideNavigation, boolean hideFooter, boolean hideColumn1, boolean hideColumn2) {
this.hideHeader = hideHeader;
this.hideNavigation = hideNavigation;
this.hideFooter = hideFooter;
this.hideColumn1 = hideColumn1;
this.hideColumn2 = hideColumn2;
}
public static WindowSettings parse(String settings) {
WindowSettings wSettings = new WindowSettings();
if(StringHelper.containsNonWhitespace(settings)) {
wSettings.hideHeader = settings.indexOf('h') >= 0;
wSettings.hideNavigation = settings.indexOf('n') >= 0;
wSettings.hideFooter = settings.indexOf('f') >= 0;
wSettings.hideColumn1 = settings.indexOf('1') >= 0;
wSettings.hideColumn2 = settings.indexOf('2') >= 0;
WindowSettings wSettings;
if(settings != null) {
boolean hideHeader = settings.indexOf('h') >= 0;
boolean hideNavigation = settings.indexOf('n') >= 0;
boolean hideFooter = settings.indexOf('f') >= 0;
boolean hideColumn1 = settings.indexOf('1') >= 0;
boolean hideColumn2 = settings.indexOf('2') >= 0;
wSettings = new WindowSettings(hideHeader, hideNavigation, hideFooter, hideColumn1, hideColumn2);
} else {
wSettings = new WindowSettings();
}
return wSettings;
}
......@@ -55,42 +65,22 @@ public class WindowSettings {
return hideHeader;
}
public void setHideHeader(boolean hideHeader) {
this.hideHeader = hideHeader;
}
public boolean isHideNavigation() {
return hideNavigation;
}
public void setHideNavigation(boolean hideNavigation) {
this.hideNavigation = hideNavigation;
}
public boolean isHideFooter() {
return hideFooter;
}
public void setHideFooter(boolean hideFooter) {
this.hideFooter = hideFooter;
}
public boolean isHideColumn1() {
return hideColumn1;
}
public void setHideColumn1(boolean hideColumn1) {
this.hideColumn1 = hideColumn1;
}
public boolean isHideColumn2() {
return hideColumn2;
}
public void setHideColumn2(boolean hideColumn2) {
this.hideColumn2 = hideColumn2;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
......@@ -101,4 +91,18 @@ public class WindowSettings {
if(hideColumn2) sb.append('2');
return sb.toString();
}
}
@Override
public boolean equals(Object obj) {
if(this == obj) {
return true;
}
if(obj instanceof WindowSettings) {
WindowSettings settings = (WindowSettings)obj;
return settings.hideHeader == hideHeader && settings.hideNavigation == hideNavigation
&& settings.hideFooter == hideFooter && settings.hideColumn1 == hideColumn1
&& settings.hideColumn2 == hideColumn2;
}
return false;
}
}
\ No newline at end of file
......@@ -73,7 +73,9 @@ public interface WindowBackOffice extends Disposable{
* Some settings for the current window
* @return
*/
WindowSettings getWindowSettings();
public WindowSettings getWindowSettings();
public void setWindowSettings(WindowSettings settings);
/**
* @param ureq
......
......@@ -167,6 +167,11 @@ public class WindowBackOfficeImpl implements WindowBackOffice {
return settings;
}
@Override
public void setWindowSettings(WindowSettings settings) {
this.settings = settings;
}
/**
* @return
*/
......
......@@ -38,6 +38,7 @@ import org.olat.core.dispatcher.Dispatcher;
import org.olat.core.dispatcher.DispatcherAction;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.UserRequestImpl;
import org.olat.core.gui.WindowSettings;
import org.olat.core.gui.Windows;
import org.olat.core.gui.components.Window;
import org.olat.core.gui.control.ChiefController;
......@@ -66,7 +67,6 @@ public class AuthenticatedDispatcher implements Dispatcher {
protected static final String AUTHDISPATCHER_ENTRYURL = "AuthDispatcher:entryUrl";
protected static final String AUTHDISPATCHER_BUSINESSPATH = "AuthDispatcher:businessPath";
public static final String AUTHDISPATCHER_OPTIONS = "AuthDispatcher:options";
protected static final String QUESTIONMARK = "?";
protected static final String GUEST = "guest";
......@@ -190,8 +190,14 @@ public class AuthenticatedDispatcher implements Dispatcher {
if (businessPath != null) {
BusinessControl bc = BusinessControlFactory.getInstance().createFromString(businessPath);
ChiefController cc = (ChiefController) Windows.getWindows(usess).getAttribute("AUTHCHIEFCONTROLLER");
WindowControl wControl = cc.getWindowControl();
String wSettings = (String) usess.removeEntryFromNonClearedStore(WINDOW_SETTINGS);
if(wSettings != null) {
WindowSettings settings = WindowSettings.parse(wSettings);
wControl.getWindowBackOffice().setWindowSettings(settings);
}
WindowControl bwControl = BusinessControlFactory.getInstance().createBusinessWindowControl(bc, wControl);
NewControllerFactory.getInstance().launch(ureq, bwControl);
// render the window
......
......@@ -294,7 +294,7 @@ public class DMZDispatcher implements Dispatcher {
if (window == null) {
// no window found, -> start a new WorkFlow/Controller and obtain the window
// main controller which also implements the windowcontroller for pagestatus and modal dialogs
Object wSettings = usess.getEntry(AuthenticatedDispatcher.AUTHDISPATCHER_OPTIONS);
Object wSettings = usess.getEntry(WINDOW_SETTINGS);
ChiefController occ = chiefControllerCreator.createChiefController(ureq);
window = occ.getWindow();
......@@ -308,7 +308,7 @@ public class DMZDispatcher implements Dispatcher {
dts.activate(ureq, null, ces);
}
//apply the settings forward
usess.putEntryInNonClearedStore(AuthenticatedDispatcher.AUTHDISPATCHER_OPTIONS, wSettings);
usess.putEntryInNonClearedStore(WINDOW_SETTINGS, wSettings);
}
window.dispatchRequest(ureq);
}
......
......@@ -205,7 +205,7 @@ public class RESTDispatcher implements Dispatcher {
boolean auth = usess.isAuthenticated();
if (auth) {
//fxdiff FXOLAT-113: business path in DMZ
setBusinessPathInUserSession(usess, businessPath, ureq.getParameter("wsettings"));
setBusinessPathInUserSession(usess, businessPath, ureq.getParameter(WINDOW_SETTINGS));
//fxdiff
if (Windows.getWindows(usess).getAttribute("AUTHCHIEFCONTROLLER") == null) {
......@@ -221,7 +221,7 @@ public class RESTDispatcher implements Dispatcher {
} else {
//prepare for redirect
//fxdiff FXOLAT-113: business path in DMZ
setBusinessPathInUserSession(usess, businessPath, ureq.getParameter("wsettings"));
setBusinessPathInUserSession(usess, businessPath, ureq.getParameter(WINDOW_SETTINGS));
String invitationAccess = ureq.getParameter(AuthenticatedDispatcher.INVITATION);
if (invitationAccess != null && LoginModule.isInvitationEnabled()) {
// try to log in as anonymous
......@@ -281,8 +281,8 @@ public class RESTDispatcher implements Dispatcher {
usess.putEntryInNonClearedStore(AuthenticatedDispatcher.AUTHDISPATCHER_BUSINESSPATH, businessPath);
}
}
if(StringHelper.containsNonWhitespace(options) && usess != null) {
usess.putEntryInNonClearedStore(AuthenticatedDispatcher.AUTHDISPATCHER_OPTIONS, options);
if(options != null && usess != null) {
usess.putEntryInNonClearedStore(WINDOW_SETTINGS, options);
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment