Search in sources :

Example 1 with ServerError

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

the class ShinyViewerTypePopupMenu method getDynamicPopupMenu.

@Override
public void getDynamicPopupMenu(final ToolbarPopupMenu.DynamicPopupMenuCallback callback) {
    final ToolbarPopupMenu menu = this;
    server_.getShinyViewerType(new ServerRequestCallback<ShinyViewerType>() {

        @Override
        public void onResponseReceived(ShinyViewerType response) {
            int viewerType = response.getViewerType();
            commands_.shinyRunInPane().setChecked(false);
            commands_.shinyRunInViewer().setChecked(false);
            commands_.shinyRunInBrowser().setChecked(false);
            if (ShinyViewerType.SHINY_VIEWER_PANE == viewerType)
                commands_.shinyRunInPane().setChecked(true);
            if (ShinyViewerType.SHINY_VIEWER_WINDOW == viewerType)
                commands_.shinyRunInViewer().setChecked(true);
            if (ShinyViewerType.SHINY_VIEWER_BROWSER == viewerType)
                commands_.shinyRunInBrowser().setChecked(true);
            callback.onPopupMenu(menu);
        }

        @Override
        public void onError(ServerError error) {
            callback.onPopupMenu(menu);
        }
    });
}
Also used : ShinyViewerType(org.rstudio.studio.client.shiny.model.ShinyViewerType) ToolbarPopupMenu(org.rstudio.core.client.widget.ToolbarPopupMenu) ServerError(org.rstudio.studio.client.server.ServerError)

Example 2 with ServerError

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

the class Workbench method onVersionControlShowRsaKey.

@Handler
public void onVersionControlShowRsaKey() {
    final ProgressIndicator indicator = new GlobalProgressDelayer(globalDisplay_, 500, "Reading RSA public key...").getIndicator();
    // compute path to public key
    String sshDir = session_.getSessionInfo().getDefaultSSHKeyDir();
    final String keyPath = FileSystemItem.createDir(sshDir).completePath("id_rsa.pub");
    // read it
    server_.gitSshPublicKey(keyPath, new ServerRequestCallback<String>() {

        @Override
        public void onResponseReceived(String publicKeyContents) {
            indicator.onCompleted();
            new ShowPublicKeyDialog("RSA Public Key", publicKeyContents).showModal();
        }

        @Override
        public void onError(ServerError error) {
            String msg = "Error attempting to read key '" + keyPath + "' (" + error.getUserMessage() + ")";
            indicator.onError(msg);
        }
    });
}
Also used : ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ShowPublicKeyDialog(org.rstudio.studio.client.common.vcs.ShowPublicKeyDialog) ServerError(org.rstudio.studio.client.server.ServerError) GlobalProgressDelayer(org.rstudio.studio.client.common.GlobalProgressDelayer) Handler(org.rstudio.core.client.command.Handler) VcsRefreshHandler(org.rstudio.studio.client.workbench.views.vcs.common.events.VcsRefreshHandler)

Example 3 with ServerError

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

the class GeneralPreferencesPane method initialize.

