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(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(); }
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) { 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 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) { 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++; }