protected boolean validateFormLogic(UserRequest ureq) {
    // validate event dates
    for (Project.EventType eventType : eventStartElementList.keySet()) {
      Date startDate = eventStartElementList.get(eventType).getDate();
      Date endDate = eventEndElementList.get(eventType).getDate();
      getLogger().debug("validate startDate=" + startDate + " enddate=" + endDate);
      if ((startDate != null) && (endDate != null) && startDate.after(endDate)) {
        eventStartElementList.get(eventType).setErrorKey("from.error.date.start.after.end", null);
        return false;
      }
    }
    if (!project.getTitle().equals(projectTitle.getValue())
        && ProjectBrokerManagerFactory.getProjectBrokerManager()
            .existProjectName(project.getProjectBroker().getKey(), projectTitle.getValue())) {
      projectTitle.setErrorKey("form.error.project.title.already.exist", null);
      return false;
    }
    if (projectTitle.getValue().trim().isEmpty()) {
      projectTitle.setErrorKey("form.error.project.title.is.empty", null);
      return false;
    }

    // http://jira.openolat.org/browse/OO-131  check for too long filename
    if (attachmentFileName.getUploadFileName() != null
        && attachmentFileName.getUploadFileName().length() > 99) {
      attachmentFileName.setErrorKey("form.error.project.filenametoolong", null);
      return false;
    }
    return true;
  }
  @Override
  protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
    super.formInnerEvent(ureq, source, event);
    if (source == cancelButton) {
      fireEvent(ureq, Event.CANCELLED_EVENT);

    } else if (source == importFile) {
      if (importFile.isUploadSuccess()) {
        File tmpJar = importFile.getUploadFile();
        Set<String> importLangKeys =
            I18nManager.getInstance().sarchForAvailableLanguagesInJarFile(tmpJar, true);
        if (importLangKeys.size() == 0) {
          showError("configuration.management.package.import.failure.empty");
          return;
        }
        //
        // enable language key selection
        String[] langKeys = ArrayHelper.toArray(importLangKeys);
        importKeys.setKeysAndValues(langKeys, langKeys);
        importKeys.selectAll();
        importKeys.setVisible(true);
        // In language adaption mode the import is done as a package - can't deselect anything
        importKeys.setEnabled(false);
      }
    }
  }
 private void uploadFiles(FileElement attachmentFileElement) {
   VFSLeaf uploadedItem = new LocalFileImpl(attachmentFileElement.getUploadFile());
   ProjectBrokerManagerFactory.getProjectBrokerManager()
       .saveAttachedFile(
           project,
           attachmentFileElement.getUploadFileName(),
           uploadedItem,
           courseEnv,
           courseNode);
 }
  @Override
  protected void formOK(UserRequest ureq) {
    if (importKeys.isVisible() && importKeys.getSelectedKeys().size() > 0) {
      Collection<String> importLangKeys = importKeys.getSelectedKeys();
      Set<String> alreadyInstalledLangs = new HashSet<String>();
      for (String langKey : importLangKeys) {
        if (I18nModule.getAvailableLanguageKeys().contains(langKey)) {
          alreadyInstalledLangs.add(langKey);
        }
      }
      if (I18nModule.isTransToolEnabled()) {
        // In translation mode importing will copy the language package
        // over an existing language or create a new language
        File tmpJar = importFile.getUploadFile();
        I18nManager.getInstance().copyLanguagesFromJar(tmpJar, importLangKeys);
        logAudit("Uploaded languages from jar::" + importFile.getUploadFileName(), null);
        showInfo("configuration.management.package.import.success", importLangKeys.toString());

      } else {
        // In language adaption mode: import is copied to user managed i18n package space in
        // olatdata
        if (alreadyInstalledLangs.size() == importLangKeys.size()) {
          showError("configuration.management.package.import.failure.installed");
          return;
        }
        // Ok, contains at least one language, copy to lang pack dir
        importFile.moveUploadFileTo(I18nModule.LANG_PACKS_DIRECTORY);
        logAudit("Uploaded language pack::" + importFile.getUploadFileName(), null);

        if (alreadyInstalledLangs.size() > 0) {
          getWindowControl()
              .setWarning(
                  getTranslator()
                      .translate(
                          "configuration.management.package.import.success.with.existing",
                          new String[] {
                            importLangKeys.toString(), alreadyInstalledLangs.toString()
                          }));
        } else {
          showInfo("configuration.management.package.import.success", importLangKeys.toString());
        }
      }
      // Reset i18n system
      I18nModule.reInitializeAndFlushCache();
      fireEvent(ureq, Event.DONE_EVENT);
    }
  }
 @Override
 protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {
   // A title, displayed in fieldset
   setFormTitle("configuration.management.package.import.title");
   if (I18nModule.isTransToolEnabled()) {
     setFormDescription("configuration.management.package.import.description.transserver");
   } else {
     setFormDescription("configuration.management.package.import.description");
   }
   //
   // The import file upload
   importFile =
       uifactory.addFileElement("configuration.management.package.import.file", formLayout);
   importFile.setLabel("configuration.management.package.import.file", null);
   importFile.setMandatory(true, "configuration.management.package.import.file.error.mandatory");
   // Limit to jar files and set upload limit to 50 MB
   importFile.setMaxUploadSizeKB(
       50000, "configuration.management.package.import.file.error.size", null);
   Set<String> mimeTypes = new HashSet<String>();
   mimeTypes.add("application/java-archive");
   mimeTypes.add("application/x-jar");
   mimeTypes.add("application/x-java-jar");
   importFile.limitToMimeType(
       mimeTypes, "configuration.management.package.import.file.error.type", null);
   importFile.addActionListener(FormEvent.ONCHANGE); // trigger auto-upload	
   //
   // Add checkboxes for the found languages - hide so far
   String[] langKeys = new String[] {};
   importKeys =
       uifactory.addCheckboxesVertical(
           "configuration.management.package.import.select", flc, langKeys, langKeys, 1);
   importKeys.setVisible(false);
   //
   // Add cancel and submit in button group layout
   FormLayoutContainer buttonGroupLayout =
       FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
   formLayout.add(buttonGroupLayout);
   cancelButton = uifactory.addFormLink("cancel", buttonGroupLayout, Link.BUTTON);
   uifactory.addFormSubmitButton("configuration.management.package.import", buttonGroupLayout);
 }
 protected void formInnerEvent(UserRequest ureq, FormItem source, FormEvent event) {
   if (source == selectionMaxMembers) {
     if (selectionMaxMembers.isSelected(0)) {
       maxMembers.setVisible(true);
       maxMembers.setIntValue(MAX_MEMBERS_DEFAULT);
     } else {
       maxMembers.setVisible(false);
       maxMembers.setIntValue(Project.MAX_MEMBERS_UNLIMITED);
     }
   } else if (source == removeAttachmentLink) {
     attachmentFileName.setInitialFile(null);
   }
   this.flc.setDirty(true);
 }
 @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();
     ProjectBrokerManagerFactory.getProjectGroupManager()
         .changeProjectGroupName(
             getIdentity(),
             project.getProjectGroup(),
             newProjectGroupName,
             newProjectGroupDescription,
             courseResource);
     ProjectBrokerManagerFactory.getProjectGroupManager()
         .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 (projectState.isSelected(0)) {
     if (!project.getState().equals(stateKeys[0])) {
       project.setState(stateKeys[0]);
       projectChanged = true;
     }
   } else {
     if (!project.getState().equals(stateKeys[1])) {
       project.setState(stateKeys[1]);
       projectChanged = true;
     }
   }
   if (project.getMaxMembers() != maxMembers.getIntValue()) {
     project.setMaxMembers(maxMembers.getIntValue());
     projectChanged = true;
   }
   if (attachmentFileName.getUploadFileName() != null
       && !attachmentFileName.getUploadFileName().equals("")) {
     project.setAttachedFileName(attachmentFileName.getUploadFileName());
     uploadFiles(attachmentFileName);
   }
   // store customfields
   int index = 0;
   for (Iterator iterator = customfieldElementList.iterator(); iterator.hasNext(); ) {
     Object 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.getSelectedKey();
       } else {
         value = "";
       }
     }
     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();
     if (!project.getProjectEvent(eventType).getStartDate().equals(startDate)
         || !project.getProjectEvent(eventType).getEndDate().equals(endDate)) {
       project.setProjectEvent(new ProjectEvent(eventType, startDate, endDate));
       projectChanged = true;
     }
   }
   if (projectChanged) {
     ProjectBrokerManagerFactory.getProjectBrokerManager().updateProject(project);
     ProjectBrokerManagerFactory.getProjectBrokerEmailer()
         .sendProjectChangedEmailToParticipants(ureq.getIdentity(), project, this.getTranslator());
     fireEvent(ureq, Event.DONE_EVENT);
   }
 }
  /** Initialize form. */
  @Override
  protected void initForm(FormItemContainer formLayout, Controller listener, UserRequest ureq) {

    // create form elements
    projectTitle =
        uifactory.addInlineTextElement(
            "detailsform.title.label", project.getTitle(), formLayout, this);
    projectTitle.setMaxLength(100);
    projectTitle.setLabel("detailsform.title.label", null);

    // account-Managers
    StringBuilder projectLeaderString = new StringBuilder();
    for (Iterator iterator = project.getProjectLeaders().iterator(); iterator.hasNext(); ) {
      Identity 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);
    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().info("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
        uifactory.addStaticTextElement(
            "customField_label" + customFieldIndex, customField.getName(), formLayout);
        TextElement textElement =
            uifactory.addTextElement(
                "customField_" + customFieldIndex,
                "",
                20,
                project.getCustomFieldValue(customFieldIndex),
                formLayout);
        //				textElement.setLabelComponent(null, null);
        textElement.showLabel(false);
        //				textElement.setTranslator(null);
        //				textElement.setLabel(customField.getName(), null);

        customfieldElementList.add(textElement);
      } else {
        // values define => dropdown selection
        List<String> valueList = new ArrayList<String>();
        while (tok.hasMoreTokens()) {
          valueList.add(tok.nextToken());
        }
        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] = value;
          arrayIndex++;
        }
        // Add StaticTextElement as workaround for non translated 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))) {
            selectionElement.select(project.getCustomFieldValue(customFieldIndex), 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", null, formLayout);
        dateChooserStart.setLabel(eventType.getI18nKey() + ".start.label", null);
        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", null, formLayout);
        dateChooserEnd.setLabel(eventType.getI18nKey() + ".end.label", null);
        dateChooserEnd.setDateChooserTimeEnabled(true);
        dateChooserEnd.setDisplaySize(CUSTOM_DATE_FORMAT.length());
        getLogger().info("Event=" + eventType + ", endDate=" + projectEvent.getEndDate());
        dateChooserEnd.setDate(projectEvent.getEndDate());
        eventEndElementList.put(eventType, dateChooserEnd);
        uifactory.addSpacerElement(eventType + "spacer", formLayout, false);
      }
    }

    projectState =
        uifactory.addDropdownSingleselect(
            "detailsform.state.label", formLayout, stateKeys, stateValues, null);
    projectState.select(project.getState(), true);

    maxMembers =
        uifactory.addInlineIntegerElement(
            "detailsform.max.members.label", project.getMaxMembers(), formLayout, this);
    maxMembers.setLabel("detailsform.max.members.label", null);
    maxMembers.setMinValueCheck(0, null);

    attachmentFileName =
        uifactory.addFileElement("detailsform.attachmentfilename.label", formLayout);
    attachmentFileName.setLabel("detailsform.attachmentfilename.label", null);
    if (project.getAttachmentFileName() != null && !project.getAttachmentFileName().equals("")) {
      attachmentFileName.setInitialFile(new File(project.getAttachmentFileName()));
    }
    attachmentFileName.addActionListener(this, FormEvent.ONCHANGE);

    uifactory.addFormSubmitButton("save", formLayout);
  }
 @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();
     ProjectBrokerManagerFactory.getProjectGroupManager()
         .changeProjectGroupName(
             getIdentity(),
             project.getProjectGroup(),
             newProjectGroupName,
             newProjectGroupDescription,
             courseResource);
     ProjectBrokerManagerFactory.getProjectGroupManager()
         .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());
     ProjectBrokerManagerFactory.getProjectGroupManager()
         .setProjectGroupMaxMembers(
             getIdentity(), project.getProjectGroup(), maxMembers.getIntValue());
     projectChanged = true;
   }
   if (attachmentFileName.getUploadFileName() != null
       && !attachmentFileName.getUploadFileName().equals("")) {
     // First call uploadFiles than setAttachedFileName because uploadFiles needs old attachment
     // name
     uploadFiles(attachmentFileName);
     project.setAttachedFileName(attachmentFileName.getUploadFileName());
     projectChanged = true;
   } else if (project.getAttachmentFileName() != null
       && !project.getAttachmentFileName().equals("")) {
     // Attachment file has been removed
     project.setAttachedFileName("");
     projectChanged = true;
   }
   // store customfields
   int index = 0;
   for (Iterator iterator = customfieldElementList.iterator(); iterator.hasNext(); ) {
     Object 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 (ProjectBrokerManagerFactory.getProjectBrokerManager().existsProject(project.getKey())) {
       ProjectBrokerManagerFactory.getProjectBrokerManager().updateProject(project);
       ProjectBrokerManagerFactory.getProjectBrokerEmailer()
           .sendProjectChangedEmailToParticipants(
               ureq.getIdentity(), project, this.getTranslator());
     } else {
       this.showInfo("info.project.nolonger.exist", project.getTitle());
     }
   }
   fireEvent(ureq, Event.DONE_EVENT);
 }
  /** 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 iterator = project.getProjectLeaders().iterator(); iterator.hasNext(); ) {
      Identity 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(
                ProjectBrokerManagerFactory.getProjectBrokerManager()
                    .getStateFor(project, ureq.getIdentity(), projectBrokerModuleConfiguration));
    projectState =
        uifactory.addStaticTextElement(
            "detailsform.state", stateValue + "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;", 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, null);
    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(listener, 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
        uifactory.addStaticTextElement(
            "customField_label" + customFieldIndex,
            null,
            customField.getName(),
            formLayout); // null > no label
        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
        uifactory.addStaticTextElement(
            "customField_label" + customFieldIndex,
            null,
            customField.getName(),
            formLayout); // null > no label
        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))) {
            String key =
                Integer.toString(
                    valueList.indexOf(project.getCustomFieldValue(customFieldIndex))
                        + 1); // '+1' because no-selection at the beginning
            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("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(this, FormEvent.ONCHANGE);

    mailNotification =
        uifactory.addCheckboxesHorizontal(
            "detailsform.mail.notification.label", formLayout, keys, values, null);
    mailNotification.select(keys[0], project.isMailNotificationEnabled());

    FormLayoutContainer buttonGroupLayout =
        FormLayoutContainer.createButtonLayout("buttonGroupLayout", getTranslator());
    formLayout.add(buttonGroupLayout);
    uifactory.addFormSubmitButton("save", buttonGroupLayout);
    if (this.enableCancel) {
      uifactory.addFormCancelButton(
          "cancel",
          buttonGroupLayout,
          ureq,
          getWindowControl()); // TODO: Frage an PB: Warum flc hier noetig ???
    }
  }