use of org.olat.modules.forms.ui.model.SliderWrapper in project openolat by klemens.
the class RubricController method forgeContinuousSlider.
private SliderWrapper forgeContinuousSlider(Slider slider, Rubric element) {
SliderElement sliderEl = uifactory.addSliderElement("slider_" + (count++), null, flc);
sliderEl.setDomReplacementWrapperRequired(false);
sliderEl.addActionListener(FormEvent.ONCHANGE);
sliderEl.setMinValue(element.getStart());
sliderEl.setMaxValue(element.getEnd());
SliderWrapper sliderWrapper = new SliderWrapper(slider, sliderEl);
sliderEl.setUserObject(sliderWrapper);
return sliderWrapper;
}
use of org.olat.modules.forms.ui.model.SliderWrapper in project OpenOLAT by OpenOLAT.
the class EvaluationFormController method formInnerEvent.
@Override
protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
if (saveAsDoneButton == source) {
doConfirmDone(ureq);
} else if (source instanceof SingleSelection) {
SingleSelection radioEl = (SingleSelection) source;
Object uobject = radioEl.getUserObject();
if (uobject instanceof SliderWrapper) {
String selectedKey = radioEl.getSelectedKey();
SliderWrapper sliderWrapper = (SliderWrapper) uobject;
saveNumericalResponse(new BigDecimal(selectedKey), selectedKey, sliderWrapper.getId());
}
} else if (source instanceof SliderElement) {
SliderElement slider = (SliderElement) source;
Object uobject = slider.getUserObject();
if (uobject instanceof SliderWrapper) {
double value = slider.getValue();
SliderWrapper sliderWrapper = (SliderWrapper) uobject;
saveNumericalResponse(BigDecimal.valueOf(value), Double.toString(value), sliderWrapper.getId());
}
} else if (source instanceof FormLink) {
FormLink link = (FormLink) source;
Object uobject = link.getUserObject();
if (uobject instanceof TextInputWrapper) {
TextInputWrapper wrapper = (TextInputWrapper) uobject;
String value = wrapper.getTextEl().getValue();
saveNumericalResponse(null, value, wrapper.getId());
}
} else if (source instanceof FileElement) {
FileElement fileElement = (FileElement) source;
Object uobject = fileElement.getUserObject();
if (uobject instanceof FileUploadWrapper) {
FileUploadWrapper wrapper = (FileUploadWrapper) uobject;
if (event instanceof FileElementEvent) {
if (FileElementEvent.DELETE.equals(event.getCommand())) {
saveFileResponse(null, null, wrapper.getId());
fileElement.setInitialFile(null);
if (fileElement.getUploadFile() != null) {
fileElement.reset();
}
flc.setDirty(true);
}
} else if (fileElement.isUploadSuccess()) {
File file = fileElement.getUploadFile();
String filename = fileElement.getUploadFileName();
saveFileResponse(file, filename, wrapper.getId());
}
}
}
super.formInnerEvent(ureq, source, event);
}
use of org.olat.modules.forms.ui.model.SliderWrapper in project OpenOLAT by OpenOLAT.
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.modules.forms.ui.model.SliderWrapper in project OpenOLAT by OpenOLAT.
the class EvaluationFormController method forgeDiscreteSlider.
private SliderWrapper forgeDiscreteSlider(Slider slider, Rubric element, EvaluationFormResponse response) {
SliderElement sliderEl = uifactory.addSliderElement("slider_" + (count++), null, flc);
sliderEl.setDomReplacementWrapperRequired(false);
sliderEl.addActionListener(FormEvent.ONCHANGE);
sliderEl.setEnabled(!readOnly);
if (response != null && response.getNumericalResponse() != null) {
double val = response.getNumericalResponse().doubleValue();
sliderEl.setInitialValue(val);
}
sliderEl.setMinValue(element.getStart());
sliderEl.setMaxValue(element.getEnd());
sliderEl.setStep(1);
SliderWrapper sliderWrapper = new SliderWrapper(slider, sliderEl);
sliderEl.setUserObject(sliderWrapper);
return sliderWrapper;
}
use of org.olat.modules.forms.ui.model.SliderWrapper in project OpenOLAT by OpenOLAT.
the class RubricController method forgeContinuousSlider.
private SliderWrapper forgeContinuousSlider(Slider slider, Rubric element) {
SliderElement sliderEl = uifactory.addSliderElement("slider_" + (count++), null, flc);
sliderEl.setDomReplacementWrapperRequired(false);
sliderEl.addActionListener(FormEvent.ONCHANGE);
sliderEl.setMinValue(element.getStart());
sliderEl.setMaxValue(element.getEnd());
SliderWrapper sliderWrapper = new SliderWrapper(slider, sliderEl);
sliderEl.setUserObject(sliderWrapper);
return sliderWrapper;
}
Aggregations