Search in sources :

Example 1 with NewWindowOptions

use of org.rstudio.studio.client.common.GlobalDisplay.NewWindowOptions in project rstudio by rstudio.

the class Workbench method onBrowseUrl.

public void onBrowseUrl(BrowseUrlEvent event) {
    BrowseUrlInfo urlInfo = event.getUrlInfo();
    NewWindowOptions newWindowOptions = new NewWindowOptions();
    newWindowOptions.setName(urlInfo.getWindow());
    globalDisplay_.openWindow(urlInfo.getUrl(), newWindowOptions);
}
Also used : NewWindowOptions(org.rstudio.studio.client.common.GlobalDisplay.NewWindowOptions)

Example 2 with NewWindowOptions

use of org.rstudio.studio.client.common.GlobalDisplay.NewWindowOptions in project rstudio by rstudio.

the class ZoomUtils method openZoomWindow.

public static void openZoomWindow(String name, String url, Size size, final OperationWithInput<WindowEx> onOpened) {
    NewWindowOptions options = new NewWindowOptions();
    options.setName(name);
    options.setFocus(true);
    options.setCallback(onOpened);
    RStudioGinjector.INSTANCE.getGlobalDisplay().openMinimalWindow(url, false, size.width, size.height, options);
}
Also used : NewWindowOptions(org.rstudio.studio.client.common.GlobalDisplay.NewWindowOptions)

Example 3 with NewWindowOptions

use of org.rstudio.studio.client.common.GlobalDisplay.NewWindowOptions in project rstudio by rstudio.

the class SatelliteManager method openSatellite.

// open a satellite window (optionally activate existing)
public void openSatellite(String name, JavaScriptObject params, Size preferredSize, boolean adjustSize, Point position, boolean activate) {
    // if we don't need to.
    if (isCurrentWindowSatellite()) {
        Debug.log("Satellite windows can't launch other satellites");
        assert false;
        return;
    }
    // check for a re-activation of an existing window
    for (ActiveSatellite satellite : satellites_) {
        if (satellite.getName().equals(name)) {
            WindowEx window = satellite.getWindow();
            if (!window.isClosed()) {
                // it that it has been reactivated, then exit. 
                if (!Desktop.isDesktop()) {
                    // window will be reloaded)
                    if (!BrowseCap.isChrome() || !activate) {
                        if (activate)
                            window.focus();
                        callNotifyReactivated(window, params);
                        return;
                    } else {
                        // for Chrome, let the window know it's about to be 
                        // closed and reopened
                        callNotifyPendingReactivate(window);
                    }
                } else // desktop mode: activate and return
                {
                    if (activate) {
                        Desktop.getFrame().activateSatelliteWindow(SatelliteUtils.getSatelliteWindowName(satellite.getName()));
                    }
                    callNotifyReactivated(window, params);
                    return;
                }
            }
        }
    }
    // anything while the satellite is being loaded/reactivated
    if (!pendingEventsBySatelliteName_.containsKey(name)) {
        pendingEventsBySatelliteName_.put(name, new ArrayList<JavaScriptObject>());
    }
    // by the satellite within the call to registerAsSatellite)
    if (params != null)
        satelliteParams_.put(name, params);
    // set size and position, if desired
    Size windowSize = adjustSize ? ScreenUtils.getAdjustedWindowSize(preferredSize) : preferredSize;
    NewWindowOptions options = new NewWindowOptions();
    options.setFocus(activate);
    if (position != null)
        options.setPosition(position);
    // open the satellite - it will call us back on registerAsSatellite
    // at which time we'll call setSessionInfo, setParams, etc.
    RStudioGinjector.INSTANCE.getGlobalDisplay().openSatelliteWindow(name, windowSize.width, windowSize.height, options);
}
Also used : JavaScriptObject(com.google.gwt.core.client.JavaScriptObject) NewWindowOptions(org.rstudio.studio.client.common.GlobalDisplay.NewWindowOptions) Size(org.rstudio.core.client.Size) WindowEx(org.rstudio.core.client.dom.WindowEx)

Example 4 with NewWindowOptions

use of org.rstudio.studio.client.common.GlobalDisplay.NewWindowOptions in project rstudio by rstudio.

the class WebWindowOpener method openSatelliteWindow.

