Examples of FormItem


Examples of org.olat.core.gui.components.form.flexible.FormItem

    // 1) Make room for the new row if the row is inserted between existing
    // rows. Increment the row id in the user object of the form elements and
    // move them in the form element arrays
    Map formComponents = flc.getFormComponents();
    for (int move = rowPos + 1; move <= columnAttribute.size(); move++) {
      FormItem oldPos = (FormItem) formComponents.get((String) columnAttribute.get(move - 1));
      oldPos.setUserObject(Integer.valueOf(move));
      oldPos = (FormItem) formComponents.get((String) columnOperator.get(move - 1));
      oldPos.setUserObject(Integer.valueOf(move));
      oldPos = (FormItem) formComponents.get((String) columnValueText.get(move - 1));
      oldPos.setUserObject(Integer.valueOf(move));
      oldPos = (FormItem) formComponents.get((String) columnValueSelection.get(move - 1));
      oldPos.setUserObject(Integer.valueOf(move));
      oldPos = (FormItem) formComponents.get((String) columnAddRow.get(move - 1));
      oldPos.setUserObject(Integer.valueOf(move));
      oldPos = (FormItem) formComponents.get((String) columnRemoveRow.get(move - 1));
      oldPos.setUserObject(Integer.valueOf(move));
    }
    // 2) create the new row

    // get gui translated shib attributes - fallback is to use the key also as value
    final String[] guiTranslatedAttKeys = new String[attrKeys.length];
    for (int j = 0; j < attrKeys.length; j++) {
      String key = attrKeys[j];
      // OLAT-5089: use translate(String key, String[] args, boolean fallBackToDefaultLocale) version
      //            of Translator because that's the only one not
      String translated = getTranslator().translate(key, null, Level.OFF);
      if (translated.indexOf(PackageTranslator.NO_TRANSLATION_ERROR_PREFIX) == 0) {
         Translator translator = UserManager.getInstance().getPropertyHandlerTranslator(getTranslator());
         String prefix = "form.name.";
          // OLAT-5089: use translate(String key, String[] args, boolean fallBackToDefaultLocale) version
          //            of Translator because that's the only one not
         translated = translator.translate(prefix + key, null, Level.OFF);
         if (translated.indexOf(PackageTranslator.NO_TRANSLATION_ERROR_PREFIX) == 0) {
           // could not translate this key, use key for non-translated values
           guiTranslatedAttKeys[j] = key;
         } else {
           guiTranslatedAttKeys[j] = translated;
         }
      } else {
        guiTranslatedAttKeys[j] = translated;
      }
    }
    // sort after the values
    ArrayHelper.sort(attrKeys, guiTranslatedAttKeys, false, true, true);
    // use this sorted keys-values
    SingleSelection attribute = uifactory.addDropdownSingleselect(PRE_ATTRIBUTE + rowCreationCounter, null, flc, attrKeys, guiTranslatedAttKeys, null);
    attribute.setUserObject(Integer.valueOf(rowPos));
    attribute.addActionListener(this, FormEvent.ONCHANGE);
    columnAttribute.add(rowPos, attribute.getName());

    // 2b) Operator selector
    String[] values = OperatorManager.getRegisteredAndAlreadyTranslatedOperatorLabels(getLocale(), operatorKeys);
    FormItem operator = uifactory.addDropdownSingleselect(PRE_OPERATOR + rowCreationCounter, null, flc, operatorKeys, values, null);
    operator.setUserObject(Integer.valueOf(rowPos));
    columnOperator.add(rowPos, operator.getName());

    // 2c) Attribute value - can be either a text input field or a selection
    // drop down box - create both and hide the selection box
    //
    TextElement valuetxt = uifactory.addTextElement(PRE_VALUE_TEXT + rowCreationCounter, null, -1, null, flc);
    valuetxt.setDisplaySize(25);
    valuetxt.setNotEmptyCheck("form.easy.error.attribute");
    valuetxt.setUserObject(Integer.valueOf(rowPos));
    columnValueText.add(rowPos, valuetxt.getName());
    // now the selection box
    FormItem iselect = uifactory.addDropdownSingleselect(PRE_VALUE_SELECTION + rowCreationCounter, null, flc, new String[0], new String[0], null);
    iselect.setUserObject(Integer.valueOf(rowPos));
    iselect.setVisible(false);
    columnValueSelection.add(rowPos, iselect.getName());
    // 3) Init values for this row, assume selection of attribute at position 0
    updateValueElementForAttribute(attribute.getKey(0), rowPos, null);

    // 4) Add the 'add' and 'remove' buttons
    FormLinkImpl addL = new FormLinkImpl("add_" + rowCreationCounter, "add." + rowPos, "+", Link.BUTTON_SMALL + Link.NONTRANSLATED);
