Package org.rstudio.core.client.files

Examples of org.rstudio.core.client.files.FileSystemItem


               // if we're starting with an absolute path
               if (document != null &&
                   option.getValue() != null &&
                   FilePathUtils.pathIsAbsolute(option.getValue()))
               {
                  FileSystemItem selFile =
                        FileSystemItem.createFile(option.getValue());
                  // this will be null if no relative path can be found; if
                  // this is the case, we'll use the absolute path as-is
                  String relativePath =
                        selFile.getPathRelativeTo(document.getParentPath());
                  addOption(optionList, option.getOption(),
                            relativePath == null ? option.getValue() :
                                                   relativePath);
               }
               else
View Full Code Here


      };
   }
  
   private boolean isMarkdownFile(String file)
   {
      FileSystemItem fsi = FileSystemItem.createFile(file);
      FileTypeRegistry ftReg = RStudioGinjector.INSTANCE.getFileTypeRegistry();
      FileType fileType = ftReg.getTypeForFile(fsi);
      return (fileType != null) &&
             (fileType.equals(FileTypeRegistry.MARKDOWN) ||
              fileType.equals(FileTypeRegistry.RMARKDOWN));
View Full Code Here

   @Handler
   public void onSaveHtmlPreviewAsLocalFile()
   {
      if (lastSuccessfulPreview_ != null)
      {
         final FileSystemItem htmlFile = FileSystemItem.createFile(
                                       lastSuccessfulPreview_.getHtmlFile());
         pFileExport_.get().export("Download to Local File",
                                   "web page",
                                   htmlFile);
      }
View Full Code Here

   @Handler
   public void onSaveHtmlPreviewAs()
   {
      if (lastSuccessfulPreview_ != null)
      {
         FileSystemItem defaultDir = savePreviewDir_ != null ?
               FileSystemItem.createDir(savePreviewDir_) :
               FileSystemItem.home();
        
         final FileSystemItem sourceFile = FileSystemItem.createFile(
                                          lastSuccessfulPreview_.getHtmlFile());
        
         FileSystemItem initialFilePath =
            FileSystemItem.createFile(defaultDir.completePath(
                                                         sourceFile.getStem()));
        
         fileDialogs_.saveFile(
            "Save File As",
View Full Code Here

      if (title.length() == 0)
      {
         String htmlFile = getHtmlFile();
         if (htmlFile != null)
         {
            FileSystemItem fsi = FileSystemItem.createFile(htmlFile);
            return fsi.getStem();
         }
         else
         {
            return "(Untitled)";
         }
View Full Code Here

               display_.getSearchOracle().navigationTargetFromSuggestion(
                                                event.getSelectedItem());
             
            // create full file path and position
            String srcFile = target.getFile();
            final FileSystemItem srcItem = FileSystemItem.createFile(srcFile);
            final FilePosition pos = target.getPosition()
           
            // fire editing event (delayed so the Enter keystroke
            // doesn't get routed into the source editor)
            Scheduler.get().scheduleDeferred(new ScheduledCommand() {
               @Override
               public void execute()
               {
                  display_.getSearchDisplay().clear();
                  display_.getSearchOracle().clear();

                  if (observer_ != null)
                     observer_.onCompleted();
                 
                  fileTypeRegistry.editFile(srcItem, pos);
               }
            });
         }
      });
     
      searchDisplay.addCloseHandler(new CloseHandler<SearchDisplay>() {
         @Override
         public void onClose(CloseEvent<SearchDisplay> event)
         {
            display_.getSearchDisplay().clear();
           
            if (observer_ != null)
              observer_.onCancel();
         }
      });
    
     // various conditions invalidate the search oracle's cache
     
     searchDisplay.addBlurHandler(new BlurHandler() {
         @Override
         public void onBlur(BlurEvent event)
         {
            display_.getSearchOracle().clear();
         }
     });

    
     searchDisplay.addFocusHandler(new FocusHandler() {
        @Override
        public void onFocus(FocusEvent event)
        {
           display_.getSearchOracle().clear();
        }
     });
    
     eventBusHandlers_.add(
           eventBus.addHandler(FileChangeEvent.TYPE, new FileChangeHandler() {
        @Override
        public void onFileChange(FileChangeEvent event)
        {          
           // if this was an R file then invalide the cache
           CodeSearchOracle oracle = display_.getSearchOracle();
           if (oracle.hasCachedResults())
           {
              FileSystemItem fsi = event.getFileChange().getFile();
              if (fsi.getExtension().toLowerCase().equals(".r"))
                 oracle.clear();
           }
        }
     }));
    
View Full Code Here

               for (int i = 0; i<fileResults.size(); i++)
                  suggestions.add(new CodeSearchSuggestion(fileResults.get(i)))
              
              
               // src results
               FileSystemItem context = workbenchContext_.getActiveProjectDir();
               ArrayList<SourceItem> srcResults =
                                    response.getSourceItems().toArrayList();
               for (int i = 0; i<srcResults.size(); i++)
               {
                  suggestions.add(
View Full Code Here

      String filename = fileNameTextBox.getText().trim();
      if (filename.length() == 0)
         return null;
     
      // compute the target path
      FileSystemItem targetPath = FileSystemItem.createFile(
                                          directory.completePath(filename));
     
      // if the extension isn't already correct then append it
      if (!targetPath.getExtension().equalsIgnoreCase(ext))
         targetPath = FileSystemItem.createFile(targetPath.getPath() + ext);
     
      // return the path
      return targetPath;
   }
View Full Code Here

   {
      // get plot format
      final String format = saveAsTarget_.getFormat();
     
      // validate path
      FileSystemItem targetPath = saveAsTarget_.getTargetPath();
      if (targetPath == null)
      {
         globalDisplay_.showErrorMessage(
            "File Name Required",
            "You must provide a file name for the plot image.",
View Full Code Here

   @Override
   public void showSourceForFrame(ErrorFrame frame)
   {
      if (events_ == null)
         return;
      FileSystemItem sourceFile = FileSystemItem.createFile(
            frame.getFileName());
      events_.fireEvent(new OpenSourceFileEvent(sourceFile,
                             FilePosition.create(
                                   frame.getLineNumber(),
                                   frame.getCharacterNumber()),
View Full Code Here

TOP

Related Classes of org.rstudio.core.client.files.FileSystemItem

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.