public void openSatelliteWindow(GlobalDisplay globalDisplay, String viewName, int width, int height, NewWindowOptions options) {
    // build url
    UrlBuilder urlBuilder = Window.Location.createUrlBuilder();
    urlBuilder.setParameter("view", viewName);
    // setup options
    if (options == null)
        options = new NewWindowOptions();
    options.setName(SatelliteUtils.getSatelliteWindowName(viewName));
    options.setFocus(true);
    // open window (force web codepath b/c desktop needs this so
    // that window.opener is hooked up)
    webOpenMinimalWindow(globalDisplay, urlBuilder.buildString(), options, width, height, false);
}
Also used : NewWindowOptions(org.rstudio.studio.client.common.GlobalDisplay.NewWindowOptions) UrlBuilder(com.google.gwt.http.client.UrlBuilder)

Example 5 with NewWindowOptions

use of org.rstudio.studio.client.common.GlobalDisplay.NewWindowOptions in project rstudio by rstudio.

the class PDFViewer method openPdfUrl.

// Private methods ---------------------------------------------------------
private void openPdfUrl(final String url, final boolean synctex, boolean restorePosition) {
    int width = 1070;
    int height = 1200;
    Point pos = null;
    // if there's a window open, restore the position when we're done
    if (restorePosition && url.equals(lastSuccessfulPdfUrl_)) {
        // the window closed
        if (haveActivePdfJsWindow())
            locationHash_ = pdfJsWindow_.getLocationHash();
        executeOnPdfLoad_ = createRestorePositionOperation();
    }
    // create the operation to load the PDF--we'll call this when the window
    // is finished opening, or immediately if there's already a window open
    Operation loadPdf = new Operation() {

        @Override
        public void execute() {
            pdfJsWindow_.openPdf(server_.getApplicationURL(url), 0, synctex);
            lastSuccessfulPdfUrl_ = url;
        }
    };
    // in the browser we need to close and reopen the window
    if (haveActivePdfJsWindow() && !Desktop.isDesktop()) {
        width = pdfJsWindow_.getOuterWidth();
        height = pdfJsWindow_.getOuterHeight();
        pos = new Point(pdfJsWindow_.getLeft(), pdfJsWindow_.getTop());
        pdfJsWindow_.close();
        pdfJsWindow_ = null;
    }
    lastSuccessfulPdfUrl_ = null;
    if (!haveActivePdfJsWindow()) {
        // open the window and continue
        String viewerUrl = server_.getApplicationURL("pdf_js/web/viewer.html?file=");
        NewWindowOptions options = new NewWindowOptions();
        options.setName(WINDOW_NAME);
        options.setShowDesktopToolbar(false);
        if (pos != null)
            options.setPosition(pos);
        options.setCallback(new OperationWithInput<WindowEx>() {

            @Override
            public void execute(WindowEx win) {
                initializePdfJsWindow(win);
            }
        });
        executeOnPdfJsLoad_ = loadPdf;
        if (Desktop.isDesktop() && Desktop.getFrame().isCocoa()) {
            // on cocoa, we can open a native window
            display_.openMinimalWindow(viewerUrl, false, width, height, options);
        } else {
            // on Qt, we need to open a web window so window.opener is wired
            display_.openWebMinimalWindow(viewerUrl, false, width, height, options);
        }
    } else {
        // we already have an open window, activate it
        if (Desktop.isDesktop())
            Desktop.getFrame().activateMinimalWindow(WINDOW_NAME);
        loadPdf.execute();
    }
}
Also used : NewWindowOptions(org.rstudio.studio.client.common.GlobalDisplay.NewWindowOptions) Point(org.rstudio.core.client.Point) Operation(org.rstudio.core.client.widget.Operation) WindowEx(org.rstudio.core.client.dom.WindowEx) Point(org.rstudio.core.client.Point)

Aggregations

NewWindowOptions (org.rstudio.studio.client.common.GlobalDisplay.NewWindowOptions)6 WindowEx (org.rstudio.core.client.dom.WindowEx)3 Size (org.rstudio.core.client.Size)2 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 UrlBuilder (com.google.gwt.http.client.UrlBuilder)1 Point (org.rstudio.core.client.Point)1 EnabledChangedHandler (org.rstudio.core.client.command.EnabledChangedHandler)1 Handler (org.rstudio.core.client.command.Handler)1 Operation (org.rstudio.core.client.widget.Operation)1