Package org.apache.myfaces.tobago.model

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


    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


        new Node("Astronomy", "astro"));
    temp2.insert(new DefaultMutableTreeNode(new Node("Education", "edu")), 0);
    temp2.insert(new DefaultMutableTreeNode(new Node("Pictures", "pic")), 0);
    temp.insert(temp2, 2);
    tree.insert(temp, 2);
    treeState = new TreeState();
    treeState.addExpandState(tree);
    treeState.addSelection(temp2);
    treeState.setMarker(music);
    String[] values = {"none", "single", "singleLeafOnly", "multi", "multiLeafOnly"};
    selectionItems = getSelectItems(values, "demo");
View Full Code Here

    DefaultMutableTreeNode temp2 = new DefaultMutableTreeNode("Astronomy");
    temp2.insert(new DefaultMutableTreeNode("Education"), 0);
    temp2.insert(new DefaultMutableTreeNode("Pictures"), 0);
    temp.insert(temp2, 2);
    tree.insert(temp, 2);
    state = new TreeState();
    state.addExpandState(tree);
    state.addExpandState(temp);
    state.setMarker(music);
  }
View Full Code Here

    final ELContext elContext = FacesContext.getCurrentInstance().getELContext();
    final ValueExpression expression = getValueExpression(Attributes.STATE);

    if (expression != null) {
      TreeState state = (TreeState) expression.getValue(elContext);
      if (state == null) {
        state = new TreeState(new ExpandedState(2), new SelectedState());
        expression.setValue(elContext, state);
      }
      return state;
    }

    state = new TreeState(new ExpandedState(2), new SelectedState());
    return state;
  }
View Full Code Here

        new Node("Astronomy", "astro"));
    temp2.insert(new DefaultMutableTreeNode(new Node("Education", "edu")), 0);
    temp2.insert(new DefaultMutableTreeNode(new Node("Pictures", "pic")), 0);
    temp.insert(temp2, 2);
    tree.insert(temp, 2);
    treeState = new TreeState();
    treeState.addExpandState(tree);
    treeState.addSelection(temp2);
    treeState.setMarker(music);
    String[] values = {"none", "single", "singleLeafOnly", "multi", "multiLeafOnly"};
    selectionItems = getSelectItems(values, "demo");
View Full Code Here

    if (ComponentUtil.isOutputOnly(component)) {
      return;
    }

    UITree tree = (UITree) component;
    TreeState state = tree.getState();

    if (state != null) {
      if ("Tree".equals(tree.getRendererType())) {
        state.clearExpandState();
      }
      if (isSelectable(tree)) {
        state.clearSelection();
      }
      if (ComponentUtil.getBooleanAttribute(tree, ATTR_MUTABLE)) {
        state.setMarker(null);
      }
    }
    tree.setValid(true);
  }
View Full Code Here

      return;
    }

    UITreeNode node = (UITreeNode) component;
    UITree 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 (expandState.indexOf(searchString) > -1) {
      state.addExpandState((DefaultMutableTreeNode) node.getValue());
    }


    if (TreeRenderer.isSelectable(tree)) { // selection
      String selected = (String) requestParameterMap.get(treeId + UITree.SELECT_STATE);
      searchString = ";" + nodeId + ";";
      if (selected.indexOf(searchString) > -1) {
        state.addSelection((DefaultMutableTreeNode) node.getValue());
      }
    }

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

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


    // link
View Full Code Here

    String jsClientId = TreeRenderer.createJavascriptVariable(clientId);
    String jsParentClientId = TreeRenderer.createJavascriptVariable(
        parentClientId);
//  rootId = HtmlUtils.createJavascriptVariable(rootId);

    TreeState treeState = root.getState();
    if (treeState == null) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("No treeState found. clientId=" + clientId);
      }
    } else {

      DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeNode.getValue();

      ResponseWriter writer = facesContext.getResponseWriter();

      String debuging = null;

      writer.writeText("var ", null);
      writer.writeText(jsClientId, null);
      writer.writeText(" = new ", null);
      if (component.getChildCount() == 0) {
        writer.writeText("TreeNode", null);
      } else {
        writer.writeText("TreeFolder", null);
      }
      writer.writeText("('", null);
      Object name = treeNode.getAttributes().get(ATTR_NAME);
      if (LOG.isDebugEnabled()) {
        debuging += name + " : ";
      }
      if (name != null) {
        writer.writeText(StringEscapeUtils.escapeJavaScript(name.toString()), null);
      } else {
        LOG.warn("name = null");
      }
      writer.writeText("','", null);
      writer.writeText(clientId, null);
      writer.writeText("',", null);
      writer.writeText(Boolean.toString(!root.isShowIcons()), null);
      writer.writeText(",", null);
      writer.writeText(Boolean.toString(!root.isShowJunctions()), null);
      writer.writeText(",", null);
      writer.writeText(Boolean.toString(!root.isShowRootJunction()), null);
      writer.writeText(",", null);
      writer.writeText(Boolean.toString(!root.isShowRoot()), null);
      writer.writeText(",'", null);
      writer.writeText(rootId, null);
      writer.writeText("',", null);
      String selectable = ComponentUtil.getStringAttribute(root, ATTR_SELECTABLE);
      if (selectable != null
          && (!(selectable.equals("multi") || selectable.equals("multiLeafOnly")
          || selectable.equals("single") || selectable.equals("singleLeafOnly")
          || selectable.equals("sibling") || selectable.equals("siblingLeafOnly")))) {
        selectable = null;
      }
      if (selectable != null) {
        writer.writeText("'", null);
        writer.writeText(selectable, null);
        writer.writeText("'", null);
      } else {
        writer.writeText("false", null);
      }
      writer.writeText(",", null);
      writer.writeText(Boolean.toString(ComponentUtil.getBooleanAttribute(root,
          ATTR_MUTABLE)), null);
      writer.writeText(",'", null);
      writer.writeText(
          ComponentUtil.findPage(component).getFormId(facesContext), null);
      writer.writeText("',", null);
      if (component.getChildCount() == 0
          || (selectable != null && !selectable.endsWith("LeafOnly"))) {
        boolean selected = treeState.isSelected(node);
        writer.writeText(Boolean.toString(selected), null);
        if (LOG.isDebugEnabled()) {
          debuging += selected ? "S" : "-";
        }
      } else {
        writer.writeText("false", null);
        if (LOG.isDebugEnabled()) {
          debuging += "-";
        }
        if (treeState.isSelected(node)) {
          LOG.warn("Ignore selected FolderNode in LeafOnly selection tree!");
        }
      }
      writer.writeText(",", null);
      writer.writeText(Boolean.toString(treeState.isMarked(node)), null);
      if (component.getChildCount() > 0) {
        writer.writeText(",", null);
        boolean expanded = treeState.isExpanded(node);
        writer.writeText(Boolean.toString(expanded), null);
        if (LOG.isDebugEnabled()) {
          debuging += expanded ? "E" : "-";
        }
      }
View Full Code Here

    if (ComponentUtil.isOutputOnly(component)) {
      return;
    }

    UITreeOld tree = (UITreeOld) component;
    TreeState state = tree.getState();

    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);
      }
    }
    tree.setValid(true);
  }
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.