Builds a tree item for the given category.<p>

@param category the category
@param selectedCategories the selected categories

@return the tree item widget
760133
private CmsTreeItem buildTreeItem(CmsCategoryTreeEntry category, List<String> selectedCategories) {

        m_categories.put(category.getPath(), category);
        // set the list item widget
        CmsDataValue dataValue = new CmsDataValue(
            600,
            3,
            CmsCategoryBean.SMALL_ICON_CLASSES,
            category.getTitle(),
            CmsStringUtil.isNotEmptyOrWhitespaceOnly(category.getDescription())
            ? category.getDescription()
            : category.getPath());

        // the checkbox
        CmsCheckBox checkBox = new CmsCheckBox();
        if ((selectedCategories != null) && selectedCategories.contains(category.getPath())) {
            checkBox.setChecked(true);
        }
        SelectionHandler selectionHandler = new SelectionHandler(category.getPath(), checkBox);
        checkBox.addClickHandler(selectionHandler);
        dataValue.addClickHandler(selectionHandler);
        dataValue.addButton(createSelectButton(selectionHandler));
        dataValue.setUnselectable();
        // set the category tree item and add to list
        CmsTreeItem treeItem = new CmsTreeItem(true, checkBox, dataValue);
        treeItem.setSmallView(true);
        treeItem.setId(category.getPath());
        return treeItem;
    }
625178
@Override
    public List<Category> getCategories() {
        return categories == null ? (categories = new ArrayList<Category>()) : categories;
    }
1246824
public void setCategories(List<String> categories) {

        if ((categories != null) && !categories.isEmpty()) {
            addFilterQuery(CmsSearchField.FIELD_CATEGORY + CmsSearchField.FIELD_DYNAMIC_EXACT, categories, true, true);
        }
    }
1156582
protected function attach_nodes_to_categories() {
        foreach ($this->nodes as $node) {
            $parentcat = $node->parentcat;
            if (!isset($this->categories[$parentcat])) {
                throw new \coding_exception("Category $parentcat doesn't exist");
            } else {
                $this->categories[$parentcat]->add_node($node);
            }
        }
    }
381901
private PortletCategoryBean filterCategoryFavoritesOnly(PortletCategoryBean category) {

        // Subcategories
        final Set<PortletCategoryBean> subcategories = new HashSet<>();
        category.getSubcategories()
                .forEach(
                        sub -> {
                            final PortletCategoryBean filteredBean =
                                    filterCategoryFavoritesOnly(sub);
                            if (filteredBean != null) {
                                subcategories.add(filteredBean);
                            }
                        });

        // Portlets
        final Set<PortletDefinitionBean> portlets = new HashSet<>();
        category.getPortlets()
                .forEach(
                        child -> {
                            if (child.getFavorite()) {
                                logger.debug(
                                        "Including portlet '{}' because it is a favorite:  {}",
                                        child.getFname());
                                portlets.add(child);
                            } else {
                                logger.debug(
                                        "Skipping portlet '{}' because it IS NOT a favorite:  {}",
                                        child.getFname());
                            }
                        });

        return !subcategories.isEmpty() || !portlets.isEmpty()
                ? PortletCategoryBean.create(
                        category.getId(),
                        category.getName(),
                        category.getDescription(),
                        subcategories,
                        portlets)
                : null;
    }
101333
public void uncheckCategories(List<String> categories) {

        for (String category : categories) {
            CmsTreeItem item = searchTreeItem(m_scrollList, category);
            item.getCheckBox().setChecked(false);
        }
    }
1065724
public final ImmutableList<TaxonomyTerm> categories() {
      ImmutableList<TaxonomyTerm> categories = taxonomyTerms.get(CATEGORY_TAXONOMY);
      return categories != null ? categories : ImmutableList.of();
   }
