Package org.apache.myfaces.tobago.model

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


    temp2.add(new DefaultMutableTreeNode(new Node("1.3.3.13 Personal")));
    temp.add(temp2);

    // state

    state = new TreeState();
    state.addExpandState(tree);
    state.addExpandState(temp);
    state.addSelection(temp2);
    state.setMarker(music);
View Full Code Here

    if (ComponentUtil.isOutputOnly(component)) {
      return;
    }
    UITreeOld tree = (UITreeOld) component;
    String treeId = tree.getClientId(facesContext);
    TreeState state = tree.getState();
    final Map requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();

    if (state != null) {
      if ("TreeOld".equals(tree.getRendererType())) {
        state.clearExpandState();
      }
      if (isSelectable(tree)) {
        state.clearSelection();
      }
      if (ComponentUtil.getBooleanAttribute(tree, TobagoConstants.ATTR_MUTABLE)) {
        state.setMarker(null);
      }
      // scroll position
      String value = (String) requestParameterMap.get(treeId + UITreeOld.SCROLL_POSITION);
      if (value != null) {
        Integer[] scrollPosition = TreeState.parseScrollPosition(value);
        if (scrollPosition != null) {
          state.setScrollPosition(scrollPosition);
        }
      }
    }
    tree.setValid(true);
  }
View Full Code Here

    UITreeOld tree = (UITreeOld) component;

    String clientId = tree.getClientId(facesContext);
    UITreeOldNode root = tree.getRoot();
    TreeState state = tree.getState();

    TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
    writer.startElement(HtmlConstants.DIV, tree);
    writer.writeNameAttribute(clientId + UITreeOld.TREE_DIV);
    writer.writeIdAttribute(clientId + UITreeOld.TREE_DIV);
    writer.writeClassAttribute();
    writer.writeStyleAttribute();

    writer.startElement(HtmlConstants.INPUT, tree);
    writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
    writer.writeNameAttribute(clientId);
    writer.writeIdAttribute(clientId);
    writer.writeAttribute(HtmlAttributes.VALUE, ";", false);
    writer.endElement(HtmlConstants.INPUT);

    writer.startElement(HtmlConstants.INPUT, tree);
    writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
    writer.writeNameAttribute(clientId + UITreeOld.MARKER);
    writer.writeIdAttribute(clientId + UITreeOld.MARKER);
    writer.writeAttribute(HtmlAttributes.VALUE, "", false);
    writer.endElement(HtmlConstants.INPUT);

    if (isSelectable(tree)) {
      writer.startElement(HtmlConstants.INPUT, tree);
      writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
      writer.writeNameAttribute(clientId + UITreeOld.SELECT_STATE);
      writer.writeIdAttribute(clientId + UITreeOld.SELECT_STATE);
      writer.writeAttribute(HtmlAttributes.VALUE, ";", false);
      writer.endElement(HtmlConstants.INPUT);
    }

    writer.startElement(HtmlConstants.INPUT, tree);
    writer.writeAttribute(HtmlAttributes.TYPE, "hidden", false);
    writer.writeNameAttribute(clientId + UITreeOld.SCROLL_POSITION);
    writer.writeIdAttribute(clientId + UITreeOld.SCROLL_POSITION);
    Integer[] scrollPosition = state.getScrollPosition();
    if (scrollPosition != null) {
      String scroll = scrollPosition[0] + ";" + scrollPosition[1];
      writer.writeAttribute(HtmlAttributes.VALUE, scroll, false);
    } else {
      writer.writeAttribute(HtmlAttributes.VALUE, "", false);
View Full Code Here

    reference.add(new DefaultMutableTreeNode(new Node("reference_tool", "reference/tool")));
    reference.add(new DefaultMutableTreeNode(new Node("reference_partial", "reference/partial")));
    reference.add(new DefaultMutableTreeNode(new Node("reference_upload", "reference/upload")));
    tree.add(reference);

    state = new TreeState();
    state.expand(tree, 1);
    state.expand(overview, 1);
    state.expand(bestPractice, 1);
    state.setMarker(overview);
  }
View Full Code Here

      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

      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

      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

    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

      return;
    }

    UITreeOldNode node = (UITreeOldNode) component;
    UITreeOld tree = node.findTreeRoot();
    TreeState state = tree.getState();
    String treeId = tree.getClientId(facesContext);
    String nodeId = node.getId();
    final Map requestParameterMap
        = facesContext.getExternalContext().getRequestParameterMap();

    // expand state
    String expandState = (String) requestParameterMap.get(treeId);
    String searchString = ";" + nodeId + ";";
    if (StringUtils.contains(expandState, searchString)) {
      state.addExpandState((DefaultMutableTreeNode) node.getValue());
    }


    if (TreeOldRenderer.isSelectable(tree)) { // selection
      String selected = (String) requestParameterMap.get(treeId + UITreeOld.SELECT_STATE);
      searchString = ";" + nodeId + ";";
      if (StringUtils.contains(selected, searchString)) {
        state.addSelection((DefaultMutableTreeNode) node.getValue());
      }
    }

    // marker
    String marked = (String) requestParameterMap.get(treeId + UITreeOld.MARKER);
    if (marked != null) {
      searchString = treeId + NamingContainer.SEPARATOR_CHAR + nodeId;

      if (marked.equals(searchString)) {
        state.setMarker((DefaultMutableTreeNode) node.getValue());
      }
    }


    // link
View Full Code Here

TOP

Related Classes of org.apache.myfaces.tobago.model.TreeState

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.