Search in sources :

Example 31 with Element

use of elemental.dom.Element in project che by eclipse.

the class SimpleList method attachEventHandlers.

private void attachEventHandlers() {
    getView().addEventListener(Event.CLICK, new EventListener() {

        @Override
        public void handleEvent(Event evt) {
            Element listItemElem = CssUtils.getAncestorOrSelfWithClassName((Element) evt.getTarget(), css.listItem());
            if (listItemElem == null) {
                Log.warn(SimpleList.class, "Unable to find an ancestor that was a list item for a click on: ", evt.getTarget());
                return;
            }
            ListItem<M> listItem = ListItem.cast(listItemElem);
            eventDelegate.onListItemClicked(listItem, listItem.getData());
        }
    }, false);
    getView().addEventListener(Event.DBLCLICK, new EventListener() {

        @Override
        public void handleEvent(Event evt) {
            Element listItemElem = CssUtils.getAncestorOrSelfWithClassName((Element) evt.getTarget(), css.listItem());
            if (listItemElem == null) {
                Log.warn(SimpleList.class, "Unable to find an ancestor that was a list item for a click on: ", evt.getTarget());
                return;
            }
            ListItem<M> listItem = ListItem.cast(listItemElem);
            eventDelegate.onListItemDoubleClicked(listItem, listItem.getData());
        }
    }, false);
}
Also used : JsElement(elemental.js.dom.JsElement) Element(elemental.dom.Element) Event(elemental.events.Event) EventListener(elemental.events.EventListener)

Example 32 with Element

use of elemental.dom.Element in project che by eclipse.

the class DomUtils method calculateElementOffset.

/**
     * Returns an offset to the top-left of a child element relative to the
     * top-left of an ancestor element, optionally including any scroll top or
     * left in elements from the ancestor (inclusive) to the child (exclusive).
     *
     * @param ancestorElement
     *         optional, if null the offset from the top-left of
     *         the page will be given. Should not be the childElement.
     */
@Deprecated
public static Offset calculateElementOffset(Element childElement, Element ancestorElement, boolean includeScroll) {
    Offset offset = new Offset();
    Element element = childElement;
    for (; element.getOffsetParent() != null && element != ancestorElement; element = element.getOffsetParent()) {
        offset.top += element.getOffsetTop();
        offset.left += element.getOffsetLeft();
        if (!includeScroll) {
            offset.top -= element.getOffsetParent().getScrollTop();
            offset.left -= element.getOffsetParent().getScrollLeft();
        }
    }
    return offset;
}
Also used : DivElement(elemental.html.DivElement) JsElement(elemental.js.dom.JsElement) Element(elemental.dom.Element)

Example 33 with Element

use of elemental.dom.Element in project che by eclipse.

the class Elements method injectJs.

public static void injectJs(String js) {
    Element scriptElem = createElement("script");
    scriptElem.setAttribute("language", "javascript");
    scriptElem.setTextContent(js);
    getBody().appendChild(scriptElem);
}
Also used : DivElement(elemental.html.DivElement) AnchorElement(elemental.html.AnchorElement) ImageElement(elemental.html.ImageElement) TextAreaElement(elemental.html.TextAreaElement) JsElement(elemental.js.dom.JsElement) TableRowElement(elemental.html.TableRowElement) ParagraphElement(elemental.html.ParagraphElement) CanvasElement(elemental.html.CanvasElement) InputElement(elemental.html.InputElement) BodyElement(elemental.html.BodyElement) IFrameElement(elemental.html.IFrameElement) Element(elemental.dom.Element) PreElement(elemental.html.PreElement) TableCellElement(elemental.html.TableCellElement) BRElement(elemental.html.BRElement) HeadElement(elemental.html.HeadElement) ButtonElement(elemental.html.ButtonElement) UListElement(elemental.html.UListElement) FormElement(elemental.html.FormElement) TableElement(elemental.html.TableElement) LIElement(elemental.html.LIElement) SpanElement(elemental.html.SpanElement)

Example 34 with Element

use of elemental.dom.Element in project che by eclipse.

the class Elements method replaceContents.

/**
     * Replaces the contents of an Element with the specified ID, with a single
     * element.
     *
     * @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);
}
Also used : DivElement(elemental.html.DivElement) AnchorElement(elemental.html.AnchorElement) ImageElement(elemental.html.ImageElement) TextAreaElement(elemental.html.TextAreaElement) JsElement(elemental.js.dom.JsElement) TableRowElement(elemental.html.TableRowElement) ParagraphElement(elemental.html.ParagraphElement) CanvasElement(elemental.html.CanvasElement) InputElement(elemental.html.InputElement) BodyElement(elemental.html.BodyElement) IFrameElement(elemental.html.IFrameElement) Element(elemental.dom.Element) PreElement(elemental.html.PreElement) TableCellElement(elemental.html.TableCellElement) BRElement(elemental.html.BRElement) HeadElement(elemental.html.HeadElement) ButtonElement(elemental.html.ButtonElement) UListElement(elemental.html.UListElement) FormElement(elemental.html.FormElement) TableElement(elemental.html.TableElement) LIElement(elemental.html.LIElement) SpanElement(elemental.html.SpanElement)

Example 35 with Element

use of elemental.dom.Element in project che by eclipse.

the class Tree method renderTree.

/**
     * Renders the tree starting with the root node up until the specified depth.
     * <p/>
     * This will NOT restore any expansions. If you want to re-render the tree
     * obeying previous expansions then,
     *
     * @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("");
    rootElement.setAttribute("___depth", "0");
    // If the root is not set, we have nothing to render.
    D root = getModel().root;
    if (root == null) {
        return;
    }
    // Root is special in that we don't render a directory for it. Only its
    // children.
    List<D> children = getModel().dataAdapter.getChildren(root);
    for (int i = 0, n = children.size(); i < n; i++) {
        renderRecursive(rootElement, children.get(i), depth);
    }
}
Also used : JsElement(elemental.js.dom.JsElement) Element(elemental.dom.Element)

Aggregations

Element (elemental.dom.Element)48 SpanElement (elemental.html.SpanElement)23 DivElement (elemental.html.DivElement)15 JsElement (elemental.js.dom.JsElement)11 Event (elemental.events.Event)8 EventListener (elemental.events.EventListener)8 Node (elemental.dom.Node)7 HTMLCollection (elemental.html.HTMLCollection)5 LIElement (elemental.html.LIElement)5 TableCellElement (elemental.html.TableCellElement)5 TableElement (elemental.html.TableElement)5 InputElement (elemental.html.InputElement)4 JsLIElement (elemental.js.html.JsLIElement)4 JsUListElement (elemental.js.html.JsUListElement)4 TreeNodeElement (org.eclipse.che.ide.ui.tree.TreeNodeElement)4 SVGImage (org.vectomatic.dom.svg.ui.SVGImage)4 Scheduler (com.google.gwt.core.client.Scheduler)3 CustomEvent (elemental.events.CustomEvent)3 AnchorElement (elemental.html.AnchorElement)3 BRElement (elemental.html.BRElement)3