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); final Map<String, String> userTags = ePFMgr.getUsersMostUsedTags(getIdentity(), 8); int i = 1; tagCmpList = new ArrayList<FormToggle>(); final LinkedList<Entry<String, String>> sortEntrySet = new LinkedList<Entry<String, String>>(userTags.entrySet()); Collections.sort( sortEntrySet, new Comparator<Entry<String, String>>() { @Override public int compare(final Entry<String, String> arg0, final Entry<String, String> arg1) { return arg0.getValue().compareTo(arg1.getValue()); } }); final List<String> allActiveTagToggles = new ArrayList<String>(); for (final Entry<String, String> entry : sortEntrySet) { final String tag = entry.getValue(); final String tagCmpName = TAG_CMP_IDENTIFIER + i; if (tagFlc.getComponent(tagCmpName) != null) { tagFlc.remove(tagCmpName); } final FormToggle link = uifactory.addToggleButton(tagCmpName, tag, tagFlc, null, null); link.setLabel("tag.one", new String[] {tag}); 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(); } }
@Override protected void initForm( final FormItemContainer formLayout, final Controller listener, final UserRequest ureq) { setFormTitle("pane.tab.infos_config.title"); setFormContextHelp( InfoConfigForm.class.getPackage().getName(), "ced-info-config.html", "help.hover.info.config"); final String page = velocity_root + "/editShow.html"; final FormLayoutContainer showLayout = FormLayoutContainer.createCustomFormLayout( "pane.tab.infos_config.shown", getTranslator(), page); showLayout.setLabel("pane.tab.infos_config.shown", null); formLayout.add(showLayout); durationSelection = uifactory.addDropdownSingleselect( "pane.tab.infos_config.max_duration", showLayout, maxDurationValues, maxDurationValues, null); durationSelection.setLabel("pane.tab.infos_config.max", null); final String durationStr = (String) config.get(InfoCourseNodeConfiguration.CONFIG_DURATION); if (StringHelper.containsNonWhitespace(durationStr)) { durationSelection.select(durationStr, true); } else { durationSelection.select("30", true); } lengthSelection = uifactory.addDropdownSingleselect( "pane.tab.infos_config.max_shown", showLayout, maxLengthValues, maxLengthValues, null); lengthSelection.setLabel("pane.tab.infos_config.max", null); final String lengthStr = (String) config.get(InfoCourseNodeConfiguration.CONFIG_LENGTH); if (StringHelper.containsNonWhitespace(lengthStr)) { lengthSelection.select(lengthStr, true); } else { lengthSelection.select("5", true); } uifactory.addFormSubmitButton("save", formLayout); }
private void initOrUpdateTypeFlc(final int limit) { typeFlc.setLabel("filter.view", null); typeAllBtn = uifactory.addToggleButton("filter.all", null, typeFlc, null, null); typeAllBtn.toggleOff(); final List<EPArtefactHandler<?>> handlers = portfolioModule.getAllAvailableArtefactHandlers(); typeCmpList = new ArrayList<FormToggle>(); int i = 0; final List<String> allActiveTypeToggles = new ArrayList<String>(); for (final EPArtefactHandler<?> handler : handlers) { final String handlerClass = PortfolioFilterController.HANDLER_PREFIX + handler.getClass().getSimpleName() + HANDLER_TITLE_SUFFIX; FormToggle link = (FormToggle) typeFlc.getFormComponent(handlerClass); if (link == null) { final PackageTranslator handlerTrans = handler.getHandlerTranslator(getTranslator()); typeFlc.setTranslator(handlerTrans); link = uifactory.addToggleButton(handlerClass, null, typeFlc, null, null); link.setUserObject(handler.getType()); } if (selectedTypeList.contains(handler.getType())) { link.toggleOn(); allActiveTypeToggles.add(handler.getType()); } else { link.toggleOff(); } typeCmpList.add(link); i++; if (i > limit) { break; } } typeFlc.contextPut("typeCmpList", typeCmpList); typeEditBtn = uifactory.addToggleButton("filter.edit", null, typeFlc, null, null); typeEditBtn.toggleOff(); if (!allActiveTypeToggles.containsAll(selectedTypeList)) { typeEditBtn.toggleOn(); } if (selectedTypeList.isEmpty()) { typeAllBtn.toggleOn(); } }
@SuppressWarnings("unused") protected void initOrUpdateForm( final FormItemContainer formLayout, final Controller listener, final UserRequest ureq) { // filter by tag if (formLayout.getFormComponent("tagLayout") == null) { tagFlc = FormLayoutContainer.createCustomFormLayout( "tagLayout", getTranslator(), this.velocity_root + "/filter-tags.html"); formLayout.add(tagFlc); initTagFlc(); } else { updateTagFlc(); } // filter by type if (formLayout.getFormComponent("typeLayout") == null) { typeFlc = FormLayoutContainer.createCustomFormLayout( "typeLayout", getTranslator(), this.velocity_root + "/filter-types.html"); formLayout.add(typeFlc); initOrUpdateTypeFlc(DEFAULT_TYPE_AMOUNT); } else { updateTypeFlc(); } // filter by date if (formLayout.getFormComponent("dateLayout") == null) { final String page = this.velocity_root + "/filter_date.html"; dateFlc = FormLayoutContainer.createCustomFormLayout("dateLayout", getTranslator(), page); formLayout.add(dateFlc); dateFlc.setLabel("filter.by.date", null); dateStart = uifactory.addDateChooser("filter.date.start", "", dateFlc); dateStart.addActionListener(this, FormEvent.ONCHANGE); dateEnd = uifactory.addDateChooser("filter.date.end", "", dateFlc); dateEnd.addActionListener(listener, FormEvent.ONCHANGE); dateStart.clearError(); dateEnd.clearError(); } if (filterSettings.getDateFilter().size() == 2) { dateStart.setDate(filterSettings.getDateFilter().get(0)); dateEnd.setDate(filterSettings.getDateFilter().get(1)); } else { dateStart.setDate(null); dateEnd.setDate(new Date()); } // filter by fulltext final String searchText = filterSettings.getTextFilter(); if (formLayout.getFormComponent("search") == null) { searchFld = uifactory.addTextElement("search", "filter.search", 20, searchText, formLayout); searchFld.addActionListener(listener, FormEvent.ONCHANGE); } else { searchFld.setValue(searchText); } // show filter list and save as new if (formLayout.getFormComponent("spacer") == null) { uifactory.addSpacerElement("spacer", formLayout, false); } // filter list initFilterList(formLayout); // filter save if (formLayout.getFormComponent("filterSaveLayout") == null) { filterFlc = FormLayoutContainer.createHorizontalFormLayout("filterSaveLayout", getTranslator()); formLayout.add(filterFlc); filterFlc.setLabel("filter.save", null); filterName = uifactory.addTextElement( "filter.save.name", null, 30, filterSettings.getFilterName(), filterFlc); filterSave = uifactory.addFormLink( "filter.save.link", "filter.save.new", null, filterFlc, Link.BUTTON_XSMALL); filterDel = uifactory.addFormLink( "filter.del.link", "filter.del.link", null, filterFlc, Link.BUTTON_XSMALL); } else { filterName.setValue(filterSettings.getFilterName()); } final boolean isExistingFilter = filterSettings.getFilterName() != null; toggleSaveUpdateFilterButtons(isExistingFilter); }