use of org.olat.core.gui.components.form.flexible.elements.DateChooser in project openolat by klemens.
the class VCEditForm method addRow.
private void addRow(int index, final MeetingDate date) {
// title
TextElement vcTitle = uifactory.addTextElement("title" + counter, null, -1, date.getTitle(), editVC);
vcTitle.setDisplaySize(30);
vcTitle.setMandatory(true);
vcTitle.setNotEmptyCheck("vc.table.title.empty");
vcTitleInputList.add(index, vcTitle);
// description
TextElement vcDescription = uifactory.addTextElement("description" + counter, null, -1, date.getDescription(), editVC);
vcDescription.setDisplaySize(20);
vcDescription.setNotEmptyCheck("vc.table.description.empty");
vcDescription.setMandatory(true);
vcDescriptionInputList.add(index, vcDescription);
// begin
DateChooser vcScheduleDate = uifactory.addDateChooser("begin" + counter, "vc.table.begin", null, editVC);
vcScheduleDate.setNotEmptyCheck("vc.table.begin.empty");
vcScheduleDate.setValidDateCheck("vc.table.begin.error");
vcScheduleDate.setMandatory(true);
vcScheduleDate.setDisplaySize(20);
vcScheduleDate.setDateChooserTimeEnabled(true);
vcScheduleDate.setDate(date.getBegin());
vcCalenderbeginInputList.add(index, vcScheduleDate);
// add date duration
SimpleDateFormat sdDuration = new SimpleDateFormat("HH:mm");
TimeZone tz = TimeZone.getTimeZone("Etc/GMT+0");
sdDuration.setTimeZone(tz);
TextElement vcDuration = uifactory.addTextElement("duration" + counter, "vc.table.duration", 5, String.valueOf(0), editVC);
vcDuration.setDisplaySize(5);
vcDuration.setValue(sdDuration.format(new Date(date.getEnd().getTime() - date.getBegin().getTime())));
vcDuration.setRegexMatchCheck("\\d{1,2}:\\d\\d", "form.error.format");
vcDuration.setExampleKey("vc.table.duration.example", null);
vcDuration.setNotEmptyCheck("vc.table.duration.empty");
vcDuration.setErrorKey("vc.table.duration.error", null);
vcDuration.setMandatory(true);
vcDuration.showExample(true);
vcDuration.showError(false);
this.vcDurationInputList.add(index, vcDuration);
// add row button
FormLink addButton = new FormLinkImpl("add" + counter, "add" + counter, "vc.table.add", Link.BUTTON_SMALL);
editVC.add(addButton);
vcAddButtonList.add(index, addButton);
// remove row button
FormLink delButton = new FormLinkImpl("delete" + counter, "delete" + counter, "vc.table.delete", Link.BUTTON_SMALL);
editVC.add(delButton);
vcDelButtonList.add(index, delButton);
// increase the counter to enable unique component names
counter++;
}
use of org.olat.core.gui.components.form.flexible.elements.DateChooser in project OpenOLAT by OpenOLAT.
the class DatePropertyHandler method isValid.
/**
* @see org.olat.user.propertyhandlers.UserPropertyHandler#isValid(org.olat.core.gui.components.form.flexible.FormItem, java.util.Map)
*/
@Override
public boolean isValid(User user, FormItem formItem, Map<String, String> formContext) {
DateChooser dateElem = (DateChooser) formItem;
if (dateElem.isEmpty()) {
return !dateElem.isMandatory() || !dateElem.isEmpty("new.form.mandatory");
}
List<ValidationStatus> validation = new ArrayList<ValidationStatus>();
dateElem.validate(validation);
if (validation.size() == 0) {
return true;
} else {
// errorkey should be set by dateElem.validate formItem.setErrorKey(i18nFormElementLabelKey()+ ".error", null);
return false;
}
}
use of org.olat.core.gui.components.form.flexible.elements.DateChooser in project OpenOLAT by OpenOLAT.
the class EPShareListController method initPolicyUI.
/**
* creates the custom formLayoutContainer and adds a form-component for every
* EPSharePolicyWrapper, according to its type.
*/
protected void initPolicyUI() {
String template = Util.getPackageVelocityRoot(this.getClass()) + "/sharePolicy.html";
for (EPSharePolicyWrapper policyWrapper : policyWrappers) {
String cmpName = policyWrapper.getComponentName();
if (cmpName != null && flc.getFormComponent(cmpName) != null) {
flc.remove(cmpName);
}
cmpName = Integer.toString(cmpSuffixGenerator.getAndIncrement());
policyWrapper.setComponentName(cmpName);
FormLayoutContainer container = FormLayoutContainer.createCustomFormLayout(cmpName, getTranslator(), template);
container.contextPut("wrapper", policyWrapper);
container.setRootForm(mainForm);
if (policyWrapper.getType() != null) {
String[] curatedTargetKeys;
String[] curatedTargetValues;
if (!Type.invitation.equals(policyWrapper.getType()) && !loginModule.isInvitationEnabled()) {
curatedTargetKeys = new String[targetKeys.length - 1];
curatedTargetValues = new String[targetKeys.length - 1];
int pos = 0;
for (int i = targetKeys.length; i-- > 0; ) {
if (!targetKeys[i].equals(Type.invitation.name())) {
curatedTargetKeys[pos] = targetKeys[i];
curatedTargetValues[pos++] = targetValues[i];
}
}
} else {
curatedTargetKeys = targetKeys;
curatedTargetValues = targetValues;
}
SingleSelection type = uifactory.addDropdownSingleselect("map.share.target." + cmpName, "map.share.target", container, curatedTargetKeys, curatedTargetValues, null);
type.addActionListener(FormEvent.ONCHANGE);
type.setUserObject(policyWrapper);
type.select(policyWrapper.getType().name(), true);
switch(policyWrapper.getType()) {
case user:
createContainerForUser(policyWrapper, cmpName, container);
break;
case group:
createContainerForGroup(policyWrapper, cmpName, container);
break;
case invitation:
Invitation invitation = policyWrapper.getInvitation();
if (invitation == null) {
invitation = invitationDao.createAndPersistInvitation();
policyWrapper.setInvitation(invitation);
}
createContainerForInvitation(invitation, policyWrapper, cmpName, container);
break;
case allusers:
String text = translate("map.share.with.allOlatUsers");
uifactory.addStaticTextElement("map.share.with." + cmpName, text, container);
break;
}
}
if (policyWrapper instanceof TutorEPSharePolicyWrapper) {
String text = translate("map.share.with.tutor");
uifactory.addStaticTextElement("map.share.text." + cmpName, text, container);
} else {
DateChooser fromChooser = uifactory.addDateChooser("map.share.from." + cmpName, "map.share.from", null, container);
fromChooser.setDate(policyWrapper.getFrom());
fromChooser.setValidDateCheck("map.share.date.invalid");
policyWrapper.setFromChooser(fromChooser);
DateChooser toChooser = uifactory.addDateChooser("map.share.to." + cmpName, "map.share.to", null, container);
toChooser.setDate(policyWrapper.getTo());
toChooser.setValidDateCheck("map.share.date.invalid");
policyWrapper.setToChooser(toChooser);
FormLink addLink = uifactory.addFormLink("map.share.policy.add." + cmpName, "map.share.policy.add", null, container, Link.BUTTON);
addLink.setIconLeftCSS("o_icon o_icon-fw o_icon_add");
addLink.setUserObject(policyWrapper);
FormLink removeLink = uifactory.addFormLink("map.share.policy.delete." + cmpName, "map.share.policy.delete", null, container, Link.BUTTON);
removeLink.setIconLeftCSS("o_icon o_icon-fw o_icon_delete_item");
removeLink.setUserObject(policyWrapper);
if (!policyWrapper.getType().equals(EPMapPolicy.Type.allusers)) {
FormLink inviteLink = uifactory.addFormLink("map.share.policy.invite." + cmpName, "map.share.policy.invite", null, container, Link.BUTTON);
inviteLink.setIconLeftCSS("o_icon o_icon-fw o_icon_share");
inviteLink.setUserObject(policyWrapper);
inviteLink.setEnabled(!policyWrapper.isInvitationSend() && (loginModule.isInvitationEnabled() || !policyWrapper.getType().equals(Type.invitation)));
}
StaticTextElement genErrorPanel = uifactory.addStaticTextElement("errorpanel." + cmpName, "", container);
genErrorPanel.setUserObject(policyWrapper);
policyWrapper.setErrorEl(genErrorPanel);
}
policyWrapper.setComponentName(cmpName);
flc.add(container);
flc.contextPut("wrapper", policyWrapper);
}
flc.contextPut("wrappers", policyWrappers);
}
use of org.olat.core.gui.components.form.flexible.elements.DateChooser in project OpenOLAT by OpenOLAT.
the class ProjectEditDetailsFormController method initForm.
/**
* Initialize form.
*/
@Override
protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
// create form elements
projectTitle = uifactory.addTextElement("title", "detailsform.title.label", 100, project.getTitle(), formLayout);
// account-Managers
StringBuilder projectLeaderString = new StringBuilder();
for (Iterator<Identity> iterator = project.getProjectLeaders().iterator(); iterator.hasNext(); ) {
Identity identity = iterator.next();
String last = identity.getUser().getProperty(UserConstants.LASTNAME, getLocale());
String first = identity.getUser().getProperty(UserConstants.FIRSTNAME, getLocale());
if (projectLeaderString.length() > 0) {
projectLeaderString.append(",");
}
projectLeaderString.append(first);
projectLeaderString.append(" ");
projectLeaderString.append(last);
}
projectLeaders = uifactory.addTextElement("projectleaders", "detailsform.projectleaders.label", 100, projectLeaderString.toString(), formLayout);
projectLeaders.setEnabled(false);
// add the learning objectives rich text input element
projectDescription = uifactory.addRichTextElementForStringData("description", "detailsform.description.label", project.getDescription(), 10, -1, false, null, null, formLayout, ureq.getUserSession(), getWindowControl());
projectDescription.setMaxLength(2500);
stateLayout = FormLayoutContainer.createHorizontalFormLayout("stateLayout", getTranslator());
stateLayout.setLabel("detailsform.state.label", null);
formLayout.add(stateLayout);
String stateValue = getTranslator().translate(projectBrokerManager.getStateFor(project, ureq.getIdentity(), projectBrokerModuleConfiguration));
projectState = uifactory.addStaticTextElement("detailsform.state", stateValue + " ", stateLayout);
projectState.setLabel(null, null);
String keyDetailsformMax = null;
if (projectBrokerModuleConfiguration.isAcceptSelectionManually()) {
keyDetailsformMax = "detailsform.max.candidates.label";
} else {
keyDetailsformMax = "detailsform.max.members.label";
}
selectionMaxMembers = uifactory.addCheckboxesHorizontal(keyDetailsformMax, formLayout, keys, values);
maxMembers = uifactory.addIntegerElement("form.options.number.of.participants.per.topic_nbr", project.getMaxMembers(), formLayout);
maxMembers.setMinValueCheck(0, null);
maxMembers.setDisplaySize(3);
if (project.getMaxMembers() == Project.MAX_MEMBERS_UNLIMITED) {
maxMembers.setVisible(false);
selectionMaxMembers.select(keys[0], false);
} else {
selectionMaxMembers.select(keys[0], true);
}
selectionMaxMembers.addActionListener(FormEvent.ONCLICK);
String[] deselectValues = new String[] { translate("detailsform.allow.deselection.hint") };
allowDeselection = uifactory.addCheckboxesHorizontal("detailsform.allow.deselection", formLayout, keys, deselectValues);
allowDeselection.select(keys[0], projectGroupManager.isDeselectionAllowed(project));
allowDeselection.addActionListener(FormEvent.ONCLICK);
uifactory.addSpacerElement("spacer_1", formLayout, false);
// customfields
List<CustomField> customFields = projectBrokerModuleConfiguration.getCustomFields();
int customFieldIndex = 0;
for (Iterator<CustomField> iterator = customFields.iterator(); iterator.hasNext(); ) {
CustomField customField = iterator.next();
getLogger().debug("customField: " + customField.getName() + "=" + customField.getValue());
StringTokenizer tok = new StringTokenizer(customField.getValue(), ProjectBrokerManager.CUSTOMFIELD_LIST_DELIMITER);
if (customField.getValue() == null || customField.getValue().equals("") || !tok.hasMoreTokens()) {
// no value define => Text-input
// Add StaticTextElement as workaroung for non translated label
// null > no label
uifactory.addStaticTextElement("customField_label" + customFieldIndex, null, customField.getName(), formLayout);
TextElement textElement = uifactory.addTextElement("customField_" + customFieldIndex, "", 150, project.getCustomFieldValue(customFieldIndex), formLayout);
textElement.setDisplaySize(60);
// textElement.setTranslator(null);
// textElement.setLabel(customField.getName(), null);
textElement.showLabel(false);
customfieldElementList.add(textElement);
} else {
// values define => dropdown selection
List<String> valueList = new ArrayList<String>();
while (tok.hasMoreTokens()) {
String value = tok.nextToken();
valueList.add(value);
getLogger().debug("valueList add: " + value);
}
String[] theValues = new String[valueList.size() + 1];
String[] theKeys = new String[valueList.size() + 1];
int arrayIndex = 0;
theValues[arrayIndex] = translate(DROPDOWN_NO_SELECETION);
theKeys[arrayIndex] = DROPDOWN_NO_SELECETION;
arrayIndex++;
for (Iterator<String> iterator2 = valueList.iterator(); iterator2.hasNext(); ) {
String value = iterator2.next();
theValues[arrayIndex] = value;
theKeys[arrayIndex] = Integer.toString(arrayIndex);
arrayIndex++;
}
// Add StaticTextElement as workaround for non translated label
// null > no label
uifactory.addStaticTextElement("customField_label" + customFieldIndex, null, customField.getName(), formLayout);
SingleSelection selectionElement = uifactory.addDropdownSingleselect("customField_" + customFieldIndex, null, formLayout, theKeys, theValues, null);
if (project.getCustomFieldValue(customFieldIndex) != null && !project.getCustomFieldValue(customFieldIndex).equals("")) {
if (valueList.contains(project.getCustomFieldValue(customFieldIndex))) {
// '+1' because no-selection at the beginning
String key = Integer.toString(valueList.indexOf(project.getCustomFieldValue(customFieldIndex)) + 1);
selectionElement.select(key, true);
} else {
this.showInfo("warn.customfield.key.does.not.exist", project.getCustomFieldValue(customFieldIndex));
}
}
customfieldElementList.add(selectionElement);
}
uifactory.addSpacerElement("customField_spacer" + customFieldIndex, formLayout, false);
customFieldIndex++;
}
// Events
for (Project.EventType eventType : Project.EventType.values()) {
if (projectBrokerModuleConfiguration.isProjectEventEnabled(eventType)) {
ProjectEvent projectEvent = project.getProjectEvent(eventType);
DateChooser dateChooserStart = uifactory.addDateChooser(eventType + "start", eventType.getI18nKey() + ".start.label", null, formLayout);
dateChooserStart.setDateChooserTimeEnabled(true);
dateChooserStart.setDisplaySize(CUSTOM_DATE_FORMAT.length());
getLogger().info("Event=" + eventType + ", startDate=" + projectEvent.getStartDate());
dateChooserStart.setDate(projectEvent.getStartDate());
eventStartElementList.put(eventType, dateChooserStart);
DateChooser dateChooserEnd = uifactory.addDateChooser(eventType + "end", eventType.getI18nKey() + ".end.label", null, formLayout);
dateChooserEnd.setDateChooserTimeEnabled(true);
dateChooserEnd.setDisplaySize(CUSTOM_DATE_FORMAT.length());
getLogger().debug("Event=" + eventType + ", endDate=" + projectEvent.getEndDate());
dateChooserEnd.setDate(projectEvent.getEndDate());
eventEndElementList.put(eventType, dateChooserEnd);
uifactory.addSpacerElement(eventType + "spacer", formLayout, false);
}
}
attachmentFileName = uifactory.addFileElement(getWindowControl(), "detailsform.attachmentfilename.label", formLayout);
attachmentFileName.setLabel("detailsform.attachmentfilename.label", null);
if (project.getAttachmentFileName() != null && !project.getAttachmentFileName().equals("")) {
attachmentFileName.setInitialFile(new File(project.getAttachmentFileName()));
removeAttachmentLink = uifactory.addFormLink("detailsform.remove.attachment", formLayout, Link.BUTTON_XSMALL);
}
attachmentFileName.addActionListener(FormEvent.ONCHANGE);
mailNotification = uifactory.addCheckboxesHorizontal("detailsform.mail.notification.label", formLayout, keys, values);
mailNotification.select(keys[0], project.isMailNotificationEnabled());
FormLayoutContainer buttonGroupLayout = FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
formLayout.add(buttonGroupLayout);
uifactory.addFormSubmitButton("save", buttonGroupLayout);
if (this.enableCancel) {
// TODO: Frage an PB: Warum flc hier noetig ???
uifactory.addFormCancelButton("cancel", buttonGroupLayout, ureq, getWindowControl());
}
}
use of org.olat.core.gui.components.form.flexible.elements.DateChooser in project OpenOLAT by OpenOLAT.
the class VCEditForm method addRow.
private void addRow(int index, final MeetingDate date) {
// title
TextElement vcTitle = uifactory.addTextElement("title" + counter, null, -1, date.getTitle(), editVC);
vcTitle.setDisplaySize(30);
vcTitle.setMandatory(true);
vcTitle.setNotEmptyCheck("vc.table.title.empty");
vcTitleInputList.add(index, vcTitle);
// description
TextElement vcDescription = uifactory.addTextElement("description" + counter, null, -1, date.getDescription(), editVC);
vcDescription.setDisplaySize(20);
vcDescription.setNotEmptyCheck("vc.table.description.empty");
vcDescription.setMandatory(true);
vcDescriptionInputList.add(index, vcDescription);
// begin
DateChooser vcScheduleDate = uifactory.addDateChooser("begin" + counter, "vc.table.begin", null, editVC);
vcScheduleDate.setNotEmptyCheck("vc.table.begin.empty");
vcScheduleDate.setValidDateCheck("vc.table.begin.error");
vcScheduleDate.setMandatory(true);
vcScheduleDate.setDisplaySize(20);
vcScheduleDate.setDateChooserTimeEnabled(true);
vcScheduleDate.setDate(date.getBegin());
vcCalenderbeginInputList.add(index, vcScheduleDate);
// add date duration
SimpleDateFormat sdDuration = new SimpleDateFormat("HH:mm");
TimeZone tz = TimeZone.getTimeZone("Etc/GMT+0");
sdDuration.setTimeZone(tz);
TextElement vcDuration = uifactory.addTextElement("duration" + counter, "vc.table.duration", 5, String.valueOf(0), editVC);
vcDuration.setDisplaySize(5);
vcDuration.setValue(sdDuration.format(new Date(date.getEnd().getTime() - date.getBegin().getTime())));
vcDuration.setRegexMatchCheck("\\d{1,2}:\\d\\d", "form.error.format");
vcDuration.setExampleKey("vc.table.duration.example", null);
vcDuration.setNotEmptyCheck("vc.table.duration.empty");
vcDuration.setErrorKey("vc.table.duration.error", null);
vcDuration.setMandatory(true);
vcDuration.showExample(true);
vcDuration.showError(false);
this.vcDurationInputList.add(index, vcDuration);
// add row button
FormLink addButton = new FormLinkImpl("add" + counter, "add" + counter, "vc.table.add", Link.BUTTON_SMALL);
editVC.add(addButton);
vcAddButtonList.add(index, addButton);
// remove row button
FormLink delButton = new FormLinkImpl("delete" + counter, "delete" + counter, "vc.table.delete", Link.BUTTON_SMALL);
editVC.add(delButton);
vcDelButtonList.add(index, delButton);
// increase the counter to enable unique component names
counter++;
}
Aggregations