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);
}
});
}
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);
}
});
}
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());
}
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())));
}
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);
}
Aggregations