/** * <a href="http://www.openolat.org"> * OpenOLAT - Online Learning and Training</a><br> * <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 the * <a href="http://www.apache.org/licenses/LICENSE-2.0">Apache homepage</a> * <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> * Initial code contributed and copyrighted by<br> * frentix GmbH, http://www.frentix.com * <p> */ package org.olat.modules.forms.ui; import org.olat.core.gui.UserRequest; import org.olat.core.gui.components.Component; import org.olat.core.gui.components.dropdown.Dropdown; import org.olat.core.gui.components.link.LinkFactory; import org.olat.core.gui.components.stack.PopEvent; import org.olat.core.gui.control.Controller; import org.olat.core.gui.control.Event; import org.olat.core.gui.control.WindowControl; import org.olat.repository.RepositoryEntry; import org.olat.repository.RepositoryEntryManagedFlag; import org.olat.repository.model.RepositoryEntrySecurity; import org.olat.repository.ui.RepositoryEntryRuntimeController; /** * * Initial date: 6 déc. 2016<br> * @author srosse, stephane.rosse@frentix.com, http://www.frentix.com * */ public class EvaluationFormRuntimeController extends RepositoryEntryRuntimeController { public EvaluationFormRuntimeController(UserRequest ureq, WindowControl wControl, RepositoryEntry re, RepositoryEntrySecurity reSecurity, RuntimeControllerCreator runtimeControllerCreator) { super(ureq, wControl, re, reSecurity, runtimeControllerCreator); } @Override protected void initRuntimeTools(Dropdown toolsDropdown) { if (reSecurity.isEntryAdmin()) { boolean managed = RepositoryEntryManagedFlag.isManaged(getRepositoryEntry(), RepositoryEntryManagedFlag.editcontent); editLink = LinkFactory.createToolLink("edit.cmd", translate("details.openeditor"), this, "o_sel_repository_editor"); editLink.setIconLeftCSS("o_icon o_icon-lg o_icon_edit"); editLink.setEnabled(!managed); toolsDropdown.addComponent(editLink); membersLink = LinkFactory.createToolLink("members", translate("details.members"), this, "o_sel_repo_members"); membersLink.setIconLeftCSS("o_icon o_icon-fw o_icon_membersmanagement"); toolsDropdown.addComponent(membersLink); } if (reSecurity.isEntryAdmin()) { RepositoryEntry re = getRepositoryEntry(); ordersLink = LinkFactory.createToolLink("bookings", translate("details.orders"), this, "o_sel_repo_booking"); ordersLink.setIconLeftCSS("o_icon o_icon-fw o_icon_booking"); boolean booking = acService.isResourceAccessControled(re.getOlatResource(), null); ordersLink.setEnabled(booking); toolsDropdown.addComponent(ordersLink); } } @Override protected void event(UserRequest ureq, Component source, Event event) { if(toolbarPanel == source) { if(event instanceof PopEvent) { PopEvent pe = (PopEvent)event; Controller popedCtrl = pe.getController(); if(popedCtrl instanceof EvaluationFormEditorController) { EvaluationFormEditorController formEditorCtrl = (EvaluationFormEditorController)popedCtrl; if(formEditorCtrl.hasChanges()) { doReloadRuntimeController(ureq); } } } } super.event(ureq, source, event); } private void doReloadRuntimeController(UserRequest ureq) { disposeRuntimeController(); launchContent(ureq, reSecurity); if(toolbarPanel.getTools().isEmpty()) { initToolbar(); } } }