// {{{ record() method
  private static void record(
      View view, String action, boolean replaceAction, boolean recordFileSet) {
    Macros.Recorder recorder = view.getMacroRecorder();

    if (recorder != null) {
      recorder.record(
          "SearchAndReplace.setSearchString(\""
              + StandardUtilities.charsToEscapes(search)
              + "\");");

      if (replaceAction) {
        recorder.record(
            "SearchAndReplace.setReplaceString(\""
                + StandardUtilities.charsToEscapes(replace)
                + "\");");
        recorder.record("SearchAndReplace.setBeanShellReplace(" + beanshell + ");");
      } else {
        // only record this if doing a find next
        recorder.record("SearchAndReplace.setAutoWrapAround(" + wrap + ");");
        recorder.record("SearchAndReplace.setReverseSearch(" + reverse + ");");
      }

      recorder.record("SearchAndReplace.setWholeWord(" + wholeWord + ");");
      recorder.record("SearchAndReplace.setIgnoreCase(" + ignoreCase + ");");
      recorder.record("SearchAndReplace.setRegexp(" + regexp + ");");

      if (recordFileSet) {
        recorder.record("SearchAndReplace.setSearchFileSet(" + fileset.getCode() + ");");
      }

      recorder.record("SearchAndReplace." + action + ';');
    }
  } // }}}
Пример #2
0
  // {{{ createCenterPanel() method
  public JPanel createCenterPanel() {
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd hh:mm");

    JPanel centerPanel = new JPanel(new BorderLayout());

    JPanel propField = new JPanel();
    propField.setLayout(new GridLayout(4, 1));
    propField.add(new JLabel(jEdit.getProperty("fileprop.name") + ": " + local.getName()));
    propField.add(new JLabel(jEdit.getProperty("fileprop.path") + ": " + local.getPath()));

    // Show last modified property only for LocalFile
    if (local instanceof LocalFile) {
      propField.add(
          new JLabel(
              jEdit.getProperty("fileprop.lastmod")
                  + ": "
                  + sdf.format(new Date(((LocalFile) local).getModified()))));
    }
    if (local.getType() == VFSFile.DIRECTORY) {
      File ioFile = new File(local.getPath());
      propField.add(
          new JLabel(
              jEdit.getProperty("fileprop.size")
                  + ": "
                  + StandardUtilities.formatFileSize(IOUtilities.fileLength(ioFile))));
    } else {
      propField.add(
          new JLabel(
              jEdit.getProperty("fileprop.size")
                  + ": "
                  + StandardUtilities.formatFileSize(local.getLength())));
    }
    Border etch = BorderFactory.createEtchedBorder();
    propField.setBorder(
        BorderFactory.createTitledBorder(etch, jEdit.getProperty("fileprop.properties")));
    centerPanel.add(BorderLayout.CENTER, propField);

    JPanel attributeField = new JPanel();
    attributeField.setLayout(new GridLayout(1, 2));
    readable = new JCheckBox(jEdit.getProperty("fileprop.readable"));
    readable.setSelected(local.isReadable());
    readable.setEnabled(false);
    attributeField.add(readable);

    write = new JCheckBox(jEdit.getProperty("fileprop.writeable"));
    write.setSelected(local.isWriteable());
    write.setEnabled(false);
    attributeField.add(write);
    attributeField.setBorder(
        BorderFactory.createTitledBorder(etch, jEdit.getProperty("fileprop.attribute")));
    centerPanel.add(BorderLayout.SOUTH, attributeField);

    return centerPanel;
  } // }}}
