Examples of TreeState


Examples of org.apache.myfaces.tobago.model.TreeState

      LOG.error("No tree found!");
      return;
    }

    UITreeOld tree = (UITreeOld) component;
    TreeState treeState = tree.getState();
    DefaultMutableTreeNode marker = treeState.getMarker();
    String command = actionEvent.getComponent().getId();

    if (LOG.isDebugEnabled()) {
      LOG.debug("marker      " + marker);
      LOG.debug("lastMarker  " + treeState.getLastMarker());
      LOG.debug("root        " + tree.getValue());
      LOG.debug("command     " + command);
      LOG.debug("lastCommand " + treeState.getLastCommand());
    }
    if (marker != null) {
      boolean isRoot = tree.getValue().equals(marker);
      if (UITreeOld.COMMAND_NEW.equals(command)) {
        treeState.commandNew(create(facesContext));
      } else if (UITreeOld.COMMAND_DELETE.equals(command)) {
        if (!isRoot) {
          marker.removeFromParent();
        }
        treeState.setLastMarker(null);
        treeState.setLastCommand(null);
      } else if (UITreeOld.COMMAND_CUT.equals(command)) {
        if (!isRoot) {
          treeState.setLastMarker(marker);
          treeState.setLastCommand(command);
        }
      } else if (UITreeOld.COMMAND_COPY.equals(command)) {
        treeState.setLastMarker(marker);
        treeState.setLastCommand(command);
      } else if (UITreeOld.COMMAND_PASTE.equals(command)) {
        if (treeState.getLastMarker() != null) {
          if (UITreeOld.COMMAND_CUT.equals(treeState.getLastCommand())) {
            marker.insert(treeState.getLastMarker(), 0);
          } else if (UITreeOld.COMMAND_COPY.equals(treeState.getLastCommand())) {
            marker.insert(copy(treeState.getLastMarker()), 0);
          }
          treeState.setLastMarker(null);
          treeState.setLastCommand(null);
        }
      } else if (UITreeOld.COMMAND_MOVE_UP.equals(command)) {
        if (!isRoot) {
          MutableTreeNode node = marker;
          MutableTreeNode parent = (MutableTreeNode) node.getParent();
          int index = parent.getIndex(node);
          index = Math.max(index - 1, 0);
          parent.insert(node, index);
        }
        treeState.setLastMarker(null);
        treeState.setLastCommand(null);
      } else if (UITreeOld.COMMAND_MOVE_DOWN.equals(command)) {
        if (!isRoot) {
          MutableTreeNode node = marker;
          MutableTreeNode parent = (MutableTreeNode) node.getParent();
          int index = parent.getIndex(node);
          index = Math.min(index + 1, parent.getChildCount() - 1);
          parent.insert(node, index);
        }
        treeState.setLastMarker(null);
        treeState.setLastCommand(null);
      }
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.model.TreeState

      return treeState;
    }
    ValueBinding valueBinding = getValueBinding(TobagoConstants.ATTR_STATE);
    if (valueBinding != null) {
      FacesContext facesContext = getFacesContext();
      TreeState state = (TreeState) valueBinding.getValue(facesContext);
      if (state == null) {
        state = new TreeState();
        valueBinding.setValue(facesContext, state);
      }
      return state;
    } else {
      treeState = new TreeState();
      return treeState;
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.model.TreeState

      return treeState;
    }
    ValueBinding valueBinding = getValueBinding(TobagoConstants.ATTR_STATE);
    if (valueBinding != null) {
      FacesContext facesContext = getFacesContext();
      TreeState state = (TreeState) valueBinding.getValue(facesContext);
      if (state == null) {
        state = new TreeState();
        valueBinding.setValue(facesContext, state);
      }
      return state;
    } else {
      treeState = new TreeState();
      return treeState;
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.model.TreeState

    if (state != null) {
      return state;
    } else {
      if (FacesUtils.hasValueBindingOrValueExpression(this, Attributes.STATE)) {
        final FacesContext facesContext = FacesContext.getCurrentInstance();
        TreeState state = (TreeState)
            FacesUtils.getValueFromValueBindingOrValueExpression(facesContext, this, Attributes.STATE);
        if (state == null) {
          state = new TreeState(new ExpandedState(2), new MarkedState());
          FacesUtils.setValueOfBindingOrExpression(facesContext, state, this, Attributes.STATE);
        }
        return state;
      } else {
        state = new TreeState(new ExpandedState(2), new MarkedState());
        return state;
      }
    }
  }
View Full Code Here

Examples of org.richfaces.component.state.TreeState

    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);
    }
View Full Code Here

Examples of org.richfaces.component.state.TreeState

  public void resetDataModel() {
    this.allowCachedModel = false;
   
    super.resetDataModel();

    TreeState state = (TreeState) getComponentState();
    // re-set stopInCollapsed to handle AJAX switch type change
    state.setStopInCollapsed(isStopInCollapsed());
  }
View Full Code Here

Examples of org.richfaces.component.state.TreeState

    try {
      super.processDecodes(faces, null);

      if (null != getAttributes().get(SELECTION_INPUT_ATTRIBUTE)) {
        TreeState state = (TreeState) getComponentState();

        if (!state.isSelected(null)) {
          new NodeSelectedEvent(this, state.getSelectedNode()).queue();
        }
      }

    } finally {
      getAttributes().remove(SELECTION_INPUT_ATTRIBUTE);
View Full Code Here

Examples of org.richfaces.component.state.TreeState

   * Returns whether current node is expanded
   *
   * @return <code>true</code> if node is expanded else <code>false</code>
   */
  public boolean isExpanded() {
    TreeState treeState = (TreeState) getComponentState();
    return treeState.isExpanded((TreeRowKey) this.getRowKey());
  }
View Full Code Here

Examples of org.richfaces.component.state.TreeState

   * Returns whether current node is selected
   *
   * @return <code>true</code> if node is selected else <code>false</code>
   */
  public boolean isSelected() {
    TreeState treeState = (TreeState) getComponentState();
    return treeState.isSelected((TreeRowKey) this.getRowKey());
  }
View Full Code Here

Examples of org.richfaces.component.state.TreeState

  /**
   * Sets current node as selected
   */
  public void setSelected() {
    TreeState treeState = (TreeState) getComponentState();
    treeState.setSelected((TreeRowKey) this.getRowKey());
  }
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.