Search in sources :

Example 21 with Element

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

the class AnnotationGroupImpl method updateIconVisibility.

private void updateIconVisibility() {
    int maxLayer = 0;
    final HTMLCollection children = asElemental().getChildren();
    for (int i = 0; i < children.length(); i++) {
        final Node child = (Node) children.at(i);
        if (child instanceof elemental.dom.Element) {
            final elemental.dom.Element element = (elemental.dom.Element) child;
            final Mappable dataset = element.getDataset();
            final int layer = getLayer(dataset);
            if (maxLayer < layer) {
                maxLayer = layer;
            }
        }
    }
    for (int i = 0; i < children.length(); i++) {
        final Node child = (Node) children.at(i);
        if (child instanceof elemental.dom.Element) {
            final elemental.dom.Element element = (elemental.dom.Element) child;
            final Mappable dataset = element.getDataset();
            final int layer = getLayer(dataset);
            if (layer >= maxLayer) {
                element.getStyle().removeProperty("display");
            } else {
                element.getStyle().setDisplay("none");
            }
        }
    }
}
Also used : HTMLCollection(elemental.html.HTMLCollection) Mappable(elemental.util.Mappable) Node(elemental.dom.Node) DivElement(elemental.html.DivElement) Element(elemental.dom.Element) Element(elemental.dom.Element)

Example 22 with Element

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

the class ScrollbarSizeCalculator method createContainer.

private Element createContainer() {
    Element container = Elements.createDivElement();
    final int containerSize = 500;
    CSSStyleDeclaration containerStyle = container.getStyle();
    containerStyle.setWidth(containerSize, CSSStyleDeclaration.Unit.PX);
    containerStyle.setHeight(containerSize, CSSStyleDeclaration.Unit.PX);
    containerStyle.setPosition(CSSStyleDeclaration.Position.ABSOLUTE);
    containerStyle.setLeft(-containerSize, CSSStyleDeclaration.Unit.PX);
    containerStyle.setTop(-containerSize, CSSStyleDeclaration.Unit.PX);
    Elements.getBody().appendChild(container);
    return container;
}
Also used : Element(elemental.dom.Element) CSSStyleDeclaration(elemental.css.CSSStyleDeclaration)

Example 23 with Element

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

the class Tooltip method ensureContent.

/**
     * Creates the dom for this tooltip's content.
     * <p/>
     * <code>
     * <div class="tooltipPosition">
     * <div class="tooltip tooltipAbove/Below/Left/Right">
     * tooltipText
     * <div class="tooltipTriangle"></div>
     * </div>
     * </div>
     * </code>
     */
private void ensureContent() {
    if (contentElement == null) {
        contentElement = renderer.renderDom();
        if (contentElement == null) {
            // Guard against malformed renderers.
            Log.warn(getClass(), "Renderer for tooltip returned a null content element");
            contentElement = Elements.createDivElement();
            contentElement.setTextContent("An empty Tooltip!");
        }
        if (title != null) {
            // Insert a title if one is set.
            Element titleElem = Elements.createElement("b");
            titleElem.setTextContent(title);
            Element breakElem = Elements.createBRElement();
            contentElement.insertBefore(breakElem, contentElement.getFirstChild());
            contentElement.insertBefore(titleElem, contentElement.getFirstChild());
        }
        // Set the maximum width.
        setMaxWidth(maxWidth);
        Elements.addClassName(css.tooltip(), contentElement);
        Element triangle = Elements.createDivElement(css.triangle());
        contentElement.appendChild(triangle);
        setPositionStyle();
    }
}
Also used : Element(elemental.dom.Element)

Example 24 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 25 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)

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