use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class PackratUtil method packratProjectArg.
public String packratProjectArg() {
String projectArg = "";
FileSystemItem projectDir = session_.getSessionInfo().getActiveProjectDir();
FileSystemItem workingDir = workbenchContext_.getCurrentWorkingDir();
if (!projectDir.equalTo(workingDir))
projectArg = "project = '" + projectDir.getPath() + "'";
return projectArg;
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class RmdOutput method onWebsiteFileSaved.
@Override
public void onWebsiteFileSaved(WebsiteFileSavedEvent event) {
// skip if there is a build in progress
if (workbenchContext_.isBuildInProgress())
return;
// skip if there is a render in progress
if (renderInProgress_)
return;
// skip if there was a quit initiated since the last render
if (quitInitiatedAfterLastRender_)
return;
// is there an output frame?
if (outputFrame_ == null || outputFrame_.getWindowObject() == null)
return;
// is it showing a page from the current site?
String websiteDir = session_.getSessionInfo().getBuildTargetDir();
final RmdPreviewParams params = outputFrame_.getPreviewParams();
if (!params.getTargetFile().startsWith(websiteDir))
return;
// is the changed file one that should always produce a rebuild?
FileSystemItem file = event.getFileSystemItem();
TextFileType fileType = fileTypeRegistry_.getTextTypeForFile(file);
String typeId = fileType.getTypeId();
if (fileType.isR() || typeId.equals(FileTypeRegistry.HTML.getTypeId()) || typeId.equals(FileTypeRegistry.YAML.getTypeId()) || typeId.equals(FileTypeRegistry.JSON.getTypeId())) {
reRenderPreview();
} else // is the changed file a markdown document
if (fileType.isMarkdown()) {
// included Rmd files always produce a rebuild of the current file
if (file.getStem().startsWith("_"))
reRenderPreview();
// files in subdirectories are also includes so re-render them also
if (!file.getParentPathString().equals(websiteDir))
reRenderPreview();
// ...otherwise leave it alone (requires a knit)
} else // see if this should result in a copy + refresh
{
server_.maybeCopyWebsiteAsset(file.getPath(), new SimpleRequestCallback<Boolean>() {
@Override
public void onResponseReceived(Boolean copied) {
if (copied)
outputFrame_.showRmdPreview(params, true);
}
});
}
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class ProfilerEditingTarget method saveNewFile.
private void saveNewFile(final String suggestedPath) {
FileSystemItem fsi;
if (suggestedPath != null)
fsi = FileSystemItem.createFile(suggestedPath).getParentPath();
else
fsi = workbenchContext_.getDefaultFileDialogDir();
fileDialogs_.saveFile("Save File - " + getName().getValue(), fileContext_, fsi, fileType_.getDefaultExtension(), false, new ProgressOperationWithInput<FileSystemItem>() {
public void execute(final FileSystemItem saveItem, final ProgressIndicator indicator) {
if (saveItem == null)
return;
workbenchContext_.setDefaultFileDialogDir(saveItem.getParentPath());
final String toPath = saveItem.getPath();
server_.copyProfile(htmlLocalPath_, toPath, new ServerRequestCallback<JavaScriptObject>() {
@Override
public void onResponseReceived(JavaScriptObject response) {
savePropertiesWithPath(saveItem.getPath());
persistDocumentProperty("isUserSaved", "saved");
isUserSaved_ = true;
indicator.onCompleted();
}
@Override
public void onError(ServerError error) {
Debug.logError(error);
indicator.onCompleted();
globalDisplay_.showErrorMessage("Failed to Save Profile", error.getMessage());
}
});
}
});
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class PresentationDispatcher method performSourceCommand.
private void performSourceCommand(String param1, String param2) {
if (param1 != null) {
// get filename and type
FileSystemItem file = FileSystemItem.createFile(getPresentationPath(param1));
TextFileType fileType = fileTypeRegistry_.getTextTypeForFile(file);
// check for a file position and/or pattern
FilePosition pos = null;
String pattern = null;
if (param2 != null) {
if (param2.length() > 2 && param2.startsWith("/") && param2.endsWith("/")) {
pattern = param2.substring(1, param2.length() - 1);
} else {
int line = StringUtil.parseInt(param2, 0);
if (line > 0)
pos = FilePosition.create(line, 1);
}
}
// dispatch
fireOpenSourceFileEvent(new OpenPresentationSourceFileEvent(file, fileType, pos, pattern));
}
}
use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.
the class PresentationDispatcher method fireEventFromTutorialDirectory.
private void fireEventFromTutorialDirectory(final GwtEvent<?> event) {
SessionInfo sessionInfo = session_.getSessionInfo();
PresentationState state = sessionInfo.getPresentationState();
FileSystemItem projectDir = sessionInfo.getActiveProjectDir();
if (state.isTutorial() && (projectDir != null)) {
if (!workbenchContext_.getCurrentWorkingDir().equalTo(projectDir)) {
server_.setWorkingDirectory(projectDir.getPath(), new VoidServerRequestCallback() {
@Override
protected void onSuccess() {
eventBus_.fireEvent(event);
}
});
} else {
eventBus_.fireEvent(event);
}
} else {
eventBus_.fireEvent(event);
}
}
Aggregations