use of org.olat.core.gui.components.form.flexible.elements.TextElement 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.TextElement in project OpenOLAT by OpenOLAT.
the class CustomfieldsFormController method formOK.
@Override
protected void formOK(UserRequest ureq) {
// loop over all Element to store values
for (int i = 0; i < customFields.size(); i++) {
TextElement nameTextElement = customFieldNameElementList.get(i);
if (!customFields.get(i).getName().equals(nameTextElement.getValue())) {
customFields.get(i).setName(nameTextElement.getValue());
}
TextElement valueTextElement = customFieldValueElementList.get(i);
if (!customFields.get(i).getValue().equals(valueTextElement.getValue())) {
customFields.get(i).setValue(valueTextElement.getValue());
}
MultipleSelectionElement tableViewElement = customFieldTableFlagElementList.get(i);
if (customFields.get(i).isTableViewEnabled() != tableViewElement.isSelected(0)) {
customFields.get(i).setTableViewEnabled(tableViewElement.isSelected(0));
}
}
config.setCustomFields(customFields);
fireEvent(ureq, Event.DONE_EVENT);
fireEvent(ureq, NodeEditController.NODECONFIG_CHANGED_EVENT);
}
use of org.olat.core.gui.components.form.flexible.elements.TextElement 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.TextElement 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.TextElement in project OpenOLAT by OpenOLAT.
the class MemberSearchForm method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
FormLayoutContainer leftContainer = FormLayoutContainer.createDefaultFormLayout("left_1", getTranslator());
leftContainer.setRootForm(mainForm);
formLayout.add(leftContainer);
// user property
login = uifactory.addTextElement("login", "search.login", 128, "", leftContainer);
login.setDisplaySize(28);
userPropertyHandlers = userManager.getUserPropertyHandlersFor(getClass().getCanonicalName(), false);
propFormItems = new HashMap<String, FormItem>();
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler == null)
continue;
FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, getClass().getCanonicalName(), false, leftContainer);
fi.setTranslator(this.getTranslator());
// DO NOT validate email field => see OLAT-3324, OO-155, OO-222
if (userPropertyHandler instanceof EmailProperty && fi instanceof TextElement) {
TextElement textElement = (TextElement) fi;
textElement.setItemValidatorProvider(null);
}
if (fi instanceof TextElement) {
((TextElement) fi).setDisplaySize(28);
}
propFormItems.put(userPropertyHandler.getName(), fi);
}
// others
FormLayoutContainer rightContainer = FormLayoutContainer.createDefaultFormLayout("right_1", getTranslator());
rightContainer.setRootForm(mainForm);
formLayout.add(rightContainer);
// roles
String[] roleValues = new String[roleKeys.length];
for (int i = roleKeys.length; i-- > 0; ) {
roleValues[i] = translate("search." + roleKeys[i]);
}
rolesEl = uifactory.addCheckboxesHorizontal("roles", "search.roles", rightContainer, roleKeys, roleValues);
for (String roleKey : roleKeys) {
rolesEl.select(roleKey, true);
}
String[] openValues = new String[originKeys.length];
for (int i = originKeys.length; i-- > 0; ) {
openValues[i] = translate("search." + originKeys[i]);
}
originEl = uifactory.addRadiosHorizontal("openBg", "search.origin", rightContainer, originKeys, openValues);
originEl.select("all", true);
FormLayoutContainer buttonLayout = FormLayoutContainer.createDefaultFormLayout("button_layout", getTranslator());
formLayout.add(buttonLayout);
searchButton = uifactory.addFormLink("search", buttonLayout, Link.BUTTON);
searchButton.setCustomEnabledLinkCSS("btn btn-primary");
}
Aggregations