Search in sources :

Example 1 with SatelliteWindowGeometry

use of org.rstudio.studio.client.common.satellite.model.SatelliteWindowGeometry in project rstudio by rstudio.

the class SourceWindowManager method openSourceWindow.

private void openSourceWindow(String windowId, Point position, String docId, SourcePosition sourcePosition) {
    // create default options
    Size size = new Size(800, 800);
    Integer ordinal = null;
    // if we have geometry for the window, apply it
    SatelliteWindowGeometry geometry = windowGeometry_.getObject(windowId);
    if (geometry != null) {
        size = geometry.getSize();
        ordinal = geometry.getOrdinal();
        if (position == null)
            position = geometry.getPosition();
    }
    // window may exactly overlap an existing source window)
    if (geometry == null) {
        if (!StringUtil.isNullOrEmpty(mostRecentSourceWindow_) && isSourceWindowOpen(mostRecentSourceWindow_)) {
            WindowEx window = getSourceWindowObject(mostRecentSourceWindow_);
            if (window != null && !window.isClosed()) {
                size = new Size(window.getInnerWidth(), window.getInnerHeight());
                if (position == null)
                    position = new Point(window.getScreenX() + 50, window.getScreenY() + 50);
            }
        }
    }
    // assign ordinal if not already assigned
    if (ordinal == null)
        ordinal = ++maxOrdinal_;
    pSatelliteManager_.get().openSatellite(SourceSatellite.NAME_PREFIX + windowId, SourceWindowParams.create(ordinal, pWorkbenchContext_.get().createWindowTitle(), pWorkbenchContext_.get().getCurrentWorkingDir().getPath(), docId, sourcePosition), size, false, position);
    mostRecentSourceWindow_ = windowId;
    sourceWindows_.put(windowId, ordinal);
}
Also used : SatelliteWindowGeometry(org.rstudio.studio.client.common.satellite.model.SatelliteWindowGeometry) WindowEx(org.rstudio.core.client.dom.WindowEx)

Example 2 with SatelliteWindowGeometry

use of org.rstudio.studio.client.common.satellite.model.SatelliteWindowGeometry 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)

Aggregations

WindowEx (org.rstudio.core.client.dom.WindowEx)2 SatelliteWindowGeometry (org.rstudio.studio.client.common.satellite.model.SatelliteWindowGeometry)2 JsArrayString (com.google.gwt.core.client.JsArrayString)1 ArrayList (java.util.ArrayList)1 JsObject (org.rstudio.core.client.js.JsObject)1