Пример #3
0
  private String getPrevOrNextFile(View view, String path, Direction direction) {
    if (files == null) files = _getFiles(view);

    if (files == null || files.length == 0) return null;

    if (path == null) {
      path = view.getBuffer().getSymlinkPath();
      VFS vfs = VFSManager.getVFSForPath(path);
      boolean ignoreCase = ((vfs.getCapabilities() & VFS.CASE_INSENSITIVE_CAP) != 0);

      for (int i = 0; i < files.length; i++) {
        if (StandardUtilities.compareStrings(files[i], path, ignoreCase) == 0) {
          return path;
        }
      }

      if (direction == Direction.NEXT) {
        return getFirstFile(view);
      } else {
        return getLastFile(view);
      }
    } else {
      // -1 so that the last isn't checked
      VFS vfs = VFSManager.getVFSForPath(path);
      boolean ignoreCase = ((vfs.getCapabilities() & VFS.CASE_INSENSITIVE_CAP) != 0);

      if (direction == Direction.NEXT
          && StandardUtilities.compareStrings(files[files.length - 1], path, ignoreCase) == 0) {
        // Going forward and already at the last file
        return null;
      } else if (direction == Direction.PREV
          && StandardUtilities.compareStrings(files[0], path, ignoreCase) == 0) {
        // Going backward and already at the first file
        return null;
      }

      for (int i = 0; i < files.length - 1; i++) {
        if (StandardUtilities.compareStrings(files[i], path, ignoreCase) == 0) {
          if (direction == Direction.NEXT) return files[i + 1];
          else {
            if (i == 0) return files[files.length - 1];
            return files[i - 1];
          }
        }
      }

      return null;
    }
  } // }}}
Пример #4
0
    // {{{ update() method
    public void update() {
      Set<String> savedChecked = new HashSet<String>();
      Set<String> savedSelection = new HashSet<String>();
      saveSelection(savedChecked, savedSelection);

      PluginList pluginList = window.getPluginList();

      if (pluginList == null) return;

      entries.clear();

      for (int i = 0; i < pluginList.pluginSets.size(); i++) {
        PluginList.PluginSet set = pluginList.pluginSets.get(i);
        for (int j = 0; j < set.plugins.size(); j++) {
          PluginList.Plugin plugin = pluginList.pluginHash.get(set.plugins.get(j));
          PluginList.Branch branch = plugin.getCompatibleBranch();
          String installedVersion = plugin.getInstalledVersion();
          if (updates) {
            if (branch != null
                && branch.canSatisfyDependencies()
                && installedVersion != null
                && StandardUtilities.compareStrings(branch.version, installedVersion, false) > 0) {
              entries.add(new Entry(plugin, set.name));
            }
          } else {
            if (installedVersion == null && plugin.canBeInstalled())
              entries.add(new Entry(plugin, set.name));
          }
        }
      }

      sort(sortType);
      updateFilteredEntries();
      restoreSelection(savedChecked, savedSelection);
    } // }}}
Пример #5
0
    public int compare(VFSFile file1, VFSFile file2) {
      if (!sortMixFilesAndDirs) {
        if (file1.getType() != file2.getType()) return file2.getType() - file1.getType();
      }

      return StandardUtilities.compareStrings(file1.getName(), file2.getName(), sortIgnoreCase);
    }
Пример #6
0
  // {{{createCenterPanelAll() method
  public JPanel createCenterPanelAll() {
    long filesSize = 0L;
    JPanel centerPanel = new JPanel(new BorderLayout());

    for (VFSFile selectedFile : selectedFiles) {
      if (selectedFile.getType() == VFSFile.DIRECTORY) {
        File ioFile = new File(selectedFile.getPath());
        filesSize += IOUtilities.fileLength(ioFile);
      } else if (selectedFile.getType() == VFSFile.FILE) filesSize += selectedFile.getLength();
    }

    JPanel propField = new JPanel();
    propField.setLayout(new GridLayout(2, 1));
    String path = local.getPath();
    if (OperatingSystem.isWindows()
        || OperatingSystem.isWindows9x()
        || OperatingSystem.isWindowsNT()) {
      path = path.substring(0, path.lastIndexOf(92)); // 92 = '\'
    } else {
      path = path.substring(0, path.lastIndexOf('/'));
    }
    propField.add(new JLabel(jEdit.getProperty("fileprop.path") + ": " + path));
    propField.add(
        new JLabel(
            jEdit.getProperty("fileprop.size")
                + ": "
                + StandardUtilities.formatFileSize(filesSize)));
    Border etch = BorderFactory.createEtchedBorder();
    propField.setBorder(
        BorderFactory.createTitledBorder(etch, jEdit.getProperty("fileprop.properties")));
    centerPanel.add(BorderLayout.CENTER, propField);

    return centerPanel;
  } // }}}
