Package elemental.html

Examples of elemental.html.SpanElement


    addClassesToElement(elem, classNames);
    return elem;
  }

  public static SpanElement createSpanElement(String... classNames) {
    SpanElement elem = getDocument().createSpanElement();
    addClassesToElement(elem, classNames);
    return elem;
  }
View Full Code Here


    ParagraphElement myParagraph = createParagraphElement();
    int index = 0;
    REGEXP_MARKUP.setLastIndex(0);

    SpanElement current = createSpanElement();
    for (MatchResult match = REGEXP_MARKUP.exec(text); match != null;
        match = REGEXP_MARKUP.exec(text)) {
      current.setTextContent(text.substring(index, match.getIndex()));
      myParagraph.appendChild(current);
      current = createSpanElement();

      /*
       * If our match is a \n we need to create a <br/> element to force a line break, otherwise we
       * matched an http/www link so let's make an anchor tag out of it.
       */
      if (match.getGroup(0).equals("\n")) {
        myParagraph.appendChild(createBRElement());
      } else {
        AnchorElement anchor = createAnchorElement(linkCssClass);
        anchor.setHref(match.getGroup(0));
        anchor.setTarget("_blank");
        anchor.setTextContent(match.getGroup(0));
        myParagraph.appendChild(anchor);
      }

      index = match.getIndex() + match.getGroup(0).length();
    }
    current.setTextContent(text.substring(index));
    myParagraph.appendChild(current);
    parent.appendChild(myParagraph);
  }
View Full Code Here

    // Attach the Tree node body.
    DivElement treeNodeBody = Elements.createDivElement(css.treeNodeBody());
    treeNodeBody.setAttribute("draggable", "true");
    DivElement expandControl = Elements.createDivElement();
    SpanElement nodeContents = nodeRenderer.renderNodeContents(data);
    nodeContents.addClassName(css.treeNodeLabel());

    treeNodeBody.appendChild(expandControl);
    treeNodeBody.appendChild(nodeContents);

    treeNode.appendChild(treeNodeBody);
View Full Code Here

      DivElement swatchElement = Elements.createDivElement(css.swatch());
      swatchElement.setAttribute("style", "background-color: " + color);
      rowElement.appendChild(swatchElement);

      SpanElement nameElement = Elements.createSpanElement(css.name());
      nameElement.setTextContent(name);
      nameElement.setTitle(displayEmail);
      rowElement.appendChild(nameElement);

      getElement().appendChild(rowElement);
      rows.put(userId, rowElement);
    }
View Full Code Here

   *        label will not be an anchor.
   */
  public static SpanElement renderNodeContents(
      Css css, String name, boolean isFile, EventListener mouseDownListener, boolean renderIcon) {

    SpanElement root = Elements.createSpanElement(css.root());
    if (renderIcon) {
      DivElement icon = Elements.createDivElement(css.icon());
      icon.addClassName(isFile ? css.file() : css.folder());
      root.appendChild(icon);
    }

    final Element label;
    if (mouseDownListener != null) {
      label = Elements.createAnchorElement(css.label());
      ((AnchorElement) label).setHref("javascript:;");
      label.addEventListener(Event.MOUSEDOWN, mouseDownListener, false);
    } else {
      label = Elements.createSpanElement(css.label());
    }

    label.setTextContent(name);

    root.appendChild(label);

    return root;
  }
