/**
  * Refreshes the local version field on the modules in <code>modules</code> with the version in
  * the manifest of the downloaded "jar.new"-file for this module.
  *
  * @param modules the collections of modules to refresh
  */
 public void refreshLocalModuleVersion(Collection<ModuleInformation> modules) {
   if (modules == null) return;
   File moduleDir = OdPlugin.getInstance().getModulesDirectory();
   for (ModuleInformation pi : modules) {
     // Find the downloaded file. We have tried to install the downloaded modules
     // (ModuleHandler.installDownloadedModules). This succeeds depending on the
     // platform.
     File downloadedModuleFile = new File(moduleDir, pi.name + ".jar.new");
     if (!(downloadedModuleFile.exists() && downloadedModuleFile.canRead())) {
       downloadedModuleFile = new File(moduleDir, pi.name + ".jar");
       if (!(downloadedModuleFile.exists() && downloadedModuleFile.canRead())) {
         continue;
       }
     }
     try {
       ModuleInformation newinfo = new ModuleInformation(downloadedModuleFile, pi.name);
       ModuleInformation oldinfo = getModuleInformation(pi.name);
       if (oldinfo == null) {
         // should not happen
         continue;
       }
       oldinfo.localversion = newinfo.version;
     } catch (ModuleException e) {
       e.printStackTrace();
     }
   }
 }
 protected void updateAvailableModule(ModuleInformation other) {
   if (other == null) return;
   ModuleInformation pi = getModuleInformation(other.name);
   if (pi == null) {
     availableModules.add(other);
     return;
   }
   pi.updateFromModuleSite(other);
 }
 /**
  * Sets whether the module is selected or not.
  *
  * @param name the name of the module
  * @param selected true, if selected; false, otherwise
  */
 public void setModuleSelected(String name, boolean selected) {
   ModuleInformation pi = getModuleInformation(name);
   if (pi != null) {
     selectedModulesMap.put(pi, selected);
     if (pi.isUpdateRequired()) {
       pendingDownloads.add(pi.name);
     }
   }
   if (!selected) {
     pendingDownloads.remove(name);
   }
 }
 public void filterDisplayedModules(String filter) {
   if (filter == null) {
     displayedModules.clear();
     displayedModules.addAll(availableModules);
     this.filterExpression = null;
     return;
   }
   displayedModules.clear();
   for (ModuleInformation pi : availableModules) {
     if (pi.matches(filter)) {
       displayedModules.add(pi);
     }
   }
   filterExpression = filter;
   clearChanged();
   notifyObservers();
 }
 /**
  * Replies the module info with the name <code>name</code>. null, if no such module info exists.
  *
  * @param name the name. If null, replies null.
  * @return the module info.
  */
 public ModuleInformation getModuleInformation(String name) {
   for (ModuleInformation pi : availableModules) {
     if (pi.getName() != null && pi.getName().equals(name)) return pi;
   }
   return null;
 }