use of org.rstudio.core.client.dom.ElementEx in project rstudio by rstudio.
the class DomUtilsStandardImpl method focus.
public void focus(Element element, boolean alwaysDriveSelection) {
ElementEx el = (ElementEx) element;
el.focus();
if (alwaysDriveSelection || (el.getContentEditable() && (el.getInnerText() == null || el.getInnerText() == ""))) {
Document doc = el.getOwnerDocument();
Range range = Range.create(doc);
range.selectNodeContents(el);
Selection sel = Selection.get(NativeWindow.get(doc));
sel.setRange(range);
}
NativeWindow.get().focus();
}
use of org.rstudio.core.client.dom.ElementEx in project rstudio by rstudio.
the class CopyPlotToClipboardDesktopDialog method copyAsBitmap.
protected void copyAsBitmap(final Operation onCompleted) {
final ExportPlotSizeEditor sizeEditor = getSizeEditor();
sizeEditor.prepareForExport(new Command() {
@Override
public void execute() {
if (BrowseCap.isCocoaDesktop()) {
clipboard_.copyPlotToCocoaPasteboard(sizeEditor.getImageWidth(), sizeEditor.getImageHeight(), new Command() {
@Override
public void execute() {
onCompleted.execute();
}
});
} else {
WindowEx win = sizeEditor.getPreviewIFrame().getContentWindow();
Document doc = win.getDocument();
NodeList<Element> images = doc.getElementsByTagName("img");
if (images.getLength() > 0) {
ElementEx img = images.getItem(0).cast();
DesktopFrame frame = Desktop.getFrame();
frame.copyImageToClipboard(img.getClientLeft(), img.getClientTop(), img.getClientWidth(), img.getClientHeight());
}
onCompleted.execute();
}
}
});
}
use of org.rstudio.core.client.dom.ElementEx in project rstudio by rstudio.
the class DomUtilsIE10Impl method focus.
public void focus(Element element, boolean alwaysDriveSelection) {
ElementEx el = (ElementEx) element;
el.focus();
}
use of org.rstudio.core.client.dom.ElementEx in project rstudio by rstudio.
the class DomUtilsStandardImpl method getCursorBounds.
public Rectangle getCursorBounds(Document doc) {
Selection sel = Selection.get(NativeWindow.get(doc));
Range selRng = sel.getRangeAt(0);
if (selRng == null)
return null;
sel.removeAllRanges();
SpanElement span = doc.createSpanElement();
Range rng = selRng.cloneRange();
rng.collapse(true);
rng.insertNode(span);
int x = span.getAbsoluteLeft();
int y = span.getAbsoluteTop();
int w = 0;
int h = span.getOffsetHeight();
Rectangle result = new Rectangle(x, y, w, h);
ElementEx parent = (ElementEx) span.getParentElement();
parent.removeChild(span);
parent.normalize();
sel.setRange(selRng);
return result;
}
use of org.rstudio.core.client.dom.ElementEx in project rstudio by rstudio.
the class HelpPane method helpNavigated.
private void helpNavigated(Document doc) {
NodeList<Element> elements = doc.getElementsByTagName("a");
for (int i = 0; i < elements.getLength(); i++) {
ElementEx a = (ElementEx) elements.getItem(i);
String href = a.getAttribute("href", 2);
if (href == null)
continue;
if (href.contains(":") || href.endsWith(".pdf")) {
// external links
AnchorElement aElement = a.cast();
aElement.setTarget("_blank");
} else {
// Internal links need to be handled in JavaScript so that
// they can participate in virtual session history. This
// won't have any effect for right-click > Show in New Window
// but that's a good thing.
a.setAttribute("onclick", "window.parent.helpNavigate(this.href, " + (BrowseCap.isLinuxDesktop() || BrowseCap.isWindowsDesktop() ? "true" : "false") + "); return false");
}
}
String effectiveTitle = getDocTitle(doc);
title_.setText(effectiveTitle);
this.fireEvent(new HelpNavigateEvent(doc.getURL(), effectiveTitle));
}
Aggregations