示例#1
0
  // RStudio-specific code should use FileTypeRegistry.getIconForFile() instead
  public final ImageResource getIcon() {
    if (isDirectory()) {
      if (isPublicFolder()) return RES.iconPublicFolder();
      else return RES.iconFolder();
    }

    Match m = EXT_PATTERN.match(getName(), 0);
    if (m == null) return RES.iconText();

    String lowerExt = m.getValue().toLowerCase();
    if (lowerExt.equals(".csv")) {
      return RES.iconCsv();
    } else if (lowerExt.equals(".pdf")) {
      return RES.iconPdf();
    } else if (lowerExt.equals(".jpg")
        || lowerExt.equals(".jpeg")
        || lowerExt.equals(".gif")
        || lowerExt.equals(".bmp")
        || lowerExt.equals(".tiff")
        || lowerExt.equals(".tif")
        || lowerExt.equals(".png")) {
      return RES.iconPng();
    } else {
      return RES.iconText();
    }
  }
示例#2
0
  private boolean isRunnableChunk(Element el, AceEditorNative editor) {
    Position pos = toDocumentPosition(el, editor);
    String text = editor.getSession().getLine(pos.getRow());

    Pattern pattern = Pattern.create("engine\\s*=\\s*['\"]([^'\"]*)['\"]", "");
    Match match = pattern.match(text, 0);

    if (match == null) return true;

    String engine = match.getGroup(1).toLowerCase();

    return engine.equals("r") || engine.equals("rscript");
  }
示例#3
0
 public boolean moveSelectionToNextLine(boolean skipBlankLines) {
   int curRow = getSession().getSelection().getCursor().getRow();
   while (++curRow < getSession().getLength()) {
     String line = getSession().getLine(curRow);
     Pattern pattern = Pattern.create("[^\\s]");
     Match match = pattern.match(line, 0);
     if (skipBlankLines && match == null) continue;
     int col = (match != null) ? match.getIndex() : 0;
     getSession().getSelection().moveCursorTo(curRow, col, false);
     getSession().unfold(curRow, true);
     return true;
   }
   return false;
 }