use of org.olat.core.commons.controllers.linkchooser.CustomLinkTreeModel in project OpenOLAT by OpenOLAT.
the class STCourseNode method createNodeRunConstructionResult.
/**
* @see org.olat.course.nodes.CourseNode#createNodeRunConstructionResult(org.olat.core.gui.UserRequest,
* org.olat.core.gui.control.WindowControl,
* org.olat.course.run.userview.UserCourseEnvironment,
* org.olat.course.run.userview.NodeEvaluation)
*/
@Override
public NodeRunConstructionResult createNodeRunConstructionResult(UserRequest ureq, WindowControl wControl, final UserCourseEnvironment userCourseEnv, NodeEvaluation ne, String nodecmd) {
updateModuleConfigDefaults(false);
Controller cont;
String displayType = getModuleConfiguration().getStringValue(STCourseNodeEditController.CONFIG_KEY_DISPLAY_TYPE);
String relPath = STCourseNodeEditController.getFileName(getModuleConfiguration());
if (relPath != null && displayType.equals(STCourseNodeEditController.CONFIG_VALUE_DISPLAY_FILE)) {
// we want a user chosen overview, so display the chosen file from the
// material folder, otherwise display the normal overview
// reuse the Run controller from the "Single Page" building block, since
// we need to do exactly the same task
Boolean allowRelativeLinks = getModuleConfiguration().getBooleanEntry(STCourseNodeEditController.CONFIG_KEY_ALLOW_RELATIVE_LINKS);
if (allowRelativeLinks == null) {
allowRelativeLinks = Boolean.FALSE;
}
DeliveryOptions deliveryOptions = (DeliveryOptions) getModuleConfiguration().get(SPEditController.CONFIG_KEY_DELIVERYOPTIONS);
OLATResourceable ores = OresHelper.createOLATResourceableInstance(CourseModule.class, userCourseEnv.getCourseEnvironment().getCourseResourceableId());
SinglePageController spCtr = new SinglePageController(ureq, wControl, userCourseEnv.getCourseEnvironment().getCourseFolderContainer(), relPath, allowRelativeLinks.booleanValue(), null, ores, deliveryOptions, userCourseEnv.getCourseEnvironment().isPreview());
// check if user is allowed to edit the page in the run view
CourseGroupManager cgm = userCourseEnv.getCourseEnvironment().getCourseGroupManager();
boolean hasEditRights = (cgm.isIdentityCourseAdministrator(ureq.getIdentity()) || cgm.hasRight(ureq.getIdentity(), CourseRights.RIGHT_COURSEEDITOR)) || (getModuleConfiguration().getBooleanSafe(SPEditController.CONFIG_KEY_ALLOW_COACH_EDIT, false) && cgm.isIdentityCourseCoach(ureq.getIdentity()));
if (hasEditRights) {
spCtr.allowPageEditing();
// set the link tree model to internal for the HTML editor
CustomLinkTreeModel linkTreeModel = new CourseInternalLinkTreeModel(userCourseEnv.getCourseEnvironment().getRunStructure().getRootNode());
spCtr.setInternalLinkTreeModel(linkTreeModel);
}
spCtr.addLoggingResourceable(LoggingResourceable.wrap(this));
// create clone wrapper layout, allow popping into second window
CloneLayoutControllerCreatorCallback clccc = new CloneLayoutControllerCreatorCallback() {
@Override
public ControllerCreator createLayoutControllerCreator(final UserRequest uureq, final ControllerCreator contentControllerCreator) {
return BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(uureq, new ControllerCreator() {
@Override
public Controller createController(UserRequest lureq, WindowControl 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(), userCourseEnv.getCourseEnvironment()));
Controller wrappedCtrl = TitledWrapperHelper.getWrapper(lureq, lwControl, ctr, STCourseNode.this, ICON_CSS_CLASS);
layoutCtr.addDisposableChildController(wrappedCtrl);
return layoutCtr;
}
});
}
};
Controller wrappedCtrl = TitledWrapperHelper.getWrapper(ureq, wControl, spCtr, this, ICON_CSS_CLASS);
if (wrappedCtrl instanceof CloneableController) {
cont = new CloneController(ureq, wControl, (CloneableController) wrappedCtrl, clccc);
} else {
throw new AssertException("Need to be a cloneable");
}
} else {
// evaluate the score accounting for this node. this uses the score accountings local
// cache hash map to reduce unnecessary calculations
ScoreEvaluation se = userCourseEnv.getScoreAccounting().evalCourseNode(this);
cont = TitledWrapperHelper.getWrapper(ureq, wControl, new STCourseNodeRunController(ureq, wControl, userCourseEnv, this, se, ne), this, ICON_CSS_CLASS);
}
// displayed in the ST-Runcontroller
return new NodeRunConstructionResult(cont);
}
use of org.olat.core.commons.controllers.linkchooser.CustomLinkTreeModel in project OpenOLAT by OpenOLAT.
the class CourseRuntimeController method doCourseFolder.
private FolderRunController doCourseFolder(UserRequest ureq) {
if (delayedClose == Delayed.courseFolder || requestForClose(ureq)) {
removeCustomCSS();
// Folder for course with custom link model to jump to course nodes
ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
VFSContainer courseContainer;
if (overrideReadOnly) {
courseContainer = course.getCourseFolderContainer(overrideReadOnly);
} else {
courseContainer = course.getCourseFolderContainer();
}
VFSContainer namedCourseFolder = new NamedContainerImpl(translate("command.coursefolder"), courseContainer);
CustomLinkTreeModel customLinkTreeModel = new CourseInternalLinkTreeModel(course.getEditorTreeModel());
FolderRunController ctrl = new FolderRunController(namedCourseFolder, true, true, true, true, ureq, getWindowControl(), null, customLinkTreeModel, null);
ctrl.addLoggingResourceable(LoggingResourceable.wrap(course));
courseFolderCtrl = pushController(ureq, translate("command.coursefolder"), ctrl);
setActiveTool(folderLink);
currentToolCtr = courseFolderCtrl;
} else {
delayedClose = Delayed.courseFolder;
}
return courseFolderCtrl;
}
use of org.olat.core.commons.controllers.linkchooser.CustomLinkTreeModel in project openolat by klemens.
the class RichTextElementComponent method createFileSelectorPopupWindow.
private void createFileSelectorPopupWindow(final UserRequest ureq, final String type, final String fileName) {
// Get allowed suffixes from configuration and requested media browser type from event
final RichTextConfiguration config = element.getEditorConfiguration();
final boolean allowCustomMediaFactory = config.isAllowCustomMediaFactory();
final boolean uriValidation = config.isFilenameUriValidation();
final String[] suffixes;
if (type.equals(CMD_FILEBROWSER)) {
suffixes = null;
} else if (type.equals(CMD_IMAGEBROWSER)) {
suffixes = config.getLinkBrowserImageSuffixes();
} else if (type.equals(CMD_FLASHPLAYERBROWSER)) {
suffixes = config.getLinkBrowserFlashPlayerSuffixes();
} else {
suffixes = config.getLinkBrowserMediaSuffixes();
}
// Show popup window with file browser to select file
// Only one popup file chooser allowed at any time. ccc contains icc,
// icc gets disposed by ccc
// helper code which is used to create link chooser controller
ControllerCreator linkChooserControllerCreator = new ControllerCreator() {
@Override
public Controller createController(UserRequest lureq, WindowControl lwControl) {
LinkChooserController myLinkChooserController;
VFSContainer baseContainer = config.getLinkBrowserBaseContainer();
String uploadRelPath = config.getLinkBrowserUploadRelPath();
String absolutePath = config.getLinkBrowserAbsolutFilePath();
CustomLinkTreeModel linkBrowserCustomTreeModel = config.getLinkBrowserCustomLinkTreeModel();
if (type.equals(CMD_FILEBROWSER)) {
// when in file mode we include the internal links to the selection
myLinkChooserController = new LinkChooserController(lureq, lwControl, baseContainer, uploadRelPath, absolutePath, suffixes, uriValidation, fileName, linkBrowserCustomTreeModel, allowCustomMediaFactory);
} else {
// in media or image mode, internal links make no sense here
myLinkChooserController = new LinkChooserController(lureq, lwControl, baseContainer, uploadRelPath, absolutePath, suffixes, uriValidation, fileName, null, allowCustomMediaFactory);
}
return new LayoutMain3ColsController(lureq, lwControl, myLinkChooserController);
}
};
PopupBrowserWindow pbw = Windows.getWindows(ureq).getWindowManager().createNewPopupBrowserWindowFor(ureq, linkChooserControllerCreator);
pbw.open(ureq);
}
use of org.olat.core.commons.controllers.linkchooser.CustomLinkTreeModel in project openolat by klemens.
the class CourseRuntimeController method doCourseFolder.
private FolderRunController doCourseFolder(UserRequest ureq) {
if (delayedClose == Delayed.courseFolder || requestForClose(ureq)) {
removeCustomCSS();
// Folder for course with custom link model to jump to course nodes
ICourse course = CourseFactory.loadCourse(getRepositoryEntry());
VFSContainer courseContainer;
if (overrideReadOnly) {
courseContainer = course.getCourseFolderContainer(overrideReadOnly);
} else {
courseContainer = course.getCourseFolderContainer();
}
VFSContainer namedCourseFolder = new NamedContainerImpl(translate("command.coursefolder"), courseContainer);
CustomLinkTreeModel customLinkTreeModel = new CourseInternalLinkTreeModel(course.getEditorTreeModel());
FolderRunController ctrl = new FolderRunController(namedCourseFolder, true, true, true, true, ureq, getWindowControl(), null, customLinkTreeModel, null);
ctrl.addLoggingResourceable(LoggingResourceable.wrap(course));
courseFolderCtrl = pushController(ureq, translate("command.coursefolder"), ctrl);
setActiveTool(folderLink);
currentToolCtr = courseFolderCtrl;
} else {
delayedClose = Delayed.courseFolder;
}
return courseFolderCtrl;
}
use of org.olat.core.commons.controllers.linkchooser.CustomLinkTreeModel in project OpenOLAT by OpenOLAT.
the class RichTextElementComponent method createFileSelectorPopupWindow.
private void createFileSelectorPopupWindow(final UserRequest ureq, final String type, final String fileName) {
// Get allowed suffixes from configuration and requested media browser type from event
final RichTextConfiguration config = element.getEditorConfiguration();
final boolean allowCustomMediaFactory = config.isAllowCustomMediaFactory();
final boolean uriValidation = config.isFilenameUriValidation();
final String[] suffixes;
if (type.equals(CMD_FILEBROWSER)) {
suffixes = null;
} else if (type.equals(CMD_IMAGEBROWSER)) {
suffixes = config.getLinkBrowserImageSuffixes();
} else if (type.equals(CMD_FLASHPLAYERBROWSER)) {
suffixes = config.getLinkBrowserFlashPlayerSuffixes();
} else {
suffixes = config.getLinkBrowserMediaSuffixes();
}
// Show popup window with file browser to select file
// Only one popup file chooser allowed at any time. ccc contains icc,
// icc gets disposed by ccc
// helper code which is used to create link chooser controller
ControllerCreator linkChooserControllerCreator = new ControllerCreator() {
@Override
public Controller createController(UserRequest lureq, WindowControl lwControl) {
LinkChooserController myLinkChooserController;
VFSContainer baseContainer = config.getLinkBrowserBaseContainer();
String uploadRelPath = config.getLinkBrowserUploadRelPath();
String absolutePath = config.getLinkBrowserAbsolutFilePath();
CustomLinkTreeModel linkBrowserCustomTreeModel = config.getLinkBrowserCustomLinkTreeModel();
if (type.equals(CMD_FILEBROWSER)) {
// when in file mode we include the internal links to the selection
myLinkChooserController = new LinkChooserController(lureq, lwControl, baseContainer, uploadRelPath, absolutePath, suffixes, uriValidation, fileName, linkBrowserCustomTreeModel, allowCustomMediaFactory);
} else {
// in media or image mode, internal links make no sense here
myLinkChooserController = new LinkChooserController(lureq, lwControl, baseContainer, uploadRelPath, absolutePath, suffixes, uriValidation, fileName, null, allowCustomMediaFactory);
}
return new LayoutMain3ColsController(lureq, lwControl, myLinkChooserController);
}
};
PopupBrowserWindow pbw = Windows.getWindows(ureq).getWindowManager().createNewPopupBrowserWindowFor(ureq, linkChooserControllerCreator);
pbw.open(ureq);
}
Aggregations