1190967
private void loadCategories(SQLiteDatabase db) throws UnknownPoiCategoryException {
        // Maximum ID (for root node)
        int maxID = 0;

        // Maps categories to their parent IDs
        Map<PoiCategory, Integer> parentMap = new HashMap<>();

        Cursor cursor = null;
        try {
            cursor = db.rawQuery(SELECT_STATEMENT, null);
            while (cursor.moveToNext()) {
                // Column values
                int categoryID = cursor.getInt(0);
                String categoryTitle = cursor.getString(1);
                int categoryParentID = cursor.getInt(2);

                PoiCategory pc = new DoubleLinkedPoiCategory(categoryTitle, null, categoryID);
                this.categoryMap.put(categoryID, pc);

                // category --> parent ID
                parentMap.put(pc, categoryParentID);

                // check for root node
                if (categoryID > maxID) {
                    maxID = categoryID;
                }
            }
        } catch (Exception e) {
            LOGGER.log(Level.SEVERE, e.getMessage(), e);
        } finally {
            try {
                if (cursor != null) {
                    cursor.close();
                }
            } catch (Exception e) {
                LOGGER.log(Level.SEVERE, e.getMessage(), e);
            }
        }

        // Set root category and remove it from parents map
        this.rootCategory = getPoiCategoryByID(maxID);
        parentMap.remove(this.rootCategory);

        // Assign parent categories
        for (PoiCategory c : parentMap.keySet()) {
            c.setParent(getPoiCategoryByID(parentMap.get(c)));
        }
    }
1008312
public Category getSelectedCategory() {
    TreeItem<Category> selectedTreeItem =
        navigationView.treeView.getSelectionModel().getSelectedItem();
    if (selectedTreeItem != null) {
      return navigationView.treeView.getSelectionModel().getSelectedItem().getValue();
    }
    return null;
  }
1195675
public boolean containsCategory(String category) {
		if (this.categories == null || this.categories.isEmpty()) {
			return false;
		}

		for (String cat : categories) {
			if (category.compareToIgnoreCase(cat) == 0) {
				return true;
			}
		}

		return false;
	}
595813
protected function putInTree(CategoryInterface $category, array &$tree)
    {
        if (null === $category->getParent()) {
            $tree[$category->getId()] = $category;
        } else {
            $this->putInTree($category->getParent(), $tree);
        }
    }
1144272
private boolean hasSelectedChildren(List<CmsCategoryTreeEntry> children, Collection<String> selectedCategories) {

        boolean result = false;
        if (children == null) {
            return false;
        }
        for (CmsCategoryTreeEntry child : children) {
            result = selectedCategories.contains(child.getSitePath());
            if (result || hasSelectedChildren(child.getChildren(), selectedCategories)) {
                return true;
            }
        }

        return result;
    }
400237
public static UICategory create(String... categories)
   {
      if (categories == null || categories.length == 0)
      {
         return new UICategoryImpl(DEFAULT, null);
      }
      else if (categories.length == 1)
      {
         return new UICategoryImpl(categories[0], null);
      }
      else
      {
         return new UICategoryImpl(categories[0], Categories.create(Arrays.copyOfRange(categories, 1,
                  categories.length)));
      }
   }
705334
public static Set<String> handleBugCategories(String categories) {
        // Parse list of bug categories
        Set<String> categorySet = new HashSet<>();
        StringTokenizer tok = new StringTokenizer(categories, ",");
        while (tok.hasMoreTokens()) {
            categorySet.add(tok.nextToken());
        }

        return categorySet;
    }
1042415
public static UICategory create(UICategory category, String... categories)
   {
      Assert.notNull(category, "Parent UICategory must not be null.");
      Assert.notNull(categories, "Sub categories must not be null.");
      List<String> args = new ArrayList<>();
      args.add(category.getName());
      args.addAll(Arrays.asList(categories));
      return create(args.toArray(new String[args.size()]));
   }
338009
public boolean supportsCategory(String category) {
		if (category == null) {
			return false;
		}

		List<String> categories = this.getCategories();
		for (String cat : categories) {
			if (cat.compareToIgnoreCase(category) == 0) {
				return true;
			}
		}

		return false;
	}
26080
public void onClearCategories(List<String> categories) {

        if (categories != null) {
            m_galleryDialog.getCategoriesTab().uncheckCategories(categories);
        }
    }