Examples of UITree


Examples of org.richfaces.component.UITree

  public void initializeResources(FacesContext context, UITreeNode treeNode)
  throws IOException {
    ComponentVariables variables = ComponentsVariableResolver.getVariables(
        this, treeNode);

    UITree tree = treeNode.getUITree();
    String resource;
    String cssClass;
    resource = UITree.DEFAULT_HIGHLIGHTED_CSS_CLASS;
    resource += " rich-tree-node-highlighted";
    cssClass = tree.getHighlightedClass();
    if (cssClass != null) {
      resource += " " + cssClass;
    }
    cssClass = treeNode.getHighlightedClass();
    if (cssClass != null) {
      resource += " " + cssClass;
    }
    variables.setVariable("highlightedClass", resource);

    resource = UITree.DEFAULT_SELECTED_CSS_CLASS;
    resource += " rich-tree-node-selected";
    cssClass = tree.getSelectedClass();
    if (cssClass != null) {
      resource += " " + cssClass;
    }
    cssClass = treeNode.getSelectedClass();
    if (cssClass != null) {
      resource += " " + cssClass;
    }
    variables.setVariable("selectedClass", resource);


    resource = ViewUtil.getResourceURL(treeNode.getIcon());     
    if (resource == null) {
      resource = ViewUtil.getResourceURL(tree.getIcon());     
    }

    if (resource != null) {
      variables.setVariable("folderIcon", resource);
    }

    resource = ViewUtil.getResourceURL(treeNode.getIconCollapsed());
    if (resource == null) {
      resource = ViewUtil.getResourceURL(tree.getIconCollapsed());
    }

    if (resource != null) {
      variables.setVariable("collapsed", resource);
    }

    resource = ViewUtil.getResourceURL(treeNode.getIconExpanded());
    if (resource == null) {
      resource = ViewUtil.getResourceURL(tree.getIconExpanded());
    }

    if (resource != null) {
      variables.setVariable("expanded", resource);
    }

    resource = ViewUtil.getResourceURL(treeNode.getIconLeaf());
    if (resource == null) {
      resource = ViewUtil.getResourceURL(tree.getIconLeaf());
    }

    if (resource != null) {
      variables.setVariable("leafIcon", resource);
    }
View Full Code Here

Examples of org.richfaces.component.UITree

    return Boolean.toString(node.getUITree().isExpanded());
  }

  protected void doDecode(FacesContext context, UIComponent component) {
    UITreeNode node = (UITreeNode) component;
    UITree tree = node.getUITree();
    TreeRowKey<?> key = (TreeRowKey<?>) tree.getRowKey();
    Map<String, String> requestMap = context.getExternalContext().getRequestParameterMap();
    String id = node.getClientId(context);
    TreeState componentState = (TreeState) tree.getComponentState();

    String nodeExpandedId = id + NODE_EXPANDED_INPUT_SUFFIX;
    Object nodeExpandedValue = requestMap.get(nodeExpandedId);
    if (nodeExpandedValue != null) {
      boolean nodeExpanded = Boolean.valueOf(nodeExpandedValue.toString()).booleanValue();
      if (tree.isExpanded() ^ nodeExpanded) {
        if (nodeExpanded) {
          new ExpandNodeCommandEvent(tree, key).queue();
        } else {
          new CollapseNodeCommandEvent(tree, key).queue();
        }

        if (Boolean.valueOf((String) requestMap.get(id + AJAX_EXPANDED_SUFFIX)).booleanValue()) {
          new AjaxExpandedEvent(node).queue();
          new AjaxExpandedEvent(tree).queue();
        } else {
          new NodeExpandedEvent(node).queue();
          new NodeExpandedEvent(tree).queue();
        }
      }
    }

    if (id.equals(tree.getAttributes()
        .get(UITree.SELECTION_INPUT_ATTRIBUTE))) {
      if (!componentState.isSelected(key)) {

        if (tree.getAttributes().get(
            UITree.SELECTED_NODE_PARAMETER_NAME) == null) {

          new NodeSelectedEvent(tree, componentState.getSelectedNode()).queue();
          new NodeSelectedEvent(node, componentState.getSelectedNode()).queue();
        } else {
          new AjaxSelectedEvent(tree, componentState.getSelectedNode()).queue();
          new AjaxSelectedEvent(node, componentState.getSelectedNode()).queue();
        }
      }

      tree.getAttributes().remove(UITree.SELECTION_INPUT_ATTRIBUTE);
    }
   
    super.doDecode(context, component);
  }
