Examples of UITreeNode


Examples of org.apache.myfaces.tobago.component.UITreeNode

  private static final Logger LOG = LoggerFactory.getLogger(TreeMenuNodeRenderer.class);

  @Override
  public void decode(FacesContext facesContext, UIComponent component) {

    UITreeNode node = (UITreeNode) component;

    super.decode(facesContext, node);

    if (ComponentUtils.isOutputOnly(node)) {
      return;
    }

    final UITreeMenu tree = ComponentUtils.findAncestor(node, UITreeMenu.class);
    final String treeId = tree.getClientId(facesContext);
    final String nodeStateId = node.nodeStateId(facesContext);
    final Map<String, String> requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
    final String id = node.getClientId(facesContext);
    final boolean folder = node.isFolder();

    // expand state
//    if (folder) { XXX this value seems to be not restored...
    boolean expanded = Boolean.parseBoolean(requestParameterMap.get(id + ComponentUtils.SUB_SEPARATOR + "expanded"));
    if (node.isExpanded() != expanded) {
      new TreeExpansionEvent(node, node.isExpanded(), expanded).queue();
    }
//    }

    // marked
    String marked = (String) requestParameterMap.get(treeId + ComponentUtils.SUB_SEPARATOR + AbstractUITree.MARKED);
    if (marked != null) {
      String searchString = treeId + NamingContainer.SEPARATOR_CHAR + nodeStateId;
      boolean markedValue = marked.equals(searchString);
      if (node.isMarked() != markedValue) {
        new TreeMarkedEvent(node, node.isMarked(), markedValue).queue();
      }
    } else {
      LOG.warn("This log message is help clarifying the occurrence of this else case.");
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UITreeNode

  @Override
  public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
    super.prepareRender(facesContext, component);

    final UITreeNode node = (UITreeNode) component;
    if (node.isMarked()) {
      node.setCurrentMarkup(Markup.MARKED.add(node.getCurrentMarkup()));
    }
    if (node.isFolder()) {
      node.setCurrentMarkup(Markup.FOLDER.add(node.getCurrentMarkup()));
      if (node.isExpanded()) {
        node.setCurrentMarkup(Markup.EXPANDED.add(node.getCurrentMarkup()));
      }
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UITreeNode

  }

  @Override
  public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {

    final UITreeNode node = (UITreeNode) component;
    final UITreeMenu tree = ComponentUtils.findAncestor(node, UITreeMenu.class);

    final boolean folder = node.isFolder();
    final String id = node.getClientId(facesContext);
    final int level = node.getLevel();
    final boolean root = level == 0;
    final boolean expanded = folder && node.isExpanded() || level == 0;
    final boolean showRoot = tree.isShowRoot();
    final boolean ie6
        = VariableResolverUtils.resolveClientProperties(facesContext).getUserAgent().equals(UserAgent.MSIE_6_0);

    // XXX todo: find a better way to determine the parentId
    final String clientId = node.getClientId(facesContext);
    final int colon = clientId.lastIndexOf(":");
    final int underscore = clientId.substring(0, colon).lastIndexOf("_");
    final String parentId = root ? null : clientId.substring(0, underscore) + clientId.substring(colon);

    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UITreeNode

  @Override
  public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {

    final UITreeIndent indent = (UITreeIndent) component;
    final UITreeNode node = ComponentUtils.findAncestor(indent, UITreeNode.class);
    final AbstractUITree tree = ComponentUtils.findAncestor(indent, AbstractUITree.class);

    final boolean folder = node.isFolder();
    final int level = node.getLevel();
    final boolean hasNextSibling = node.isHasNextSibling();
    final List<Boolean> junctions = node.getJunctions();

    final boolean showRoot = ((UITree) tree).isShowRoot();
    final boolean showJunctions = indent.isShowJunctions();
    final boolean showRootJunction = ((UITree) tree).isShowRootJunction();
    final boolean expanded = folder && node.isExpanded() || !showRoot && level == 0;

    TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);
    HtmlRendererUtils.writeDataAttributes(facesContext, writer, indent);

    encodeIndent(facesContext, writer, node, showJunctions, !showRoot || !showRootJunction && showJunctions, junctions);
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UITreeNode

      = ResourceUtils.createString("image", "treeNode", "icon", "leaf", ResourceUtils.GIF);

  @Override
  public void decode(FacesContext facesContext, UIComponent component) {

    UITreeNode node = (UITreeNode) component;

    super.decode(facesContext, node);

    if (ComponentUtils.isOutputOnly(node)) {
      return;
    }

    final AbstractUITree tree = ComponentUtils.findAncestor(node, AbstractUITree.class);
    final String treeId = tree.getClientId(facesContext);
    final String nodeStateId = node.nodeStateId(facesContext);
    final Map<String, String> requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
    final String id = node.getClientId(facesContext);
    final boolean folder = node.isFolder();

    // expand state
//    if (folder) { // XXX the state of folder seems to be not restored!
      boolean expanded = Boolean.parseBoolean(requestParameterMap.get(id + ComponentUtils.SUB_SEPARATOR + "expanded"));
      if (node.isExpanded() != expanded) {
        new TreeExpansionEvent(node, node.isExpanded(), expanded).queue();
      }
//    }

    // select
    String searchString;
    if (tree.getSelectableAsEnum() != TreeSelectable.OFF) { // selection
      String selected = (String) requestParameterMap.get(treeId + AbstractUITree.SELECT_STATE);
      searchString = ";" + nodeStateId + ";";
      if (StringUtils.contains(selected, searchString)) {
        // TODO: add selection to Component
        //state.addSelection((DefaultMutableTreeNode) node.getValue());
      }
    }

    // marked
    String marked = (String) requestParameterMap.get(treeId + ComponentUtils.SUB_SEPARATOR + AbstractUITree.MARKED);
    if (marked != null) {
      searchString = treeId + NamingContainer.SEPARATOR_CHAR + nodeStateId;
      boolean markedValue = marked.equals(searchString);
      if (node.isMarked() != markedValue) {
        new TreeMarkedEvent(node, node.isMarked(), markedValue).queue();
      }
    } else {
      LOG.warn("This log message is help clarifying the occurrence of this else case.");
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UITreeNode

  @Override
  public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
    super.prepareRender(facesContext, component);

    final UITreeNode node = (UITreeNode) component;
    if (node.isMarked()) {
      node.setCurrentMarkup(Markup.MARKED.add(node.getCurrentMarkup()));
    }
    if (node.isFolder()) {
      node.setCurrentMarkup(Markup.FOLDER.add(node.getCurrentMarkup()));
      if (node.isExpanded()) {
        node.setCurrentMarkup(Markup.EXPANDED.add(node.getCurrentMarkup()));
      }
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UITreeNode

  }

  @Override
  public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {

    final UITreeNode node = (UITreeNode) component;
    final AbstractUITree tree = ComponentUtils.findAncestor(node, AbstractUITree.class);

    final boolean folder = node.isFolder();
    final String id = node.getClientId(facesContext);
    final int level = node.getLevel();
    final boolean root = level == 0;
    final boolean showRoot = ((UITree) tree).isShowRoot();
    // if the root is hidden, the root node must be expanded (otherwise you will see nothing)
    final boolean expanded = folder && node.isExpanded() || !showRoot && root;

    // XXX todo: find a better way to determine the parentId
    final String clientId = node.getClientId(facesContext);
    final int colon2 = clientId.lastIndexOf(":");
    final int colon1 = clientId.substring(0, colon2 - 1).lastIndexOf(":");
    final String structure = clientId.substring(colon1 + 1, colon2);
    String parentStructure = getParentStructure(structure);
    final String parentId = root ? null : clientId.substring(0, colon1 + 1) + parentStructure + clientId.substring(colon2);

    final TobagoResponseWriter writer = HtmlRendererUtils.getTobagoResponseWriter(facesContext);

    if (expanded) {
      tree.getExpandedCache().add(structure);
    }

    if (showRoot || !root) {
      writer.startElement(HtmlElements.DIV, null);

      // div id
      writer.writeIdAttribute(id);
      if (!folder) {
        HtmlRendererUtils.renderDojoDndItem(node, writer, true);
      }
      writer.writeClassAttribute(Classes.create(node));
      writer.writeAttribute(DataAttributes.TREEPARENT, parentId, false);
      HtmlRendererUtils.writeDataAttributes(facesContext, writer, node);

      if (!root) {
        while (parentStructure != null) {
          if (!tree.getExpandedCache().contains(parentStructure)) {
            Style style = new Style();
            style.setDisplay(Display.NONE);
            writer.writeStyleAttribute(style);
            break;
          }
          parentStructure = getParentStructure(parentStructure);
        }
      }

      // div style (width)
      Style style = new Style(facesContext, tree);
      String widthString;
      if (style.getWidth() != null) {
        widthString = "width: " + Integer.toString(style.getWidth().getPixel() - 22); // fixme: 4 + 18 for scrollbar
      } else {
        widthString = "100%";
      }
      writer.writeStyleAttribute(widthString);

      if (folder) {
        encodeExpandedHidden(writer, node, id, expanded);
      }

      for (UIComponent child : (List<UIComponent>) node.getChildren()) {
        // encode all content but not the nodes and data.
        if (!(child instanceof UITreeNode) && !(child instanceof UITreeData)) {
          RenderUtils.encode(facesContext, child);
        }
      }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UITreeNode

  private static final Logger LOG = LoggerFactory.getLogger(TreeMenuNodeRenderer.class);

  @Override
  public void decode(FacesContext facesContext, UIComponent component) {

    UITreeNode node = (UITreeNode) component;

    super.decode(facesContext, node);

    if (ComponentUtils.isOutputOnly(node)) {
      return;
    }

    final UITreeMenu tree = ComponentUtils.findAncestor(node, UITreeMenu.class);
    final String treeId = tree.getClientId(facesContext);
    final String nodeStateId = node.nodeStateId(facesContext);
    final Map<String, String> requestParameterMap = facesContext.getExternalContext().getRequestParameterMap();
    final String id = node.getClientId(facesContext);
    final boolean folder = node.isFolder();

    // expand state
//    if (folder) { XXX this value seems to be not restored...
    boolean expanded = Boolean.parseBoolean(requestParameterMap.get(id + ComponentUtils.SUB_SEPARATOR + "expanded"));
    if (node.isExpanded() != expanded) {
      new TreeExpansionEvent(node, node.isExpanded(), expanded).queue();
    }
//    }

    // marked
    String marked = (String) requestParameterMap.get(treeId + ComponentUtils.SUB_SEPARATOR + AbstractUITree.MARKED);
    if (marked != null) {
      String searchString = treeId + NamingContainer.SEPARATOR_CHAR + nodeStateId;
      boolean markedValue = marked.equals(searchString);
      if (node.isMarked() != markedValue) {
        new TreeMarkedEvent(node, node.isMarked(), markedValue).queue();
      }
    } else {
      LOG.warn("This log message is help clarifying the occurrence of this else case.");
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UITreeNode

  @Override
  public void prepareRender(FacesContext facesContext, UIComponent component) throws IOException {
    super.prepareRender(facesContext, component);

    final UITreeNode node = (UITreeNode) component;
    if (node.isMarked()) {
      node.setCurrentMarkup(Markup.MARKED.add(node.getCurrentMarkup()));
    }
    if (node.isFolder()) {
      node.setCurrentMarkup(Markup.FOLDER.add(node.getCurrentMarkup()));
      if (node.isExpanded()) {
        node.setCurrentMarkup(Markup.EXPANDED.add(node.getCurrentMarkup()));
      }
    }
  }
View Full Code Here

Examples of org.apache.myfaces.tobago.component.UITreeNode

  }

  @Override
  public void encodeBegin(FacesContext facesContext, UIComponent component) throws IOException {

    final UITreeNode node = (UITreeNode) component;
    final UITreeMenu tree = ComponentUtils.findAncestor(node, UITreeMenu.class);

    final boolean folder = node.isFolder();
    final String id = node.getClientId(facesContext);
    final int level = node.getLevel();
    final boolean root = level == 0;
    final boolean expanded = folder && node.isExpanded() || level == 0;
    final boolean showRoot = tree.isShowRoot();
    final boolean ie6
        = VariableResolverUtils.resolveClientProperties(facesContext).getUserAgent().equals(UserAgent.MSIE_6_0);

    // XXX todo: find a better way to determine the parentId
    final String clientId = node.getClientId(facesContext);
    final int colon2 = clientId.lastIndexOf(":");
    final int colon1 = clientId.substring(0, colon2 - 1).lastIndexOf(":");
    final String structure = clientId.substring(colon1 + 1, colon2);
    String parentStructure = getParentStructure(structure);
    final String parentId = root ? null : clientId.substring(0, colon1 + 1) + parentStructure + clientId.substring(colon2);
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.