use of org.rstudio.studio.client.common.FileDialogs in project rstudio by rstudio.
the class RSConnectDeploy method onAddFileClick.
private void onAddFileClick() {
FileDialogs dialogs = RStudioGinjector.INSTANCE.getFileDialogs();
final FileSystemItem sourceDir = FileSystemItem.createDir(source_.getDeployDir());
dialogs.openFile("Select File", RStudioGinjector.INSTANCE.getRemoteFileSystemContext(), sourceDir, new ProgressOperationWithInput<FileSystemItem>() {
@Override
public void execute(FileSystemItem input, ProgressIndicator indicator) {
if (input != null) {
String path = input.getPathRelativeTo(sourceDir);
if (path == null) {
display_.showMessage(GlobalDisplay.MSG_INFO, "Cannot Add File", "Only files in the same folder as the " + "document (" + sourceDir + ") or one of its " + "sub-folders may be added.");
return;
} else {
// see if the file is already in the list (we don't
// want to duplicate an existing entry)
ArrayList<String> files = getFileList();
for (String file : files) {
if (file.equals(path)) {
indicator.onCompleted();
return;
}
}
addFileToList(path);
filesAddedManually_.add(path);
}
}
indicator.onCompleted();
}
});
}
use of org.rstudio.studio.client.common.FileDialogs in project rstudio by rstudio.
the class ProjectOpener method showOpenProjectDialog.
public void showOpenProjectDialog(FileSystemContext fsContext, ProjectsServerOperations server, String defaultLocation, int defaultType, boolean showNewSession, final ProgressOperationWithInput<OpenProjectParams> onCompleted) {
initialize();
// use the default dialog on desktop mode or single-session mode
FileDialogs dialogs = RStudioGinjector.INSTANCE.getFileDialogs();
if (Desktop.isDesktop() || !RStudioGinjector.INSTANCE.getSession().getSessionInfo().getMultiSession()) {
dialogs.openFile("Open Project", fsContext, FileSystemItem.createDir(defaultLocation), "R Projects (*.Rproj)", true, new ProgressOperationWithInput<FileSystemItem>() {
@Override
public void execute(FileSystemItem input, final ProgressIndicator indicator) {
final CommandWithArg<FileSystemItem> onProjectFileReady = new CommandWithArg<FileSystemItem>() {
@Override
public void execute(FileSystemItem item) {
onCompleted.execute(new OpenProjectParams(item, null, false), indicator);
}
};
// null return values here imply a cancellation
if (input == null)
return;
if (input.isDirectory()) {
final String rprojPath = input.completePath(input.getName() + ".Rproj");
final FileSystemItem rprojFile = FileSystemItem.createFile(rprojPath);
server_.createProjectFile(rprojFile.getPath(), new ServerRequestCallback<Boolean>() {
@Override
public void onResponseReceived(Boolean success) {
onProjectFileReady.execute(rprojFile);
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
onProjectFileReady.execute(rprojFile);
}
});
} else {
onProjectFileReady.execute(input);
}
}
});
} else {
// in multi-session mode, we have a special dialog for opening projects
WebFileDialogs webDialogs = (WebFileDialogs) dialogs;
webDialogs.openProject(fsContext, FileSystemItem.createDir(defaultLocation), defaultType, showNewSession, onCompleted);
}
}
Aggregations