Search in sources :

Example 16 with FormLinkImpl

use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project openolat by klemens.

the class FlexiTableElementImpl method setSearchEnabled.

@Override
public void setSearchEnabled(boolean enable) {
    this.searchEnabled = enable;
    if (searchEnabled) {
        String dispatchId = component.getDispatchID();
        searchFieldEl = new TextElementImpl(dispatchId + "_searchField", "search", "");
        searchFieldEl.showLabel(false);
        components.put("rSearch", searchFieldEl);
        searchButton = new FormLinkImpl(dispatchId + "_searchButton", "rSearchButton", "search", Link.BUTTON);
        searchButton.setTranslator(translator);
        searchButton.setIconLeftCSS("o_icon o_icon_search");
        components.put("rSearchB", searchButton);
        rootFormAvailable(searchFieldEl);
        rootFormAvailable(searchButton);
    } else {
        components.remove("rSearch");
        components.remove("rSearchB");
        searchFieldEl = null;
        searchButton = null;
    }
}
Also used : TextElementImpl(org.olat.core.gui.components.form.flexible.impl.elements.TextElementImpl) FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)

Example 17 with FormLinkImpl

use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project openolat by klemens.

the class FlexiTableElementImpl method setExtendedFilterButton.

@Override
public void setExtendedFilterButton(String label, List<FlexiTableFilter> extendedFilters) {
    if (StringHelper.containsNonWhitespace(label) && extendedFilters != null && extendedFilters.size() > 0) {
        this.extendedFilters = extendedFilters;
        String dispatchId = component.getDispatchID();
        extendedFilterButton = new FormLinkImpl(dispatchId + "_extFilterButton", "rExtFilterButton", "extfilter", Link.BUTTON | Link.NONTRANSLATED);
        extendedFilterButton.setI18nKey(label);
        extendedFilterButton.setTranslator(translator);
        extendedFilterButton.setIconLeftCSS("o_icon o_icon_filter");
        components.put("rExtFilterB", extendedFilterButton);
        rootFormAvailable(extendedFilterButton);
        extendedFilterButton.setElementCssClass("o_sel_flexi_extendedsearch");
    } else {
        extendedFilterButton = null;
        extendedFilters = null;
    }
}
Also used : FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)

Example 18 with FormLinkImpl

use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project openolat by klemens.

the class AttributeEasyRowAdderController method addRowAt.

/**
 * Internal method to add a new row at the given position
 *
 * @param i
 */
