예제 #1
0
  protected void encodeIcon(FacesContext context, UIComponent component) throws IOException {
    TreeNodeState nodeState = getNodeState(context);

    AbstractTreeNode treeNode = (AbstractTreeNode) component;

    AbstractTree tree = treeNode.findTreeComponent();

    if (nodeState.isLeaf()) {
      String iconLeaf = (String) getFirstNonEmptyAttribute("iconLeaf", treeNode, tree);
      encodeIconForNodeState(context, tree, treeNode, nodeState, iconLeaf);
    } else {
      String iconExpanded = (String) getFirstNonEmptyAttribute("iconExpanded", treeNode, tree);
      String iconCollapsed = (String) getFirstNonEmptyAttribute("iconCollapsed", treeNode, tree);

      if (Strings.isNullOrEmpty(iconCollapsed) && Strings.isNullOrEmpty(iconExpanded)) {
        encodeIconForNodeState(context, tree, treeNode, nodeState, null);
      } else {
        SwitchType toggleType =
            TreeRendererBase.getToggleTypeOrDefault(treeNode.findTreeComponent());

        if (toggleType == SwitchType.client || nodeState == TreeNodeState.collapsed) {
          encodeIconForNodeState(context, tree, treeNode, TreeNodeState.collapsed, iconCollapsed);
        }

        if (toggleType == SwitchType.client
            || nodeState == TreeNodeState.expanded
            || nodeState == TreeNodeState.expandedNoChildren) {
          encodeIconForNodeState(context, tree, treeNode, TreeNodeState.expanded, iconExpanded);
        }
      }
    }
  }
예제 #2
0
  protected UIComponent getHandleLoadingFacetIfApplicable(UIComponent component) {
    AbstractTreeNode treeNode = (AbstractTreeNode) component;

    AbstractTree tree = treeNode.findTreeComponent();

    if (TreeRendererBase.getToggleTypeOrDefault(tree) != SwitchType.ajax) {
      return null;
    }

    UIComponent facet = treeNode.getFacet(HANDLE_LOADING_FACET_NAME);
    if (facet == null) {
      facet = tree.getFacet(HANDLE_LOADING_FACET_NAME);
    }

    if (facet != null && facet.isRendered()) {
      return facet;
    }

    return null;
  }