Package org.olat.core.gui.components.form.flexible.elements

Examples of org.olat.core.gui.components.form.flexible.elements.SingleSelection


   * @param theKeys
   * @param theValues
   * @return
   */
  public SingleSelection addRadiosHorizontal(final String name, final String i18nLabel, FormItemContainer formLayout, final String[] theKeys, final String[] theValues) {
    SingleSelection ss = new SingleSelectionImpl(name, SingleSelectionImpl.createHorizontalLayout(name)){
      {
        this.keys = theKeys;
        this.values = theValues;
      }
    };
View Full Code Here


   * @param theKeys
   * @param theValues
   * @return
   */
  public SingleSelection addRadiosVertical(final String name, final String i18nLabel, FormItemContainer formLayout, final String[] theKeys, final String[] theValues) {
    SingleSelection ss = new SingleSelectionImpl(name, SingleSelectionImpl.createVerticalLayout(name)){
      {
        this.keys = theKeys;
        this.values = theValues;
      }
    };
View Full Code Here

   * @param theValues
   * @param theCssClasses
   * @return
   */
  public SingleSelection addDropdownSingleselect(final String name, final String i18nLabel, FormItemContainer formLayout, final String[] theKeys, final String[] theValues, final String[] theCssClasses) {
    SingleSelection ss = new SingleSelectionImpl(name, SingleSelectionImpl.createSelectboxLayouter(name)){
      {
        this.keys = theKeys;
        this.values = theValues;
        this.cssClasses = theCssClasses;
      }
View Full Code Here

    super(triggerElement, triggerValue, targets, type);
  }

  @Override
  protected boolean doesTrigger() {
    SingleSelection singlsel =(SingleSelection)this.triggerElement;
    String selected = singlsel.getSelectedKey();
    return selected.equals(this.triggerVal);
  }
View Full Code Here

        int clickPos = ((Integer) source.getUserObject()).intValue();
        removeRowAt(clickPos);
      }
      if (compName.startsWith(PRE_ATTRIBUTE)) {
        // one of the attribute selection drop boxes has been clicked
        SingleSelection s1 = (SingleSelection) source;
        String attr;
        if (s1.isOneSelected()) {
          attr = s1.getSelectedKey();
        } else {
          // Special case: two new rows, modify the attribute on the second one
          // without touching the first one -> nothing selected on the first row
          // In this case we use the first one which is the visible one.
          attr = s1.getKey(0);
        }
        // update the value form element depending on the selected attribute
        int clickPos = ((Integer) s1.getUserObject()).intValue();
        updateValueElementForAttribute(attr, clickPos, null);
      }
    }
    // update whole container to reflect changes.
    this.flc.setDirty(true);
View Full Code Here

  public List<ExtendedCondition> getAttributeConditions() {
    List<ExtendedCondition> le = new ArrayList<ExtendedCondition>();
    for (Iterator<String> iterator = columnAttribute.iterator(); iterator.hasNext();) {
      String aname = iterator.next();
      String row = aname.replace(PRE_ATTRIBUTE, "");
      SingleSelection attribute = (SingleSelection) flc.getFormComponent(PRE_ATTRIBUTE + row);
      String condName = attribute.getSelectedKey();
      SingleSelection operator = (SingleSelection) flc.getFormComponent(PRE_OPERATOR + row);
      String condOperator = operator.getSelectedKey();
      String condValue = "";
      SingleSelection valuessi = (SingleSelection) flc.getFormComponent(PRE_VALUE_SELECTION + row);
      if (valuessi.isVisible()) {
        if (valuessi.isOneSelected()) {
          condValue = valuessi.getSelectedKey();
        } else {
          // user did not actively select one, maybe because the first one was already the one he wanted. Use this one
          condValue = valuessi.getKey(0);
        }
      } else {
        TextElement valuetei = (TextElement) flc.getFormComponent(PRE_VALUE_TEXT + row);
        condValue = valuetei.getValue();
      }
View Full Code Here

      // now count is always one more than the row position, thus the next position to add a row
      // is the same as the current row count
      addRowAt(row);
      try {
        // set value in attribute selection
        SingleSelection ssi = (SingleSelection) flc.getFormComponent((String) columnAttribute.get(row));
        ssi.select(extendedCondition.getAttribute(), true);
        // set value in operator selection
        ssi = (SingleSelection) flc.getFormComponent((String) columnOperator.get(row));
        ssi.select(extendedCondition.getOperator().getOperatorKey(), true);
        // set the selectable values for this attribute if available and set the
        // preselected / predefined value.
        String attribute = extendedCondition.getAttribute();
        updateValueElementForAttribute(attribute, row, extendedCondition.getValue());
      } catch (Exception e) {
View Full Code Here

      }
    }
    // 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);
    addL.setUserObject(Integer.valueOf(rowPos));
    flc.add(addL);
View Full Code Here

        getAttributeTranslator().getSelectableValuesForAttribute(attribute) :
          null;
    // Get the value text input and selection drop down form elements for this
    // row. Don't use the element name since there we have the global row
    // counter in the name and _not_ the current row id!
    SingleSelection iselect = (SingleSelection) flc.getFormComponent(columnValueSelection.get(row));
    TextElement tei = (TextElement) flc.getFormComponent(columnValueText.get(row));

    if (selectableKeys != null) {
      // to set value on selection drop down we first need to remove it and create it as new one with new keys
      // create an object array with key - value pairs in it
      String[] guiTranslatedKeys = new String[selectableKeys.length];
      for (int i = 0; i < selectableKeys.length; i++) {
        String key = selectableKeys[i];
        String translated = getTranslator().translate(attribute + "." + key);
        if (translated.indexOf(PackageTranslator.NO_TRANSLATION_ERROR_PREFIX) == 0) {
          // could not translate this key, use key for non-translated values
          guiTranslatedKeys[i] = key;
        } else {
          guiTranslatedKeys[i] = translated;
        }
      }     
      // sort the key-value-pairs by value
      ArrayHelper.sort(selectableKeys, guiTranslatedKeys, false, true, true);
     
      // update keys and values now
      iselect.setKeysAndValues(selectableKeys, guiTranslatedKeys, null);
      // set user value
      if (value != null) {
        // check if stored value exists, otherwise don't select anything
        if (Arrays.asList(selectableKeys).contains(value)) {
          iselect.select(value, true);
        } else {
          // ups, maybe this value has been removed from the list? maybe a programming error?
          logWarn("could not select value::" + value + " for shibboleth attribute::" + attribute
              + " in course easy mode, not found in selectable list", null);
        }
      }
      iselect.setVisible(true);
      // set alternative text input field as non visible
      tei.setVisible(false);
    } else {
      // update text element visibility and the value
      tei.setValue(value);
      tei.setVisible(true);
      // and hide selection box
      iselect.setVisible(false);
    }
  }
View Full Code Here

    String[] keys = CheckpointMode.getModes();
    String[] values = new String[keys.length];
    for (int i = 0; i < keys.length; i++) {
      values[i] = translate(keys[i]);
    }
    SingleSelection mode = uifactory.addDropdownSingleselect("modus" + counter, "form.enableCancelEnroll", titleContainer, keys, values, null);
    mode.select(checkpoint.getMode(), checkpoint.getMode() != null);
    mode.setUserObject(checkpoint);
    modeInputList.add(index, mode);
   
    // add link add action button
    FormLink addButton = new FormLinkImpl("add" + counter, "add" + counter, "cl.table.add", Link.BUTTON_SMALL);
    addButton.setUserObject(checkpoint);
View Full Code Here

TOP

Related Classes of org.olat.core.gui.components.form.flexible.elements.SingleSelection

Copyright © 2018 www.massapicom. 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.