Search in sources :

Example 1 with Element

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

the class AnnotationGroupImpl method buildIncludedElement.

private elemental.dom.Element buildIncludedElement(Annotation annotation, int offset) {
    final elemental.dom.Element element = annotation.getImageElement();
    final CSSStyleDeclaration style = element.getStyle();
    int layer = annotation.getLayer();
    style.setZIndex(layer);
    style.setPosition(ABSOLUTE);
    style.setTop("0");
    style.setLeft("0");
    style.setRight("0");
    style.setBottom("0");
    element.getDataset().setAt(MESSAGE_DATASET_NAME, annotation.getText());
    element.getDataset().setAt(TYPE_DATASET_NAME, annotation.getType());
    element.getDataset().setAt(LAYER_DATASET_NAME, Integer.toString(layer));
    element.getDataset().setAt(OFFSET_DATASET_NAME, Integer.toString(offset));
    return element;
}
Also used : Element(elemental.dom.Element) CSSStyleDeclaration(elemental.css.CSSStyleDeclaration)

Example 2 with Element

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

the class GutterAnnotationRenderer method removeAnnotationItem.

private void removeAnnotationItem(final AnnotationModelEvent event, final Annotation annotation) {
    final Position position = event.getPositionOfRemovedAnnotation(annotation);
    final TextPosition textPosition = this.document.getPositionFromIndex(position.getOffset());
    final Element annotationItem = this.hasGutter.getGutterItem(textPosition.getLine(), ANNOTATION_GUTTER);
    if (AnnotationGroupImpl.isAnnotation(annotationItem)) {
        final AnnotationGroup group = AnnotationGroupImpl.create(annotationItem);
        group.removeAnnotation(annotation, position.getOffset());
        if (group.getAnnotationCount() != 0) {
            return;
        }
    }
    // else
    this.hasGutter.removeGutterItem(textPosition.getLine(), ANNOTATION_GUTTER);
}
Also used : TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) Position(org.eclipse.che.ide.api.editor.text.Position) TextPosition(org.eclipse.che.ide.api.editor.text.TextPosition) Element(elemental.dom.Element)

Example 3 with Element

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

the class FindActionViewImpl method showActions.

@Override
public void showActions(Map<Action, String> actions) {
    this.actions = actions;
    actionsContainer.getElement().setInnerHTML("");
    TableElement itemHolder = Elements.createTableElement();
    itemHolder.setClassName(css.items());
    actionsContainer.getElement().appendChild(((com.google.gwt.dom.client.Element) itemHolder));
    list = SimpleList.create((SimpleList.View) actionsContainer.getElement().cast(), (Element) actionsContainer.getElement(), itemHolder, resources.defaultSimpleListCss(), listItemRenderer, eventDelegate);
    list.render(new ArrayList<>(actions.keySet()));
    if (!actions.isEmpty()) {
        list.getSelectionModel().setSelectedItem(0);
    }
    layoutPanel.setWidgetHidden(actionsPanel, false);
    layoutPanel.setHeight("250px");
    if (isVisible()) {
        Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {

            @Override
            public void execute() {
                center();
            }
        });
    }
}
Also used : Scheduler(com.google.gwt.core.client.Scheduler) Element(elemental.dom.Element) TableCellElement(elemental.html.TableCellElement) TableElement(elemental.html.TableElement) TableElement(elemental.html.TableElement)

Example 4 with Element

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

the class PopupWidget method addItem.

/**
     * Add an item in the popup view.
     * @param itemModel the data for the item
     */
public void addItem(final T itemModel) {
    if (itemModel == null) {
        return;
    }
    Element element = createItem(itemModel);
    element.setTabIndex(1);
    listElement.appendChild(element);
}
Also used : Element(elemental.dom.Element)

Example 5 with Element

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

the class PopupWidget method show.

/**
     * Show the widget at the given document position.
     * @param left the horizontal pixel position in the document
     * @param top the vertical pixel position in the document
     */
public void show(final float left, final float top) {
    if (!listElement.hasChildNodes()) {
        Element emptyElement = Elements.createLiElement(popupResources.popupStyle().item());
        emptyElement.setTextContent(getEmptyMessage());
        listElement.appendChild(emptyElement);
        return;
    }
    /* Reset popup dimensions and show. */
    popupElement.getStyle().setLeft(left, PX);
    popupElement.getStyle().setTop(top, PX);
    popupElement.getStyle().setWidth("" + MIN_WIDTH + "px");
    popupElement.getStyle().setHeight("" + MIN_HEIGHT + "px");
    popupElement.getStyle().setOpacity(0);
    Elements.getDocument().getBody().appendChild(popupElement);
    Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {

        @Override
        public void execute() {
            popupElement.getStyle().setOpacity(1);
        }
    });
    Elements.getDocument().addEventListener(Event.MOUSEDOWN, popupListener, false);
    // does it fit inside the doc body?
    // This does exactly the same thing for height/top and width/left
    final Window window = Elements.getWindow();
    final int winX = window.getInnerWidth();
    final int winY = window.getInnerHeight();
    ClientRect widgetRect = this.popupElement.getBoundingClientRect();
    if (widgetRect.getBottom() > winY) {
        // it doesn't fit
        final float overflow = widgetRect.getBottom() - winY;
        if (widgetRect.getHeight() - overflow > MIN_HEIGHT) {
            // the widget can be shrunk to fit
            this.popupElement.getStyle().setHeight(widgetRect.getHeight() - overflow, PX);
        } else {
            // we need to shrink AND move the widget up
            this.popupElement.getStyle().setHeight(MIN_HEIGHT, PX);
            final int newTop = Math.max(winY - MIN_HEIGHT, MIN_HEIGHT);
            this.popupElement.getStyle().setTop(newTop, PX);
        }
    }
    // bounding rect has changed
    widgetRect = this.popupElement.getBoundingClientRect();
    if (widgetRect.getRight() > winX) {
        // it doesn't fit
        final float overflow = widgetRect.getRight() - winX;
        if (widgetRect.getWidth() - overflow > MIN_WIDTH) {
            // the widget can be shrunk to fit
            this.popupElement.getStyle().setWidth(widgetRect.getWidth() - overflow, PX);
        } else {
            // we need to shrink AND move the widget up
            this.popupElement.getStyle().setWidth(MIN_WIDTH, PX);
            final int newLeft = Math.max(winX - MIN_WIDTH, MIN_WIDTH);
            this.popupElement.getStyle().setLeft(newLeft - MIN_WIDTH, PX);
        }
    }
    if (needsFocus()) {
        // save previous focus and set focus in popup
        previousFocus = Elements.getDocument().getActiveElement();
        listElement.getFirstElementChild().focus();
    }
    // add key event listener on popup
    listElement.addEventListener(Event.KEYDOWN, keyboardListener, false);
}
Also used : Window(elemental.html.Window) Scheduler(com.google.gwt.core.client.Scheduler) Element(elemental.dom.Element) ClientRect(elemental.html.ClientRect)

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