Search in sources :

Example 1 with PdfLocation

use of org.rstudio.studio.client.common.synctex.model.PdfLocation in project rstudio by rstudio.

the class PDFViewer method onCompilePdfCompleted.

@Override
public void onCompilePdfCompleted(CompilePdfCompletedEvent event) {
    // only handle PDF compile events when we're the preferred viewer
    if (!prefs_.pdfPreview().getValue().equals(UIPrefs.PDF_PREVIEW_RSTUDIO))
        return;
    // only handle successful compiles
    final CompilePdfResult result = event.getResult();
    if (!result.getSucceeded())
        return;
    // when the PDF is finished rendering, optionally navigate to the desired
    // location, or set and restore the current location
    final PdfLocation pdfLocation = result.getPdfLocation();
    if (pdfLocation != null) {
        executeOnPdfLoad_ = new Operation() {

            @Override
            public void execute() {
                PdfJsWindow.navigateTo(pdfJsWindow_, pdfLocation);
            }
        };
    }
    lastSuccessfulPdfPath_ = result.getPdfPath();
    openPdfUrl(result.getViewPdfUrl(), result.isSynctexAvailable(), pdfLocation == null);
}
Also used : PdfLocation(org.rstudio.studio.client.common.synctex.model.PdfLocation) CompilePdfResult(org.rstudio.studio.client.common.compilepdf.model.CompilePdfResult) Operation(org.rstudio.core.client.widget.Operation)

Example 2 with PdfLocation

use of org.rstudio.studio.client.common.synctex.model.PdfLocation in project rstudio by rstudio.

the class Synctex method doForwardSearch.

private void doForwardSearch(String rootDocument, JavaScriptObject sourceLocationObject) {
    SourceLocation sourceLocation = sourceLocationObject.cast();
    final ProgressIndicator indicator = getSyncProgress();
    server_.synctexForwardSearch(rootDocument, sourceLocation, new ServerRequestCallback<PdfLocation>() {

        @Override
        public void onResponseReceived(PdfLocation location) {
            indicator.onCompleted();
            if (location != null)
                eventBus_.fireEvent(new SynctexViewPdfEvent(location));
        }

        @Override
        public void onError(ServerError error) {
            indicator.onError(error.getUserMessage());
        }
    });
}
Also used : SourceLocation(org.rstudio.studio.client.common.synctex.model.SourceLocation) PdfLocation(org.rstudio.studio.client.common.synctex.model.PdfLocation) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) SynctexViewPdfEvent(org.rstudio.studio.client.common.synctex.events.SynctexViewPdfEvent)

Example 3 with PdfLocation

use of org.rstudio.studio.client.common.synctex.model.PdfLocation in project rstudio by rstudio.

the class Synctex method doInverseSearch.

private void doInverseSearch(JavaScriptObject pdfLocationObject) {
    PdfLocation pdfLocation = pdfLocationObject.cast();
    final ProgressIndicator indicator = getSyncProgress();
    server_.synctexInverseSearch(pdfLocation, new ServerRequestCallback<SourceLocation>() {

        @Override
        public void onResponseReceived(SourceLocation location) {
            indicator.onCompleted();
            if (location != null)
                goToSourceLocation(location);
        }

        @Override
        public void onError(ServerError error) {
            indicator.onError(error.getUserMessage());
        }
    });
}
Also used : SourceLocation(org.rstudio.studio.client.common.synctex.model.SourceLocation) PdfLocation(org.rstudio.studio.client.common.synctex.model.PdfLocation) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError)

Aggregations

PdfLocation (org.rstudio.studio.client.common.synctex.model.PdfLocation)3 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)2 SourceLocation (org.rstudio.studio.client.common.synctex.model.SourceLocation)2 ServerError (org.rstudio.studio.client.server.ServerError)2 Operation (org.rstudio.core.client.widget.Operation)1 CompilePdfResult (org.rstudio.studio.client.common.compilepdf.model.CompilePdfResult)1 SynctexViewPdfEvent (org.rstudio.studio.client.common.synctex.events.SynctexViewPdfEvent)1