Search in sources :

Example 16 with FormToggle

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

the class PortfolioFilterController method initTagFlc.

/**
 */
private void initTagFlc() {
    tagFlc.setLabel("filter.tag", null);
    tagAllBtn = uifactory.addToggleButton("filter.all", null, tagFlc, null, null);
    tagAllBtn.toggleOff();
    tagNoneBtn = uifactory.addToggleButton("filter.notag", null, tagFlc, null, null);
    Map<String, String> userTags = ePFMgr.getUsersMostUsedTags(getIdentity(), 8);
    int i = 1;
    tagCmpList = new ArrayList<FormToggle>();
    LinkedList<Entry<String, String>> sortEntrySet = new LinkedList<Entry<String, String>>(userTags.entrySet());
    Collections.sort(sortEntrySet, new Comparator<Entry<String, String>>() {

        public int compare(Entry<String, String> arg0, Entry<String, String> arg1) {
            return arg0.getValue().compareTo(arg1.getValue());
        }
    });
    List<String> allActiveTagToggles = new ArrayList<String>();
    for (Entry<String, String> entry : sortEntrySet) {
        String tag = entry.getValue();
        String tagText = StringHelper.escapeHtml(tag);
        String tagCmpName = TAG_CMP_IDENTIFIER + i;
        if (tagFlc.getComponent(tagCmpName) != null)
            tagFlc.remove(tagCmpName);
        FormToggle link = uifactory.addToggleButton(tagCmpName, tagText, tagFlc, null, null);
        link.setLabel("tag.one", new String[] { tagText });
        link.setUserObject(tag);
        if (!selectedTagsList.isEmpty() && selectedTagsList.contains(tag)) {
            link.toggleOn();
            allActiveTagToggles.add(tag);
        }
        tagCmpList.add(link);
        i++;
    }
    tagFlc.contextPut("tagCmpList", tagCmpList);
    tagEditBtn = uifactory.addToggleButton("filter.edit", null, tagFlc, null, null);
    tagEditBtn.toggleOff();
    if (!allActiveTagToggles.containsAll(selectedTagsList))
        tagEditBtn.toggleOn();
    if (selectedTagsList.isEmpty())
        tagAllBtn.toggleOn();
}
Also used : Entry(java.util.Map.Entry) ArrayList(java.util.ArrayList) FormToggle(org.olat.core.gui.components.form.flexible.elements.FormToggle) LinkedList(java.util.LinkedList)

Aggregations

FormToggle (org.olat.core.gui.components.form.flexible.elements.FormToggle)16 ArrayList (java.util.ArrayList)10 FormLink (org.olat.core.gui.components.form.flexible.elements.FormLink)8 UserPropertyHandler (org.olat.user.propertyhandlers.UserPropertyHandler)6 FormItem (org.olat.core.gui.components.form.flexible.FormItem)4 SingleSelection (org.olat.core.gui.components.form.flexible.elements.SingleSelection)4 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Entry (java.util.Map.Entry)2 CloseableCalloutWindowController (org.olat.core.gui.control.generic.closablewrapper.CloseableCalloutWindowController)2 CloseableModalController (org.olat.core.gui.control.generic.closablewrapper.CloseableModalController)2 Translator (org.olat.core.gui.translator.Translator)2 SingleKeyTranslatorController (org.olat.core.util.i18n.ui.SingleKeyTranslatorController)2 EPArtefactHandler (org.olat.portfolio.EPArtefactHandler)2