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);
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class AceEditorBackgroundLinkHighlighter method navigateToUrl.
private void navigateToUrl(String url) {
// allow web links starting with 'www'
if (url.startsWith("www."))
url = "http://" + url;
// attempt to open web links in a new window
Pattern reWebLink = Pattern.create("^https?://");
if (reWebLink.test(url)) {
globalDisplay_.openWindow(url);
return;
}
// handle testthat links
Pattern reSrcRef = Pattern.create("@[^#]+#\\d+");
if (reSrcRef.test(url))
return;
// treat other URLs as paths to files on the server
final String finalUrl = url;
server_.stat(finalUrl, new ServerRequestCallback<FileSystemItem>() {
@Override
public void onResponseReceived(FileSystemItem file) {
// inform user when no file found
if (file == null || !file.exists()) {
String message = "No file at path '" + finalUrl + "'.";
String caption = "Error navigating to file";
globalDisplay_.showErrorMessage(caption, message);
return;
}
// if we have a registered filetype for this file, try
// to open it in the IDE; otherwise open in browser
FileType fileType = fileTypeRegistry_.getTypeForFile(file);
if (fileType != null && fileType instanceof EditableFileType) {
fileType.openFile(file, null, NavigationMethods.DEFAULT, events_);
} else {
events_.fireEvent(new OpenFileInBrowserEvent(file));
}
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
}
});
}
use of org.rstudio.studio.client.server.ServerError in project rstudio by rstudio.
the class TextEditingTargetRMarkdownHelper method createDraftFromTemplate.
private void createDraftFromTemplate(final RmdChosenTemplate template, final String target) {
final ProgressIndicator progress = new GlobalProgressDelayer(globalDisplay_, 250, "Creating R Markdown Document...").getIndicator();
server_.createRmdFromTemplate(target, template.getTemplatePath(), template.createDir(), new ServerRequestCallback<RmdCreatedTemplate>() {
@Override
public void onResponseReceived(RmdCreatedTemplate created) {
// write a pref indicating this is the preferred template--
// we'll default to it the next time we load the template list
prefs_.rmdPreferredTemplatePath().setGlobalValue(template.getTemplatePath());
prefs_.writeUIPrefs();
FileSystemItem file = FileSystemItem.createFile(created.getPath());
eventBus_.fireEvent(new FileEditEvent(file));
progress.onCompleted();
}
@Override
public void onError(ServerError error) {
progress.onError("Couldn't create a template from " + template.getTemplatePath() + " at " + target + ".\n\n" + error.getMessage());
}
});
}
Aggregations