use of com.google.gwt.dom.client.Document in project rstudio by rstudio.
the class SatelliteManager method forceReopenSatellite.
// Forcefully reopen a satellite window. This refreshes the window and
// pushes it to the front in Chrome. It should be used as a last resort;
// if responding to a UI event, use openSatellite instead, since Chrome
// permits window.open to reactivate windows in that context.
public void forceReopenSatellite(final String name, final JavaScriptObject params, boolean activate) {
Size preferredSize = null;
Point preferredPos = null;
for (ActiveSatellite satellite : satellites_) {
if (satellite.getName().equals(name) && !satellite.getWindow().isClosed()) {
// save the window's geometry so we can restore it after the window
// is destroyed
final WindowEx win = satellite.getWindow();
Document doc = win.getDocument();
preferredSize = new Size(doc.getClientWidth(), doc.getClientHeight());
preferredPos = new Point(win.getLeft(), win.getTop());
callNotifyPendingReactivate(win);
satellite.close();
break;
}
}
// didn't find an open window to reopen
if (preferredSize == null)
return;
// open a new window with the same geometry as the one we just destroyed,
// but with the newly supplied set of parameters
final Size windowSize = preferredSize;
final Point windowPos = preferredPos;
openSatellite(name, params, windowSize, false, windowPos, activate);
}
use of com.google.gwt.dom.client.Document in project rstudio by rstudio.
the class ModalDialogBase method closeDialog.
public void closeDialog() {
hide();
removeFromParent();
try {
if (originallyActiveElement_ != null && !originallyActiveElement_.getTagName().equalsIgnoreCase("body")) {
Document doc = originallyActiveElement_.getOwnerDocument();
if (doc != null) {
originallyActiveElement_.focus();
}
}
} catch (Exception e) {
// focus() fail if the element is no longer visible. It's
// easier to just catch this than try to detect it.
// Also originallyActiveElement_.getTagName() can fail with:
// "Permission denied to access property 'tagName' from a non-chrome context"
// possibly due to Firefox "anonymous div" issue.
}
originallyActiveElement_ = null;
}
use of com.google.gwt.dom.client.Document in project rstudio by rstudio.
the class DiffMatchPatch method injectJavascript.
private static void injectJavascript(String source) {
Document doc = Document.get();
HeadElement head = (HeadElement) doc.getElementsByTagName("head").getItem(0);
if (head == null) {
head = doc.createHeadElement();
doc.insertBefore(head, doc.getBody());
}
ScriptElement script = doc.createScriptElement(source);
script.setType("text/javascript");
head.appendChild(script);
}
use of com.google.gwt.dom.client.Document in project rstudio by rstudio.
the class DomUtilsStandardImpl method setSelectionOffsets.
public void setSelectionOffsets(Element container, int start, int end) {
NodeRelativePosition startp = NodeRelativePosition.toPosition(container, start);
NodeRelativePosition endp = NodeRelativePosition.toPosition(container, end);
Document doc = container.getOwnerDocument();
Range rng = Range.create(doc);
rng.setStart(startp.node, startp.offset);
rng.setEnd(endp.node, endp.offset);
Selection.get(NativeWindow.get(doc)).setRange(rng);
}
use of com.google.gwt.dom.client.Document 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();
}
Aggregations