View Full Code Here

Examples of org.olat.core.gui.components.form.flexible.FormItem

    flc.remove(flc.getFormComponent((String) columnRemoveRow.get(clickPos)));
    columnRemoveRow.remove(clickPos);
    // 2) adjust all rows below the removed row. set the new row id in the user
    // object of the form element and move the element in the element arrays
    for (int move = clickPos; move < columnAttribute.size(); move++) {
      FormItem oldPos = flc.getFormComponent((String) columnAttribute.get(move));
      oldPos.setUserObject(Integer.valueOf(move));
      oldPos = flc.getFormComponent((String) columnOperator.get(move));
      oldPos.setUserObject(Integer.valueOf(move));
      oldPos = flc.getFormComponent((String) columnValueText.get(move));
      oldPos.setUserObject(Integer.valueOf(move));
      oldPos = flc.getFormComponent((String) columnValueSelection.get(move));
      oldPos.setUserObject(Integer.valueOf(move));
      oldPos = flc.getFormComponent((String) columnAddRow.get(move));
      oldPos.setUserObject(Integer.valueOf(move));
      oldPos = flc.getFormComponent((String) columnRemoveRow.get(move));
      oldPos.setUserObject(Integer.valueOf(move));
    }
  }
View Full Code Here

Examples of org.olat.core.gui.components.form.flexible.FormItem

  // adds or updates the list of already existing attachments with a delete
  // button for each
  @SuppressWarnings("unchecked")
  private void createOrUpdateAttachmentListLayout(FormItemContainer formLayout) {
    FormUIFactory formUIf = FormUIFactory.getInstance();
    FormItem attachLayout = formLayout.getFormComponent("attachLayout");

    List<VFSItem> attachments = new ArrayList<VFSItem>();
    // add already existing attachments:
    if (message.getKey() != null) {
      OlatRootFolderImpl msgContainer = fm.getMessageContainer(message.getForum().getKey(), message.getKey());
View Full Code Here

Examples of org.olat.core.gui.components.form.flexible.FormItem

        assessmentSwitch.clearError();

       
        // all dependent elements become invisible
        for (Iterator<FormItem> iter = dependenciesCoachExclusiveReadonly.iterator(); iter.hasNext();) {
          FormItem element = iter.next();
          element.setVisible(false);
        }
      }
    });

    // two rules to bring them back visible and also checkable
View Full Code Here

Examples of org.olat.core.gui.components.form.flexible.FormItem

        target.append("<td class=\"").append(cssClass).append("\">");
        if (j == 0) target.append("<a name=\"table\"></a>"); //add once for accessabillitykey
       
        Object cellValue = ftE.getTableDataModel().getValueAt(i, j);
        if (cellValue instanceof FormItem) {
          FormItem formItem = (FormItem)cellValue;
          formItem.setTranslator(translator);
          formItem.setRootForm(ftE.getRootForm());
          formItem.getComponent().getHTMLRendererSingleton().render(renderer, target, formItem.getComponent(), ubu, translator, renderResult, args);
        } else {
          ftE.getTableDataModel().getTableColumnModel().getColumnModel(j).
            getCellRenderer().render(target, cellValue, translator);
        }
        target.append("</td>");
View Full Code Here

