Package org.richfaces.component

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


    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

  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

  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

    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

    public void dropListener(DropEvent dropEvent) {

  // resolve drag destination attributes
  UITreeNode destNode = (dropEvent.getSource() instanceof UITreeNode) ? (UITreeNode) dropEvent.getSource() : null;
  UITree destTree = destNode != null ? destNode.getUITree() : null;
  TreeRowKey dropNodeKey = (dropEvent.getDropValue() instanceof TreeRowKey) ? (TreeRowKey) dropEvent.getDropValue() : null;
  TreeNode droppedInNode = dropNodeKey != null ? destTree.getTreeNode(dropNodeKey) : null;

  // resolve drag source attributes
  UITreeNode srcNode = (dropEvent.getDraggableSource() instanceof UITreeNode) ? (UITreeNode) dropEvent.getDraggableSource() : null;
  UITree srcTree = srcNode != null ? srcNode.getUITree() : null;
  TreeRowKey dragNodeKey = (dropEvent.getDragValue() instanceof TreeRowKey) ? (TreeRowKey) dropEvent.getDragValue() : null;
  TreeNode draggedNode = dragNodeKey != null ? srcTree.getTreeNode(dragNodeKey) : null;
  if (dropEvent.getDraggableSource() instanceof UIDragSupport && srcTree == null && draggedNode == null && dropEvent.getDragValue() instanceof TreeNode) {     
      srcTree = destTree;
      draggedNode = (TreeNode) dropEvent.getDragValue();
      dragNodeKey = srcTree.getTreeNodeRowKey(draggedNode) instanceof TreeRowKey ? (TreeRowKey) srcTree.getTreeNodeRowKey(draggedNode) : null;
  }

  // Note: check if we dropped node on to itself or to item instead of
  // folder here
  if (droppedInNode != null && (droppedInNode.equals(draggedNode) || droppedInNode.getParent().getParent() != null || draggedNode.getParent().getParent() == null)) {
      return;
  }

  FacesContext context = FacesContext.getCurrentInstance();

  if (dropNodeKey != null) {
      // add destination node for rerender
      destTree.addRequestKey(dropNodeKey);

      Object state = null;
      if (dragNodeKey != null) { // Drag from this or other tree
    TreeNode parentNode = draggedNode.getParent();
    // 1. remove node from tree
    state = srcTree.removeNode(dragNodeKey);
    // 2. add parent for rerender
    Object rowKey = srcTree.getTreeNodeRowKey(parentNode);
    srcTree.addRequestKey(rowKey);
    if (dropEvent.getDraggableSource() instanceof UIDragSupport) {
        selectedNodeChildren.remove(draggedNode);
        // if node was gragged in it's parent place dragged node to
        // the end of selected nodes in grid
        if (droppedInNode.equals(parentNode)) {
View Full Code Here

          + "\"" + "- \"" + ((MyTreeNode) selectedNode).getOrderNum() + "\"");
    }
  }

  public void onExpand(NodeExpandedEvent event) {
    UITree tree = getTree(event);
    System.out.println("Node "
        + (tree.isExpanded() ? "expanded" : "collapsed") + " "
        + tree.getRowKey());
  }
View Full Code Here

   
    return rootNode;
  }

  public void processSelection(NodeSelectedEvent event) {
    UITree tree = (UITree) event.getComponent();
    nodeTitle = (String) tree.getRowData();
  }
View Full Code Here

    // unfortunately can't tell whether this is an open or close event
    // so we have to re-do the childMap in all cases
    public void changeExpandListener(org.richfaces.event.NodeExpandedEvent event)
    {
        UIComponent comp = event.getComponent();
        UITree tree = (UITree)comp;
        JONTreeNode jonTreeNode = (JONTreeNode)(tree.getTreeNode().getData());
        jonTreeNode.reInitializeChildrenMap();
    }
View Full Code Here

  public void processDrop(DropEvent dropEvent) {
//    log.info("StorageBackingBean processDrop()");
      // resolve drag source attributes
        UITreeNode srcNode = (dropEvent.getDraggableSource() instanceof UITreeNode) ? (UITreeNode) dropEvent.getDraggableSource() : null;
        UITree srcTree = srcNode != null ? srcNode.getUITree() : null;
        TreeRowKey dragNodeKey = (dropEvent.getDragValue() instanceof TreeRowKey) ? (TreeRowKey) dropEvent.getDragValue() : null;
        TreeNode draggedNode = dragNodeKey != null ? srcTree.getTreeNode(dragNodeKey) : null;
       
        log.info("dropped key: " + dragNodeKey);
      
        //add to list of selected properties
        if(draggedNode!=null) {
View Full Code Here

TOP

Related Classes of org.richfaces.component.UITree

Copyright © 2018 www.massapicom. 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.