use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project openolat by klemens.
the class EditScoreCalculationEasyForm method initNodeSelectionElement.
/**
* Initializes the node selection form elements first check if the form has a
* selection on a node that has been deleted in since the last edition of this
* form. if so, set remember this to later add a dummy placeholder for the
* deleted node. We do not just ignore this since the form would look ok then
* to the user, the generated rule visible in the expert mode however would
* still be invalid. user must explicitly uncheck this deleted node reference.
*
* @param elemId name of the generated form element
* @param scoreCalculator
* @param selectedNodeList List of course nodes that are preselected
* @param allNodesList List of all assessable course nodes
* @return StaticMultipleSelectionElement The configured form element
*/
private MultipleSelectionElement initNodeSelectionElement(FormItemContainer formLayout, String elemId, ScoreCalculator scoreCalculator, List<String> selectedNodeList, List<CourseNode> allNodesList) {
boolean addDeletedNodeIdent = false;
if (scoreCalculator != null && selectedNodeList != null) {
for (Iterator<String> iter = selectedNodeList.iterator(); iter.hasNext(); ) {
String nodeIdent = iter.next();
boolean found = false;
for (Iterator<CourseNode> nodeIter = allNodesList.iterator(); nodeIter.hasNext(); ) {
CourseNode node = nodeIter.next();
if (node.getIdent().equals(nodeIdent)) {
found = true;
}
}
if (!found)
addDeletedNodeIdent = true;
}
}
String[] nodeKeys = new String[allNodesList.size() + (addDeletedNodeIdent ? 1 : 0)];
String[] nodeValues = new String[allNodesList.size() + (addDeletedNodeIdent ? 1 : 0)];
for (int i = 0; i < allNodesList.size(); i++) {
CourseNode courseNode = allNodesList.get(i);
nodeKeys[i] = courseNode.getIdent();
nodeValues[i] = courseNode.getShortName() + " (Id:" + courseNode.getIdent() + ")";
}
// add a deleted dummy node at last position
if (addDeletedNodeIdent) {
nodeKeys[allNodesList.size()] = DELETED_NODE_IDENTIFYER;
nodeValues[allNodesList.size()] = translate("scform.deletedNode");
}
MultipleSelectionElement mse = uifactory.addCheckboxesVertical(elemId, formLayout, nodeKeys, nodeValues, 2);
// preselect nodes from configuration
if (scoreCalculator != null && selectedNodeList != null) {
for (Iterator<String> iter = selectedNodeList.iterator(); iter.hasNext(); ) {
String nodeIdent = iter.next();
boolean found = false;
for (Iterator<CourseNode> nodeIter = allNodesList.iterator(); nodeIter.hasNext(); ) {
CourseNode node = nodeIter.next();
if (node.getIdent().equals(nodeIdent)) {
found = true;
}
}
if (found) {
mse.select(nodeIdent, true);
} else {
mse.select(DELETED_NODE_IDENTIFYER, true);
}
}
}
return mse;
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement 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.core.gui.components.form.flexible.elements.MultipleSelectionElement in project openolat by klemens.
the class AccessRightsEditController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (removeLink == source) {
fireEvent(ureq, new AccessRightsEvent(AccessRightsEvent.REMOVE_ALL_RIGHTS));
} else if (selectAll == source) {
binderRow.setCoach();
binderRow.recalculate();
} else if (deselectAll == source) {
binderRow.unsetCoach();
binderRow.unsetReviewer();
for (SectionAccessRightsRow sectionRow : binderRow.getSections()) {
sectionRow.unsetCoach();
sectionRow.unsetReviewer();
for (PortfolioElementAccessRightsRow pageRow : sectionRow.getPages()) {
pageRow.unsetCoach();
pageRow.unsetReviewer();
}
}
} else if (source instanceof MultipleSelectionElement) {
binderRow.recalculate();
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project openolat by klemens.
the class BinderAssessmentController method forgeAssessmentSection.
private void forgeAssessmentSection(AssessmentSectionWrapper row) {
AssessmentSection assessmentSection = row.getAssessmentSection();
Section section = row.getSection();
if (!SectionStatus.isClosed(section)) {
// score
String pointVal = null;
if (assessmentSection != null && assessmentSection.getScore() != null) {
BigDecimal score = assessmentSection.getScore();
pointVal = AssessmentHelper.getRoundedScore(score);
}
TextElement pointEl = uifactory.addTextElement("point" + (++counter), null, 5, pointVal, flc);
pointEl.setDisplaySize(5);
row.setScoreEl(pointEl);
// passed
Boolean passed = assessmentSection == null ? null : assessmentSection.getPassed();
MultipleSelectionElement passedEl = uifactory.addCheckboxesHorizontal("check" + (++counter), null, flc, onKeys, onValues);
if (passed != null && passed.booleanValue()) {
passedEl.select(onKeys[0], passed.booleanValue());
}
row.setPassedEl(passedEl);
}
if (SectionStatus.isClosed(section)) {
FormLink reopenButton = uifactory.addFormLink("reopen" + (++counter), "reopen", "reopen", null, flc, Link.BUTTON);
reopenButton.setElementCssClass("o_sel_pf_reopen_section");
reopenButton.setUserObject(row);
row.setButton(reopenButton);
} else {
FormLink closeButton = uifactory.addFormLink("close" + (++counter), "close", "close.section", null, flc, Link.BUTTON);
closeButton.setElementCssClass("o_sel_pf_close_section");
closeButton.setUserObject(row);
row.setButton(closeButton);
}
}
use of org.olat.core.gui.components.form.flexible.elements.MultipleSelectionElement in project openolat by klemens.
the class InvitationEditRightsController method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
formLayout.setElementCssClass("o_sel_pf_invitation_form");
FormLayoutContainer inviteeCont = FormLayoutContainer.createDefaultFormLayout("inviteeInfos", getTranslator());
inviteeCont.setRootForm(mainForm);
formLayout.add("inviteeInfos", inviteeCont);
firstNameEl = uifactory.addTextElement("firstName", "firstName", 64, invitation.getFirstName(), inviteeCont);
firstNameEl.setElementCssClass("o_sel_pf_invitation_firstname");
firstNameEl.setMandatory(true);
lastNameEl = uifactory.addTextElement("lastName", "lastName", 64, invitation.getLastName(), inviteeCont);
lastNameEl.setElementCssClass("o_sel_pf_invitation_lastname");
lastNameEl.setMandatory(true);
String invitationEmail = email != null ? email : invitation.getMail();
mailEl = uifactory.addTextElement("mail", "mail", 128, invitationEmail, inviteeCont);
mailEl.setElementCssClass("o_sel_pf_invitation_mail");
mailEl.setMandatory(true);
mailEl.setNotEmptyCheck("map.share.empty.warn");
mailEl.setEnabled(invitation.getKey() == null);
if (StringHelper.containsNonWhitespace(invitation.getMail()) && MailHelper.isValidEmailAddress(invitation.getMail())) {
SecurityGroup allUsers = securityManager.findSecurityGroupByName(Constants.GROUP_OLATUSERS);
List<Identity> shareWithIdentities = userManager.findIdentitiesByEmail(Collections.singletonList(invitation.getMail()));
if (isAtLeastOneInSecurityGroup(shareWithIdentities, allUsers)) {
mailEl.setErrorKey("map.share.with.mail.error.olatUser", new String[] { invitation.getMail() });
}
}
String link = getInvitationLink();
StaticTextElement linkEl = uifactory.addStaticTextElement("invitation.link", link, inviteeCont);
linkEl.setElementCssClass("o_sel_pf_invitation_url");
linkEl.setLabel("invitation.link", null);
if (mailTemplate != null) {
subjectEl = uifactory.addTextElement("subjectElem", "mail.subject", 128, mailTemplate.getSubjectTemplate(), inviteeCont);
subjectEl.setDisplaySize(60);
subjectEl.setMandatory(true);
bodyEl = uifactory.addTextAreaElement("bodyElem", "mail.body", -1, 15, 60, true, mailTemplate.getBodyTemplate(), inviteeCont);
bodyEl.setHelpUrlForManualPage("E-Mail");
bodyEl.setMandatory(true);
}
// binder
MultipleSelectionElement accessEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
accessEl.addActionListener(FormEvent.ONCHANGE);
binderRow = new BinderAccessRightsRow(accessEl, binder);
// sections
List<Section> sections = portfolioService.getSections(binder);
Map<Long, SectionAccessRightsRow> sectionMap = new HashMap<>();
for (Section section : sections) {
MultipleSelectionElement sectionAccessEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
sectionAccessEl.addActionListener(FormEvent.ONCHANGE);
SectionAccessRightsRow sectionRow = new SectionAccessRightsRow(sectionAccessEl, section, binderRow);
binderRow.getSections().add(sectionRow);
sectionMap.put(section.getKey(), sectionRow);
}
// pages
List<Page> pages = portfolioService.getPages(binder, null);
for (Page page : pages) {
Section section = page.getSection();
SectionAccessRightsRow sectionRow = sectionMap.get(section.getKey());
MultipleSelectionElement pageAccessEl = uifactory.addCheckboxesHorizontal("access-" + (counter++), null, formLayout, theKeys, theValues);
pageAccessEl.addActionListener(FormEvent.ONCHANGE);
PortfolioElementAccessRightsRow pageRow = new PortfolioElementAccessRightsRow(pageAccessEl, page, sectionRow);
sectionRow.getPages().add(pageRow);
}
if (formLayout instanceof FormLayoutContainer) {
FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout;
layoutCont.contextPut("binderRow", binderRow);
}
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");
FormLayoutContainer buttonsCont = FormLayoutContainer.createButtonLayout("buttons", getTranslator());
formLayout.add(buttonsCont);
buttonsCont.setRootForm(mainForm);
uifactory.addFormCancelButton("cancel", buttonsCont, ureq, getWindowControl());
if (invitation.getKey() != null) {
removeLink = uifactory.addFormLink("remove", buttonsCont, Link.BUTTON);
}
uifactory.addFormSubmitButton("save", buttonsCont);
}
Aggregations