Search in sources :

Example 6 with Document

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

the class DomUtilsStandardImpl method selectElement.

@Override
public void selectElement(Element el) {
    Document doc = el.getOwnerDocument();
    Range rng = Range.create(doc);
    rng.selectNode(el);
    Selection.get(NativeWindow.get(doc)).setRange(rng);
}
Also used : Document(com.google.gwt.dom.client.Document)

Example 7 with Document

use of com.google.gwt.dom.client.Document 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();
            }
        }
    });
}
Also used : Command(com.google.gwt.user.client.Command) ElementEx(org.rstudio.core.client.dom.ElementEx) NodeList(com.google.gwt.dom.client.NodeList) WindowEx(org.rstudio.core.client.dom.WindowEx) Document(com.google.gwt.dom.client.Document) DesktopFrame(org.rstudio.studio.client.application.DesktopFrame) ExportPlotSizeEditor(org.rstudio.studio.client.workbench.exportplot.ExportPlotSizeEditor)

Example 8 with Document

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

the class RmdOutputPanel method createFrame.

@Override
protected AnchorableFrame createFrame(String url) {
    AnchorableFrame frame = new AnchorableFrame();
    // allow full screen
    Element el = frame.getElement();
    el.setAttribute("webkitallowfullscreen", "");
    el.setAttribute("mozallowfullscreen", "");
    el.setAttribute("allowfullscreen", "");
    frame.navigate(url);
    final Operation initSlides = new Operation() {

        @Override
        public void execute() {
            if (getNavigationMenu().isVisible()) {
                fireSlideIndexChanged();
                slideChangeMonitor_.scheduleRepeating(100);
            }
        }
    };
    if (isShiny_) {
        shinyFrame_.initialize(url, new Operation() {

            @Override
            public void execute() {
                shinyFrame_.setScrollPosition(scrollPosition_);
                initSlides.execute();
            }
        });
    } else {
        // poll for document availability then perform initialization
        // tasks once it's available (addLoadHandler wasn't always 
        // getting called at least under Cocoa WebKit)
        Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {

            @Override
            public boolean execute() {
                // see if the document is ready
                AnchorableFrame frame = getFrame();
                if (frame == null)
                    return true;
                IFrameElementEx iframe = frame.getIFrame();
                if (iframe == null)
                    return true;
                Document doc = iframe.getContentDocument();
                if (doc == null)
                    return true;
                initSlides.execute();
                // Even though the document exists, it may not have rendered all
                // its content yet
                ScrollUtil.setScrollPositionOnLoad(frame, scrollPosition_);
                return false;
            }
        }, 50);
    }
    return frame;
}
Also used : Element(com.google.gwt.dom.client.Element) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) IFrameElementEx(org.rstudio.core.client.dom.IFrameElementEx) Operation(org.rstudio.core.client.widget.Operation) AnchorableFrame(org.rstudio.core.client.widget.AnchorableFrame) Document(com.google.gwt.dom.client.Document)

Example 9 with Document

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

the class PlotsPanePreviewer method getPreviewClientRect.

public Rectangle getPreviewClientRect() {
    WindowEx win = imageFrame_.getElement().<IFrameElementEx>cast().getContentWindow();
    Document doc = win.getDocument();
    NodeList<Element> images = doc.getElementsByTagName("img");
    if (images.getLength() > 0) {
        ElementEx img = images.getItem(0).cast();
        return new Rectangle(img.getClientLeft(), img.getClientTop(), img.getClientWidth(), img.getClientHeight());
    } else {
        return new Rectangle(0, 0, 0, 0);
    }
}
Also used : IFrameElementEx(org.rstudio.core.client.dom.IFrameElementEx) ElementEx(org.rstudio.core.client.dom.ElementEx) Element(com.google.gwt.dom.client.Element) Rectangle(org.rstudio.core.client.Rectangle) WindowEx(org.rstudio.core.client.dom.WindowEx) 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