use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class ShibbolethRegistrationUserPropertiesFrom method updateShibboletAttribute.
private void updateShibboletAttribute(UserPropertyHandler userPropertyHandler) {
String propertyName = userPropertyHandler.getName();
FormItem propertyItem = this.flc.getFormComponent(propertyName);
String propertyValue = userPropertyHandler.getStringValue(propertyItem);
shibbolethAttributes.setValueForUserPropertyName(propertyName, propertyValue);
}
use of org.olat.core.gui.components.form.flexible.FormItem in project OpenOLAT by OpenOLAT.
the class ShibbolethRegistrationUserPropertiesFrom method initForm.
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// Add all available user fields to this form
for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
if (userPropertyHandler != null) {
FormItem fi = userPropertyHandler.addFormItem(getLocale(), null, USERPROPERTIES_FORM_IDENTIFIER, false, formLayout);
propFormItems.put(userPropertyHandler.getName(), fi);
if (fi instanceof TextElement) {
String value = shibbolethAttributes.getValueForUserPropertyName(userPropertyHandler.getName());
if (StringHelper.containsNonWhitespace(value)) {
TextElement formElement = (TextElement) fi;
formElement.setValue(value);
formElement.setEnabled(false);
}
}
}
}
FormLayoutContainer buttonLayout = FormLayoutContainer.createButtonLayout("button_layout", getTranslator());
formLayout.add(buttonLayout);
uifactory.addFormSubmitButton("save", buttonLayout);
}
use of org.olat.core.gui.components.form.flexible.FormItem 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.FormItem in project OpenOLAT by OpenOLAT.
the class MessageEditController method createOrUpdateAttachmentListLayout.
// adds or updates the list of already existing attachments with a delete
// button for each
private void createOrUpdateAttachmentListLayout(FormItemContainer formLayout) {
FormItem attachLayout = formLayout.getFormComponent("attachLayout");
List<VFSItem> attachments = new ArrayList<VFSItem>();
// add already existing attachments:
if (message.getKey() != null) {
VFSContainer msgContainer = fm.getMessageContainer(message.getForum().getKey(), message.getKey());
attachments.addAll(msgContainer.getItems(exclFilter));
}
// add files from TempFolder
attachments.addAll(getTempFolderFileList());
Collections.sort(attachments, new Comparator<VFSItem>() {
final Collator c = Collator.getInstance(getLocale());
public int compare(final VFSItem o1, final VFSItem o2) {
return c.compare((o1).getName(), (o2).getName());
}
});
FormLayoutContainer tmpLayout;
if (attachLayout == null) {
String editPage = Util.getPackageVelocityRoot(this.getClass()) + "/attachments-editview.html";
tmpLayout = FormLayoutContainer.createCustomFormLayout("attachLayout", getTranslator(), editPage);
formLayout.add(tmpLayout);
} else {
tmpLayout = (FormLayoutContainer) attachLayout;
}
tmpLayout.contextPut("attachments", attachments);
// add delete links for each attachment if user is allowed to see them
int attNr = 1;
for (VFSItem tmpFile : attachments) {
FormLink tmpLink = uifactory.addFormLink(CMD_DELETE_ATTACHMENT + attNr, tmpLayout, Link.BUTTON_XSMALL);
if (!(foCallback.mayEditMessageAsModerator() || ((userIsMsgCreator) && (msgHasChildren == false)))) {
tmpLink.setEnabled(false);
tmpLink.setVisible(false);
}
tmpLink.setUserObject(tmpFile);
tmpLink.setI18nKey("attachments.remove.string");
attNr++;
}
}
use of org.olat.core.gui.components.form.flexible.FormItem 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;
}
Aggregations