Search in sources :

Example 56 with ServerError

use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.

the class Synctex method forwardSearch.

// NOTE: the original design was for a single internal pdf viewer. for
// that configuration we could keep a global pdfPath_ around and be
// confident that it was always correct. we were also globally managing
// the state of the synctex command based on any external viewer closing.
// now that we optionally support desktop viewers for synctex this 
// assumption may not hold -- specfically there might be multiple active
// PDF viewers for different document or we might not know that the 
// external viewer has closed . we have explicitly chosen to 
// avoid the complexity of tracking distinct viewer states. if we want
// to do this we probably should do the following:
//
//    - always keep the the syncex command available in all editors
//      so long as there is at least one preview window alive; OR
//
//    - for cases where we do know whether the window is still alive
//      editors could dynamically show/hide their synctex button
//      based on that more granular state
//
public boolean forwardSearch(final String pdfFile, SourceLocation sourceLocation) {
    if (handleDesktopSynctex()) {
        // apply concordane
        final ProgressIndicator indicator = getSyncProgress();
        server_.applyForwardConcordance(pdfFile, sourceLocation, new ServerRequestCallback<SourceLocation>() {

            @Override
            public void onResponseReceived(SourceLocation sourceLocation) {
                indicator.onCompleted();
                if (sourceLocation != null) {
                    Desktop.getFrame().externalSynctexView(pdfFile, sourceLocation.getFile(), sourceLocation.getLine(), sourceLocation.getColumn());
                }
            }

            @Override
            public void onError(ServerError error) {
                indicator.onError(error.getUserMessage());
            }
        });
        return true;
    } else // use internal viewer
    {
        doForwardSearch(targetFile_, sourceLocation);
        return true;
    }
}
Also used : SourceLocation(org.rstudio.studio.client.common.synctex.model.SourceLocation) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError)

Example 57 with ServerError

use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.

the class RoxygenHelper method insertRoxygenSkeletonSetMethod.

private void insertRoxygenSkeletonSetMethod(TokenCursor cursor) {
    final Position startPos = cursor.currentPosition();
    String call = extractCall(cursor);
    if (call == null)
        return;
    server_.getSetMethodCall(call, new ServerRequestCallback<SetMethodCall>() {

        @Override
        public void onResponseReceived(SetMethodCall response) {
            if (hasRoxygenBlock(startPos)) {
                amendExistingRoxygenBlock(startPos.getRow() - 1, response.getGeneric(), response.getParameterNames(), response.getParameterTypes(), "param", RE_ROXYGEN_PARAM);
            } else {
                insertRoxygenTemplate(response.getGeneric(), response.getParameterNames(), response.getParameterTypes(), "param", "method", startPos);
            }
        }

        @Override
        public void onError(ServerError error) {
            Debug.logError(error);
        }
    });
}
Also used : Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position) ServerError(org.rstudio.studio.client.server.ServerError) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 58 with ServerError

use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.

the class RoxygenHelper method insertRoxygenSkeletonS4Class.

private void insertRoxygenSkeletonS4Class(TokenCursor cursor) {
    final Position startPos = cursor.currentPosition();
    String setClassCall = extractCall(cursor);
    if (setClassCall == null)
        return;
    server_.getSetClassCall(setClassCall, new ServerRequestCallback<SetClassCall>() {

        @Override
        public void onResponseReceived(SetClassCall response) {
            if (hasRoxygenBlock(startPos)) {
                amendExistingRoxygenBlock(startPos.getRow() - 1, response.getClassName(), response.getSlots(), null, "slot", RE_ROXYGEN_SLOT);
            } else {
                insertRoxygenTemplate(response.getClassName(), response.getSlots(), response.getTypes(), "slot", "S4 class", startPos);
            }
        }

        @Override
        public void onError(ServerError error) {
            Debug.logError(error);
        }
    });
}
Also used : Position(org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position) ServerError(org.rstudio.studio.client.server.ServerError) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 59 with ServerError

use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.

the class RPubsUploader method performUpload.