View Full Code Here

Examples of org.richfaces.component.UITree

      String path, Set ids, Set renderedAreas) throws IOException {
    super.encodeAjaxChildren(context, component, path, ids, renderedAreas);

    try {
      if (component instanceof UITree) {
        UITree tree = (UITree) component;

        String id = path + tree.getId();

        tree.captureOrigValue();
        //Object rowKey = tree.getRowKey();

        boolean encodeScripts = false;

        tree.setRowKey(context, null);

        //we should add xmlns to AJAX response
        //we'll write neutral inner element and add xmlns there
        ResponseWriter responseWriter = context.getResponseWriter();
        responseWriter.startElement("div", tree);
        writeNamespace(context, component);

        List encodedAreaIds = new ArrayList();
       
        try {
          List<RowKeyHolder> keyHoldersList = getKeyHoldersList(
            tree.getAllAjaxKeys(),
            tree.getAllAjaxNodeKeys(),
            id);

          Collections.sort(keyHoldersList, new Comparator<RowKeyHolder>() {

            public int compare(RowKeyHolder o1, RowKeyHolder o2) {
              int d1 = o1.rowKey == null ? 0 : o1.rowKey.depth();
              int d2 = o2.rowKey == null ? 0 : o2.rowKey.depth();

              return d1 < d2 ? -1 : (d2 > d1 ? 1 : 0);
            }

          });

          List<RowKeyHolder> holders = new ArrayList<RowKeyHolder>();
          for (RowKeyHolder holder : keyHoldersList) {
            boolean isSubKey = false;

            for (RowKeyHolder rowKeyHolder : holders) {
              if (rowKeyHolder.rowKey == null ||
                  rowKeyHolder.rowKey.isSubKey(holder.rowKey)) {

                isSubKey = true;
                break;
              }
            }

            if (!isSubKey) {
              holders.add(holder);
            }
          }

          Iterator<RowKeyHolder> ajaxKeysItr = holders.iterator();
          while (ajaxKeysItr.hasNext()) {
            RowKeyHolder keyHolder = ajaxKeysItr.next();
            TreeRowKey key = keyHolder.getRowKey();

            if (key != null && key.depth() == 0) {
              key = null;
            }

            tree.setRowKey(context, key);

            if (key == null || tree.isRowAvailable()) {
              String treeClientId;
              if (key == null) {
                treeClientId = tree.getClientId(context);
              } else {
                treeClientId = tree.getNodeFacet().getClientId(context);
              }

              encodeScripts = true;
             
              //should be added before children id
              renderedAreas.add(treeClientId);

              if (keyHolder.isNodeKey()) {
                writeContent(context, tree, key, false);
              } else {
                writeContent(context, tree, key, true);
                String treeChildrenId = treeClientId + NamingContainer.SEPARATOR_CHAR + "childs";
                renderedAreas.add(treeChildrenId);
              }

              //add node to set of nodes refreshed by script
              encodedAreaIds.add(treeClientId);
            } else {
              String cid = tree.getClientId(context);
              String message = MessageFormat.format(
                  "Failed to re-render tree node: {0} due to model data unavailability! " +
                  "Maybe parent node should be re-rendered instead?",
                  new Object[] { cid });

              ExternalContext externalContext = context.getExternalContext();
              externalContext.log(message);
            }
          }
          //ajaxKeys.clear();
        } catch (Exception e) {
          throw new FacesException(e);
        } finally {
          try {
            tree.setRowKey(context, null);
            tree.restoreOrigValue();
          } catch (Exception e) {
            context.getExternalContext().log(e.getMessage(), e);
          }
        }

        if (encodeScripts) {
          writeScript(context, tree, encodedAreaIds, renderedAreas);
        }

        responseWriter.endElement("div");
        tree.clearRequestKeysSet();
      }
    } finally {
      try {
        ComponentsVariableResolver.removeVariables(this, component);
      } catch (Exception e) {
View Full Code Here

Examples of org.richfaces.component.UITree

      String path, Set ids, Set renderedAreas) throws IOException {
    super.encodeAjaxChildren(context, component, path, ids, renderedAreas);

    try {
      if (component instanceof UITree) {
        UITree tree = (UITree) component;

        String id = path + tree.getId();

        tree.captureOrigValue();
        //Object rowKey = tree.getRowKey();

        boolean encodeScripts = false;

        tree.setRowKey(context, null);

        //we should add xmlns to AJAX response
        //we'll write neutral inner element and add xmlns there
        ResponseWriter responseWriter = context.getResponseWriter();
        responseWriter.startElement("div", tree);
        writeNamespace(context, component);

        List encodedAreaIds = new ArrayList();

        try {
          Set ajaxKeys = tree.getAllAjaxKeys();
          if (ajaxKeys != null) {
            List sortedKeys = new ArrayList(ajaxKeys.size());
            sortedKeys.addAll(ajaxKeys);
            Collections.sort(sortedKeys, treeRowKeyComparator);
            Iterator ajaxKeysItr = sortedKeys.iterator();
            TreeRowKey lastKey = null;
            boolean nullRoot = false;

            while (!nullRoot && ajaxKeysItr.hasNext()) {
              TreeRowKey key = (TreeRowKey) ajaxKeysItr.next();

              if (lastKey == null) {
                lastKey = key;
              } else {
                if (!lastKey.isSubKey(key)) {
                  lastKey = key;
                } else {
                  //skip nodes that's parent nodes have been rendered
                  continue;
                }
              }

              if (key == null || key.depth() == 0) {
                nullRoot = true;
                key = null;
              }

              tree.setRowKey(context, key);

              if (key == null || tree.isRowAvailable()) {
                String treeClientId;
                if (key == null) {
                  treeClientId = tree.getClientId(context);
                } else {
                  treeClientId = tree.getNodeFacet().getClientId(context);
                }

                String treeChildrenId = treeClientId + NamingContainer.SEPARATOR_CHAR + "childs";
               
                writeContent(context, tree, key);
                encodeScripts = true;
                renderedAreas.add(treeClientId);
                encodedAreaIds.add(treeClientId);

                renderedAreas.add(treeChildrenId);
                //encodedAreaIds.add(id+":childs");
              } else {
                String cid = tree.getClientId(context);
                String message = MessageFormat.format(
                    "Failed to re-render tree node: {0} due to model data unavailability! " +
                    "Maybe parent node should be re-rendered instead?",
                    new Object[] { cid });
               
                ExternalContext externalContext = context.getExternalContext();
                externalContext.log(message);
              }
            }
            //ajaxKeys.clear();
          }
        } catch (Exception e) {
          throw new FacesException(e);
        } finally {
          try {
            tree.setRowKey(context, null);
            tree.restoreOrigValue();
          } catch (Exception e) {
            context.getExternalContext().log(e.getMessage(), e);
          }
        }
        if (encodeScripts) {
          writeScript(context, tree, encodedAreaIds, renderedAreas);

          String inputId = encodeSelectionStateInput(context, tree);
          if (inputId != null) {
            renderedAreas.add(inputId);
          }
        }

        responseWriter.endElement("div");
        tree.clearRequestKeysSet();
      }
    } finally {
      try {
        ComponentsVariableResolver.removeVariables(this, component);
      } catch (Exception e) {
View Full Code Here

Examples of org.richfaces.component.UITree

    addParameterEncoder(DnDParametersEncoder.getInstance());
  }

  protected String getToggleScript(FacesContext context, UITreeNode treeNode, String to) {
    UITree tree = treeNode.getUITree();
    if ("handle".equals(to) && tree.isToggleOnClick() ||
        "mainRow".equals(to) && !tree.isToggleOnClick())
      return "";

    boolean showLines = tree.isShowConnectingLines();
    String id = treeNode.getClientId(context);

    StringBuilder script = new StringBuilder();
    script.append("Tree.Item.");
    boolean expanded = tree.isExpanded();
    if (expanded) {
      script.append("fireCollapsionEvent(this);");
    } else {
      script.append("fireExpansionEvent(this);");
    }
   
    if (UITree.SWITCH_AJAX.equals(tree.getSwitchType())) {
      UITreeNode nodeFacet = tree.getNodeFacet();
      JSFunction function = AjaxRendererUtils.buildAjaxFunction(nodeFacet,
          context);
      Map eventOptions = AjaxRendererUtils.buildEventOptions(context,
          nodeFacet);
      Map parameters = (Map) eventOptions.get("parameters");
      parameters.remove(id);

      parameters.put(id + NODE_EXPANDED_INPUT_SUFFIX, String.valueOf(!expanded));
      parameters.put(id + AJAX_EXPANDED_SUFFIX, Boolean.TRUE);
     
      function.addParameter(eventOptions);

      StringBuffer buffer = new StringBuffer();
      buffer.append(script);
      buffer.append(";");
      function.appendScript(buffer);
      buffer.append(";");
      return buffer.toString();
     
    } else if (UITree.SWITCH_SERVER.equals(tree.getSwitchType())) {
      String paramName = id + NODE_EXPANDED_INPUT_SUFFIX;
     
      StringBuffer result = new StringBuffer();
      result.append(script);
      result.append(";");
View Full Code Here

Examples of org.richfaces.component.UITree

  public void initializeLines(FacesContext context, UITreeNode treeNode)
  throws IOException {
    ComponentVariables variables = ComponentsVariableResolver.getVariables(
        this, treeNode);

    UITree tree = treeNode.getUITree();

    if (tree.isShowConnectingLines()) {
      if (Boolean.TRUE.equals(treeNode.getAttributes().get("isLastElement"))) {
        variables.setVariable("line", "dr-tree-h-ic-line-last");
      } else {
        variables.setVariable("line", "dr-tree-h-ic-line-node");
      }
      if (tree.isExpanded() && !tree.isLeaf()) {
        variables
        .setVariable("lineFirst", "dr-tree-h-ic-line-exp");
      } else {
        variables.setVariable("lineFirst",
        "dr-tree-h-ic-line-clp");
View Full Code Here

Examples of org.richfaces.component.UITree

  public void initializeResources(FacesContext context, UITreeNode treeNode)
  throws IOException {
    ComponentVariables variables = ComponentsVariableResolver.getVariables(
        this, treeNode);

    UITree tree = treeNode.getUITree();
    String resource;
    String cssClass;
    resource = UITree.DEFAULT_HIGHLIGHTED_CSS_CLASS;
    resource += " rich-tree-node-highlighted";
    cssClass = tree.getHighlightedClass();
    if (cssClass != null) {
      resource += " " + cssClass;
    }
    cssClass = treeNode.getHighlightedClass();
    if (cssClass != null) {
      resource += " " + cssClass;
    }
    variables.setVariable("highlightedClass", resource);

    resource = UITree.DEFAULT_SELECTED_CSS_CLASS;
    resource += " rich-tree-node-selected";
    cssClass = tree.getSelectedClass();
    if (cssClass != null) {
      resource += " " + cssClass;
    }
    cssClass = treeNode.getSelectedClass();
    if (cssClass != null) {
      resource += " " + cssClass;
    }
    variables.setVariable("selectedClass", resource);


    resource = ViewUtil.getResourceURL(treeNode.getIcon());     
    if (resource == null) {
      resource = ViewUtil.getResourceURL(tree.getIcon());     
    }

    if (resource != null) {
      variables.setVariable("folder", resource);
    }

    resource = ViewUtil.getResourceURL(treeNode.getIconCollapsed());
    if (resource == null) {
      resource = ViewUtil.getResourceURL(tree.getIconCollapsed());
    }

    if (resource != null) {
      variables.setVariable("collapsed", resource);
    }

    resource = ViewUtil.getResourceURL(treeNode.getIconExpanded());
    if (resource == null) {
      resource = ViewUtil.getResourceURL(tree.getIconExpanded());
    }

    if (resource != null) {
      variables.setVariable("expanded", resource);
    }

    resource = ViewUtil.getResourceURL(treeNode.getIconLeaf());
    if (resource == null) {
      resource = ViewUtil.getResourceURL(tree.getIconLeaf());
    }

    if (resource != null) {
      variables.setVariable("leaf", resource);
    }
View Full Code Here

Examples of org.richfaces.component.UITree

    return Boolean.toString(node.getUITree().isExpanded());
  }

  protected void doDecode(FacesContext context, UIComponent component) {
    UITreeNode node = (UITreeNode) component;
    UITree tree = node.getUITree();
    TreeRowKey key = (TreeRowKey) tree.getRowKey();
    Map requestMap = context.getExternalContext().getRequestParameterMap();
    String id = node.getClientId(context);
    TreeState componentState = (TreeState) tree.getComponentState();

    String nodeExpandedId = id + NODE_EXPANDED_INPUT_SUFFIX;
    Object nodeExpandedValue = requestMap.get(nodeExpandedId);
    if (nodeExpandedValue != null) {
      boolean nodeExpanded = Boolean.valueOf(nodeExpandedValue.toString()).booleanValue();
      if (tree.isExpanded() ^ nodeExpanded) {
        if (nodeExpanded) {
          new ExpandNodeCommandEvent(tree, key).queue();
        } else {
          new CollapseNodeCommandEvent(tree, key).queue();
        }

        if (Boolean.valueOf((String) requestMap.get(id + AJAX_EXPANDED_SUFFIX)).booleanValue()) {
          new AjaxExpandedEvent(node).queue();
          new AjaxExpandedEvent(tree).queue();
        } else {
          new NodeExpandedEvent(node).queue();
          new NodeExpandedEvent(tree).queue();
        }
      }
    }

    if (id.equals(tree.getAttributes()
        .get(UITree.SELECTION_INPUT_ATTRIBUTE))) {
      if (!componentState.isSelected(key)) {

        if (tree.getAttributes().get(
            UITree.SELECTED_NODE_PARAMETER_NAME) == null) {

          new NodeSelectedEvent(tree, componentState.getSelectedNode()).queue();
          new NodeSelectedEvent(node, componentState.getSelectedNode()).queue();
        } else {
          new AjaxSelectedEvent(tree, componentState.getSelectedNode()).queue();
          new AjaxSelectedEvent(node, componentState.getSelectedNode()).queue();
        }
      }

      tree.getAttributes().remove(UITree.SELECTION_INPUT_ATTRIBUTE);
    }
   
    super.doDecode(context, component);
  }
View Full Code Here

Examples of org.richfaces.component.UITree

        descriptor.setUrl(url);
    }

    //XXX what is this for?
    public void processSelection(NodeSelectedEvent event) {
        UITree tree = (UITree) event.getComponent();

        try {
            Object node = tree.getRowData();
            ResourceTreeNode selectedNode = (ResourceTreeNode) node;

            Object data = selectedNode.getData();
            if (data instanceof ResourceWithAvailability) {
                FacesContext.getCurrentInstance();
View Full Code Here

Examples of org.richfaces.component.UITree

    addParameterEncoder(DnDParametersEncoder.getInstance());
  }

  protected String getToggleScript(FacesContext context, UITreeNode treeNode, String to) {
    UITree tree = treeNode.getUITree();
    if ("handle".equals(to) && tree.isToggleOnClick() ||
        "mainRow".equals(to) && !tree.isToggleOnClick())
      return "";

    boolean showLines = tree.isShowConnectingLines();
    String id = treeNode.getClientId(context);

    StringBuilder script = new StringBuilder();
    script.append("Tree.Item.");
    boolean expanded = tree.isExpanded();
    if (expanded) {
      script.append("fireCollapsionEvent(this);");
    } else {
      script.append("fireExpansionEvent(this);");
    }
   
    if (UITree.SWITCH_AJAX.equals(tree.getSwitchType())) {
      UITreeNode nodeFacet = tree.getNodeFacet();
      JSFunction function = AjaxRendererUtils.buildAjaxFunction(nodeFacet,
          context);
      Map eventOptions = AjaxRendererUtils.buildEventOptions(context,
          nodeFacet);
      Map parameters = (Map) eventOptions.get("parameters");
      parameters.remove(id);

      parameters.put(id + NODE_EXPANDED_INPUT_SUFFIX, String.valueOf(!expanded));
      parameters.put(id + AJAX_EXPANDED_SUFFIX, Boolean.TRUE);
     
      function.addParameter(eventOptions);

      StringBuffer buffer = new StringBuffer();
      buffer.append(script);
      buffer.append(";");
      function.appendScript(buffer);
      buffer.append(";");
      return buffer.toString();
     
    } else if (UITree.SWITCH_SERVER.equals(tree.getSwitchType())) {
      String paramName = id + NODE_EXPANDED_INPUT_SUFFIX;
     
      StringBuffer result = new StringBuffer();
      result.append(script);
      result.append(";");
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.