Package elemental.dom

Examples of elemental.dom.Element

The articles listed here span the above and include links to the appropriate W3C DOM specification.

While these interfaces are generally shared by most HTML and XML elements, there are more specialized interfaces for particular objects listed in the DOM HTML Specification. Note, however, that these HTML interfaces are "only for [HTML 4.01] and [XHTML 1.0] documents and are not guaranteed to work with any future version of XHTML." The HTML 5 draft does state it aims for backwards compatibility with these HTML interfaces but says of them that "some features that were formerly deprecated, poorly supported, rarely used or considered unnecessary have been removed." One can avoid the potential conflict by moving entirely to DOM XML attribute methods such as getAttribute().

Html , Head , Link , Title , Meta , Base , IsIndex , Style , Body , Form , Select , OptGroup , Option, Input , TextArea , Button , Label , FieldSet , Legend , UList , OList , DList , Directory , Menu , LI , Div , Paragraph , Heading , Quote , Pre , BR , BaseFont , Font , HR , Mod , Anchor , Image , Object , Param , Applet , Map , Area , Script , Table , TableCaption , TableCol , TableSection , TableRow , TableCell , FrameSet , Frame , IFrame


   */
  final void ensureChildrenContainer(NodeDataAdapter<D> dataAdapter, Tree.Css css) {
    if (!hasChildrenContainer()) {
      D data = getData();
      if (dataAdapter.hasChildren(data)) {
        Element childrenContainer = Elements.createElement("ul", css.childrenContainer());
        this.appendChild(childrenContainer);
        childrenContainer.getStyle().setDisplay(CSSStyleDeclaration.Display.NONE);
        getExpandControl().setClassName(css.expandControl() + " " + css.closedIcon());
      } else {
        getExpandControl().setClassName(css.expandControl() + " " + css.leafIcon());
      }
    }
View Full Code Here


   * Updates the name value for the model object for a node, and then replaces
   * the label's contents with the new value.
   */
  public void mutateNodeKey(TreeNodeElement<D> node, String newName) {
    getDataAdapter().setNodeName(node.getData(), newName);
    Element elem = getRenderer().getNodeKeyTextContainer(node.getNodeLabel());
    elem.setTextContent(newName);
  }
View Full Code Here

        // We might have set the CSS to say it is closed, but the animation
        // takes a little while. As such, we check to make sure the children
        // container is set to display:none before trying to dispatch an open.
        // Otherwise we can get into an inconsistent state if we click really
        // fast.
        Element childrenContainer = treeNode.getChildrenContainer();
        if (childrenContainer != null && !CssUtils.isVisible(childrenContainer)) {
          getDelegate().onNodeExpanded(treeNode);
        }
      }
    }
View Full Code Here

        if (getDelegate() == null || (primaryMouseButtonOnly
            && ((MouseEvent) evt).getButton() != MouseEvent.Button.PRIMARY)) {
          return;
        }

        Element eventTarget = (Element) evt.getTarget();

        if (CssUtils.containsClassName(eventTarget, css.expandControl())) {
          onExpansionControlEvent(evt, eventTarget);
        } else {
          Element treeNodeBody =
              CssUtils.getAncestorOrSelfWithClassName(eventTarget, css.treeNodeBody());
          if (treeNodeBody != null) {
           
            if (Event.CLICK.equals(evt.getType())) {
              double currentClickMs = Duration.currentTimeMillis();
              if (currentClickMs - previousClickMs < MouseGestureListener.MAX_CLICK_TIMEOUT_MS
                  && treeNodeBody.equals(previousClickTreeNodeBody)) {
                // Swallow double, triple, etc. clicks on an item's label
                return;
              } else {
                this.previousClickMs = currentClickMs;
                this.previousClickTreeNodeBody = treeNodeBody;
View Full Code Here

    // If we are already mutating, return.
    if (isMutating()) {
      return;
    }

    Element element = callback.getElementForMutation(node);
    if (element == null) {
      return;
    }

    String oldLabel = element.getTextContent();
    callback.onBeforeMutation(node);

    // Make a temporary text input box to grab user input, and place it inside
    // the label element.
    InputElement input = Elements.createInputElement();
    if (css != null) {
      input.setClassName(css.nodeNameInput());
    }
    input.setType("text");
    input.setValue(oldLabel);

    // Wipe the content from the element.
    element.setTextContent("");

    // Attach the temporary input box.
    element.appendChild(input);
    input.focus();
    input.select();

    // If we hit enter, commit the action.
    input.addEventListener(Event.KEYUP, keyListener, false);
View Full Code Here

   * @param depth integer indicating how deep we should auto-expand. -1 means
   *        render the entire tree.
   */
  public void renderTree(int depth) {
    // Clear the current view.
    Element rootElement = getView().getElement();
    rootElement.setInnerHTML("");

    // If the root is not set, we have nothing to render.
    D root = getModel().root;
    if (root == null) {
      return;
View Full Code Here

   * Returns the tree node whose element is or contains the given element, or
   * null if the given element cannot be matched to a tree node.
   */
  public TreeNodeElement<D> getNodeFromElement(Element element) {
    Css css = getModel().resources.treeCss();
    Element treeNodeBody = CssUtils.getAncestorOrSelfWithClassName(element, css.treeNodeBody());
    return treeNodeBody != null ? getView().getTreeNodeFromTreeNodeBody(treeNodeBody, css) : null;
  }
View Full Code Here

    addClassesToElement(elem, classNames);
    return elem;
  }

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

  public static Element getElementById(String id) {
    return getDocument().getElementById(id);
  }

  public static void injectJs(String js) {
    Element scriptElem = createElement("script");
    scriptElem.setAttribute("language", "javascript");
    scriptElem.setTextContent(js);
    getBody().appendChild(scriptElem);
  }
View Full Code Here

   * @param id The ID of the Element that we will erase the contents of.
   * @param with The element that we will attach to the element that we just
   *        erased the contents of.
   */
  public static void replaceContents(String id, Element with) {
    Element parent = getElementById(id);
    replaceContents(parent, with);
  }
View Full Code Here

TOP

Related Classes of elemental.dom.Element

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.