Search in sources :

Example 36 with Element

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

the class Tree method getNodeFromElement.

/**
     * 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;
}
Also used : JsElement(elemental.js.dom.JsElement) Element(elemental.dom.Element)

Example 37 with Element

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

the class Tree method asWidget.

/** {@inheritDoc} */
@Override
public Widget asWidget() {
    if (widget == null) {
        widget = new HTML();
        Element element = getView().getElement();
        widget.getElement().appendChild((Node) element);
        widget.getElement().getStyle().setOverflow(Style.Overflow.AUTO);
    }
    return widget;
}
Also used : JsElement(elemental.js.dom.JsElement) Element(elemental.dom.Element) HTML(com.google.gwt.user.client.ui.HTML)

Example 38 with Element

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

the class TreeNodeElement method updateLeafOffset.

public final void updateLeafOffset(Element parent) {
    if (!parent.hasAttribute("___depth")) {
        return;
    }
    try {
        int depth = Integer.parseInt(parent.getAttribute("___depth"));
        Element expandElement = (Element) getNodeBody().getChildren().item(0);
        expandElement.getStyle().setMarginLeft("" + (depth * 8) + "px");
        if (!hasChildNodes()) {
            return;
        }
        final JsUListElement childrenContainer = getChildrenContainer();
        if (childrenContainer != null) {
            getChildrenContainer().setAttribute("___depth", "" + (depth + 1));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : DivElement(elemental.html.DivElement) Element(elemental.dom.Element) JsLIElement(elemental.js.html.JsLIElement) SpanElement(elemental.html.SpanElement) JsUListElement(elemental.js.html.JsUListElement) JsUListElement(elemental.js.html.JsUListElement)

Example 39 with Element

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

the class TreeNodeElement method ensureChildrenContainer.

/**
     * If this node does not have a children container, but has children data,
     * then we coerce a children container into existence.
     */
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);
            ((Element) getExpandControl().getChildNodes().item(0)).getStyle().setDisplay("block");
            ((Element) getExpandControl().getChildNodes().item(1)).getStyle().setDisplay("none");
        } else {
            getExpandControl().setClassName(css.expandControl() + " " + css.leafIcon());
        }
    }
}
Also used : DivElement(elemental.html.DivElement) Element(elemental.dom.Element) JsLIElement(elemental.js.html.JsLIElement) SpanElement(elemental.html.SpanElement) JsUListElement(elemental.js.html.JsUListElement)

Example 40 with Element

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

the class Elements method createElement.

public static Element createElement(String tagName, String... classNames) {
    Element elem = getDocument().createElement(tagName);
    addClassesToElement(elem, classNames);
    return elem;
}
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)

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