Search in sources :

Example 1 with Point

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

use of org.rstudio.core.client.Point in project rstudio by rstudio.

the class DesktopWindowOpener method openSatelliteWindow.

@Override
public void openSatelliteWindow(GlobalDisplay globalDisplay, String mode, int width, int height, NewWindowOptions options) {
    String windowName = SatelliteUtils.getSatelliteWindowName(mode);
    // default to desktop-assigned location, but if a specific position was
    // assigned, use it
    int x = -1;
    int y = -1;
    Point pos = options.getPosition();
    if (pos != null) {
        x = pos.getX();
        y = pos.getY();
    }
    Desktop.getFrame().prepareForSatelliteWindow(windowName, x, y, width, height);
    super.openSatelliteWindow(globalDisplay, mode, width, height, options);
}
Also used : Point(org.rstudio.core.client.Point) Point(org.rstudio.core.client.Point)

Example 3 with Point

use of org.rstudio.core.client.Point in project rstudio by rstudio.

the class DoubleClickState method checkForDoubleClick.

public boolean checkForDoubleClick(NativeEvent event) {
    if (event.getButton() != NativeEvent.BUTTON_LEFT) {
        lastClickPos_ = null;
        lastClickTime_ = null;
        return false;
    }
    Date now = new Date();
    if (!isDoubleClick(event, now)) {
        lastClickPos_ = new Point(event.getClientX(), event.getClientY());
        lastClickTime_ = now;
        return false;
    } else {
        // Prevent three clicks from generating two double clicks
        lastClickPos_ = null;
        lastClickTime_ = null;
        return true;
    }
}
Also used : Point(org.rstudio.core.client.Point) Date(java.util.Date)

Example 4 with Point

use of org.rstudio.core.client.Point in project rstudio by rstudio.

the class DomUtils method getRelativePosition.

public static Point getRelativePosition(Element container, Element child) {
    int left = 0, top = 0;
    while (child != null && child != container) {
        left += child.getOffsetLeft();
        top += child.getOffsetTop();
        child = child.getOffsetParent();
    }
    return new Point(left, top);
}
Also used : Point(org.rstudio.core.client.Point) Point(org.rstudio.core.client.Point)

Example 5 with Point

use of org.rstudio.core.client.Point in project rstudio by rstudio.

the class MiniPopupPanel method positionNearRange.

public void positionNearRange(DocDisplay display, Range range) {
    Rectangle bounds = display.getRangeBounds(range);
    Point center = bounds.center();
    int pageX = center.getX() - (getOffsetWidth() / 2);
    // prefer displaying popup below associated text, but place above text
    // if it won't fit below
    int pageY = bounds.getBottom() + 10;
    if (pageY + getOffsetHeight() > display.getBounds().getBottom()) {
        pageY = bounds.getTop() - 10 - getOffsetHeight();
    }
    // avoid leaking off left side of page
    pageX = Math.max(20, pageX);
    pageY = Math.max(20, pageY);
    setPopupPosition(pageX, pageY);
}
Also used : Rectangle(org.rstudio.core.client.Rectangle) Point(org.rstudio.core.client.Point) Point(org.rstudio.core.client.Point)

Aggregations

Point (org.rstudio.core.client.Point)9 WindowEx (org.rstudio.core.client.dom.WindowEx)2 Animation (com.google.gwt.animation.client.Animation)1 RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)1 Document (com.google.gwt.dom.client.Document)1 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)1 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 Token (org.rstudio.core.client.Invalidation.Token)1 Rectangle (org.rstudio.core.client.Rectangle)1 Size (org.rstudio.core.client.Size)1 Operation (org.rstudio.core.client.widget.Operation)1 NewWindowOptions (org.rstudio.studio.client.common.GlobalDisplay.NewWindowOptions)1 ViewFileRevisionEvent (org.rstudio.studio.client.workbench.views.vcs.common.events.ViewFileRevisionEvent)1