diff --git a/src/main/java/org/olat/core/commons/chiefcontrollers/BaseChiefController.java b/src/main/java/org/olat/core/commons/chiefcontrollers/BaseChiefController.java index 9c1ad8355a5720ecc5e51b67fcc9a0ca18d09f81..bfb266a1a3897290dc5186f5fdc855d9331ff42a 100644 --- a/src/main/java/org/olat/core/commons/chiefcontrollers/BaseChiefController.java +++ b/src/main/java/org/olat/core/commons/chiefcontrollers/BaseChiefController.java @@ -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(); diff --git a/src/main/java/org/olat/core/commons/fullWebApp/BaseFullWebappController.java b/src/main/java/org/olat/core/commons/fullWebApp/BaseFullWebappController.java index 388fac51a1d17666203145889ae7c5c4e4532501..7401721fd7e5fa744e74690aeab05069f8545d64 100644 --- a/src/main/java/org/olat/core/commons/fullWebApp/BaseFullWebappController.java +++ b/src/main/java/org/olat/core/commons/fullWebApp/BaseFullWebappController.java @@ -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 diff --git a/src/main/java/org/olat/core/dispatcher/Dispatcher.java b/src/main/java/org/olat/core/dispatcher/Dispatcher.java index ed2c966faa3c8695483fb11baaf18abe41fad850..42eb4830735013a2aa22a5ae5eb3b55c55f81c5e 100644 --- a/src/main/java/org/olat/core/dispatcher/Dispatcher.java +++ b/src/main/java/org/olat/core/dispatcher/Dispatcher.java @@ -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 diff --git a/src/main/java/org/olat/core/gui/WindowSettings.java b/src/main/java/org/olat/core/gui/WindowSettings.java index 288518a2ead7122882b2dd35d7e44cf82e8ba0b8..11d1f27c0bbfb9efe0c7c5f398b19ae6700f4d9f 100644 --- a/src/main/java/org/olat/core/gui/WindowSettings.java +++ b/src/main/java/org/olat/core/gui/WindowSettings.java @@ -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 diff --git a/src/main/java/org/olat/core/gui/control/WindowBackOffice.java b/src/main/java/org/olat/core/gui/control/WindowBackOffice.java index b120217fb9497578ef9f6b47337f94d28978f39d..82914fd2d6b69c756ff1bb7b8967d2c936707b85 100644 --- a/src/main/java/org/olat/core/gui/control/WindowBackOffice.java +++ b/src/main/java/org/olat/core/gui/control/WindowBackOffice.java @@ -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 diff --git a/src/main/java/org/olat/core/gui/control/winmgr/WindowBackOfficeImpl.java b/src/main/java/org/olat/core/gui/control/winmgr/WindowBackOfficeImpl.java index 445a2f417d2dad9bf31be8e961c834c1291a7311..7dbda4a8f90b4a91cefa0f41260c7735de079da4 100644 --- a/src/main/java/org/olat/core/gui/control/winmgr/WindowBackOfficeImpl.java +++ b/src/main/java/org/olat/core/gui/control/winmgr/WindowBackOfficeImpl.java @@ -167,6 +167,11 @@ public class WindowBackOfficeImpl implements WindowBackOffice { return settings; } + @Override + public void setWindowSettings(WindowSettings settings) { + this.settings = settings; + } + /** * @return */ diff --git a/src/main/java/org/olat/dispatcher/AuthenticatedDispatcher.java b/src/main/java/org/olat/dispatcher/AuthenticatedDispatcher.java index 0887f4fe24803a5c5fb8a6c46c1ce2f70cdb438f..9907ccbba40ecb889e5fcf75fa4aaeb19946a62f 100644 --- a/src/main/java/org/olat/dispatcher/AuthenticatedDispatcher.java +++ b/src/main/java/org/olat/dispatcher/AuthenticatedDispatcher.java @@ -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 diff --git a/src/main/java/org/olat/dispatcher/DMZDispatcher.java b/src/main/java/org/olat/dispatcher/DMZDispatcher.java index 25338e70820c134751a6e5b26ce965d5d96fc179..db5bcd034b4016352378a9ca824f4ff6224dc8b7 100644 --- a/src/main/java/org/olat/dispatcher/DMZDispatcher.java +++ b/src/main/java/org/olat/dispatcher/DMZDispatcher.java @@ -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); } diff --git a/src/main/java/org/olat/dispatcher/RESTDispatcher.java b/src/main/java/org/olat/dispatcher/RESTDispatcher.java index 97583c7580c6e33af04c63ab9f852a98c2a46b44..05e1ddd412a16a990beaa7ec70fc292338a316bd 100644 --- a/src/main/java/org/olat/dispatcher/RESTDispatcher.java +++ b/src/main/java/org/olat/dispatcher/RESTDispatcher.java @@ -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); } }