Пример #1
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;
    }
  } // }}}
Пример #2
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);
    } // }}}
Пример #3
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);
    }
Пример #4
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;
    }
Пример #5
0
 public int compare(Object obj1, Object obj2) {
   return StandardUtilities.compareStrings(((Button) obj1).label, ((Button) obj2).label, true);
 }