Free cookie consent management tool by TermsFeed Policy Generator

Changeset 37


Ignore:
Timestamp:
03/04/08 15:16:51 (17 years ago)
Author:
gkronber
Message:
  • fixed #37. Assemblies that have missing references (wrong versions) are also listed in the disabled plugins.
  • plugin-manager shows a message why a plugin has been disabled (see #8)
Location:
trunk/sources
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.PluginInfrastructure.GUI/ManagerForm.cs

    r29 r37  
    310310      allAvailablePlugins.ForEach(delegate(PluginDescription availablePlugin) {
    311311        List<PluginTag> oldPlugins = allTags.FindAll(delegate(PluginTag currentPlugin) {
    312           return currentPlugin.PluginName == availablePlugin.Name && currentPlugin.State == (PluginState.Installed | PluginState.Disabled);
     312          return currentPlugin.PluginName == availablePlugin.Name &&
     313            (currentPlugin.State & (PluginState.Installed | PluginState.Disabled)) !=0;
    313314        });
    314315
     
    330331        });
    331332
    332         if(currentPlugins.Count == 1) {
    333           if(currentPlugins[0].PluginVersion < availablePlugin.Version) {
    334             overrides.Add(availablePlugin);
    335           }
     333        if(currentPlugins.Count == 1 && currentPlugins[0].PluginVersion < availablePlugin.Version) {
     334          overrides.Add(availablePlugin);
    336335        }
    337336      });
     
    584583
    585584    private void UpdateActionButtons(PluginTag tag) {
    586 
    587585      publishButton.Enabled = (tag.State & PluginState.Installed) == PluginState.Installed;
    588586      installButton.Enabled = (tag.State & PluginState.Available) == PluginState.Available;
     
    597595      installMenuItem.Checked = installButton.Checked;
    598596      deleteMenuItem.Checked = deleteButton.Checked;
    599 
    600597    }
    601598
     
    634631      return nodes;
    635632    }
    636 
    637 
    638 
    639633    private void DisplayPluginInfo(string pluginInformation) {
    640634      infoTextBox.Text = pluginInformation;
    641635    }
    642 
    643 
    644636    private void upgradeButton_Click(object sender, EventArgs args) {
    645637      try {
     
    683675      });
    684676    }
    685 
    686 
    687677    private List<string> upgradedPlugins = new List<string>();
    688678    private void OnPreUpgradePlugins() {
     
    697687      });
    698688    }
    699 
    700689    private void OnPostUpgradePlugins() {
    701690      allTags.ForEach(delegate(PluginTag tag) {
     
    706695      upgradedPlugins.Clear();
    707696    }
    708 
    709697    /// <summary>
    710698    /// Deletes all files in the directories cacheDir, backupDir, tempDir
  • trunk/sources/HeuristicLab.PluginInfrastructure.GUI/PluginTag.cs

    r29 r37  
    8585    }
    8686
     87    private string message;
     88    public string Message {
     89      get { return message; }
     90    }
     91
    8792    public List<PluginTag> hull = new List<PluginTag>();
    8893
     
    9499      this.pluginName = plugin.Name;
    95100      this.pluginVersion = plugin.Version;
     101      this.message = plugin.Message;
    96102      pluginDetails = GeneratePluginDetails(plugin);
    97103      pluginDependencies = GeneratePluginDependencies(plugin);
     
    125131        dependents += dependentPlugin.Name + " (" + dependentPlugin.Version + ")\n";
    126132      });
    127       return "plugin: " + plugin.Name + "\n" +
     133      return "Plugin: " + plugin.Name + "\n" +
    128134      "Version: " + plugin.Version + "\n\n" +
    129       "Requires: \n" + dependencies + "\n" +
    130       "Used by:\n" + dependents + "\n" +
    131       "Files:\n" + filenames + "\n";
     135      (dependencies.Length != 0 ? "Requires: \n" + dependencies + "\n" : "") +
     136      (dependents.Length != 0 ? "Used by:\n" + dependents + "\n" : "") +
     137      (filenames.Length != 0 ? "Files:\n" + filenames + "\n" : "") + message;
     138      ;
    132139    }
    133140
  • trunk/sources/HeuristicLab.PluginInfrastructure/Loader.cs

    r29 r37  
    7575
    7676    private IPlugin FindPlugin(PluginInfo plugin) {
    77       return allPlugins[plugin];
     77      if(allPlugins.ContainsKey(plugin)) {
     78        return allPlugins[plugin];
     79      } else return null;
    7880    }
    7981
     
    9092    /// </summary>
    9193    internal void Init() {
    92       AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += delegate(object sender, ResolveEventArgs args) { return Assembly.ReflectionOnlyLoad(args.Name); };
     94      AppDomain.CurrentDomain.ReflectionOnlyAssemblyResolve += delegate(object sender, ResolveEventArgs args) {
     95        try {
     96          return Assembly.ReflectionOnlyLoad(args.Name);
     97        } catch(FileLoadException ex) {
     98          return null;
     99        }
     100        };
    93101      allPlugins.Clear();
    94102      disabledPlugins.Clear();
     
    150158            }
    151159          }
    152         } catch(FileNotFoundException) {
    153           // when a referenced assembly cannot be loaded then ignore this assembly in the plugin discovery
     160        } catch(FileNotFoundException ex) {
     161          PluginInfo info = new PluginInfo();
     162          AssemblyName name = assembly.GetName();
     163          info.Name = name.Name;
     164          info.Version = name.Version;
     165          info.Assemblies.Add(assembly.FullName);
     166          info.Files.Add(assembly.Location);
     167          info.Message = "File not found: " + ex.FileName;
     168          disabledPlugins.Add(info);
     169        } catch(FileLoadException ex) {
     170          PluginInfo info = new PluginInfo();
     171          AssemblyName name = assembly.GetName();
     172          info.Name = name.Name;
     173          info.Version = name.Version;
     174          info.Files.Add(assembly.Location);
     175          info.Assemblies.Add(assembly.FullName);
     176          info.Message = "Couldn't load file: " + ex.FileName;
     177          disabledPlugins.Add(info);
    154178        }
    155179      }
     
    208232        PluginInfo info = new PluginInfo();
    209233        info.Name = pluginName;
     234        info.Version = t.Assembly.GetName().Version;
    210235        info.Assemblies = pluginAssemblies;
    211236        info.Files.AddRange(pluginFiles);
     
    226251        visitedDependencies.Clear();
    227252        if(!CheckPluginDependencies(pluginInfo.Name)) {
     253          PluginInfo matchingInfo = preloadedPluginInfos.Find(delegate(PluginInfo info) { return info.Name == pluginInfo.Name; });
     254          if(matchingInfo == null) throw new InvalidProgramException(); // shouldn't happen
     255          foreach(string dependency in pluginDependencies[matchingInfo]) {
     256            PluginInfo dependencyInfo = new PluginInfo();
     257            dependencyInfo.Name = dependency;
     258            pluginInfo.Dependencies.Add(dependencyInfo);
     259          }
     260
     261          pluginInfo.Message = "Disabled: missing plugin dependency.";
    228262          disabledPlugins.Add(pluginInfo);
    229263        }
     
    325359      foreach(PluginInfo plugin in preloadedPluginInfos) {
    326360        if(!CheckPluginFiles(plugin)) {
     361          plugin.Message = "Disabled: missing plugin file.";
    327362          disabledPlugins.Add(plugin);
    328363        }
     
    348383
    349384    internal void OnDelete(PluginInfo pluginInfo) {
    350       FindPlugin(pluginInfo).OnDelete();
     385      IPlugin plugin = FindPlugin(pluginInfo);
     386      if(plugin!=null) plugin.OnDelete();
    351387    }
    352388
    353389    internal void OnInstall(PluginInfo pluginInfo) {
    354       FindPlugin(pluginInfo).OnInstall();
     390      IPlugin plugin = FindPlugin(pluginInfo);
     391      if(plugin != null) plugin.OnInstall();
    355392    }
    356393
    357394    internal void OnPreUpdate(PluginInfo pluginInfo) {
    358       FindPlugin(pluginInfo).OnPreUpdate();
     395      IPlugin plugin = FindPlugin(pluginInfo);
     396      if(plugin != null) plugin.OnPreUpdate();
    359397    }
    360398
    361399    internal void OnPostUpdate(PluginInfo pluginInfo) {
    362       FindPlugin(pluginInfo).OnPostUpdate();
     400      IPlugin plugin = FindPlugin(pluginInfo);
     401      if(plugin != null) plugin.OnPostUpdate();
    363402    }
    364403  }
  • trunk/sources/HeuristicLab.PluginInfrastructure/PluginInfo.cs

    r29 r37  
    6868    }
    6969
     70
     71    private string message;
     72    public string Message {
     73      get { return message; }
     74      set { message = value; }
     75    }
     76
    7077    public override string ToString() {
    7178      return Name;
Note: See TracChangeset for help on using the changeset viewer.