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();
}
Aggregations