use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project openolat by klemens.
the class AbstractPageListController method forgeSectionRow.
protected PortfolioElementRow forgeSectionRow(Section section, AssessmentSection assessmentSection, List<Assignment> assignments, Map<OLATResourceable, List<Category>> categorizedElementMap) {
PortfolioElementRow row = new PortfolioElementRow(section, assessmentSection, config.isAssessable(), (assignments != null && assignments.size() > 0));
String openLinkId = "open_" + (++counter);
FormLink openLink = uifactory.addFormLink(openLinkId, "open.full", "open.full.page", null, flc, Link.BUTTON_SMALL);
openLink.setIconRightCSS("o_icon o_icon_start");
openLink.setPrimary(true);
row.setOpenFormLink(openLink);
openLink.setUserObject(row);
addCategoriesToRow(row, categorizedElementMap);
if (assignments != null && secCallback.canViewPendingAssignments(section) && secCallback.canInstantiateAssignment()) {
List<Assignment> startableAssignments = assignments.stream().filter(ass -> ass.getAssignmentStatus() == AssignmentStatus.notStarted).filter(ass -> ass.getPage() == null).collect(Collectors.toList());
if (!startableAssignments.isEmpty()) {
String[] keys = new String[startableAssignments.size() + 1];
String[] values = new String[startableAssignments.size() + 1];
keys[0] = "start.assignment.hint";
values[0] = translate("start.assignment.hint");
int count = 1;
for (Assignment assignment : startableAssignments) {
keys[count] = Long.toString(assignment.getKey());
values[count] = assignment.getTitle();
count++;
}
SingleSelection startEl = uifactory.addDropdownSingleselect("assignments_" + (++counter), "", flc, keys, values, null);
startEl.setDomReplacementWrapperRequired(false);
startEl.addActionListener(FormEvent.ONCHANGE);
row.setStartSelection(startEl);
}
}
return row;
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project openolat by klemens.
the class ExtendedSearchController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (source == searchButton) {
doSearch(ureq);
} else if (source instanceof SingleSelection) {
SingleSelection attrEl = (SingleSelection) source;
if (attrEl.isOneSelected()) {
Object uObject = attrEl.getUserObject();
if (uObject instanceof ConditionalQuery) {
ConditionalQuery query = (ConditionalQuery) uObject;
query.selectAttributeType(attrEl.getSelectedKey(), null);
}
}
} else if (source instanceof FormLink) {
FormLink button = (FormLink) source;
if (button.getCmd().startsWith("add")) {
ConditionalQuery query = (ConditionalQuery) button.getUserObject();
addParameter(query);
} else if (button.getCmd().startsWith("remove")) {
ConditionalQuery query = (ConditionalQuery) button.getUserObject();
removeParameter(query);
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project openolat by klemens.
the class EvaluationFormController method forgeDiscreteRadioButtons.
private SliderWrapper forgeDiscreteRadioButtons(Slider slider, Rubric element, EvaluationFormResponse response) {
int start = element.getStart();
int end = element.getEnd();
int steps = element.getSteps();
double[] theSteps = new double[steps];
String[] theKeys = new String[steps];
String[] theValues = new String[steps];
double step = (end - start + 1) / (double) steps;
for (int i = 0; i < steps; i++) {
theSteps[i] = start + (i * step);
theKeys[i] = Double.toString(theSteps[i]);
theValues[i] = "";
}
SingleSelection radioEl = uifactory.addRadiosVertical("slider_" + (count++), null, flc, theKeys, theValues);
radioEl.setDomReplacementWrapperRequired(false);
radioEl.addActionListener(FormEvent.ONCHANGE);
radioEl.setEnabled(!readOnly);
radioEl.setAllowNoSelection(true);
int widthInPercent = EvaluationFormElementWrapper.getWidthInPercent(element);
radioEl.setWidthInPercent(widthInPercent, true);
if (response != null && response.getNumericalResponse() != null) {
double val = response.getNumericalResponse().doubleValue();
double error = step / 10.0d;
for (int i = 0; i < theSteps.length; i++) {
double theStep = theSteps[i];
double margin = Math.abs(theStep - val);
if (margin < error) {
radioEl.select(theKeys[i], true);
}
}
}
SliderWrapper sliderWrapper = new SliderWrapper(slider, radioEl);
radioEl.setUserObject(sliderWrapper);
return sliderWrapper;
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project openolat by klemens.
the class EPShareListController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
// process all form-input fields and update data-model
secureListBox();
// policy might be persisted. check with validateFormLogic()
if (source == addPolicyButton) {
if (validateFormLogic(ureq)) {
addEPSharePolicyWrapper(null);
initPolicyUI();
}
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
Object userObject = link.getUserObject();
if (userObject instanceof EPSharePolicyWrapper) {
EPSharePolicyWrapper wrapper = (EPSharePolicyWrapper) userObject;
if (link.getName().startsWith("map.share.policy.add")) {
if (validateFormLogic(ureq)) {
addEPSharePolicyWrapper(wrapper);
initPolicyUI();
}
} else if (link.getName().startsWith("map.share.policy.delete")) {
removeEPSharePolicyWrapper(wrapper);
initPolicyUI();
} else if (link.getName().startsWith("map.share.policy.invite")) {
if (validateFormLogic(ureq)) {
sendInvitation(ureq, wrapper);
initPolicyUI();
}
} else if (link.getName().startsWith("choose.group")) {
doSelectGroup(ureq, wrapper);
} else if (link.getName().startsWith("choose.identity")) {
doSelectIdentity(ureq, wrapper);
}
} else if (userObject instanceof EPShareGroupWrapper) {
EPShareGroupWrapper wrapper = (EPShareGroupWrapper) userObject;
wrapper.remove();
initPolicyUI();
} else if (userObject instanceof EPShareUserWrapper) {
EPShareUserWrapper wrapper = (EPShareUserWrapper) userObject;
wrapper.remove();
initPolicyUI();
}
} else if (source instanceof SingleSelection && source.getUserObject() instanceof EPSharePolicyWrapper) {
SingleSelection selection = (SingleSelection) source;
if (selection.isOneSelected()) {
String type = selection.getSelectedKey();
EPSharePolicyWrapper wrapper = (EPSharePolicyWrapper) selection.getUserObject();
changeType(wrapper, type);
}
initPolicyUI();
}
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project openolat by klemens.
the class EPStructureDetailsController method setCollectRestrictions.
protected void setCollectRestrictions() {
if (restrictionElements == null || restrictionElements.isEmpty()) {
return;
}
for (int i = 0; i < restrictionElements.size(); i++) {
final SingleSelection restrictionElement = restrictionElements.get(i);
final SingleSelection restrictToArtefactElement = restrictToArtefactElements.get(i);
final TextElement amountElement = amountElements.get(i);
final CollectRestriction cr = (CollectRestriction) restrictionElement.getUserObject();
String restriction = "";
if (restrictionElement.isOneSelected()) {
restriction = restrictionElement.getSelectedKey();
}
String artefactType = "";
if (restrictToArtefactElement.isOneSelected()) {
artefactType = restrictToArtefactElement.getSelectedKey();
}
final String amount = amountElement.getValue();
cr.setRestriction(restriction);
cr.setArtefactType(artefactType);
if (StringHelper.containsNonWhitespace(amount)) {
try {
cr.setAmount(Integer.parseInt(amount));
} catch (final NumberFormatException e) {
logWarn("Wrong format for number", e);
}
}
}
}
Aggregations