/**
* OLAT - Online Learning and Training<br>
* http://www.olat.org
* <p>
* Licensed under the Apache License, Version 2.0 (the "License"); <br>
* you may not use this file except in compliance with the License.<br>
* You may obtain a copy of the License at
* <p>
* http://www.apache.org/licenses/LICENSE-2.0
* <p>
* Unless required by applicable law or agreed to in writing,<br>
* software distributed under the License is distributed on an "AS IS" BASIS,
* <br>
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. <br>
* See the License for the specific language governing permissions and <br>
* limitations under the License.
* <p>
* Copyright (c) since 2004 at Multimedia- & E-Learning Services (MELS),<br>
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.modules.fo;
import org.olat.core.commons.fullWebApp.LayoutMain3ColsController;
import org.olat.core.commons.fullWebApp.popup.BaseFullWebappPopupLayoutFactory;
import org.olat.core.gui.UserRequest;
import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.creator.ControllerCreator;
import org.olat.core.gui.control.generic.popup.PopupBrowserWindow;
import org.olat.core.gui.control.generic.title.TitleInfo;
import org.olat.core.gui.control.generic.title.TitledWrapperController;
import org.olat.core.util.StringHelper;
/**
*
* Description:<br>
* Factory for a Titled <code>ForumController</code>, either in a popup or not.
*
* <P>
* Initial Date: 25.06.2007 <br>
* @author Lavinia Dumitrescu
*/
public class ForumUIFactory {
/**
* Provides a popable ForumController wrapped in a titled controller.
* @param ureq
* @param forum
* @param forumCallback
* @param title
* @return a ChiefController
*/
public static PopupBrowserWindow getPopupableForumController(UserRequest ureq, WindowControl wControl, final Forum forum, final ForumCallback forumCallback, final TitleInfo titleInfo) {
ControllerCreator ctrlCreator = new ControllerCreator() {
public Controller createController(UserRequest lureq, WindowControl lwControl) {
Controller forumWrapperController = getTitledForumController(lureq, lwControl, forum, forumCallback, titleInfo);
// use on column layout
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, null, null, forumWrapperController.getInitialComponent(), null);
layoutCtr.addDisposableChildController(forumWrapperController); // dispose content on layout dispose
return layoutCtr;
}
};
//wrap the content controller into a full header layout
ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
PopupBrowserWindow pbw = wControl.getWindowBackOffice().getWindowManager().createNewPopupBrowserWindowFor(ureq, layoutCtrlr);
return pbw;
}
/**
* Provides a ForumController wrapped in a titled controller.
* @param ureq
* @param forum
* @param forumCallback
* @param title
* @return a TitledWrapperController
*/
public static Controller getTitledForumController(UserRequest ureq, WindowControl wControl, Forum forum, ForumCallback forumCallback, TitleInfo titleInfo) {
ForumController popupFoCtr = new ForumController(forum, forumCallback, ureq, wControl);
TitledWrapperController forumWrapperController = new TitledWrapperController(ureq, wControl, popupFoCtr, "o_course_run", titleInfo);
// Set CSS values to default forum icons if no values are set in the title info
if (!StringHelper.containsNonWhitespace(titleInfo.getCssClass())) {
forumWrapperController.setTitleCssClass(" b_with_small_icon_left " + ForumHelper.CSS_ICON_CLASS_FORUM + " ");
}
return forumWrapperController;
}
/**
* Provides a standard forum controller without a title element
* @param ureq
* @param wControl
* @param forum
* @param forumCallback
* @return
*/
public static ForumController getStandardForumController(UserRequest ureq, WindowControl wControl, Forum forum, ForumCallback forumCallback) {
return new ForumController(forum, forumCallback, ureq, wControl);
}
}