private void addRowAt(final int rowPos) {
    // 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
    final Map<String, FormItem> formComponents = flc.getFormComponents();
    for (int move = rowPos + 1; move <= columnAttribute.size(); move++) {
        FormItem oldPos = formComponents.get(columnAttribute.get(move - 1));
        oldPos.setUserObject(Integer.valueOf(move));
        oldPos = formComponents.get(columnOperator.get(move - 1));
        oldPos.setUserObject(Integer.valueOf(move));
        oldPos = formComponents.get(columnValueText.get(move - 1));
        oldPos.setUserObject(Integer.valueOf(move));
        oldPos = formComponents.get(columnValueSelection.get(move - 1));
        oldPos.setUserObject(Integer.valueOf(move));
        oldPos = formComponents.get(columnAddRow.get(move - 1));
        oldPos.setUserObject(Integer.valueOf(move));
        oldPos = formComponents.get(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++) {
        final 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(Translator.NO_TRANSLATION_ERROR_PREFIX) == 0) {
            final Translator translator = UserManager.getInstance().getPropertyHandlerTranslator(getTranslator());
            final 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(Translator.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
    final SingleSelection attribute = uifactory.addDropdownSingleselect(PRE_ATTRIBUTE + rowCreationCounter, null, flc, attrKeys, guiTranslatedAttKeys, null);
    attribute.setUserObject(Integer.valueOf(rowPos));
    attribute.addActionListener(FormEvent.ONCHANGE);
    columnAttribute.add(rowPos, attribute.getName());
    // 2b) Operator selector
    final String[] values = OperatorManager.getRegisteredAndAlreadyTranslatedOperatorLabels(getLocale(), operatorKeys);
    final 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
    // 
    final 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
    final 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
    if (ArrayUtils.contains(attrKeys, preselectedAttribute)) {
        attribute.select(preselectedAttribute, true);
        updateValueElementForAttribute(attribute.getKey(ArrayUtils.indexOf(attrKeys, preselectedAttribute)), rowPos, preselectedAttributeValue);
    } else {
        updateValueElementForAttribute(attribute.getKey(0), rowPos, null);
    }
    // 4) Add the 'add' and 'remove' buttons
    final FormLinkImpl addL = new FormLinkImpl("add_" + rowCreationCounter, "add." + rowPos, "+", Link.BUTTON_SMALL + Link.NONTRANSLATED);
    addL.setUserObject(Integer.valueOf(rowPos));
    flc.add(addL);
    columnAddRow.add(rowPos, addL.getName());
    // 
    final FormLinkImpl removeL = new FormLinkImpl("remove_" + rowCreationCounter, "remove." + rowPos, "-", Link.BUTTON_SMALL + Link.NONTRANSLATED);
    removeL.setUserObject(Integer.valueOf(rowPos));
    flc.add(removeL);
    columnRemoveRow.add(rowPos, removeL.getName());
    // new row created, increment counter for unique form element id's
    rowCreationCounter++;
}
Also used : TextElement(org.olat.core.gui.components.form.flexible.elements.TextElement) AttributeTranslator(org.olat.shibboleth.util.AttributeTranslator) Translator(org.olat.core.gui.translator.Translator) SingleSelection(org.olat.core.gui.components.form.flexible.elements.SingleSelection) FormItem(org.olat.core.gui.components.form.flexible.FormItem) FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)

Example 19 with FormLinkImpl

use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project openolat by klemens.

the class TranslationToolI18nItemEditCrumbController method initOrUpdateCurrentItem.

private void initOrUpdateCurrentItem(UserRequest ureq) {
    // Set keys (must call before setting new currentItemPosition bundle name!
    if (bundlesSelection.getSelectedKey().equals(currentItem.getBundleName())) {
        // still in same bundle, just select the currentItemPosition key
        keysSelection.select(currentItem.getKey(), true);
        // Update key progress bar
        progressBarKey.setActual(keysSelection.getSelected() + 1);
    } else {
        // in new bundle, load new keys
        updateKeysSelectionAndProgress();
    }
    // Set reference value
    String refValue = i18nMgr.getLocalizedString(currentItem.getBundleName(), currentItem.getKey(), null, referenceLocale, false, false, false, false, 0);
    referenceArea.setValue(refValue);
    // Add target value
    String targetValue = i18nMgr.getLocalizedString(currentItem, null);
    targetArea.setValue(targetValue);
    // Add compare value
    updateCompareArea(ureq);
    // Add annotation
    currentAnnotation = i18nMgr.getAnnotation(currentItem);
    annotationArea.setValue(currentAnnotation);
    if (currentAnnotation == null) {
        annotationArea.setVisible(false);
        annotationAddLink = new FormLinkImpl("annotationAddLink", "annotationAddLink", "edit.button.add.annotation", Link.BUTTON_SMALL);
        this.flc.add(annotationAddLink);
    } else {
        annotationArea.setVisible(true);
        if (annotationAddLink != null) {
            this.flc.remove(annotationAddLink);
            annotationAddLink = null;
        }
    }
    // Push item to velocity
    this.flc.contextPut("i18nItem", currentItem);
    // Set all links
    this.flc.contextPut("hasPrevious", (currentItemPosition == 0 ? Boolean.FALSE : Boolean.TRUE));
    this.flc.contextPut("hasNext", (currentItemPosition + 1 == i18nItems.size() ? Boolean.FALSE : Boolean.TRUE));
}
Also used : FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)

Example 20 with FormLinkImpl

use of org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl in project openolat by klemens.

the class TranslationToolStartCrumbController method initAllItemsElements.

private void initAllItemsElements(FormUIFactory formFactory, FormItemContainer formLayout, String[] bundlesKeys, String[] bundlesValues) {
    // Add all bundles selector
    allBundlesSelection = formFactory.addDropdownSingleselect("allBundlesSelection", this.flc, bundlesKeys, bundlesValues, null);
    allBundlesSelection.addActionListener(FormEvent.ONCHANGE);
    allBundlesSelection.select(ALL_BUNDLES_IDENTIFYER, true);
    // Add all bundles children switch
    String[] allBundlesIncludeBundles = new String[] { translate("generic.limit.bundles.includeChildren") };
    allBundlesIncludeBundlesChildrenSwitch = formFactory.addCheckboxesHorizontal("allBundlesIncludeBundlesChildrenSwitch", null, flc, new String[] { KEYS_ENABLED }, // disabled label by setting i18nLabel to null
    allBundlesIncludeBundles);
    allBundlesIncludeBundlesChildrenSwitch.select(KEYS_ENABLED, true);
    allBundlesIncludeBundlesChildrenSwitch.addActionListener(FormEvent.ONCLICK);
    formLayout.add(allBundlesIncludeBundlesChildrenSwitch);
    allBundlesIncludeBundlesChildrenSwitch.setEnabled(false);
    // Add priority sort switch
    String[] allBundlesIncludePrio = new String[] { translate("generic.sort.by.priority") };
    allBundlesPrioritySortSwitch = formFactory.addCheckboxesHorizontal("allBundlesPrioritySortSwitch", null, flc, new String[] { KEYS_ENABLED }, // disabled label by setting i18nLabel to null
    allBundlesIncludePrio);
    allBundlesPrioritySortSwitch.select(KEYS_ENABLED, true);
    allBundlesPrioritySortSwitch.addActionListener(FormEvent.ONCLICK);
    formLayout.add(allBundlesPrioritySortSwitch);
    // Add button to trigger all keys search
    allListButton = new FormLinkImpl("allListButton", "allListButton", "generic.listButton", Link.BUTTON);
    formLayout.add(allListButton);
    allTranslateButton = new FormLinkImpl("allTranslateButton", "allTranslateButton", "generic.translateButton", Link.BUTTON);
    formLayout.add(allTranslateButton);
}
Also used : FormLinkImpl(org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)

Aggregations

FormLinkImpl (org.olat.core.gui.components.form.flexible.impl.elements.FormLinkImpl)52 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)12 TextElement (org.olat.core.gui.components.form.flexible.elements.TextElement)8 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)6 ArrayList (java.util.ArrayList)4 HashSet (java.util.HashSet)4 FormItem (org.olat.core.gui.components.form.flexible.FormItem)4 FormLayoutContainer (org.olat.core.gui.components.form.flexible.impl.FormLayoutContainer)4 BusinessGroupShort (org.olat.group.BusinessGroupShort)4 BGArea (org.olat.group.area.BGArea)4 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 SimpleDateFormat (java.text.SimpleDateFormat)2 Date (java.util.Date)2 Locale (java.util.Locale)2 TimeZone (java.util.TimeZone)2 ValidationError (org.olat.core.gui.components.form.ValidationError)2 DateChooser (org.olat.core.gui.components.form.flexible.elements.DateChooser)2 AutoCompleterImpl (org.olat.core.gui.components.form.flexible.impl.elements.AutoCompleterImpl)2 ItemValidatorProvider (org.olat.core.gui.components.form.flexible.impl.elements.ItemValidatorProvider)2