use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class ConsoleErrorFrame method showSourceForFrame.
private void showSourceForFrame(ErrorFrame frame) {
FileSystemItem sourceFile = FileSystemItem.createFile(frame.getFileName());
RStudioGinjector.INSTANCE.getEventBus().fireEvent(new OpenSourceFileEvent(sourceFile, FilePosition.create(frame.getLineNumber(), frame.getCharacterNumber()), FileTypeRegistry.R, NavigationMethods.HIGHLIGHT_LINE));
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class DebugCommander method highlightDebugPosition.
// Private methods ---------------------------------------------------------
private void highlightDebugPosition(LineData lineData, boolean finished) {
FileSystemItem sourceFile = FileSystemItem.createFile(debugFile_);
DebugFilePosition position = DebugFilePosition.create(lineData.getLineNumber(), lineData.getEndLineNumber(), lineData.getCharacterNumber(), lineData.getEndCharacterNumber());
eventBus_.fireEvent(new OpenSourceFileEvent(sourceFile, (FilePosition) position.cast(), FileTypeRegistry.R, finished ? NavigationMethods.DEBUG_END : NavigationMethods.DEBUG_STEP));
}
use of org.rstudio.core.client.files.FileSystemItem 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);
}
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class Projects method onOpenProjectFile.
@Override
public void onOpenProjectFile(final OpenProjectFileEvent event) {
// project options for current project
FileSystemItem projFile = event.getFile();
if (projFile.getPath().equals(session_.getSessionInfo().getActiveProjectFile())) {
onProjectOptions();
return;
}
// prompt to confirm
String projectPath = projFile.getParentPathString();
globalDisplay_.showYesNoMessage(GlobalDisplay.MSG_QUESTION, "Confirm Open Project", "Do you want to open the project " + projectPath + "?", new Operation() {
public void execute() {
switchToProject(event.getFile().getPath());
}
}, true);
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class NewPackagePage method validateAsync.
@Override
protected void validateAsync(final NewProjectResult input, final OperationWithInput<Boolean> onValidated) {
// validate package name first
String packageName = txtProjectName_.getText().trim();
if (!isPackageNameValid(packageName)) {
globalDisplay_.showMessage(MessageDialog.WARNING, "Error", "Invalid package name '" + packageName + "'. Package names " + "should start with a letter, and contain only letters and numbers.");
onValidated.execute(false);
return;
}
final FileSystemItem projFile = FileSystemItem.createFile(input.getProjectFile());
final FileSystemItem projDir = projFile.getParentPath();
server_.stat(projDir.getPath(), new ServerRequestCallback<FileSystemItem>() {
@Override
public void onResponseReceived(final FileSystemItem item) {
// no file at this path -- safe for use
if (!item.exists()) {
onValidated.execute(true);
return;
}
// if it was a file, bail
if (!item.isDirectory()) {
globalDisplay_.showMessage(MessageDialog.WARNING, "Error", "A file already exists at path '" + item.getPath() + "'");
onValidated.execute(false);
return;
}
// check if this directory is empty
server_.listFiles(item, false, new ServerRequestCallback<DirectoryListing>() {
@Override
public void onResponseReceived(DirectoryListing listing) {
boolean ok = true;
JsArray<FileSystemItem> children = listing.getFiles();
for (FileSystemItem child : JsUtil.asIterable(children)) {
boolean canIgnore = child.getExtension().equals(".Rproj") || child.getName().startsWith(".");
if (canIgnore)
continue;
ok = false;
break;
}
if (!ok) {
globalDisplay_.showMessage(MessageDialog.WARNING, "Error", "Directory '" + item.getPath() + "' already exists and is not empty.");
}
onValidated.execute(ok);
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
onValidated.execute(true);
}
});
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
onValidated.execute(true);
}
});
}
Aggregations