Free cookie consent management tool by TermsFeed Policy Generator

Changeset 11


Ignore:
Timestamp:
02/20/08 13:15:31 (17 years ago)
Author:
gkronber
Message:

fixed #22 by moving the code that creates tree-nodes for availablePlugins into the InitPlugins method

Location:
trunk/sources
Files:
2 edited

Legend:

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

    r10 r11  
    3737    private TreeNode availablePlugins;
    3838    private TreeNode allPlugins;
    39 
    4039    private List<PluginTag> allTags = new List<PluginTag>();
    4140    private Dictionary<PluginTag, PluginAction> actions = new Dictionary<PluginTag, PluginAction>();
    42 
     41    private List<PluginDescription> allAvailablePlugins = new List<PluginDescription>();
    4342    private string pluginDir = Application.StartupPath + "/" + HeuristicLab.PluginInfrastructure.GUI.Properties.Settings.Default.PluginDir;
    4443    private string cacheDir = Application.StartupPath + "/" + HeuristicLab.PluginInfrastructure.GUI.Properties.Settings.Default.CacheDir;
     
    4847    public ManagerForm() {
    4948      InitializeComponent();
    50 
    5149      InitializePlugins();
    5250    }
    5351
    5452    private void InitializePlugins() {
    55 
    5653      pluginTreeView.Nodes.Clear();
    5754      allTags.Clear();
     
    10299      }
    103100
    104       // TASK populate the "inactive plugins" node by reading a list of inactive plugins from the PluginManager
     101      allAvailablePlugins = FilterMostRecentPluginVersions(allAvailablePlugins);
     102      // find all plugins that are installed for which a new version is available
     103      List<PluginDescription> upgrades = FindUpgrades(allTags, allAvailablePlugins);
     104      // find all available plugins that are not installed and new (= new name not new version) since the last update
     105      List<PluginDescription> newPlugins = FindNewPlugins(allTags, allAvailablePlugins);
     106      // find all plugins that are available (not installed) for which a new version has been released since the last update
     107      List<PluginDescription> overridingPlugins = FindOverridingPlugins(allTags, allAvailablePlugins);
     108      newPlugins.ForEach(delegate(PluginDescription plugin) {
     109        PluginTag tag = new PluginTag(allTags, plugin, PluginState.Available);
     110        allTags.Add(tag);
     111        TreeNode node = new TreeNode(plugin.Name);
     112        node.ContextMenuStrip = pluginContextMenuStrip;
     113        node.Tag = tag;
     114        node.ImageIndex = 0;
     115        allPlugins.Nodes.Add(node);
     116        TreeNode availableNode = new TreeNode(plugin.Name);
     117        availableNode.ContextMenuStrip = pluginContextMenuStrip;
     118        availableNode.Tag = tag;
     119        availablePlugins.Nodes.Add(availableNode);
     120
     121      });
     122      upgrades.ForEach(delegate(PluginDescription upgrade) {
     123        // find the installed plugins that have the same name
     124        List<PluginTag> oldPlugins = allTags.FindAll(delegate(PluginTag tag) {
     125          return tag.PluginName == upgrade.Name;
     126        });
     127        PluginTag oldPlugin = oldPlugins[0];
     128        // store the upgrade in the old plugin
     129        oldPlugin.UpgradePluginDescription = upgrade;
     130        UpdateTreeNodes(oldPlugins);
     131      });
     132      overridingPlugins.ForEach(delegate(PluginDescription overridingPlugin) {
     133        List<PluginTag> currentPlugins = allTags.FindAll(delegate(PluginTag tag) {
     134          return tag.PluginName == overridingPlugin.Name;
     135        });
     136        PluginTag currentPlugin = currentPlugins[0];
     137        // replace the plugin description of the available plugin to point to the overriding plugin
     138        currentPlugin.PluginDescription = overridingPlugin;
     139      });
     140      RebuildActionHulls();
    105141    }
    106142
     
    111147
    112148    private void publishButton_Click(object sender, EventArgs args) {
    113 
    114149      PluginInfo plugin = ((PluginTag)pluginTreeView.SelectedNode.Tag).Plugin;
    115 
    116150      try {
    117151        string packageFileName = plugin.Name + "-" + plugin.Version + ".zip";
     
    128162        zipFile.CommitUpdate();
    129163        zipFile.Close();
    130 
    131164        FileInfo fileInfo = new FileInfo(packageFileName);
    132 
    133165        infoTextBox.Text += "\nCreated " + packageFileName + " (" + fileInfo.Length + " bytes)\n";
    134166        infoTextBox.Text += "Upload this file to your plugin source and add the following entry to" +
     
    145177
    146178    private void updateButton_Click(object sender, EventArgs e) {
    147 
    148179      // connect to all plugin sources and get a list of available plugins
    149180      // log progress in the infoPane
     
    162193
    163194      worker.DoWork += delegate(object doWorkSender, DoWorkEventArgs args) {
    164         List<PluginDescription> allAvailablePlugins = new List<PluginDescription>();
    165 
    166         //infoTextBox.Text = "Updating available plugins...\n";
     195        allAvailablePlugins.Clear();
    167196        dialog.SetDownloadDescription("Updating available plugins...");
    168 
    169197        int i = 0;
    170198        int n = HeuristicLab.PluginInfrastructure.GUI.Properties.Settings.Default.PluginSources.Count;
    171 
    172199        foreach(string pluginSourceUrl in HeuristicLab.PluginInfrastructure.GUI.Properties.Settings.Default.PluginSources) {
    173200          if(!worker.CancellationPending) {
     
    200227      worker.RunWorkerCompleted += delegate(object runWorkerCompletedSender, RunWorkerCompletedEventArgs args) {
    201228        if(!args.Cancelled && args.Error == null) {
    202           List<PluginDescription> allAvailablePlugins = (List<PluginDescription>)args.Result;
    203           allAvailablePlugins = FilterMostRecentPluginVersions(allAvailablePlugins);
    204 
    205           // find all plugins that are installed for which a new version is available
    206           List<PluginDescription> upgrades = FindUpgrades(allTags, allAvailablePlugins);
    207 
    208           // find all available plugins that are not installed and new (= new name not new version) since the last update
    209           List<PluginDescription> newPlugins = FindNewPlugins(allTags, allAvailablePlugins);
    210 
    211           // find all plugins that are available (not installed) for which a new version has been released since the last update
    212           List<PluginDescription> overridingPlugins = FindOverridingPlugins(allTags, allAvailablePlugins);
    213 
    214           newPlugins.ForEach(delegate(PluginDescription plugin) {
    215             PluginTag tag = new PluginTag(allTags, plugin, PluginState.Available);
    216             allTags.Add(tag);
    217 
    218             TreeNode node = new TreeNode(plugin.Name);
    219             node.ContextMenuStrip = pluginContextMenuStrip;
    220             node.Tag = tag;
    221             node.ImageIndex = 0;
    222             allPlugins.Nodes.Add(node);
    223 
    224             TreeNode availableNode = new TreeNode(plugin.Name);
    225             availableNode.ContextMenuStrip = pluginContextMenuStrip;
    226             availableNode.Tag = tag;
    227             availablePlugins.Nodes.Add(availableNode);
    228 
    229           });
    230 
    231           upgrades.ForEach(delegate(PluginDescription upgrade) {
    232             // find the installed plugins that have the same name
    233             List<PluginTag> oldPlugins = allTags.FindAll(delegate(PluginTag tag) {
    234               return tag.PluginName == upgrade.Name;
    235             });
    236             PluginTag oldPlugin = oldPlugins[0];
    237 
    238             // store the upgrade in the old plugin
    239             oldPlugin.UpgradePluginDescription = upgrade;
    240 
    241             UpdateTreeNodes(oldPlugins);
    242           });
    243 
    244           overridingPlugins.ForEach(delegate(PluginDescription overridingPlugin) {
    245             List<PluginTag> currentPlugins = allTags.FindAll(delegate(PluginTag tag) {
    246               return tag.PluginName == overridingPlugin.Name;
    247             });
    248 
    249             PluginTag currentPlugin = currentPlugins[0];
    250 
    251             // replace the plugin description of the available plugin to point to the overriding plugin
    252             currentPlugin.PluginDescription = overridingPlugin;
    253           });
    254 
    255           RebuildActionHulls();
     229          InitializePlugins();
    256230        }
    257231        dialog.Close();
  • trunk/sources/HeuristicLab.PluginInfrastructure/Loader.cs

    r8 r11  
    4141
    4242    private List<string> loadablePlugins = new List<string>();
    43     private string pluginDir = Application.StartupPath+"/"+ HeuristicLab.PluginInfrastructure.Properties.Settings.Default.PluginDir;
     43    private string pluginDir = Application.StartupPath + "/" + HeuristicLab.PluginInfrastructure.Properties.Settings.Default.PluginDir;
    4444
    4545    internal event PluginLoadFailedEventHandler MissingPluginFile;
     
    207207        if(filenameArg.MemberInfo != null && filetypeArg.MemberInfo != null) {
    208208          if((PluginFileType)filetypeArg.TypedValue.Value == PluginFileType.Assembly) {
    209             pluginAssemblies.Add(pluginDir +"/"+ (string)filenameArg.TypedValue.Value);
     209            pluginAssemblies.Add(pluginDir + "/" + (string)filenameArg.TypedValue.Value);
    210210          }
    211211        }
     
    296296        string filename = pluginDir + "/" + file;
    297297        // always use \ as the directory separator
    298         pluginInfo.Files.Add(filename.Replace('/','\\'));
     298        pluginInfo.Files.Add(filename.Replace('/', '\\'));
    299299      });
    300300
Note: See TracChangeset for help on using the changeset viewer.