private SliderRow forgeSliderRow(Slider slider) { String startLabel = slider.getStartLabel(); TextElement startLabelEl = uifactory.addTextElement( "start.label." + count.incrementAndGet(), "start.label", 256, startLabel, flc); startLabelEl.setDomReplacementWrapperRequired(false); String endLabel = slider.getEndLabel(); TextElement endLabelEl = uifactory.addTextElement( "end.label." + count.incrementAndGet(), "end.label", 256, endLabel, flc); endLabelEl.setDomReplacementWrapperRequired(false); SliderRow row = new SliderRow(slider, startLabelEl, endLabelEl); if (!restrictedEdit) { FormLink deleteButton = uifactory.addFormLink( "del." + count.incrementAndGet(), "delete_slider", "", null, flc, Link.BUTTON | Link.NONTRANSLATED); deleteButton.setDomReplacementWrapperRequired(false); deleteButton.setIconLeftCSS("o_icon o_icon-lg o_icon_delete_item"); deleteButton.setUserObject(row); row.setDeleteButton(deleteButton); flc.contextPut("deleteButtons", Boolean.TRUE); } return row; }
@Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { addSolutionLink = uifactory.addFormLink("add.solution", formLayout, Link.BUTTON); addSolutionLink.setElementCssClass("o_sel_course_gta_add_solution"); addSolutionLink.setIconLeftCSS("o_icon o_icon_upload"); createSolutionLink = uifactory.addFormLink("create.solution", formLayout, Link.BUTTON); createSolutionLink.setElementCssClass("o_sel_course_gta_create_solution"); createSolutionLink.setIconLeftCSS("o_icon o_icon_edit"); FlexiTableColumnModel columnsModel = FlexiTableDataModelFactory.createFlexiTableColumnModel(); columnsModel.addFlexiColumnModel( new DefaultFlexiColumnModel(SolCols.title.i18nKey(), SolCols.title.ordinal())); columnsModel.addFlexiColumnModel( new DefaultFlexiColumnModel(SolCols.file.i18nKey(), SolCols.file.ordinal())); columnsModel.addFlexiColumnModel( new DefaultFlexiColumnModel(SolCols.author.i18nKey(), SolCols.author.ordinal())); columnsModel.addFlexiColumnModel( new StaticFlexiColumnModel( "table.header.edit", SolCols.edit.ordinal(), "edit", new BooleanCellRenderer( new StaticFlexiCellRenderer(translate("edit"), "edit"), new StaticFlexiCellRenderer(translate("replace"), "edit")))); columnsModel.addFlexiColumnModel( new StaticFlexiColumnModel("table.header.edit", translate("delete"), "delete")); solutionModel = new SolutionTableModel(columnsModel); solutionTable = uifactory.addTableElement( getWindowControl(), "table", solutionModel, getTranslator(), formLayout); solutionTable.setExportEnabled(true); updateModel(); }
@Override protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) { if (applyToAllEl == source) { boolean allGroup = applyToAllEl.isAtLeastSelected(1); table.setVisible(!allGroup); if (groupPassedEl != null) { groupPassedEl.setVisible(allGroup); } if (groupScoreEl != null) { groupScoreEl.setVisible(allGroup); } if (groupCommentEl != null) { groupCommentEl.setVisible(allGroup); } } else if (source == saveAndDoneButton) { if (validateFormLogic(ureq)) { applyChanges(true); fireEvent(ureq, Event.CLOSE_EVENT); } } else if (source instanceof FormLink) { FormLink link = (FormLink) source; if ("comment".equals(link.getCmd())) { AssessmentRow row = (AssessmentRow) link.getUserObject(); doEditComment(ureq, row); } } super.formInnerEvent(ureq, source, event); }
@Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { if (editable) { List<AccessMethod> methods = acService.getAvailableMethods(getIdentity(), ureq.getUserSession().getRoles()); for (AccessMethod method : methods) { AccessMethodHandler handler = acModule.getAccessMethodHandler(method.getType()); if (handler.isPaymentMethod() && !allowPaymentMethod) { continue; } String title = handler.getMethodName(getLocale()); FormLink add = uifactory.addFormLink( "create." + handler.getType(), title, null, formLayout, Link.LINK | Link.NONTRANSLATED); add.setUserObject(method); add.setIconLeftCSS(("o_icon " + method.getMethodCssClass() + "_icon o_icon-lg").intern()); addMethods.add(add); formLayout.add(add.getName(), add); } ((FormLayoutContainer) formLayout).contextPut("methods", addMethods); } String confPage = velocity_root + "/configuration_list.html"; confControllerContainer = FormLayoutContainer.createCustomFormLayout("conf-controllers", getTranslator(), confPage); confControllerContainer.setRootForm(mainForm); formLayout.add(confControllerContainer); loadConfigurations(); confControllerContainer.contextPut("confControllers", confControllers); if (!embbed) { setFormTitle("accesscontrol.title"); setFormContextHelp( AccessConfigurationController.class.getPackage().getName(), "accesscontrol.html", "chelp.accesscontrol.hover"); if (editable) { final FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonLayout", getTranslator()); buttonGroupLayout.setRootForm(mainForm); formLayout.add(buttonGroupLayout); formLayout.add("buttonLayout", buttonGroupLayout); uifactory.addFormSubmitButton("save", buttonGroupLayout); } } confControllerContainer.contextPut( "emptyConfigGrantsFullAccess", Boolean.valueOf(emptyConfigGrantsFullAccess)); }
@Override public boolean isInterceptionRequired(UserRequest ureq) { UserSession usess = ureq.getUserSession(); boolean interception = false; if (isREST(ureq)) { // do nothing } else if (!historyModule.isResumeEnabled()) { String bc = getLandingBC(ureq); launch(ureq, bc); } else if (usess.getRoles().isGuestOnly()) { String bc = getLandingBC(ureq); launch(ureq, bc); } else { Preferences prefs = usess.getGuiPreferences(); String resumePrefs = (String) prefs.get(WindowManager.class, "resume-prefs"); if (!StringHelper.containsNonWhitespace(resumePrefs)) { resumePrefs = historyModule.getResumeDefaultSetting(); } if ("none".equals(resumePrefs)) { String bc = getLandingBC(ureq); launch(ureq, bc); } else if ("auto".equals(resumePrefs)) { HistoryPoint historyEntry = HistoryManager.getInstance().readHistoryPoint(ureq.getIdentity()); if (historyEntry != null && StringHelper.containsNonWhitespace(historyEntry.getBusinessPath())) { List<ContextEntry> cloneCes = BusinessControlFactory.getInstance().cloneContextEntries(historyEntry.getEntries()); BusinessControl bc = BusinessControlFactory.getInstance().createFromContextEntries(cloneCes); launch(ureq, bc); } else { String bc = getLandingBC(ureq); launch(ureq, bc); } } else if ("ondemand".equals(resumePrefs)) { HistoryPoint historyEntry = historyManager.readHistoryPoint(ureq.getIdentity()); if (historyEntry != null && StringHelper.containsNonWhitespace(historyEntry.getBusinessPath())) { interception = true; String bc = getLandingBC(ureq); if (StringHelper.containsNonWhitespace(bc)) { noButton.setVisible(false); } else { landingButton.setVisible(false); } } else { String bc = getLandingBC(ureq); launch(ureq, bc); } } } return interception; }
protected void addConfiguration(OfferAccess link) { AccessMethodHandler handler = acModule.getAccessMethodHandler(link.getMethod().getType()); AccessInfo infos = new AccessInfo(handler.getMethodName(getLocale()), handler.isPaymentMethod(), null, link); confControllers.add(infos); if (editable) { FormLink editLink = uifactory.addFormLink( "edit_" + link.getKey(), "edit", "edit", null, confControllerContainer, Link.BUTTON_SMALL); editLink.setUserObject(infos); editLink.setIconLeftCSS("o_icon o_icon-fw o_icon_edit"); confControllerContainer.add(editLink.getName(), editLink); FormLink delLink = uifactory.addFormLink( "del_" + link.getKey(), "delete", "delete", null, confControllerContainer, Link.BUTTON_SMALL); delLink.setUserObject(infos); delLink.setIconLeftCSS("o_icon o_icon-fw o_icon_delete_item"); confControllerContainer.add(delLink.getName(), delLink); } }
@Override protected void initForm( final FormItemContainer formLayout, final Controller listener, final UserRequest ureq) { setFormTitle("cpmd.flexi.formtitle"); final int defaultDisplaySize = 32; // title-field final String titleString = page.getTitle(); title = uifactory.addTextElement("title", "cpmd.flexi.title", 256, titleString, formLayout); title.setDisplaySize(defaultDisplaySize); title.setMandatory(true); title.setNotEmptyCheck("cpmd.flexi.mustbefilled"); // description = formUIf.addTextAreaElement("descr", 256, 5, 2, true, metadata.getDescription(), // "cpmd.flexi.descr", formLayout); // description.setDisplaySize(defaultDisplaySize); // // // keywords-field // keywords = formUIf.addTextElement("keywords", 256, metadata.getKeywords(), // "cpmd.flexi.keywords", formLayout); // keywords.setDisplaySize(defaultDisplaySize); // // formUIf.addStaticTextElement("hr", "<hr />", formLayout); // // version = formUIf.addTextElement("version", 256, metadata.getVersion(), "cpmd.flexi.version", // formLayout); // status = formUIf.addTextElement("status", 256, metadata.getStatus(), "cpmd.flexi.status", // formLayout); // date = formUIf.addDateChooser("date", metadata.getDate(), formLayout); // format = formUIf.addTextElement("format", 256, metadata.getFormat(), "cpmd.flexi.format", // formLayout); // author = formUIf.addTextElement("author", 256, metadata.getAuthor(), "cpmd.flexi.author", // formLayout); final FormItemContainer buttonContainer = FormLayoutContainer.createHorizontalFormLayout("buttonContainer", getTranslator()); formLayout.add(buttonContainer); // Submit buttons lSave = new FormLinkImpl("lSave", "lSave", "submit", Link.BUTTON); lSave.addActionListener(this, FormEvent.ONCLICK); lSaveandclose = new FormLinkImpl("lSaveandclose", "lSaveandclose", "saveandclose", Link.BUTTON); lSaveandclose.addActionListener(this, FormEvent.ONCLICK); buttonContainer.add(lSave); buttonContainer.add(lSaveandclose); }
@Override protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) { if (addMethods.contains(source)) { AccessMethod method = (AccessMethod) source.getUserObject(); addMethod(ureq, method); } else if (source instanceof FormLink) { FormLink button = (FormLink) source; String cmd = button.getCmd(); if ("delete".equals(cmd)) { AccessInfo infos = (AccessInfo) source.getUserObject(); acService.deleteOffer(infos.getLink().getOffer()); confControllers.remove(infos); } else if ("edit".equals(cmd)) { AccessInfo infos = (AccessInfo) source.getUserObject(); editMethod(ureq, infos); } } super.formInnerEvent(ureq, source, event); }
@Override protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) { if (addSliderButton == source) { doAddSlider(); } else if (typeEl == source) { updateTypeSettings(); updateSteps(); } else if (stepsEl == source) { updateSteps(); } else if (saveButton == source) { if (validateFormLogic(ureq)) { formOK(ureq); } } else if (source instanceof FormLink) { FormLink button = (FormLink) source; if ("delete_slider".equals(button.getCmd())) { doRemoveSlider((SliderRow) button.getUserObject()); } } super.formInnerEvent(ureq, source, event); }
@Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { setFormTitle("educational"); setFormContextHelp( "org.olat.modules.qpool.ui.metadata", "educational.html", "help.hover.educational"); if (edit) { editLink = uifactory.addFormLink("edit", "edit", null, formLayout, Link.BUTTON_XSMALL); editLink.setIconLeftCSS("o_icon o_icon-fw o_icon_edit"); } contextEl = uifactory.addStaticTextElement("educational.context", "", formLayout); learningTimeEl = uifactory.addStaticTextElement("educational.learningTime", "", formLayout); }
@Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { askagainCheckbox = uifactory.addCheckboxesHorizontal( "askagain", null, formLayout, askagain_keys, new String[] {translate("askagain.label")}); // Button layout FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator()); formLayout.add(buttonLayout); okButton = uifactory.addFormSubmitButton("submit", "resume.button", buttonLayout); okButton.setElementCssClass("o_sel_resume_yes"); landingButton = uifactory.addFormLink("landing", "resume.button.landing", null, buttonLayout, Link.BUTTON); landingButton.setElementCssClass("o_sel_resume_landing"); noButton = uifactory.addFormLink("cancel", "resume.button.cancel", null, buttonLayout, Link.BUTTON); noButton.setElementCssClass("o_sel_resume_cancel"); }
@Override protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) { rubricCtrl = new RubricController(ureq, getWindowControl(), rubric, mainForm); listenTo(rubricCtrl); formLayout.add("rubric", rubricCtrl.getInitialFormItem()); settingsLayout = FormLayoutContainer.createDefaultFormLayout("settings", getTranslator()); settingsLayout.setRootForm(mainForm); formLayout.add("settings", settingsLayout); String[] sliderTypeValues = new String[] { translate("slider.discrete"), translate("slider.discrete.slider"), translate("slider.continuous") }; typeEl = uifactory.addDropdownSingleselect( "slider.type." + count.incrementAndGet(), "slider.type", settingsLayout, sliderTypeKeys, sliderTypeValues, null); typeEl.addActionListener(FormEvent.ONCHANGE); typeEl.setEnabled(!restrictedEdit); boolean typeSelected = false; if (rubric != null && rubric.getSliderType() != null) { for (String sliderTypeKey : sliderTypeKeys) { if (sliderTypeKey.equals(rubric.getSliderType().name())) { typeEl.select(sliderTypeKey, true); typeSelected = true; } } } if (!typeSelected) { typeEl.select(sliderTypeKeys[0], true); } stepsEl = uifactory.addDropdownSingleselect( "slider.steps." + count.incrementAndGet(), "slider.steps", settingsLayout, sliderStepKeys, sliderStepKeys, null); stepsEl.addActionListener(FormEvent.ONCHANGE); stepsEl.setEnabled(!restrictedEdit); boolean stepSelected = false; if (rubric != null && rubric.getSteps() > 0) { String steps = Integer.toString(rubric.getSteps()); for (String sliderStepKey : sliderStepKeys) { if (sliderStepKey.equals(steps)) { stepsEl.select(sliderStepKey, true); stepSelected = true; } } } if (!stepSelected) { stepsEl.select(sliderStepKeys[4], true); } updateTypeSettings(); updateSteps(); for (Slider slider : rubric.getSliders()) { SliderRow row = forgeSliderRow(slider); sliders.add(row); } if (formLayout instanceof FormLayoutContainer) { FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout; layoutCont.contextPut("sliders", sliders); } long postfix = CodeHelper.getRAMUniqueID(); saveButton = uifactory.addFormLink("save_" + postfix, "save", null, formLayout, Link.BUTTON); if (!restrictedEdit) { addSliderButton = uifactory.addFormLink( "add.slider." + postfix, "add.slider", null, formLayout, Link.BUTTON); addSliderButton.setIconLeftCSS("o_icon o_icon-lg o_icon_add"); } if (formLayout instanceof FormLayoutContainer) { FormLayoutContainer layoutCont = (FormLayoutContainer) formLayout; layoutCont.contextPut("postfix", Long.toString(postfix)); } }
/** @return True if all results are the same */ private ModelInfos loadModel() { // load participants, load datas ICourse course = CourseFactory.loadCourse(courseEnv.getCourseResourceableId()); List<Identity> identities = businessGroupService.getMembers(assessedGroup, GroupRoles.participant.name()); Map<Identity, AssessmentEntry> identityToEntryMap = new HashMap<>(); List<AssessmentEntry> entries = course .getCourseEnvironment() .getAssessmentManager() .getAssessmentEntries(assessedGroup, gtaNode); for (AssessmentEntry entry : entries) { identityToEntryMap.put(entry.getIdentity(), entry); } int count = 0; boolean same = true; StringBuilder duplicateWarning = new StringBuilder(); Float scoreRef = null; Boolean passedRef = null; String commentRef = null; List<AssessmentRow> rows = new ArrayList<>(identities.size()); for (Identity identity : identities) { AssessmentEntry entry = identityToEntryMap.get(identity); ScoreEvaluation scoreEval = null; if (withScore || withPassed) { scoreEval = gtaNode.getUserScoreEvaluation(entry); if (scoreEval == null) { scoreEval = ScoreEvaluation.EMPTY_EVALUATION; } } String comment = null; if (withComment && entry != null) { comment = entry.getComment(); } boolean duplicate = duplicateMemberKeys.contains(identity.getKey()); if (duplicate) { if (duplicateWarning.length() > 0) duplicateWarning.append(", "); duplicateWarning.append(StringHelper.escapeHtml(userManager.getUserDisplayName(identity))); } AssessmentRow row = new AssessmentRow(identity, duplicate); rows.add(row); if (withScore) { Float score = scoreEval.getScore(); String pointVal = AssessmentHelper.getRoundedScore(score); TextElement pointEl = uifactory.addTextElement("point" + count, null, 5, pointVal, flc); pointEl.setDisplaySize(5); row.setScoreEl(pointEl); if (count == 0) { scoreRef = score; } else if (!same(scoreRef, score)) { same = false; } } if (withPassed && cutValue == null) { Boolean passed = scoreEval.getPassed(); MultipleSelectionElement passedEl = uifactory.addCheckboxesHorizontal("check" + count, null, flc, onKeys, onValues); if (passed != null && passed.booleanValue()) { passedEl.select(onKeys[0], passed.booleanValue()); } row.setPassedEl(passedEl); if (count == 0) { passedRef = passed; } else if (!same(passedRef, passed)) { same = false; } } if (withComment) { FormLink commentLink = uifactory.addFormLink( "comment-" + CodeHelper.getRAMUniqueID(), "comment", "comment", null, flc, Link.LINK); if (StringHelper.containsNonWhitespace(comment)) { commentLink.setIconLeftCSS("o_icon o_icon_comments"); } else { commentLink.setIconLeftCSS("o_icon o_icon_comments_none"); } commentLink.setUserObject(row); row.setComment(comment); row.setCommentEditLink(commentLink); if (count == 0) { commentRef = comment; } else if (!same(commentRef, comment)) { same = false; } } count++; } model.setObjects(rows); table.reset(); return new ModelInfos(same, scoreRef, passedRef, commentRef, duplicateWarning.toString()); }
/** * Add a new form link line to the list of link elements. * * @param link the link model object */ private void addNewFormLink(int index, final LLModel link) { // add link target TextElement lTarget = uifactory.addTextElement("target" + counter, null, -1, link.getTarget(), flc); lTarget.clearError(); lTarget.setEnabled(!link.isIntern()); lTarget.setDisplaySize(40); lTarget.setMandatory(true); lTarget.setExampleKey("target.example", null); lTarget.setNotEmptyCheck("ll.table.target.error"); lTarget.setItemValidatorProvider( new ItemValidatorProvider() { public boolean isValidValue( String value, ValidationError validationError, Locale locale) { try { if (!value.contains("://")) { value = "http://".concat(value); } new URL(value); } catch (MalformedURLException e) { validationError.setErrorKey("ll.table.target.error.format"); return false; } return true; } }); lTarget.addActionListener(FormEvent.ONCHANGE); lTarget.setUserObject(link); lTargetInputList.add(index, lTarget); // add html target SingleSelection htmlTargetSelection = uifactory.addDropdownSingleselect( "html_target" + counter, flc, new String[] {BLANK_KEY, SELF_KEY}, new String[] { translate("ll.table.html_target"), translate("ll.table.html_target.self") }, null); htmlTargetSelection.setUserObject(link); htmlTargetSelection.select( (SELF_KEY.equals(link.getHtmlTarget()) ? SELF_KEY : BLANK_KEY), true); lHtmlTargetInputList.add(index, htmlTargetSelection); // add link description TextElement lDescription = uifactory.addTextElement("description" + counter, null, -1, link.getDescription(), flc); lDescription.clearError(); lDescription.setDisplaySize(20); lDescription.setNotEmptyCheck("ll.table.description.error"); lDescription.setMandatory(true); lDescription.setExampleKey("ll.table.description", null); lDescription.setUserObject(link); lDescriptionInputList.add(index, lDescription); // add link comment TextElement lComment = uifactory.addTextAreaElement( "comment" + counter, null, -1, 2, 50, true, link.getComment(), flc); lComment.setDisplaySize(20); lComment.setExampleKey("ll.table.comment", null); lComment.setUserObject(link); lCommentInputList.add(index, lComment); // add link add action button FormLink addButton = new FormLinkImpl( "add" + counter, "add" + counter, "", Link.BUTTON_SMALL + Link.NONTRANSLATED); addButton.setUserObject(link); addButton.setIconLeftCSS("o_icon o_icon-lg o_icon-fw o_icon_add"); flc.add(addButton); lAddButtonList.add(index, addButton); // add link deletion action button FormLink delButton = new FormLinkImpl( "delete" + counter, "delete" + counter, "", Link.BUTTON_SMALL + Link.NONTRANSLATED); delButton.setUserObject(link); delButton.setIconLeftCSS("o_icon o_icon-lg o_icon-fw o_icon_delete_item"); flc.add(delButton); lDelButtonList.add(index, delButton); // custom media action button FormLink mediaButton = new FormLinkImpl("media" + counter, "media" + counter, " ", Link.NONTRANSLATED); mediaButton.setIconLeftCSS("o_icon o_icon_browse o_icon-lg"); mediaButton.setUserObject(link); flc.add(mediaButton); lCustomMediaButtonList.add(index, mediaButton); // increase the counter to enable unique component names counter++; }