View Full Code Here

        .setTooltipRenderer(new TooltipRenderer() {
          @Override
          public elemental.html.Element renderDom() {
            DivElement container = Elements.createDivElement();

            SpanElement text = Elements.createSpanElement();
            text.setTextContent(
                "The run target has been set to your newly created app.yaml file. ");
            container.appendChild(text);

            // TODO: We'd like to offer an option to undo the
            // automatic setting of the run target, but I don't have time
            // to write a coach tips class right now and tool tips can't be
            // clicked.
            return container;
          }
        }).build();

    Tooltip targetResetTooltip = new Tooltip.Builder(
        context.getResources(), target, positioner).setShouldListenToHover(false)
        .setTooltipRenderer(new TooltipRenderer() {
          @Override
          public elemental.html.Element renderDom() {
            DivElement container = Elements.createDivElement();

            SpanElement text = Elements.createSpanElement();
            text.setTextContent(
                "You deleted your run target, the run button has been reset to preview "
                + "the active file.");
            container.appendChild(text);

            // TODO: We'd like to offer undo, but I don't have time
View Full Code Here

  /**
   * Renders the chunk by creating a span with all of the individual line
   * renderer's styles.
   */
  private void renderChunk(String lineText, int lineIndex, int chunkLength, Element targetElement) {
    SpanElement element = Elements.createSpanElement();
    // TODO: file a Chrome bug, place link here
    element.getStyle().setDisplay(CSSStyleDeclaration.Display.INLINE_BLOCK);
    setTextContentSafely(element, lineText.substring(lineIndex, lineIndex + chunkLength));
    applyStyles(element);
    targetElement.appendChild(element);
  }
View Full Code Here

                SearchPlace.PLACE.createNavigationEvent(query, page - 1));
          }
        });
      }
      if (page > 7) {
        SpanElement elipsis = Elements.createSpanElement(css.thispage());
        elipsis.setTextContent("...");
        getView().pager.appendChild(elipsis);
      }
      // page numbers are one-based (i.e. human-oriented)
      for (int i = page > 6 ? page - 6 : 1; i < pageCount + 1 && i < page + 6; i++) {
        SpanElement counter =
            Elements.createSpanElement(i == page ? css.thispage() : css.otherpage());
        counter.setTextContent(Integer.toString(i));
        getView().pager.appendChild(counter);
        final int pageNumber = i;
        counter.setOnClick(new EventListener() {
          @Override
          public void handleEvent(Event evt) {
            currentPlace.fireChildPlaceNavigation(
                SearchPlace.PLACE.createNavigationEvent(query, pageNumber));
          }
        });
        if (page + 7 < pageCount + 1) {
          SpanElement elipsis = Elements.createSpanElement(css.thispage());
          elipsis.setTextContent("...");
          getView().pager.appendChild(elipsis);
        }
      }
      if (page < pageCount) {
        DivElement next = Elements.createDivElement(css.next());
View Full Code Here

      actionsContainer.getStyle().setDisplay(
          statusActions.size() > 0 ? Display.BLOCK : Display.NONE);
      actionsContainer.setInnerHTML("");
      for (int i = 0, n = statusActions.size(); i < n; i++) {
        final StatusAction statusAction = statusActions.get(i);
        SpanElement action = Elements.createSpanElement(css.action());
        statusAction.renderAction(action);       
        action.setOnClick(new EventListener() {
          @Override
          public void handleEvent(Event evt) {
            statusAction.onAction();
          }
        });
View Full Code Here

    return (Element) treeNodeLabel.getChildNodes().item(LABEL_NODE_INDEX);
  }

  @Override
  public SpanElement renderNodeContents(OutlineNode data) {
    SpanElement root = Elements.createSpanElement(css.root());

    DivElement icon = Elements.createDivElement(css.icon());
    switch (data.getType()) {
      case CLASS:
        icon.addClassName(css.clazz());
        break;

      case FUNCTION:
        icon.addClassName(css.function());
        break;

      case FIELD:
        icon.addClassName(css.jsField());
        break;

      case CSS_CLASS:
        icon.addClassName(css.cssClazz());
        break;
    }

    SpanElement label = Elements.createSpanElement(css.label());
    label.setTextContent(data.getName());

    root.appendChild(icon);
    root.appendChild(label);

    CssUtils.setClassNameEnabled(label, css.disabled(), !data.isEnabled());
View Full Code Here

TOP

Related Classes of elemental.html.SpanElement

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.