Search in sources :

Example 26 with WindowEx

use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.

the class ProfilerEditingTargetWidget method print.

public void print() {
    WindowEx window = profilePage_.getWindow();
    window.focus();
    window.print();
}
Also used : WindowEx(org.rstudio.core.client.dom.WindowEx)

Example 27 with WindowEx

use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.

the class SourceWindowManager method fireEventToSourceWindow.

// Private methods ---------------------------------------------------------
private void fireEventToSourceWindow(String windowId, CrossWindowEvent<?> evt, boolean focus) {
    if (StringUtil.isNullOrEmpty(windowId) && !isMainSourceWindow()) {
        pSatellite_.get().focusMainWindow();
        events_.fireEventToMainWindow(evt);
    } else {
        // focus window if requested
        if (focus) {
            pSatelliteManager_.get().activateSatelliteWindow(SourceSatellite.NAME_PREFIX + windowId);
        }
        WindowEx window = getSourceWindowObject(windowId);
        if (window != null) {
            events_.fireEventToSatellite(evt, window);
        }
    }
}
Also used : WindowEx(org.rstudio.core.client.dom.WindowEx)

Example 28 with WindowEx

use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.

the class SourceWindowManager method saveWithPrompt.

public void saveWithPrompt(UnsavedChangesItem item, Command onCompleted) {
    String windowId = getWindowIdOfDocId(item.getId());
    WindowEx window = getSourceWindowObject(windowId);
    if (window == null || window.isClosed()) {
        onCompleted.execute();
        return;
    }
    // raise the window and ask it to save the item
    window.focus();
    saveWithPrompt(getSourceWindowObject(windowId), item, onCompleted);
}
Also used : JsArrayString(com.google.gwt.core.client.JsArrayString) WindowEx(org.rstudio.core.client.dom.WindowEx)

Example 29 with WindowEx

use of org.rstudio.core.client.dom.WindowEx in project rstudio by rstudio.

the class SourceWindowManager method updateWindowGeometry.

private boolean updateWindowGeometry() {
    final ArrayList<String> changedWindows = new ArrayList<String>();
    final JsObject newGeometries = JsObject.createJsObject();
    doForAllSourceWindows(new OperationWithInput<Pair<String, WindowEx>>() {

        @Override
        public void execute(Pair<String, WindowEx> input) {
            String windowId = input.first;
            WindowEx window = input.second;
            // read the window's current geometry
            SatelliteWindowGeometry newGeometry = SatelliteWindowGeometry.create(sourceWindows_.get(windowId), window.getScreenX(), window.getScreenY(), window.getInnerWidth(), window.getInnerHeight());
            // compare to the old geometry (if any)
            if (windowGeometry_.hasKey(windowId)) {
                SatelliteWindowGeometry oldGeometry = windowGeometry_.getObject(windowId);
                if (!oldGeometry.equals(newGeometry))
                    changedWindows.add(windowId);
            } else {
                changedWindows.add(windowId);
            }
            newGeometries.setObject(windowId, newGeometry);
        }

        ;
    });
    if (changedWindows.size() > 0)
        windowGeometry_ = newGeometries;
    return changedWindows.size() > 0;
}
Also used : SatelliteWindowGeometry(org.rstudio.studio.client.common.satellite.model.SatelliteWindowGeometry) JsObject(org.rstudio.core.client.js.JsObject) ArrayList(java.util.ArrayList) JsArrayString(com.google.gwt.core.client.JsArrayString) WindowEx(org.rstudio.core.client.dom.WindowEx)

Example 30 with WindowEx

use of org.rstudio.core.client.dom.WindowEx 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

WindowEx (org.rstudio.core.client.dom.WindowEx)34 JsArrayString (com.google.gwt.core.client.JsArrayString)5 Size (org.rstudio.core.client.Size)5 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)3 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)3 Document (com.google.gwt.dom.client.Document)3 KeyDownEvent (com.google.gwt.event.dom.client.KeyDownEvent)3 KeyDownHandler (com.google.gwt.event.dom.client.KeyDownHandler)3 ArrayList (java.util.ArrayList)3 Point (org.rstudio.core.client.Point)3 FindTextBox (org.rstudio.core.client.widget.FindTextBox)3 NewWindowOptions (org.rstudio.studio.client.common.GlobalDisplay.NewWindowOptions)3 Command (com.google.gwt.user.client.Command)2 ElementEx (org.rstudio.core.client.dom.ElementEx)2 JsObject (org.rstudio.core.client.js.JsObject)2 CanFocus (org.rstudio.core.client.widget.CanFocus)2 Operation (org.rstudio.core.client.widget.Operation)2 ToolbarButton (org.rstudio.core.client.widget.ToolbarButton)2 ToolbarLabel (org.rstudio.core.client.widget.ToolbarLabel)2 SatelliteWindowGeometry (org.rstudio.studio.client.common.satellite.model.SatelliteWindowGeometry)2