Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/21/10 18:36:15 (14 years ago)
Author:
epitzer
Message:

Group assemblies by plugin and replace assembly and namespace list boxes with tree views (#842)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Operators.Programmable/3.2/ProgrammableOperator.cs

    r2660 r2668  
    3535using System.Data.Linq;
    3636using System.Xml.XPath;
     37using HeuristicLab.PluginInfrastructure;
    3738
    3839namespace HeuristicLab.Operators.Programmable {
     
    6566    private object syncRoot = new object();
    6667
     68    public readonly Dictionary<string, List<Assembly>> Plugins;
     69
    6770    protected Dictionary<Assembly, bool> Assemblies;
    6871    public IEnumerable<Assembly> AvailableAssemblies {
     
    8487
    8588    public void SelectAssembly(Assembly a) {
    86       Assemblies[a] = true;
     89      if (a != null && Assemblies.ContainsKey(a))
     90        Assemblies[a] = true;
    8791    }
    8892
    8993    public void UnselectAssembly(Assembly a) {
    90       Assemblies[a] = false;
     94      if (a != null && Assemblies.ContainsKey(a))
     95        Assemblies[a] = false;
    9196    }
    9297
     
    132137      Assemblies = DiscoverAssemblies();
    133138      namespaces = new HashSet<string>(DiscoverNamespaces());
     139      Plugins = GroupAssemblies();
     140    }
     141
     142    private Dictionary<string, List<Assembly>> GroupAssemblies() {
     143      var plugins = new Dictionary<string, List<Assembly>>();
     144      var assemblyNames = Assemblies.ToDictionary(a => a.Key.Location, a => a.Key);
     145      foreach (var plugin in ApplicationManager.Manager.Plugins) {
     146        var aList = new List<Assembly>();
     147        foreach (var aName in plugin.Assemblies) {
     148          Assembly a;
     149          assemblyNames.TryGetValue(aName, out a);
     150          if (a != null) {
     151            aList.Add(a);
     152            assemblyNames.Remove(aName);
     153          }
     154        }
     155        plugins[plugin.Name] = aList;
     156      }
     157      plugins["other"] = assemblyNames.Values.ToList();
     158      return plugins;
    134159    }
    135160
     
    248273      foreach (var ns in Namespaces)
    249274        if (possibleNamespaces.Contains(ns))
    250           yield return ns;     
     275          yield return ns;
    251276    }
    252277
Note: See TracChangeset for help on using the changeset viewer.