Ejemplo n.º 1
0
 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();
   }
 }
Ejemplo n.º 2
0
 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();
   }
 }