Search in sources :

Example 1 with Document

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);
}
Also used : Size(org.rstudio.core.client.Size) Point(org.rstudio.core.client.Point) WindowEx(org.rstudio.core.client.dom.WindowEx) Document(com.google.gwt.dom.client.Document)

Example 2 with Document

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;
}
Also used : Document(com.google.gwt.dom.client.Document)

Example 3 with Document

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);
}
Also used : HeadElement(com.google.gwt.dom.client.HeadElement) ScriptElement(com.google.gwt.dom.client.ScriptElement) Document(com.google.gwt.dom.client.Document)

Example 4 with Document

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);
}
Also used : Document(com.google.gwt.dom.client.Document)

Example 5 with Document

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();
}
Also used : ElementEx(org.rstudio.core.client.dom.ElementEx) Document(com.google.gwt.dom.client.Document)

Aggregations

Document (com.google.gwt.dom.client.Document)9 ElementEx (org.rstudio.core.client.dom.ElementEx)3 WindowEx (org.rstudio.core.client.dom.WindowEx)3 Element (com.google.gwt.dom.client.Element)2 IFrameElementEx (org.rstudio.core.client.dom.IFrameElementEx)2 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)1 HeadElement (com.google.gwt.dom.client.HeadElement)1 NodeList (com.google.gwt.dom.client.NodeList)1 ScriptElement (com.google.gwt.dom.client.ScriptElement)1 Command (com.google.gwt.user.client.Command)1 Point (org.rstudio.core.client.Point)1 Rectangle (org.rstudio.core.client.Rectangle)1 Size (org.rstudio.core.client.Size)1 AnchorableFrame (org.rstudio.core.client.widget.AnchorableFrame)1 Operation (org.rstudio.core.client.widget.Operation)1 DesktopFrame (org.rstudio.studio.client.application.DesktopFrame)1 ExportPlotSizeEditor (org.rstudio.studio.client.workbench.exportplot.ExportPlotSizeEditor)1