Пример #7
0
    @Override
    public int compare(Entry e1, Entry e2) {
      int result;

      switch (type) {
        case COLUMN_INSTALL:
          result = (e1.install == e2.install) ? 0 : (e1.install ? 1 : -1);
          break;
        case COLUMN_NAME:
          result = e1.name.compareToIgnoreCase(e2.name);
          break;
        case COLUMN_CATEGORY:
          result = e1.set.compareToIgnoreCase(e2.set);
          if (result == 0) {
            result = e1.name.compareToIgnoreCase(e2.name);
          }
          break;
        case COLUMN_VERSION:
          // lets avoid NPE. Maybe we should move
          // this code to StandardUtilities.compareStrings
          if (e1.version == e2.version) {
            result = 0;
          } else if (e1.version == null) {
            result = -1;
          } else if (e2.version == null) {
            result = 1;
          } else {
            result = StandardUtilities.compareStrings(e1.version, e2.version, true);
          }
          break;
        case COLUMN_SIZE:
          result = (e1.size < e2.size) ? -1 : ((e1.size == e2.size) ? 0 : 1);
          break;
        case COLUMN_RELEASE:
          result = (e1.timestamp < e2.timestamp) ? -1 : ((e1.timestamp == e2.timestamp) ? 0 : 1);
          break;
        default:
          result = 0;
      }
      return result * sortDirection;
    }
Пример #8
0
  // {{{ invokeReadNextChar() method
  protected void invokeReadNextChar(char ch) {
    JEditBuffer buffer = view.getBuffer();

    /* if(buffer.insideCompoundEdit())
    buffer.endCompoundEdit(); */

    String charStr = StandardUtilities.charsToEscapes(String.valueOf(ch));

    // this might be a bit slow if __char__ occurs a lot
    int index;
    while ((index = readNextChar.indexOf("__char__")) != -1) {
      readNextChar =
          readNextChar.substring(0, index)
              + '\''
              + charStr
              + '\''
              + readNextChar.substring(index + 8);
    }

    Macros.Recorder recorder = view.getMacroRecorder();
    if (recorder != null) recorder.record(getRepeatCount(), readNextChar);

    view.getStatus().setMessage(null);

    if (getRepeatCount() != 1) {
      try {
        buffer.beginCompoundEdit();

        BeanShell.eval(
            view,
            BeanShell.getNameSpace(),
            "for(int i = 1; i < " + getRepeatCount() + "; i++)\n{\n" + readNextChar + "\n}");
      } finally {
        buffer.endCompoundEdit();
      }
    } else BeanShell.eval(view, BeanShell.getNameSpace(), readNextChar);

    readNextChar = null;
  } // }}}
Пример #9
0
  // {{{ loadColors() method
  private static void loadColors() {
    synchronized (lock) {
      colors = new ArrayList<ColorEntry>();

      if (!jEdit.getBooleanProperty("vfs.browser.colorize")) return;

      String glob;
      int i = 0;
      while ((glob = jEdit.getProperty("vfs.browser.colors." + i + ".glob")) != null) {
        try {
          colors.add(
              new ColorEntry(
                  Pattern.compile(StandardUtilities.globToRE(glob)),
                  jEdit.getColorProperty("vfs.browser.colors." + i + ".color", Color.black)));
        } catch (PatternSyntaxException e) {
          Log.log(Log.ERROR, VFS.class, "Invalid regular expression: " + glob);
          Log.log(Log.ERROR, VFS.class, e);
        }

        i++;
      }
    }
  } // }}}
Пример #10
0
 public int calculateIndent(JEditBuffer buffer, int line, int oldIndent, int newIndent) {
   int current =
       StandardUtilities.getLeadingWhiteSpaceWidth(
           buffer.getLineSegment(line), buffer.getTabSize());
   return (current < newIndent) ? current : newIndent;
 }
Пример #11
0
 /**
  * Escapes characters with special meaning in a regexp.
  *
  * @param str the string to escape
  * @param multiline Should \n be escaped?
  * @return the string with escaped characters
  * @since jEdit 4.3pre1
  */
 public static String escapeRegexp(String str, boolean multiline) {
   return StandardUtilities.charsToEscapes(str, "\r\t\\()[]{}$^*+?|." + (multiline ? "" : "\n"));
 } // }}}
Пример #12
0
 public int compare(Object obj1, Object obj2) {
   return StandardUtilities.compareStrings(((Button) obj1).label, ((Button) obj2).label, true);
 }