// Private methods --------------------------------------------------------
private void performUpload(final String title, final String rmdFile, final String htmlFile, final String uploadId, final WindowEx progressWindow, final boolean modify) {
    // record progress window
    uploadProgressWindow_ = progressWindow;
    // subscribe to notification of upload completion
    eventRegistrations_.add(eventBus_.addHandler(RPubsUploadStatusEvent.TYPE, new RPubsUploadStatusEvent.Handler() {

        @Override
        public void onRPubsPublishStatus(RPubsUploadStatusEvent event) {
            // make sure it applies to our context
            RPubsUploadStatusEvent.Status status = event.getStatus();
            if (!status.getContextId().equals(contextId_))
                return;
            uploadInProgress_ = false;
            onUploadComplete(true);
            if (!StringUtil.isNullOrEmpty(status.getError())) {
                if (progressWindow != null)
                    progressWindow.close();
                new ConsoleProgressDialog("Upload Error Occurred", status.getError(), 1).showModal();
            } else {
                if (progressWindow != null) {
                    progressWindow.replaceLocationHref(status.getContinueUrl());
                } else {
                    globalDisplay_.openWindow(status.getContinueUrl());
                }
            }
        }
    }));
    // initiate the upload
    server_.rpubsUpload(contextId_, title, rmdFile == null ? "" : rmdFile, htmlFile, uploadId == null ? "" : uploadId, modify, new ServerRequestCallback<Boolean>() {

        @Override
        public void onResponseReceived(Boolean response) {
            if (!response.booleanValue()) {
                onUploadComplete(false);
                globalDisplay_.showErrorMessage("Error", "Unable to continue " + "(another publish is currently running)");
            }
        }

        @Override
        public void onError(ServerError error) {
            onUploadComplete(false);
            globalDisplay_.showErrorMessage("Error", error.getUserMessage());
        }
    });
}
Also used : ConsoleProgressDialog(org.rstudio.studio.client.workbench.views.vcs.common.ConsoleProgressDialog) ServerError(org.rstudio.studio.client.server.ServerError) RPubsUploadStatusEvent(org.rstudio.studio.client.common.rpubs.events.RPubsUploadStatusEvent)

Example 60 with ServerError

use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.

the class BreakpointManager method setFunctionBreakpoints.

// Private methods ---------------------------------------------------------
private void setFunctionBreakpoints(FileFunction function) {
    ArrayList<String> steps = new ArrayList<String>();
    final ArrayList<Breakpoint> breakpoints = new ArrayList<Breakpoint>();
    for (Breakpoint breakpoint : breakpoints_) {
        if (function.containsBreakpoint(breakpoint)) {
            steps.add(breakpoint.getFunctionSteps());
            breakpoints.add(breakpoint);
        }
    }
    server_.setFunctionBreakpoints(function.functionName, function.fileName, function.packageName, steps, new ServerRequestCallback<Void>() {

        @Override
        public void onResponseReceived(Void v) {
            for (Breakpoint breakpoint : breakpoints) {
                breakpoint.setState(Breakpoint.STATE_ACTIVE);
            }
            notifyBreakpointsSaved(breakpoints, true);
        }

        @Override
        public void onError(ServerError error) {
            discardUnsettableBreakpoints(breakpoints);
        }
    });
}
Also used : Breakpoint(org.rstudio.studio.client.common.debugging.model.Breakpoint) ServerError(org.rstudio.studio.client.server.ServerError) ArrayList(java.util.ArrayList) Void(org.rstudio.studio.client.server.Void)

Aggregations

ServerError (org.rstudio.studio.client.server.ServerError)109 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)26 JsArrayString (com.google.gwt.core.client.JsArrayString)22 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)20 FileSystemItem (org.rstudio.core.client.files.FileSystemItem)18 Void (org.rstudio.studio.client.server.Void)16 ArrayList (java.util.ArrayList)13 JsArray (com.google.gwt.core.client.JsArray)12 Command (com.google.gwt.user.client.Command)11 GlobalProgressDelayer (org.rstudio.studio.client.common.GlobalProgressDelayer)10 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)9 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)9 Operation (org.rstudio.core.client.widget.Operation)8 Handler (org.rstudio.core.client.command.Handler)7 TextEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)7 JSONString (com.google.gwt.json.client.JSONString)6 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)6 CodeBrowserEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget)6 DataEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget)6 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)6