@Override
protected void initialize(RPrefs rPrefs) {
    // general prefs
    final GeneralPrefs generalPrefs = rPrefs.getGeneralPrefs();
    showServerHomePage_.setEnabled(true);
    reuseSessionsForProjectLinks_.setEnabled(true);
    saveWorkspace_.setEnabled(true);
    loadRData_.setEnabled(true);
    dirChooser_.setEnabled(true);
    showServerHomePage_.setValue(generalPrefs.getShowUserHomePage());
    reuseSessionsForProjectLinks_.setValue(generalPrefs.getReuseSessionsForProjectLinks());
    int saveWorkspaceIndex;
    switch(generalPrefs.getSaveAction()) {
        case SaveAction.NOSAVE:
            saveWorkspaceIndex = 1;
            break;
        case SaveAction.SAVE:
            saveWorkspaceIndex = 0;
            break;
        case SaveAction.SAVEASK:
        default:
            saveWorkspaceIndex = 2;
            break;
    }
    saveWorkspace_.getListBox().setSelectedIndex(saveWorkspaceIndex);
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            server_.getTerminalShells(new ServerRequestCallback<JsArray<TerminalShellInfo>>() {

                @Override
                public void onResponseReceived(JsArray<TerminalShellInfo> shells) {
                    int currentShell = generalPrefs.getDefaultTerminalShellValue();
                    int currentShellIndex = 0;
                    GeneralPreferencesPane.this.terminalShell_.getListBox().clear();
                    for (int i = 0; i < shells.length(); i++) {
                        TerminalShellInfo info = shells.get(i);
                        GeneralPreferencesPane.this.terminalShell_.addChoice(info.getShellName(), Integer.toString(info.getShellType()));
                        if (info.getShellType() == currentShell)
                            currentShellIndex = i;
                    }
                    if (GeneralPreferencesPane.this.terminalShell_.getListBox().getItemCount() > 0) {
                        GeneralPreferencesPane.this.terminalShell_.setEnabled((true));
                        GeneralPreferencesPane.this.terminalShell_.getListBox().setSelectedIndex(currentShellIndex);
                    }
                }

                @Override
                public void onError(ServerError error) {
                }
            });
        }
    });
    loadRData_.setValue(generalPrefs.getLoadRData());
    dirChooser_.setText(generalPrefs.getInitialWorkingDirectory());
    // history prefs
    HistoryPrefs historyPrefs = rPrefs.getHistoryPrefs();
    alwaysSaveHistory_.setEnabled(true);
    removeHistoryDuplicates_.setEnabled(true);
    alwaysSaveHistory_.setValue(historyPrefs.getAlwaysSave());
    removeHistoryDuplicates_.setValue(historyPrefs.getRemoveDuplicates());
    rProfileOnResume_.setValue(generalPrefs.getRprofileOnResume());
    rProfileOnResume_.setEnabled(true);
    showLastDotValue_.setValue(generalPrefs.getShowLastDotValue());
    showLastDotValue_.setEnabled(true);
    if (rServerRVersion_ != null)
        rServerRVersion_.setRVersion(generalPrefs.getDefaultRVersion());
    if (rememberRVersionForProjects_ != null) {
        rememberRVersionForProjects_.setValue(generalPrefs.getRestoreProjectRVersion());
    }
    // projects prefs
    ProjectsPrefs projectsPrefs = rPrefs.getProjectsPrefs();
    restoreLastProject_.setEnabled(true);
    restoreLastProject_.setValue(projectsPrefs.getRestoreLastProject());
}
Also used : GeneralPrefs(org.rstudio.studio.client.workbench.prefs.model.GeneralPrefs) TerminalShellInfo(org.rstudio.studio.client.workbench.views.terminal.TerminalShellInfo) JsArray(com.google.gwt.core.client.JsArray) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) ServerError(org.rstudio.studio.client.server.ServerError) ProjectsPrefs(org.rstudio.studio.client.workbench.prefs.model.ProjectsPrefs) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback) HistoryPrefs(org.rstudio.studio.client.workbench.prefs.model.HistoryPrefs)

Example 4 with ServerError

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

the class PreferencesDialog method doSaveChanges.

@Override
protected void doSaveChanges(final RPrefs rPrefs, final Operation onCompleted, final ProgressIndicator progressIndicator, final boolean reload) {
    // save changes
    server_.setPrefs(rPrefs, session_.getSessionInfo().getUiPrefs(), new SimpleRequestCallback<Void>() {

        @Override
        public void onResponseReceived(Void response) {
            progressIndicator.onCompleted();
            if (onCompleted != null)
                onCompleted.execute();
            if (reload)
                reload();
        }

        @Override
        public void onError(ServerError error) {
            progressIndicator.onError(error.getUserMessage());
        }
    });
    // broadcast UI pref changes to satellites
    RStudioGinjector.INSTANCE.getSatelliteManager().dispatchCrossWindowEvent(new UiPrefsChangedEvent(UiPrefsChangedEvent.Data.create(UiPrefsChangedEvent.GLOBAL_TYPE, session_.getSessionInfo().getUiPrefs())));
}
Also used : UiPrefsChangedEvent(org.rstudio.studio.client.workbench.prefs.events.UiPrefsChangedEvent) ServerError(org.rstudio.studio.client.server.ServerError) Void(org.rstudio.studio.client.server.Void)

Example 5 with ServerError

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

the class RemoteServerAuth method schedulePeriodicCredentialsUpdate.

public void schedulePeriodicCredentialsUpdate() {
    // create the callback
    periodicUpdateTimer_ = new Timer() {

        @Override
        public void run() {
            updateCredentials(new ServerRequestCallback<Integer>() {

                @Override
                public void onResponseReceived(Integer response) {
                    switch(response) {
                        case CREDENTIALS_UPDATE_SUCCESS:
                            // credentials)
                            break;
                        case CREDENTIALS_UPDATE_FAILURE:
                            // we are not authorized, blow the client away
                            remoteServer_.handleUnauthorizedError();
                            break;
                        case CREDENTIALS_UPDATE_UNSUPPORTED:
                            // not supported by the back end so cancel the timer
                            periodicUpdateTimer_.cancel();
                            break;
                    }
                }

                @Override
                public void onError(ServerError serverError) {
                    // if method is not supported then cancel the timer
                    Debug.logError(serverError);
                }
            });
        }
    };
    // schedule for every 5 minutes
    final int kMinutes = 5;
    int milliseconds = kMinutes * 60 * 1000;
    periodicUpdateTimer_.scheduleRepeating(milliseconds);
}
Also used : Timer(com.google.gwt.user.client.Timer) ServerError(org.rstudio.studio.client.server.ServerError) ServerRequestCallback(org.rstudio.studio.client.server.ServerRequestCallback)

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