private void saveFileAs() { fileDialogs_.saveFile( "Save File - " + targetFile_.getName(), fileContext_, FileSystemItem.createFile( session_.getSessionInfo().getActiveProjectDir().completePath(targetFile_.getName())), targetFile_.getExtension(), false, new ProgressOperationWithInput<FileSystemItem>() { @Override public void execute(FileSystemItem input, ProgressIndicator indicator) { if (input == null) { indicator.onCompleted(); return; } indicator.onProgress("Saving file..."); server_.gitExportFile( commitId_, targetFile_.getPath(), input.getPath(), new VoidServerRequestCallback(indicator)); } }); }
public final FileSystemItem getActiveProjectDir() { String projFile = getActiveProjectFile(); if (projFile != null) { return FileSystemItem.createFile(projFile).getParentPath(); } else { return null; } }
private String buildSwitchMessage(String switchToProject) { String msg = !switchToProject.equals("none") ? "Switching to project " + FileSystemItem.createFile(switchToProject).getParentPathString() : "Closing project"; return msg + "..."; }
@Override public void onOpenProjectNewWindow(OpenProjectNewWindowEvent event) { // call the desktop to open the project (since it is // a conventional foreground gui application it has // less chance of running afowl of desktop app creation // & activation restrictions) FileSystemItem project = FileSystemItem.createFile(event.getProject()); if (Desktop.isDesktop()) Desktop.getFrame().openProjectInNewWindow(project.getPath()); else serverOpenProjectInNewWindow(project, null); }
void openFile(String filePath) { // get the file system item FileSystemItem file = FileSystemItem.createFile(filePath); // don't open directories (these can sneak in if the user // passes a directory on the command line) if (!file.isDirectory()) { // open the file. pass false for second param to prevent // the default handler (the browser) from taking it fileTypeRegistry_.openFile(file, false); } }
private void sendDefaultWorkspaceCommandToConsole(String command) { String renvPath = workbenchContext_.getREnvironmentPath(); consoleDispatcher_.executeCommand(command, FileSystemItem.createFile(renvPath)); }
// rebuilds the popup menu--this can happen when the menu is invoked; it can // also happen when the button is created if we're aggressively checking // publish status private void rebuildPopupMenu(final ToolbarPopupMenu.DynamicPopupMenuCallback callback) { final ToolbarPopupMenu menu = publishMenu_; // prevent reentrancy if (populating_) { if (callback != null) callback.onPopupMenu(menu); return; } // handle case where we don't have a content path (i.e. plots) if (contentPath_ == null) { setPreviousDeployments(null); if (callback != null) callback.onPopupMenu(menu); return; } // avoid populating if we've already set the deployments for this path // (unless we're forcefully repopulating) if (populatedPath_ != null && populatedPath_.equals(contentPath_)) { if (callback != null) callback.onPopupMenu(menu); return; } String contentPath = contentPath_; boolean parent = false; // if this is a Shiny application and an .R file is being invoked, check // for deployments of its parent path (single-file apps have // CONTENT_TYPE_APP_SINGLE and their own deployment records) if (contentType_ == RSConnect.CONTENT_TYPE_APP && StringUtil.getExtension(contentPath_).equalsIgnoreCase("r")) parent = true; // if this is a document in a website, use the parent path if (contentType_ == RSConnect.CONTENT_TYPE_WEBSITE) parent = true; // apply parent path if needed if (parent) { FileSystemItem fsiContent = FileSystemItem.createFile(contentPath_); contentPath = fsiContent.getParentPathString(); } populating_ = true; server_.getRSConnectDeployments( contentPath, outputPath_ == null ? "" : outputPath_, new ServerRequestCallback<JsArray<RSConnectDeploymentRecord>>() { @Override public void onResponseReceived(JsArray<RSConnectDeploymentRecord> recs) { populatedPath_ = contentPath_; populating_ = false; // if publishing a website but not content, filter deployments // that are static (as we can't update them) if (contentType_ == RSConnect.CONTENT_TYPE_WEBSITE && (docPreview_ == null || StringUtil.isNullOrEmpty(docPreview_.getOutputFile()))) { JsArray<RSConnectDeploymentRecord> codeRecs = JsArray.createArray().cast(); for (int i = 0; i < recs.length(); i++) { if (!recs.get(i).getAsStatic()) codeRecs.push(recs.get(i)); } recs = codeRecs; } setPreviousDeployments(recs); if (callback != null) callback.onPopupMenu(menu); } @Override public void onError(ServerError error) { populating_ = false; if (callback != null) callback.onPopupMenu(menu); } }); }