use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.
the class ProjectEditDetailsFormController method formOK.
@Override
protected void formOK(UserRequest ureq) {
boolean projectChanged = false;
if (!project.getTitle().equals(projectTitle.getValue())) {
// title has been changed => change project-group name too
String newProjectGroupName = translate("project.member.groupname", projectTitle.getValue());
String newProjectGroupDescription = translate("project.member.groupdescription", projectTitle.getValue());
OLATResource courseResource = courseEnv.getCourseGroupManager().getCourseResource();
projectGroupManager.changeProjectGroupName(getIdentity(), project.getProjectGroup(), newProjectGroupName, newProjectGroupDescription, courseResource);
projectGroupManager.sendGroupChangeEvent(project, courseEnv.getCourseResourceableId(), ureq.getIdentity());
projectChanged = true;
}
if (!project.getTitle().equals(projectTitle.getValue())) {
project.setTitle(projectTitle.getValue());
projectChanged = true;
}
if (!project.getDescription().equals(projectDescription.getValue())) {
project.setDescription(projectDescription.getValue());
projectChanged = true;
}
if (project.getMaxMembers() != maxMembers.getIntValue()) {
project.setMaxMembers(maxMembers.getIntValue());
projectGroupManager.setProjectGroupMaxMembers(getIdentity(), project.getProjectGroup(), maxMembers.getIntValue());
projectChanged = true;
}
if (StringHelper.containsNonWhitespace(attachmentFileName.getUploadFileName())) {
// First call uploadFiles than setAttachedFileName because uploadFiles needs old attachment name
uploadFiles(attachmentFileName);
project.setAttachedFileName(attachmentFileName.getUploadFileName());
projectChanged = true;
} else if (StringHelper.containsNonWhitespace(project.getAttachmentFileName()) && attachmentFileName.getInitialFile() == null) {
// Attachment file has been removed
project.setAttachedFileName("");
projectChanged = true;
}
// store customfields
int index = 0;
for (Iterator<FormItem> iterator = customfieldElementList.iterator(); iterator.hasNext(); ) {
FormItem element = iterator.next();
String value = "";
if (element instanceof TextElement) {
TextElement textElement = (TextElement) element;
value = textElement.getValue();
} else if (element instanceof SingleSelection) {
SingleSelection selectionElement = (SingleSelection) element;
if (!selectionElement.getSelectedKey().equals(DROPDOWN_NO_SELECETION)) {
value = selectionElement.getValue(selectionElement.getSelected());
} else {
value = "";
}
}
getLogger().debug("customfield index=" + index + " value=" + value + " project.getCustomFieldValue(index)=" + project.getCustomFieldValue(index));
if (!project.getCustomFieldValue(index).equals(value)) {
project.setCustomFieldValue(index, value);
projectChanged = true;
}
index++;
}
// store events
for (Project.EventType eventType : eventStartElementList.keySet()) {
Date startDate = eventStartElementList.get(eventType).getDate();
Date endDate = eventEndElementList.get(eventType).getDate();
// First handle startdate
if (hasBeenChanged(project.getProjectEvent(eventType).getStartDate(), startDate) || hasBeenChanged(project.getProjectEvent(eventType).getEndDate(), endDate)) {
project.setProjectEvent(new ProjectEvent(eventType, startDate, endDate));
projectChanged = true;
}
}
if (mailNotification.isSelected(0) != project.isMailNotificationEnabled()) {
project.setMailNotificationEnabled(mailNotification.isSelected(0));
projectChanged = true;
}
if (projectChanged) {
if (projectBrokerManager.existsProject(project.getKey())) {
projectBrokerManager.updateProject(project);
projectBrokerMailer.sendProjectChangedEmailToParticipants(ureq.getIdentity(), project, this.getTranslator());
} else {
showInfo("info.project.nolonger.exist", project.getTitle());
}
}
fireEvent(ureq, Event.DONE_EVENT);
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.
the class RubricController method forgeDiscreteRadioButtons.
private SliderWrapper forgeDiscreteRadioButtons(Slider slider, Rubric element) {
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);
int widthInPercent = EvaluationFormElementWrapper.getWidthInPercent(element);
radioEl.setWidthInPercent(widthInPercent, 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 OpenOLAT.
the class ColorLA method getFormItem.
/**
* @see org.olat.course.config.ui.courselayout.attribs.AbstractLayoutAttribute#getFormItem(java.lang.String, org.olat.core.gui.components.form.flexible.FormItemContainer)
* get a dropdown and an input field wrapped in a FormLayoutContainer
*/
@Override
public FormItem getFormItem(String compName, FormItemContainer formLayout) {
FormUIFactory uifact = FormUIFactory.getInstance();
FormLayoutContainer colorFLC = FormLayoutContainer.createVerticalFormLayout(compName, formLayout.getTranslator());
formLayout.add(compName, colorFLC);
FormItem dropDown = super.getFormItem(compName + "sel", formLayout);
dropDown.addActionListener(FormEvent.ONCHANGE);
colorFLC.add(dropDown);
String inputValue = "";
if (getAttributeValue() != null && !((SingleSelection) dropDown).isOneSelected()) {
inputValue = getAttributeValue();
}
TextElement inputEl = uifact.addTextElement(compName + "value", null, 7, inputValue, colorFLC);
inputEl.setDisplaySize(7);
colorFLC.setUserObject(new ColorSpecialHandler(colorFLC));
return colorFLC;
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.
the class ColorSpecialHandler method getValue.
@Override
public String getValue() {
FormLayoutContainer innerFLC = (FormLayoutContainer) getFormItem();
Map<String, FormItem> items = innerFLC.getFormComponents();
String ddValue = "";
String inputValue = "";
FormItem inputItem = null;
for (Entry<String, FormItem> fiEntry : items.entrySet()) {
String compName = fiEntry.getKey();
FormItem fi = fiEntry.getValue();
if (compName.endsWith("sel") && fi instanceof SingleSelection) {
ddValue = ((SingleSelection) fi).isOneSelected() ? ((SingleSelection) fi).getSelectedKey() : "";
}
if (compName.endsWith("value") && fi instanceof TextElement) {
inputItem = fi;
inputValue = ((TextElement) fi).getValue();
}
}
if (ddValue.equals("") && StringHelper.containsNonWhitespace(inputValue)) {
// use input-value if valid
Pattern pattern = Pattern.compile(HEX_PATTERN);
Matcher matcher = pattern.matcher(inputValue);
if (matcher.matches()) {
hasError = false;
return inputValue;
} else {
hasError = true;
inputItem.setErrorKey("color.hex.error", null);
return "";
}
}
if (!ddValue.equals("") && StringHelper.containsNonWhitespace(inputValue)) {
inputItem.setErrorKey("color.double.error", null);
}
return ddValue;
}
use of org.olat.core.gui.components.form.flexible.elements.SingleSelection in project OpenOLAT by OpenOLAT.
the class GenericSelectionPropertyHandler method isValid.
@Override
public boolean isValid(User user, FormItem formItem, Map<String, String> formContext) {
if (formItem.isMandatory()) {
if (isMultiselect) {
MultipleSelectionElement msel = (MultipleSelectionElement) formItem;
msel.setErrorKey("form.legende.mandatory", null);
return msel.isAtLeastSelected(1);
} else {
SingleSelection ssel = (SingleSelection) formItem;
if (ssel.getSelectedKey().equals(NO_SEL_KEY)) {
ssel.setErrorKey("form.legende.mandatory", null);
return false;
}
}
}
return true;
}
Aggregations