Search in sources :

Example 46 with Element

use of com.google.gwt.dom.client.Element in project rstudio by rstudio.

the class ShortcutManager method isPrefixForEditor.

// TODO: In a perfect world, this function does not exist and
// instead we populate an editor key map based on the current state
// of the Ace editor, which we could check for prefix matches.
private boolean isPrefixForEditor(KeyCombination keys, NativeEvent event) {
    // Check to see if the event target was Ace.
    Element target = Element.as(event.getEventTarget());
    AceEditorNative editor = AceEditorNative.getEditor(target);
    if (editor == null)
        return false;
    if (editor.isEmacsModeOn()) {
        if (keys.isCtrlPressed()) {
            int keyCode = keys.getKeyCode();
            return keyCode == KeyCodes.KEY_C || keyCode == KeyCodes.KEY_X;
        }
    }
    return false;
}
Also used : AceEditorNative(org.rstudio.studio.client.workbench.views.source.editors.text.ace.AceEditorNative) Element(com.google.gwt.dom.client.Element)

Example 47 with Element

use of com.google.gwt.dom.client.Element in project rstudio by rstudio.

the class ShortcutViewer method onPreviewNativeEvent.

@Override
public void onPreviewNativeEvent(NativePreviewEvent event) {
    if (event.isCanceled())
        return;
    if (event.getTypeInt() == Event.ONKEYDOWN || event.getTypeInt() == Event.ONMOUSEDOWN) {
        if (event.getTypeInt() == Event.ONMOUSEDOWN && event.getNativeEvent().getButton() == NativeEvent.BUTTON_RIGHT)
            return;
        // Don't dismiss the dialog if the click is targeted for a child
        // of the shortcut info panel's root element
        EventTarget et = event.getNativeEvent().getEventTarget();
        if (Element.is(et) && event.getTypeInt() == Event.ONMOUSEDOWN) {
            Element e = Element.as(et);
            while (e != null) {
                if (e == shortcutInfo_.getRootElement())
                    return;
                e = e.getParentElement();
            }
        }
        // This is a keystroke or a click outside the panel; dismiss the panel
        if (shortcutInfo_ != null)
            RootLayoutPanel.get().remove(shortcutInfo_);
        shortcutInfo_ = null;
        if (preview_ != null)
            preview_.removeHandler();
        preview_ = null;
        event.cancel();
    }
}
Also used : Element(com.google.gwt.dom.client.Element) EventTarget(com.google.gwt.dom.client.EventTarget)

Example 48 with Element

use of com.google.gwt.dom.client.Element in project rstudio by rstudio.

the class ExternalJavaScriptLoader method startLoading.

private void startLoading() {
    assert state_ == State.Start;
    ScriptElement script = document_.createScriptElement();
    script.setType("text/javascript");
    script.setSrc(url_);
    registerCallback(script);
    Element head = document_.getElementsByTagName("head").getItem(0);
    head.appendChild(script);
}
Also used : ScriptElement(com.google.gwt.dom.client.ScriptElement) Element(com.google.gwt.dom.client.Element) ScriptElement(com.google.gwt.dom.client.ScriptElement)

Example 49 with Element

use of com.google.gwt.dom.client.Element in project rstudio by rstudio.

the class DocTabLayoutPanel method getTabsEffectiveWidth.

public int getTabsEffectiveWidth() {
    if (getWidgetCount() == 0)
        return 0;
    Element parent = getTabBarElement();
    if (parent == null) {
        return 0;
    }
    Element lastChild = getLastChildElement(parent);
    if (lastChild == null) {
        return 0;
    }
    return lastChild.getOffsetLeft() + lastChild.getOffsetWidth();
}
Also used : Element(com.google.gwt.dom.client.Element)

Example 50 with Element

use of com.google.gwt.dom.client.Element in project rstudio by rstudio.

the class DocTabLayoutPanel method moveTab.

public void moveTab(int index, int delta) {
    // do no work if we haven't been asked to move anywhere
    if (delta == 0)
        return;
    Element tabHost = getTabBarElement();
    // ignore moving left if the tab is already the leftmost tab (same for
    // right)
    int dest = index + delta;
    if (dest < 0 || dest >= tabHost.getChildCount())
        return;
    // rearrange the DOM 
    Element tab = Element.as(tabHost.getChild(index));
    Element prev = Element.as(tabHost.getChild(dest));
    tabHost.removeChild(tab);
    if (delta > 0)
        tabHost.insertAfter(tab, prev);
    else
        tabHost.insertBefore(tab, prev);
    // fire the tab reorder event (this syncs the editor state)
    TabReorderEvent event = new TabReorderEvent(index, dest);
    fireEvent(event);
}
Also used : Element(com.google.gwt.dom.client.Element) Point(org.rstudio.core.client.Point) TabReorderEvent(org.rstudio.core.client.events.TabReorderEvent)

Aggregations

Element (com.google.gwt.dom.client.Element)340 DivElement (com.google.gwt.dom.client.DivElement)19 TableRowElement (com.google.gwt.dom.client.TableRowElement)19 NativeEvent (com.google.gwt.dom.client.NativeEvent)16 Test (org.junit.Test)14 EventTarget (com.google.gwt.dom.client.EventTarget)11 SVGSVGElement (elemental.svg.SVGSVGElement)11 InputElement (com.google.gwt.dom.client.InputElement)10 Node (com.google.gwt.dom.client.Node)9 TableCellElement (com.google.gwt.dom.client.TableCellElement)9 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)8 AnchorElement (com.google.gwt.dom.client.AnchorElement)8 ImageElement (com.google.gwt.dom.client.ImageElement)8 LabelElement (com.google.gwt.dom.client.LabelElement)8 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)8 Image (com.google.gwt.user.client.ui.Image)8 SpanElement (com.google.gwt.dom.client.SpanElement)7 Style (com.google.gwt.dom.client.Style)7 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)7 Widget (com.google.gwt.user.client.ui.Widget)7