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;
}
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();
}
}
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);
}
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();
}
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);
}
Aggregations