use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class ItemsController method createButtonsForItem.
private void createButtonsForItem(UserRequest ureq, Feed feed, Item item) {
boolean author = getIdentity().getKey().equals(item.getAuthorKey());
boolean edit = callback.mayEditItems() || (author && callback.mayEditOwnItems());
boolean delete = callback.mayDeleteItems() || (author && callback.mayDeleteOwnItems());
String guid = item.getGuid();
String editId = "feed.edit.item.".concat(guid);
Link editButton = LinkFactory.createCustomLink(editId, editId, "feed.edit.item", Link.BUTTON_SMALL, vcItems, this);
editButton.setElementCssClass("o_sel_feed_item_edit");
editButton.setEnabled(edit);
editButton.setVisible(edit);
String deleteId = "delete.".concat(guid);
Link deleteButton = LinkFactory.createCustomLink(deleteId, deleteId, "delete", Link.BUTTON_SMALL, vcItems, this);
deleteButton.setElementCssClass("o_sel_feed_item_delete");
deleteButton.setEnabled(delete);
deleteButton.setVisible(delete);
if (feedResource.isInternal() && getIdentity().getKey() != null && getIdentity().getKey().equals(item.getAuthorKey())) {
String businessPath = BusinessControlFactory.getInstance().getAsString(getWindowControl().getBusinessControl());
businessPath += "[item=" + item.getKey() + ":0]";
if (portfolioModule.isEnabled()) {
String name = "feed.artefact.item.".concat(guid);
BlogEntryMedia media = new BlogEntryMedia(feed, item);
MediaCollectorComponent collectorCmp = new MediaCollectorComponent(name, getWindowControl(), media, blogMediaHandler, businessPath);
vcItems.put(name, collectorCmp);
} else {
Controller artefactCtrl = EPUIFactory.createArtefactCollectWizzardController(ureq, getWindowControl(), feedResource, businessPath);
if (artefactCtrl != null) {
artefactLinks.put(item, artefactCtrl);
vcItems.put("feed.artefact.item.".concat(guid), artefactCtrl.getInitialComponent());
}
}
}
editButton.setUserObject(item);
deleteButton.setUserObject(item);
editButtons.add(editButton);
deleteButtons.add(deleteButton);
}
use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class NotesPortletRunController method event.
/**
* @see org.olat.core.gui.control.ControllerEventListener#dispatchEvent(org.olat.core.gui.UserRequest, org.olat.core.gui.control.Controller, org.olat.core.gui.control.Event)
*/
public void event(UserRequest ureq, Controller source, Event event) {
super.event(ureq, source, event);
if (source == tableCtr) {
if (event.getCommand().equals(Table.COMMANDLINK_ROWACTION_CLICKED)) {
TableEvent te = (TableEvent) event;
String actionid = te.getActionId();
if (actionid.equals(CMD_LAUNCH)) {
int rowid = te.getRowId();
final NotePortletEntry pe = (NotePortletEntry) notesListModel.getObject(rowid);
final Note note = pe.getValue();
// will not be disposed on course run dispose, popus up as new browserwindow
ControllerCreator ctrlCreator = new ControllerCreator() {
public Controller createController(UserRequest lureq, WindowControl lwControl) {
Controller nc = new NoteController(lureq, lwControl, note);
// use on column layout
LayoutMain3ColsController layoutCtr = new LayoutMain3ColsController(lureq, lwControl, nc);
// dispose content on layout dispose
layoutCtr.addDisposableChildController(nc);
return layoutCtr;
}
};
// wrap the content controller into a full header layout
ControllerCreator layoutCtrlr = BaseFullWebappPopupLayoutFactory.createAuthMinimalPopupLayout(ureq, ctrlCreator);
// open in new browser window
PopupBrowserWindow pbw = getWindowControl().getWindowBackOffice().getWindowManager().createNewPopupBrowserWindowFor(ureq, layoutCtrlr);
pbw.open(ureq);
//
}
}
}
}
use of org.olat.core.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class FeedRuntimeController method doQuota.
private void doQuota(UserRequest ureq) {
if (quotaManager.hasQuotaEditRights(ureq.getIdentity())) {
RepositoryEntry entry = getRepositoryEntry();
OlatRootFolderImpl feedRoot = FileResourceManager.getInstance().getFileResourceRootImpl(entry.getOlatResource());
WindowControl bwControl = getSubWindowControl("Quota");
Controller quotaCtrl = quotaManager.getQuotaEditorInstance(ureq, addToHistory(ureq, bwControl), feedRoot.getRelPath());
pushController(ureq, translate("tab.quota.edit"), quotaCtrl);
setActiveTool(quotaLink);
}
}
use of org.olat.core.gui.control.Controller 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.gui.control.Controller in project OpenOLAT by OpenOLAT.
the class PodcastCourseNode method createPeekViewRunController.
/**
* @see org.olat.course.nodes.GenericCourseNode#createPeekViewRunController(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 Controller createPeekViewRunController(UserRequest ureq, WindowControl wControl, UserCourseEnvironment userCourseEnv, NodeEvaluation ne) {
if (ne.isAtLeastOneAccessible()) {
// Create a feed peekview controller that shows the latest two entries
RepositoryEntry entry = getReferencedRepositoryEntry();
Long courseId = userCourseEnv.getCourseEnvironment().getCourseResourceableId();
String nodeId = this.getIdent();
boolean isAdmin = ureq.getUserSession().getRoles().isOLATAdmin();
boolean isGuest = ureq.getUserSession().getRoles().isGuestOnly();
// fxdiff BAKS-18
boolean isOwner = RepositoryManager.getInstance().isOwnerOfRepositoryEntry(ureq.getIdentity(), entry);
FeedSecurityCallback callback = new FeedNodeSecurityCallback(ne, isAdmin, isOwner, isGuest);
FeedUIFactory uiFactory = PodcastUIFactory.getInstance(ureq.getLocale());
Controller peekViewController = new FeedPeekviewController(entry.getOlatResource(), ureq, wControl, callback, courseId, nodeId, uiFactory, 2, "o_podcast_peekview");
return peekViewController;
} else {
// use standard peekview
return super.createPeekViewRunController(ureq, wControl, userCourseEnv, ne);
}
}
Aggregations