Search in sources :

Example 6 with Point

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

the class ModalDialogBase method move.

public void move(Point p, boolean allowAnimation) {
    if (!isShowing() || !allowAnimation) {
        // Don't animate if not showing
        setPopupPosition(p.getX(), p.getY());
        return;
    }
    if (currentAnimation_ != null) {
        currentAnimation_.cancel();
        currentAnimation_ = null;
    }
    final int origLeft = getPopupLeft();
    final int origTop = getPopupTop();
    final int deltaX = p.getX() - origLeft;
    final int deltaY = p.getY() - origTop;
    currentAnimation_ = new Animation() {

        @Override
        protected void onUpdate(double progress) {
            if (!isShowing())
                cancel();
            else {
                setPopupPosition((int) (origLeft + deltaX * progress), (int) (origTop + deltaY * progress));
            }
        }
    };
    currentAnimation_.run(200);
}
Also used : Animation(com.google.gwt.animation.client.Animation) Point(org.rstudio.core.client.Point)

Example 7 with Point

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

the class WebWindowOpener method webOpenMinimalWindow.

// enable callers to prevent subclass implementations from taking
// the open window by calling this directly
private void webOpenMinimalWindow(GlobalDisplay globalDisplay, String url, NewWindowOptions options, int width, int height, boolean showLocation) {
    String loc = showLocation ? "1" : "0";
    String features = "width=" + width + "," + "height=" + height + "," + "menubar=0,toolbar=0,location=" + loc + "," + "status=0,scrollbars=1,resizable=1,directories=0";
    // open window at specific position if specified
    Point pos = options.getPosition();
    if (pos != null) {
        features += ",left=" + pos.x + ",top=" + pos.y;
    }
    openWindowInternal(globalDisplay, url, options, features, width, height);
}
Also used : Point(org.rstudio.core.client.Point)

Example 8 with Point

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

Example 9 with Point

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

the class CommitDetail method setDetails.

@Override
public void setDetails(final DiffParser unifiedParser, final boolean suppressViewLink) {
    setProgressVisible(false);
    invalidation_.invalidate();
    final Token token = invalidation_.getInvalidationToken();
    Scheduler.get().scheduleIncremental(new RepeatingCommand() {

        @Override
        public boolean execute() {
            if (token.isInvalid())
                return false;
            final DiffFileHeader fileHeader = unifiedParser.nextFilePair();
            if (fileHeader == null)
                return false;
            int filesCompared = 2;
            ArrayList<ChunkOrLine> lines = new ArrayList<ChunkOrLine>();
            DiffChunk chunk;
            while (null != (chunk = unifiedParser.nextChunk())) {
                if (!chunk.shouldIgnore())
                    filesCompared = chunk.getRanges().length;
                lines.addAll(ChunkOrLine.fromChunk(chunk));
            }
            LineTableView view = new LineTableView(filesCompared);
            view.setUseStartBorder(true);
            view.setUseEndBorder(false);
            view.setShowActions(false);
            view.setData(lines, PatchMode.Stage);
            view.setWidth("100%");
            final DiffFrame diffFrame = new DiffFrame(null, fileHeader.getDescription(), null, commit_.getId(), view, new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    fireEvent(new ViewFileRevisionEvent(commit_.getId(), fileHeader.getDescription().trim()));
                }
            }, suppressViewLink);
            diffFrame.setWidth("100%");
            detailPanel_.add(diffFrame);
            CommitTocRow tocAnchor = new CommitTocRow(fileHeader.getDescription());
            tocAnchor.addClickHandler(new ClickHandler() {

                @Override
                public void onClick(ClickEvent event) {
                    Point relativePosition = DomUtils.getRelativePosition(container_.getElement(), diffFrame.getElement());
                    container_.setVerticalScrollPosition(relativePosition.getY());
                }
            });
            tocPanel_.add(tocAnchor);
            return true;
        }
    });
}
Also used : ClickEvent(com.google.gwt.event.dom.client.ClickEvent) ArrayList(java.util.ArrayList) Token(org.rstudio.core.client.Invalidation.Token) Point(org.rstudio.core.client.Point) ClickHandler(com.google.gwt.event.dom.client.ClickHandler) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) ViewFileRevisionEvent(org.rstudio.studio.client.workbench.views.vcs.common.events.ViewFileRevisionEvent)

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