use of org.olat.user.DisplayPortraitController in project OpenOLAT by OpenOLAT.
the class MemberInfoController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
Controller dpc = new DisplayPortraitController(ureq, getWindowControl(), identity, true, false);
// auto dispose
listenTo(dpc);
layoutCont.put("image", dpc.getInitialComponent());
layoutCont.contextPut("fullname", StringHelper.escapeHtml(userManager.getUserDisplayName(identity)));
}
// user properties
FormLayoutContainer userPropertiesContainer = FormLayoutContainer.createDefaultFormLayout_6_6("userProperties", getTranslator());
formLayout.add("userProperties", userPropertiesContainer);
List<UserPropertyHandler> userPropertyHandlers = userManager.getUserPropertyHandlersFor(getClass().getCanonicalName(), false);
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null)
continue;
String propName = userPropertyHandler.getName();
String value = userPropertyHandler.getUserProperty(identity.getUser(), getLocale());
String key = userPropertyHandler.i18nFormElementLabelKey();
if (value == null) {
value = "";
}
uifactory.addStaticTextElement("up_" + propName, key, value, userPropertiesContainer);
}
// course informations
FormLayoutContainer courseInfosContainer = FormLayoutContainer.createDefaultFormLayout_9_3("courseInfos", getTranslator());
formLayout.add("courseInfos", courseInfosContainer);
membershipCreationEl = uifactory.addStaticTextElement("firstTime", "course.membership.creation", "", courseInfosContainer);
if (securityModule.isUserLastVisitVisible(ureq.getUserSession().getRoles())) {
Formatter formatter = Formatter.getInstance(getLocale());
String lastVisit = "";
String numOfVisits = "0";
if (courseInfos != null) {
if (courseInfos.getRecentLaunch() != null) {
lastVisit = formatter.formatDate(courseInfos.getRecentLaunch());
}
if (courseInfos.getVisit() >= 0) {
numOfVisits = Integer.toString(courseInfos.getVisit());
}
}
uifactory.addStaticTextElement("lastTime", "course.lastTime", lastVisit, courseInfosContainer);
uifactory.addStaticTextElement("numOfVisits", "course.numOfVisits", numOfVisits, courseInfosContainer);
}
// links
if (withLinks) {
homeLink = uifactory.addFormLink("home", formLayout, Link.BUTTON);
homeLink.setIconLeftCSS("o_icon o_icon_home");
formLayout.add("home", homeLink);
contactLink = uifactory.addFormLink("contact", formLayout, Link.BUTTON);
contactLink.setIconLeftCSS("o_icon o_icon_mail");
formLayout.add("contact", contactLink);
if (repoEntryKey != null) {
assessmentLink = uifactory.addFormLink("assessment", formLayout, Link.BUTTON);
assessmentLink.setIconLeftCSS("o_icon o_icon_certificate");
formLayout.add("assessment", assessmentLink);
}
}
}
use of org.olat.user.DisplayPortraitController in project OpenOLAT by OpenOLAT.
the class OlatTopNavController method getPortraitCmp.
private Component getPortraitCmp(UserRequest ureq) {
Controller ctr = new DisplayPortraitController(ureq, getWindowControl(), getIdentity(), false, false, false, true);
listenTo(ctr);
return ctr.getInitialComponent();
}
use of org.olat.user.DisplayPortraitController in project OpenOLAT by OpenOLAT.
the class EPMapViewController method initForm.
protected void initForm(UserRequest ureq) {
Identity ownerIdentity = ePFMgr.getFirstOwnerIdentity(map);
if (ownerIdentity != null) {
DisplayPortraitController portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), ownerIdentity, false, true, true, false);
mainVc.put("ownerportrait", portraitCtr.getInitialComponent());
}
mainVc.contextPut("map", map);
mainVc.contextPut("style", ePFMgr.getValidStyleName(map));
mainVc.remove(mainVc.getComponent("map.editButton"));
if (secCallback.canEditStructure()) {
editButton = LinkFactory.createButton("map.editButton", mainVc, this);
editButton.setElementCssClass("o_sel_ep_edit_map");
editButton.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
if (editMode == EditMode.view) {
editButton.setCustomDisplayText(translate("map.editButton.on"));
} else {
editButton.setCustomDisplayText(translate("map.editButton.off"));
}
}
if (back) {
backLink = LinkFactory.createLinkBack(mainVc, this);
}
mainVc.remove(mainVc.getComponent("map.submit.assess"));
if (secCallback.canSubmitAssess() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
submitAssessLink = LinkFactory.createButtonSmall("map.submit.assess", mainVc, this);
}
if (map instanceof EPStructuredMap) {
EPTargetResource resource = ((EPStructuredMap) map).getTargetResource();
RepositoryEntry repoEntry = repositoryManager.lookupRepositoryEntry(resource.getOLATResourceable(), false);
if (repoEntry != null) {
mainVc.contextPut("courseName", StringHelper.escapeHtml(repoEntry.getDisplayname()));
String url = Settings.getServerContextPathURI();
url += "/url/RepositoryEntry/" + repoEntry.getKey() + "/CourseNode/" + resource.getSubPath();
mainVc.contextPut("courseLink", url);
}
}
mainVc.remove(mainVc.getComponent("addButton"));
if (secCallback.canAddPage() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
EPAddElementsController addButton = new EPAddElementsController(ureq, getWindowControl(), map);
if (secCallback.canAddPage()) {
addButton.setShowLink(EPAddElementsController.ADD_PAGE);
}
mainVc.put("addButton", addButton.getInitialComponent());
listenTo(addButton);
}
mainVc.contextPut("closed", Boolean.valueOf((StructureStatusEnum.CLOSED.equals(map.getStatus()))));
List<PortfolioStructure> pageList = ePFMgr.loadStructureChildren(map);
if (pageList != null && pageList.size() != 0) {
// prepare to paint pages also
removeAsListenerAndDispose(pageCtrl);
pageCtrl = new EPMultiplePageController(ureq, getWindowControl(), pageList, secCallback);
mainVc.put("pagesCtrl", pageCtrl.getInitialComponent());
listenTo(pageCtrl);
} else if (mainVc.getComponent("pagesCtrl") != null) {
mainVc.remove(mainVc.getComponent("pagesCtrl"));
}
}
use of org.olat.user.DisplayPortraitController in project openolat by klemens.
the class AccessRightsEditController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (member != null && formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
Controller portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), member, true, true);
layoutCont.getFormItemComponent().put("portrait", portraitCtr.getInitialComponent());
listenTo(portraitCtr);
Controller userShortDescrCtr = new UserShortDescription(ureq, getWindowControl(), member);
layoutCont.getFormItemComponent().put("userShortDescription", userShortDescrCtr.getInitialComponent());
listenTo(userShortDescrCtr);
}
selectAll = uifactory.addFormLink("form.checkall", "form.checkall", null, formLayout, Link.LINK);
selectAll.setIconLeftCSS("o_icon o_icon-sm o_icon_check_on");
deselectAll = uifactory.addFormLink("form.uncheckall", "form.uncheckall", null, formLayout, Link.LINK);
deselectAll.setIconLeftCSS("o_icon o_icon-sm o_icon_check_off");
// binder
MultipleSelectionElement coachEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
coachEl.addActionListener(FormEvent.ONCHANGE);
coachEl.setVisible(grading);
MultipleSelectionElement reviewerEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
reviewerEl.addActionListener(FormEvent.ONCHANGE);
binderRow = new BinderAccessRightsRow(coachEl, reviewerEl, binder);
coachEl.setUserObject(binderRow);
reviewerEl.setUserObject(binderRow);
// sections
List<Section> sections = portfolioService.getSections(binder);
Map<Long, SectionAccessRightsRow> sectionMap = new HashMap<>();
for (Section section : sections) {
MultipleSelectionElement sectionCoachEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
sectionCoachEl.addActionListener(FormEvent.ONCHANGE);
sectionCoachEl.setVisible(grading);
MultipleSelectionElement sectionReviewerEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
sectionReviewerEl.addActionListener(FormEvent.ONCHANGE);
SectionAccessRightsRow sectionRow = new SectionAccessRightsRow(sectionCoachEl, sectionReviewerEl, section, binderRow);
binderRow.getSections().add(sectionRow);
sectionMap.put(section.getKey(), sectionRow);
sectionCoachEl.setUserObject(sectionRow);
sectionReviewerEl.setUserObject(sectionRow);
}
// pages
List<Page> pages = portfolioService.getPages(binder, null);
for (Page page : pages) {
Section section = page.getSection();
SectionAccessRightsRow sectionRow = sectionMap.get(section.getKey());
MultipleSelectionElement pageCoachEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
pageCoachEl.addActionListener(FormEvent.ONCHANGE);
pageCoachEl.setVisible(grading);
MultipleSelectionElement pageReviewerEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
pageReviewerEl.addActionListener(FormEvent.ONCHANGE);
PortfolioElementAccessRightsRow pageRow = new PortfolioElementAccessRightsRow(pageCoachEl, pageReviewerEl, page, sectionRow);
sectionRow.getPages().add(pageRow);
pageCoachEl.setUserObject(pageRow);
pageReviewerEl.setUserObject(pageRow);
}
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("binderRow", binderRow);
layoutCont.contextPut("grading", new Boolean(grading));
}
if (hasButtons) {
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonsCont);
buttonsCont.setRootForm(mainForm);
formLayout.add("buttons", buttonsCont);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
removeLink = uifactory.addFormLink("remove", buttonsCont, Link.BUTTON);
if (canEdit) {
uifactory.addFormSubmitButton("save", buttonsCont);
}
}
}
use of org.olat.user.DisplayPortraitController in project openolat by klemens.
the class EPMapViewController method initForm.
protected void initForm(UserRequest ureq) {
Identity ownerIdentity = ePFMgr.getFirstOwnerIdentity(map);
if (ownerIdentity != null) {
DisplayPortraitController portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), ownerIdentity, false, true, true, false);
mainVc.put("ownerportrait", portraitCtr.getInitialComponent());
}
mainVc.contextPut("map", map);
mainVc.contextPut("style", ePFMgr.getValidStyleName(map));
mainVc.remove(mainVc.getComponent("map.editButton"));
if (secCallback.canEditStructure()) {
editButton = LinkFactory.createButton("map.editButton", mainVc, this);
editButton.setElementCssClass("o_sel_ep_edit_map");
editButton.setIconLeftCSS("o_icon o_icon-fw o_icon_edit");
if (editMode == EditMode.view) {
editButton.setCustomDisplayText(translate("map.editButton.on"));
} else {
editButton.setCustomDisplayText(translate("map.editButton.off"));
}
}
if (back) {
backLink = LinkFactory.createLinkBack(mainVc, this);
}
mainVc.remove(mainVc.getComponent("map.submit.assess"));
if (secCallback.canSubmitAssess() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
submitAssessLink = LinkFactory.createButtonSmall("map.submit.assess", mainVc, this);
}
if (map instanceof EPStructuredMap) {
EPTargetResource resource = ((EPStructuredMap) map).getTargetResource();
RepositoryEntry repoEntry = repositoryManager.lookupRepositoryEntry(resource.getOLATResourceable(), false);
if (repoEntry != null) {
mainVc.contextPut("courseName", StringHelper.escapeHtml(repoEntry.getDisplayname()));
String url = Settings.getServerContextPathURI();
url += "/url/RepositoryEntry/" + repoEntry.getKey() + "/CourseNode/" + resource.getSubPath();
mainVc.contextPut("courseLink", url);
}
}
mainVc.remove(mainVc.getComponent("addButton"));
if (secCallback.canAddPage() && !StructureStatusEnum.CLOSED.equals(map.getStatus())) {
EPAddElementsController addButton = new EPAddElementsController(ureq, getWindowControl(), map);
if (secCallback.canAddPage()) {
addButton.setShowLink(EPAddElementsController.ADD_PAGE);
}
mainVc.put("addButton", addButton.getInitialComponent());
listenTo(addButton);
}
mainVc.contextPut("closed", Boolean.valueOf((StructureStatusEnum.CLOSED.equals(map.getStatus()))));
List<PortfolioStructure> pageList = ePFMgr.loadStructureChildren(map);
if (pageList != null && pageList.size() != 0) {
// prepare to paint pages also
removeAsListenerAndDispose(pageCtrl);
pageCtrl = new EPMultiplePageController(ureq, getWindowControl(), pageList, secCallback);
mainVc.put("pagesCtrl", pageCtrl.getInitialComponent());
listenTo(pageCtrl);
} else if (mainVc.getComponent("pagesCtrl") != null) {
mainVc.remove(mainVc.getComponent("pagesCtrl"));
}
}
Aggregations