Examples of org.olat.core.gui.components.form.flexible.FormItem

    UserManager um = UserManager.getInstance();
    userPropertyHandlers = um.getUserPropertyHandlersFor(formIdentifyer, true);
    // Add all available user fields to this form
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
      if (userPropertyHandler == null) continue;
      FormItem formItem = userPropertyHandler.addFormItem(ureq.getLocale(), null, formIdentifyer, true, formLayout);
      // special case to handle email field
      if(userPropertyHandler.getName().equals(UserConstants.EMAIL)) {
        emailTextElement = (TextElement) formItem;
      }
    }
View Full Code Here

Examples of org.olat.core.gui.components.form.flexible.FormItem

    usernameTextElement.clearError();

    // validate special rules for each user property
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {     
      //we assume here that there are only textElements for the user properties
      FormItem formItem = this.flc.getFormComponent(userPropertyHandler.getName());
      if ( ! userPropertyHandler.isValid(formItem, null) || formItem.hasError()) {
        return false;       
      }
      formItem.clearError();
    }
    // special test on email address: validate if email is already used
    if (emailTextElement != null) {     
      String email = emailTextElement.getValue();
      // Check if email is not already taken
View Full Code Here

Examples of org.olat.core.gui.components.form.flexible.FormItem

    // Create transient user without firstName,lastName, email
    UserManager um = UserManager.getInstance();
    User newUser = um.createUser(null, null, null);
    // Now add data from user fields (firstName,lastName and email are mandatory)
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
      FormItem propertyItem = this.flc.getFormComponent(userPropertyHandler.getName());
      userPropertyHandler.updateUserFromFormItem(newUser, propertyItem);
    }
    // Init preferences
    newUser.getPreferences().setLanguage(lang);
    newUser.getPreferences().setInformSessionTimeout(true);
View Full Code Here

Examples of org.olat.core.gui.components.form.flexible.FormItem

    //
    Manager im = ManagerFactory.getManager();
    Identity identity = im.findIdentityByName(getIdentity().getName());
    for (UserPropertyHandler userPropertyHandler : userPropertyHandlers) {
      String propertyName = userPropertyHandler.getName();
      FormItem fi = this.flc.getFormComponent(propertyName);
      String propertyValue = userPropertyHandler.getStringValue(fi);
      //(propertyname, propertyvalue) for mailtemplate
      propsAndValues.add(new String[]{translate(userPropertyHandler.i18nFormElementLabelKey()), propertyValue});
      //set property value
      identity.getUser().setProperty(propertyName, propertyValue);
View Full Code Here

Examples of org.olat.core.gui.components.form.flexible.FormItem

      int i = 0;
      HashMap<String, String> attributeChangeMap = new HashMap<String, String>();
      for (Iterator<MultipleSelectionElement> iterator = checkBoxes.iterator(); iterator.hasNext();) {
        MultipleSelectionElement checkbox = iterator.next();
        if (checkbox.isSelected(0)) {
          FormItem formItem = formItems.get(i);
          // first get the values from the hardcoded items
          if (formItem.getName().equals(UserBulkChangeManager.LANG_IDENTIFYER)) {
            SingleSelection selectField = (SingleSelection) formItem;
            attributeChangeMap.put(UserBulkChangeManager.LANG_IDENTIFYER, selectField.getSelectedKey());           
          } else if (formItem.getName().equals(UserBulkChangeManager.PWD_IDENTIFYER)) {
            TextElement propertyField = (TextElement) formItem;
            attributeChangeMap.put(UserBulkChangeManager.PWD_IDENTIFYER, propertyField.getValue());           
          }         
          // second get the values from all configured user properties
          else {
            // find corresponding user property handler
            for (UserPropertyHandler propertyHanlder : userPropertyHandlers) {
              if (propertyHanlder.getName().equals(formItem.getName())) {
                String inputText;
                if (formItem instanceof DateChooser) {
                  // special case: don't use getStringValue, this would encode
                  // the date with the date formatter, use raw text input value
                  // instead
                  DateChooser dateItem = (DateChooser) formItem; 
                  inputText = dateItem.getValue();
                } else {
                  inputText = propertyHanlder.getStringValue(formItem);
                }

                attributeChangeMap.put(formItem.getName(), inputText);
              }
            }
          }
        }
        i++;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.