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

OO-3997: fix activation path for course element calendar

parent 8ce5752c
No related branches found
No related tags found
No related merge requests found
......@@ -234,7 +234,7 @@ public class WeeklyCalendarController extends FormBasicController implements Act
@Override
public void setFocusOnEvent(String eventId, String recurenceId) {
if (eventId.length() > 0) {
if(StringHelper.containsNonWhitespace(eventId)) {
for(KalendarRenderWrapper wrapper:calendarWrappers) {
KalendarEvent event = wrapper.getKalendar().getEvent(eventId, recurenceId);
if(event != null) {
......
......@@ -351,7 +351,7 @@ public class BusinessControlFactory {
* @return
*/
public List<ContextEntry> createCEListFromResourceType(String resourceType) {
List<ContextEntry> entries = new ArrayList<ContextEntry>(3);
List<ContextEntry> entries = new ArrayList<>(3);
if(StringHelper.containsNonWhitespace(resourceType)) {
OLATResourceable ores = OresHelper.createOLATResourceableInstanceWithoutCheck(resourceType, 0l);
ContextEntry entry = createContextEntry(ores);
......@@ -366,7 +366,7 @@ public class BusinessControlFactory {
* @return
*/
public List<ContextEntry> createCEListFromString(String businessControlString) {
List<ContextEntry> entries = new ArrayList<ContextEntry>();
List<ContextEntry> entries = new ArrayList<>();
if(!StringHelper.containsNonWhitespace(businessControlString)) {
return entries;
}
......
......@@ -21,6 +21,7 @@
package org.olat.course.nodes.cal;
import java.util.Date;
import java.util.List;
import org.olat.core.commons.fullWebApp.LayoutMain3ColsController;
import org.olat.core.commons.fullWebApp.popup.BaseFullWebappPopupLayoutFactory;
......@@ -31,11 +32,13 @@ import org.olat.core.gui.control.Controller;
import org.olat.core.gui.control.Event;
import org.olat.core.gui.control.WindowControl;
import org.olat.core.gui.control.controller.BasicController;
import org.olat.core.gui.control.creator.ControllerCreator;
import org.olat.core.gui.control.generic.clone.CloneController;
import org.olat.core.gui.control.generic.clone.CloneLayoutControllerCreatorCallback;
import org.olat.core.id.OLATResourceable;
import org.olat.core.gui.control.generic.dtabs.Activateable2;
import org.olat.core.id.context.BusinessControlFactory;
import org.olat.core.id.context.ContextEntry;
import org.olat.core.id.context.StateEntry;
import org.olat.core.util.StringHelper;
import org.olat.course.CourseFactory;
import org.olat.course.nodes.CalCourseNode;
import org.olat.course.run.userview.NodeEvaluation;
......@@ -50,11 +53,11 @@ import org.olat.modules.ModuleConfiguration;
* Initial Date: 4 nov. 2009 <br>
* @author srosse, stephane.rosse@frentix.com, www.frentix.com
*/
public class CalRunController extends BasicController {
public class CalRunController extends BasicController implements Activateable2 {
private CourseCalendarController calCtr;
private ModuleConfiguration config;
private CloneController cloneCtr;
private final CourseCalendarController calCtr;
private final CloneController cloneCtr;
private final ModuleConfiguration config;
/**
*
......@@ -65,59 +68,48 @@ public class CalRunController extends BasicController {
*/
public CalRunController(WindowControl wControl, UserRequest ureq, CalCourseNode calCourseNode, UserCourseEnvironment courseEnv, NodeEvaluation ne) {
super(ureq, wControl);
this.config = calCourseNode.getModuleConfiguration();
config = calCourseNode.getModuleConfiguration();
VelocityContainer mainVC = createVelocityContainer("run");
CourseCalendars myCal = CourseCalendars.createCourseCalendarsWrapper(ureq, wControl, courseEnv, ne);
calCtr = new CourseCalendarController(ureq, wControl, myCal, courseEnv, ne);
boolean focused = false;
ContextEntry ce = wControl.getBusinessControl().popLauncherContextEntry();
if ( ce != null ) { // a context path is left for me
OLATResourceable ores = ce.getOLATResourceable();
String typeName = ores.getResourceableTypeName();
String eventId = typeName.substring("path=".length());
if(eventId.indexOf(':') > 0) {
eventId = eventId.substring(0, eventId.indexOf(':'));
}
if (eventId.length() > 0) {
calCtr.setFocusOnEvent(eventId, null);
focused = true;
}
}
if(!focused) {
Date startDate = null;
if(CalEditController.getAutoDate(config)) {
startDate = new Date();
} else {
startDate = CalEditController.getStartDate(config);
if(startDate == null) startDate = new Date();
}
calCtr.setFocus(startDate);
listenTo(calCtr);
Date startDate = null;
if(CalEditController.getAutoDate(config)) {
startDate = new Date();
} else {
startDate = CalEditController.getStartDate(config);
if(startDate == null) startDate = new Date();
}
calCtr.setFocus(startDate);
CloneLayoutControllerCreatorCallback clccc = new CloneLayoutControllerCreatorCallback() {
@Override
public ControllerCreator createLayoutControllerCreator(UserRequest uureq, final ControllerCreator contentControllerCreator) {
return BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(uureq, new ControllerCreator() {
@Override
public Controller createController(UserRequest lureq, WindowControl lwControl) {
// wrapp in column layout, popup window needs a layout controller
Controller ctr = contentControllerCreator.createController(lureq, lwControl);
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, ctr);
layoutCtr.setCustomCSS(CourseFactory.getCustomCourseCss(lureq.getUserSession(), courseEnv.getCourseEnvironment()));
layoutCtr.addDisposableChildController(ctr);
return layoutCtr;
}
});
}
CloneLayoutControllerCreatorCallback clccc = (uureq, contentControllerCreator) -> {
return BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(uureq, (lureq, lwControl) -> {
// wrap in column layout, popup window needs a layout controller
Controller ctr = contentControllerCreator.createController(lureq, lwControl);
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, ctr);
layoutCtr.setCustomCSS(CourseFactory.getCustomCourseCss(lureq.getUserSession(), courseEnv.getCourseEnvironment()));
layoutCtr.addDisposableChildController(ctr);
return layoutCtr;
});
};
cloneCtr = new CloneController(ureq, getWindowControl(), calCtr, clccc);
cloneCtr = new CloneController(ureq, getWindowControl(), calCtr, clccc);
mainVC.put("cal", cloneCtr.getInitialComponent());
putInitialPanel(mainVC);
}
@Override
public void activate(UserRequest ureq, List<ContextEntry> entries, StateEntry state) {
if(entries == null || entries.isEmpty()) return;
ContextEntry ce = entries.get(0);
String eventId = BusinessControlFactory.getInstance().getPath(ce);
if(StringHelper.containsNonWhitespace(eventId)) {
calCtr.setFocusOnEvent(eventId, null);
}
}
@Override
public void event(UserRequest ureq, Component source, Event event) {
//no events yet
......@@ -127,11 +119,9 @@ public class CalRunController extends BasicController {
protected void doDispose() {
if(calCtr != null){
calCtr.dispose();
calCtr = null;
}
if(cloneCtr != null){
cloneCtr.dispose();
cloneCtr = null;
}
}
}
\ No newline at end of file
......@@ -67,9 +67,7 @@ public class CourseCalendarController extends DefaultController implements Clone
courseEnv.getCourseEnvironment().getCourseGroupManager().getCourseResource(), false);
calendarController.setDifferentiateManagedEvent(CourseCalendars.needToDifferentiateManagedEvents(calendars));
setInitialComponent(calendarController.getInitialComponent());
}
}
public CourseCalendarSubscription getCalendarSubscription() {
return calendarSubscription;
......
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