use of org.olat.user.DisplayPortraitController in project openolat by klemens.
the class SingleParticipantCallController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
int numOfChecks = lectureBlock.getPlannedLecturesNumber();
List<Integer> absences = rollCall.getLecturesAbsentList();
for (int i = 0; i < numOfChecks; i++) {
String checkId = "check_" + i;
MultipleSelectionElement check = uifactory.addCheckboxesHorizontal(checkId, null, layoutCont, onKeys, onValues);
check.setDomReplacementWrapperRequired(false);
check.addActionListener(FormEvent.ONCHANGE);
if (absences.contains(i)) {
check.select(onKeys[0], true);
}
checks.add(check);
}
layoutCont.contextPut("checks", checks);
DisplayPortraitController portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), calledIdentity, true, false);
listenTo(portraitCtr);
layoutCont.getFormItemComponent().put("portrait", portraitCtr.getInitialComponent());
UserShortDescription userDescr = new UserShortDescription(ureq, getWindowControl(), calledIdentity);
listenTo(userDescr);
layoutCont.getFormItemComponent().put("userDescr", userDescr.getInitialComponent());
}
if (autorizedAbsenceEnabled) {
authorizedAbsencedEl = uifactory.addCheckboxesHorizontal("authorized.absence", "authorized.absence", formLayout, onKeys, onValues);
authorizedAbsencedEl.setDomReplacementWrapperRequired(false);
authorizedAbsencedEl.addActionListener(FormEvent.ONCHANGE);
if (rollCall.getAbsenceAuthorized() != null && rollCall.getAbsenceAuthorized().booleanValue()) {
authorizedAbsencedEl.select(onKeys[0], true);
}
String reason = rollCall.getAbsenceReason();
absenceReasonEl = uifactory.addTextAreaElement("absence.reason", "authorized.absence.reason", 2000, 4, 36, false, reason, formLayout);
absenceReasonEl.setDomReplacementWrapperRequired(false);
absenceReasonEl.setPlaceholderKey("authorized.absence.reason", null);
absenceReasonEl.setVisible(authorizedAbsencedEl.isAtLeastSelected(1));
absenceReasonEl.setMandatory(!absenceDefaultAuthorized);
}
String comment = rollCall.getComment();
commentEl = uifactory.addTextAreaElement("comment", "rollcall.comment", 2000, 4, 36, false, comment, formLayout);
commentEl.setPlaceholderKey("rollcall.comment", null);
selectAllLink = uifactory.addFormLink("all", formLayout);
uifactory.addFormSubmitButton("save", "save.next", formLayout);
uifactory.addFormCancelButton("cancel", formLayout, ureq, getWindowControl());
}
use of org.olat.user.DisplayPortraitController in project openolat by klemens.
the class GTACoachController method initContainer.
@Override
protected void initContainer(UserRequest ureq) {
mainVC = createVelocityContainer("coach");
reviewedButton = LinkFactory.createCustomLink("coach.reviewed.button", "reviewed", "coach.reviewed.button", Link.BUTTON, mainVC, this);
reviewedButton.setElementCssClass("o_sel_course_gta_reviewed");
reviewedButton.setIconLeftCSS("o_icon o_icon_accepted");
reviewedButton.setPrimary(true);
reviewedButton.setVisible(!coachCourseEnv.isCourseReadOnly());
if (config.getBooleanSafe(GTACourseNode.GTASK_REVISION_PERIOD)) {
needRevisionsButton = LinkFactory.createCustomLink("coach.need.revision.button", "need-revision", "coach.need.revision.button", Link.BUTTON, mainVC, this);
needRevisionsButton.setElementCssClass("o_sel_course_gta_need_revision");
needRevisionsButton.setPrimary(true);
needRevisionsButton.setVisible(!coachCourseEnv.isCourseReadOnly());
needRevisionsButton.setIconLeftCSS("o_icon o_icon_rejected");
}
if (withTitle) {
if (assessedGroup != null) {
mainVC.contextPut("groupName", assessedGroup.getName());
emailLink = LinkFactory.createButtonXSmall("mailto.group", mainVC, this);
emailLink.setIconLeftCSS("o_icon o_icon_mail");
} else if (assessedIdentity != null) {
mainVC.contextPut("identityFullName", userManager.getUserDisplayName(assessedIdentity));
Controller dpc = new DisplayPortraitController(ureq, getWindowControl(), assessedIdentity, false, true, true, true);
// auto dispose, no need to keep local reference
listenTo(dpc);
mainVC.put("image", dpc.getInitialComponent());
emailLink = LinkFactory.createButtonXSmall("mailto.user", mainVC, this);
emailLink.setIconLeftCSS("o_icon o_icon_mail");
}
}
if (withReset) {
resetTaskButton = LinkFactory.createCustomLink("coach.reset.button", "reset", "coach.reset.button", Link.BUTTON, mainVC, this);
resetTaskButton.setElementCssClass("o_sel_course_gta_reset");
resetTaskButton.setVisible(false);
}
putInitialPanel(mainVC);
}
use of org.olat.user.DisplayPortraitController in project openolat by klemens.
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 klemens.
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 klemens.
the class MessageEditController method initForm.
/**
* @see org.olat.core.gui.components.form.flexible.impl.FormBasicController#initForm(org.olat.core.gui.components.form.flexible.FormItemContainer,
* org.olat.core.gui.control.Controller, org.olat.core.gui.UserRequest)
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
formLayout.setElementCssClass("o_sel_forum_message_form");
titleEl = uifactory.addTextElement("msgTitle", "msg.title", 100, message.getTitle(), formLayout);
titleEl.setElementCssClass("o_sel_forum_message_title");
titleEl.setMandatory(true);
titleEl.setNotEmptyCheck("error.field.not.empty");
bodyEl = uifactory.addRichTextElementForStringData("msgBody", "msg.body", message.getBody(), 15, -1, true, null, null, formLayout, ureq.getUserSession(), getWindowControl());
bodyEl.setMandatory(true);
bodyEl.setNotEmptyCheck("error.field.not.empty");
bodyEl.setMaxLength(MAX_BODY_LENGTH);
bodyEl.setNotLongerThanCheck(MAX_BODY_LENGTH, "input.toolong");
bodyEl.getEditorConfiguration().enableCharCount();
setEditPermissions(message);
// list existing attachments. init attachment layout now, to place it in
// right position
createOrUpdateAttachmentListLayout(formLayout);
// provide upload field
if (foCallback.mayEditMessageAsModerator() || ((userIsMsgCreator) && (msgHasChildren == false))) {
fileUpload = uifactory.addFileElement(getWindowControl(), "msg.upload", formLayout);
fileUpload.addActionListener(FormEvent.ONCHANGE);
fileUpload.setMaxUploadSizeKB((int) FolderConfig.getLimitULKB(), "attachments.too.big", new String[] { ((Long) (FolderConfig.getLimitULKB() / 1024)).toString() });
}
if (foCallback.mayUsePseudonym() || guestOnly) {
String[] enablePseudonymValues = new String[] { translate("use.pseudonym.label") };
usePseudonymEl = uifactory.addCheckboxesHorizontal("use.pseudonym", formLayout, enableKeys, enablePseudonymValues);
if (StringHelper.containsNonWhitespace(message.getPseudonym()) || guestOnly || foCallback.pseudonymAsDefault()) {
usePseudonymEl.select(enableKeys[0], true);
}
pseudonymEl = uifactory.addTextElement("pseudonym", "pseudonym", 128, message.getPseudonym(), formLayout);
pseudonymEl.setElementCssClass("o_sel_forum_message_alias");
passwordEl = uifactory.addPasswordElement("password", "password", 128, "", formLayout);
passwordEl.setElementCssClass("o_sel_forum_message_alias_pass");
passwordEl.setPlaceholderKey("password.placeholder", null);
passwordEl.setAutocomplete("new-password");
if (guestOnly) {
usePseudonymEl.setVisible(false);
pseudonymEl.setLabel("use.pseudonym", null);
pseudonymEl.setMandatory(true);
proposedPseudonym = (String) ureq.getUserSession().getEntry("FOPseudo" + forum.getKey());
if (StringHelper.containsNonWhitespace(proposedPseudonym)) {
pseudonymEl.setValue(proposedPseudonym);
String proposedPassword = (String) ureq.getUserSession().getEntry("FOPseudo-" + proposedPseudonym);
if (StringHelper.containsNonWhitespace(proposedPassword)) {
passwordEl.setValue(proposedPassword);
}
}
} else if (userIsMsgCreator) {
pseudonymEl.setLabel(null, null);
usePseudonymEl.addActionListener(FormEvent.ONCHANGE);
proposedPseudonym = fm.getPseudonym(forum, getIdentity());
if (StringHelper.containsNonWhitespace(proposedPseudonym)) {
pseudonymEl.setValue(proposedPseudonym);
usePseudonymEl.select(enableKeys[0], true);
String proposedPassword = (String) ureq.getUserSession().getEntry("FOPseudo-" + proposedPseudonym);
if (StringHelper.containsNonWhitespace(proposedPassword)) {
passwordEl.setValue(proposedPassword);
}
}
usePseudonymEl.setMandatory(usePseudonymEl.isAtLeastSelected(1));
pseudonymEl.setVisible(usePseudonymEl.isAtLeastSelected(1));
passwordEl.setVisible(usePseudonymEl.isAtLeastSelected(1));
} else {
usePseudonymEl.setVisible(false);
pseudonymEl.setLabel("use.pseudonym", null);
pseudonymEl.setEnabled(false);
passwordEl.setVisible(false);
}
}
// save and cancel buttons
FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonLayout);
uifactory.addFormSubmitButton("msg.save", buttonLayout);
uifactory.addFormCancelButton("msg.cancel", buttonLayout, ureq, getWindowControl());
// show message replying to, if in reply modus
if (editMode == EditMode.reply) {
String previewPage = Util.getPackageVelocityRoot(this.getClass()) + "/msg-preview.html";
FormLayoutContainer replyMsgLayout = FormLayoutContainer.createCustomFormLayout("replyMsg", getTranslator(), previewPage);
uifactory.addSpacerElement("spacer1", formLayout, false);
formLayout.add(replyMsgLayout);
replyMsgLayout.setLabel("label.replytomsg", new String[] { StringHelper.escapeHtml(parentMessage.getTitle()) });
replyMsgLayout.contextPut("messageBody", parentMessage.getBody());
replyMsgLayout.contextPut("message", parentMessage);
replyMsgLayout.contextPut("guestOnly", new Boolean(guestOnly));
Identity creator = parentMessage.getCreator();
if (creator != null) {
replyMsgLayout.contextPut("identity", creator);
portraitCtr = new DisplayPortraitController(ureq, getWindowControl(), creator, true, true);
replyMsgLayout.put("portrait", portraitCtr.getInitialComponent());
}
}
}
Aggregations