Search in sources :

Example 86 with FileSystemItem

use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.

the class TextEditingTarget method isPackageDocumentationFile.

private boolean isPackageDocumentationFile() {
    if (getPath() == null) {
        return false;
    }
    String type = session_.getSessionInfo().getBuildToolsType();
    if (!type.equals(SessionInfo.BUILD_TOOLS_PACKAGE)) {
        return false;
    }
    FileSystemItem srcFile = FileSystemItem.createFile(getPath());
    FileSystemItem projectDir = session_.getSessionInfo().getActiveProjectDir();
    if (srcFile.getPath().startsWith(projectDir.getPath() + "/vignettes"))
        return true;
    else if (srcFile.getParentPathString().equals(projectDir.getPath()) && srcFile.getExtension().toLowerCase().equals(".md"))
        return true;
    else
        return false;
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) JsArrayString(com.google.gwt.core.client.JsArrayString)

Example 87 with FileSystemItem

use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.

the class TextEditingTarget method onClearKnitrCache.

@Handler
void onClearKnitrCache() {
    withSavedDoc(new Command() {

        @Override
        public void execute() {
            // determine the cache path (use relative path if possible)
            String path = docUpdateSentinel_.getPath();
            FileSystemItem fsi = FileSystemItem.createFile(path);
            path = fsi.getParentPath().completePath(fsi.getStem() + "_cache");
            String relativePath = FileSystemItem.createFile(path).getPathRelativeTo(workbenchContext_.getCurrentWorkingDir());
            if (relativePath != null)
                path = relativePath;
            final String docPath = path;
            globalDisplay_.showYesNoMessage(MessageDialog.QUESTION, "Clear Knitr Cache", "Clearing the Knitr cache will delete the cache " + "directory for " + docPath + ". " + "\n\nAre you sure you want to clear the cache now?", false, new Operation() {

                @Override
                public void execute() {
                    String code = "unlink(" + ConsoleDispatcher.escapedPath(docPath) + ", recursive = TRUE)";
                    events_.fireEvent(new SendToConsoleEvent(code, true));
                }
            }, null, true);
        }
    });
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) Command(com.google.gwt.user.client.Command) AppCommand(org.rstudio.core.client.command.AppCommand) SendToConsoleEvent(org.rstudio.studio.client.workbench.views.console.events.SendToConsoleEvent) JsArrayString(com.google.gwt.core.client.JsArrayString) CppCompletionOperation(org.rstudio.studio.client.workbench.views.source.editors.text.cpp.CppCompletionOperation) Handler(org.rstudio.core.client.command.Handler) ChangeFontSizeHandler(org.rstudio.studio.client.application.events.ChangeFontSizeHandler) RecordNavigationPositionHandler(org.rstudio.studio.client.workbench.views.source.events.RecordNavigationPositionHandler) EnsureHeightHandler(org.rstudio.core.client.events.EnsureHeightHandler) EnsureVisibleHandler(org.rstudio.core.client.events.EnsureVisibleHandler) HideMessageHandler(org.rstudio.studio.client.workbench.views.source.editors.text.status.StatusBar.HideMessageHandler) FileChangeHandler(org.rstudio.studio.client.workbench.views.files.events.FileChangeHandler)

Example 88 with FileSystemItem

use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.

the class TextEditingTarget method fireCompilePdfEvent.

private void fireCompilePdfEvent(String path, String encoding, String completedAction, boolean useInternalPreview) {
    // first validate the path to make sure it doesn't contain spaces
    FileSystemItem file = FileSystemItem.createFile(path);
    if (file.getName().indexOf(' ') != -1) {
        globalDisplay_.showErrorMessage("Invalid Filename", "The file '" + file.getName() + "' cannot be compiled to " + "a PDF because TeX does not understand paths with spaces. " + "If you rename the file to remove spaces then " + "PDF compilation will work correctly.");
        return;
    }
    CompilePdfEvent event = new CompilePdfEvent(compilePdfHelper_.getTargetFile(file), encoding, getSelectionAsSourceLocation(false), completedAction, useInternalPreview);
    events_.fireEvent(event);
}
Also used : FileSystemItem(org.rstudio.core.client.files.FileSystemItem) CompilePdfEvent(org.rstudio.studio.client.workbench.views.output.compilepdf.events.CompilePdfEvent)

Example 89 with FileSystemItem

use of org.rstudio.core.client.files.FileSystemItem in project rstudio by rstudio.

the class ViewerPresenter method onViewerSaveAsImage.

@Handler
public void onViewerSaveAsImage() {
    display_.bringToFront();
    final ProgressIndicator indicator = globalDisplay_.getProgressIndicator("Error");
    indicator.onProgress("Preparing to export plot...");
    // get the default directory
    FileSystemItem defaultDir = ExportPlotUtils.getDefaultSaveDirectory(workbenchContext_.getCurrentWorkingDir());
    // get context
    server_.getViewerExportContext(defaultDir.getPath(), new SimpleRequestCallback<SavePlotAsImageContext>() {

        @Override
        public void onResponseReceived(SavePlotAsImageContext context) {
            indicator.onCompleted();
            new SaveViewerPlotAsImageDesktopDialog(globalDisplay_, display_.getUrl(), context, ExportPlotOptions.adaptToSize(pUIPrefs_.get().exportViewerOptions().getValue(), display_.getViewerFrameSize()), saveExportOptionsOperation_).showModal();
        }

        @Override
        public void onError(ServerError error) {
            indicator.onError(error.getUserMessage());
        }
    });
}
Also used : SavePlotAsImageContext(org.rstudio.studio.client.workbench.exportplot.model.SavePlotAsImageContext) FileSystemItem(org.rstudio.core.client.files.FileSystemItem) ProgressIndicator(org.rstudio.core.client.widget.ProgressIndicator) ServerError(org.rstudio.studio.client.server.ServerError) SaveViewerPlotAsImageDesktopDialog(org.rstudio.studio.client.workbench.views.viewer.export.SaveViewerPlotAsImageDesktopDialog) EnabledChangedHandler(org.rstudio.core.client.command.EnabledChangedHandler) Handler(org.rstudio.core.client.command.Handler)

Aggregations

FileSystemItem (org.rstudio.core.client.files.FileSystemItem)89 ServerError (org.rstudio.studio.client.server.ServerError)18 ProgressIndicator (org.rstudio.core.client.widget.ProgressIndicator)16 JsArrayString (com.google.gwt.core.client.JsArrayString)14 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)10 Handler (org.rstudio.core.client.command.Handler)10 Command (com.google.gwt.user.client.Command)9 ArrayList (java.util.ArrayList)7 AppCommand (org.rstudio.core.client.command.AppCommand)7 VoidServerRequestCallback (org.rstudio.studio.client.server.VoidServerRequestCallback)6 TextFileType (org.rstudio.studio.client.common.filetypes.TextFileType)5 JsArray (com.google.gwt.core.client.JsArray)4 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)4 JSONString (com.google.gwt.json.client.JSONString)4 FilePosition (org.rstudio.core.client.FilePosition)4 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)4 EditingTarget (org.rstudio.studio.client.workbench.views.source.editors.EditingTarget)4 CodeBrowserEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.codebrowser.CodeBrowserEditingTarget)4 DataEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.data.DataEditingTarget)4 TextEditingTarget (org.rstudio.studio.client.workbench.views.source.editors.text.TextEditingTarget)4