Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/23/15 11:32:22 (7 years ago)
Author:
gkronber
Message:

#2522: removed classes for plugin uploading and updating

Location:
branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Advanced
Files:
19 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Advanced/InstallationManagerForm.Designer.cs

    r12012 r13333  
    5151      this.localPluginsTabPage = new System.Windows.Forms.TabPage();
    5252      this.localPluginsView = new HeuristicLab.PluginInfrastructure.Advanced.InstalledPluginsView();
    53       this.availablePluginsTabPage = new System.Windows.Forms.TabPage();
    54       this.remotePluginInstaller = new HeuristicLab.PluginInfrastructure.Advanced.AvailablePluginsView();
    55       this.uploadPluginsTabPage = new System.Windows.Forms.TabPage();
    56       this.pluginEditor = new HeuristicLab.PluginInfrastructure.Advanced.UploadPluginsView();
    57       this.manageProductsTabPage = new System.Windows.Forms.TabPage();
    58       this.productEditor = new HeuristicLab.PluginInfrastructure.Advanced.EditProductsView();
    5953      this.logTabPage = new System.Windows.Forms.TabPage();
    6054      this.logTextBox = new System.Windows.Forms.TextBox();
    61       this.menuStrip = new System.Windows.Forms.MenuStrip();
    62       this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    63       this.connectionSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    6455      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    6556      this.statusStrip.SuspendLayout();
    6657      this.tabControl.SuspendLayout();
    6758      this.localPluginsTabPage.SuspendLayout();
    68       this.availablePluginsTabPage.SuspendLayout();
    69       this.uploadPluginsTabPage.SuspendLayout();
    70       this.manageProductsTabPage.SuspendLayout();
    7159      this.logTabPage.SuspendLayout();
    72       this.menuStrip.SuspendLayout();
    7360      this.SuspendLayout();
    7461      //
     
    10289                  | System.Windows.Forms.AnchorStyles.Right)));
    10390      this.tabControl.Controls.Add(this.localPluginsTabPage);
    104       this.tabControl.Controls.Add(this.availablePluginsTabPage);
    105       this.tabControl.Controls.Add(this.uploadPluginsTabPage);
    106       this.tabControl.Controls.Add(this.manageProductsTabPage);
    10791      this.tabControl.Controls.Add(this.logTabPage);
    10892      this.tabControl.Location = new System.Drawing.Point(12, 27);
     
    130114                  | System.Windows.Forms.AnchorStyles.Left)
    131115                  | System.Windows.Forms.AnchorStyles.Right)));
    132       this.localPluginsView.InstallationManager = null;
     116//       this.localPluginsView.InstallationManager = null;
    133117      this.localPluginsView.Location = new System.Drawing.Point(6, 6);
    134118      this.localPluginsView.Name = "localPluginsView";
     
    137121      this.localPluginsView.StatusView = null;
    138122      this.localPluginsView.TabIndex = 0;
    139       //
    140       // availablePluginsTabPage
    141       //
    142       this.availablePluginsTabPage.Controls.Add(this.remotePluginInstaller);
    143       this.availablePluginsTabPage.Location = new System.Drawing.Point(4, 22);
    144       this.availablePluginsTabPage.Name = "availablePluginsTabPage";
    145       this.availablePluginsTabPage.Padding = new System.Windows.Forms.Padding(3);
    146       this.availablePluginsTabPage.Size = new System.Drawing.Size(590, 366);
    147       this.availablePluginsTabPage.TabIndex = 1;
    148       this.availablePluginsTabPage.Text = "Available Plugins";
    149       this.toolTip.SetToolTip(this.availablePluginsTabPage, "Download and install new plugins");
    150       this.availablePluginsTabPage.UseVisualStyleBackColor = true;
    151       //
    152       // remotePluginInstaller
    153       //
    154       this.remotePluginInstaller.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    155                   | System.Windows.Forms.AnchorStyles.Left)
    156                   | System.Windows.Forms.AnchorStyles.Right)));
    157       this.remotePluginInstaller.InstallationManager = null;
    158       this.remotePluginInstaller.Location = new System.Drawing.Point(6, 6);
    159       this.remotePluginInstaller.Name = "remotePluginInstaller";
    160       this.remotePluginInstaller.PluginManager = null;
    161       this.remotePluginInstaller.Size = new System.Drawing.Size(578, 354);
    162       this.remotePluginInstaller.StatusView = null;
    163       this.remotePluginInstaller.TabIndex = 14;
    164       //
    165       // uploadPluginsTabPage
    166       //
    167       this.uploadPluginsTabPage.Controls.Add(this.pluginEditor);
    168       this.uploadPluginsTabPage.Location = new System.Drawing.Point(4, 22);
    169       this.uploadPluginsTabPage.Name = "uploadPluginsTabPage";
    170       this.uploadPluginsTabPage.Padding = new System.Windows.Forms.Padding(3);
    171       this.uploadPluginsTabPage.Size = new System.Drawing.Size(590, 366);
    172       this.uploadPluginsTabPage.TabIndex = 3;
    173       this.uploadPluginsTabPage.Text = "Upload Plugins";
    174       this.toolTip.SetToolTip(this.uploadPluginsTabPage, "Upload plugins");
    175       this.uploadPluginsTabPage.UseVisualStyleBackColor = true;
    176       //
    177       // pluginEditor
    178       //
    179       this.pluginEditor.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    180                   | System.Windows.Forms.AnchorStyles.Left)
    181                   | System.Windows.Forms.AnchorStyles.Right)));
    182       this.pluginEditor.Location = new System.Drawing.Point(6, 6);
    183       this.pluginEditor.Name = "pluginEditor";
    184       this.pluginEditor.PluginManager = null;
    185       this.pluginEditor.Size = new System.Drawing.Size(578, 354);
    186       this.pluginEditor.StatusView = null;
    187       this.pluginEditor.TabIndex = 0;
    188       //
    189       // manageProductsTabPage
    190       //
    191       this.manageProductsTabPage.Controls.Add(this.productEditor);
    192       this.manageProductsTabPage.Location = new System.Drawing.Point(4, 22);
    193       this.manageProductsTabPage.Name = "manageProductsTabPage";
    194       this.manageProductsTabPage.Padding = new System.Windows.Forms.Padding(3);
    195       this.manageProductsTabPage.Size = new System.Drawing.Size(590, 366);
    196       this.manageProductsTabPage.TabIndex = 4;
    197       this.manageProductsTabPage.Text = "Manage Products";
    198       this.toolTip.SetToolTip(this.manageProductsTabPage, "Create and manage products");
    199       this.manageProductsTabPage.UseVisualStyleBackColor = true;
    200       //
    201       // productEditor
    202       //
    203       this.productEditor.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    204                   | System.Windows.Forms.AnchorStyles.Left)
    205                   | System.Windows.Forms.AnchorStyles.Right)));
    206       this.productEditor.Location = new System.Drawing.Point(6, 6);
    207       this.productEditor.Name = "productEditor";
    208       this.productEditor.Size = new System.Drawing.Size(578, 354);
    209       this.productEditor.StatusView = null;
    210       this.productEditor.TabIndex = 0;
    211123      //
    212124      // logTabPage
     
    234146      this.logTextBox.TabIndex = 0;
    235147      //
    236       // menuStrip
    237       //
    238       this.menuStrip.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
    239             this.optionsToolStripMenuItem});
    240       this.menuStrip.Location = new System.Drawing.Point(0, 0);
    241       this.menuStrip.Name = "menuStrip";
    242       this.menuStrip.Size = new System.Drawing.Size(622, 24);
    243       this.menuStrip.TabIndex = 17;
    244       this.menuStrip.Text = "menuStrip1";
    245       //
    246       // optionsToolStripMenuItem
    247       //
    248       this.optionsToolStripMenuItem.DropDownItems.AddRange(new System.Windows.Forms.ToolStripItem[] {
    249             this.connectionSettingsToolStripMenuItem});
    250       this.optionsToolStripMenuItem.Name = "optionsToolStripMenuItem";
    251       this.optionsToolStripMenuItem.Size = new System.Drawing.Size(61, 20);
    252       this.optionsToolStripMenuItem.Text = "Options";
    253       //
    254       // connectionSettingsToolStripMenuItem
    255       //
    256       this.connectionSettingsToolStripMenuItem.Image = global::HeuristicLab.PluginInfrastructure.Resources.NetworkConnections;
    257       this.connectionSettingsToolStripMenuItem.Name = "connectionSettingsToolStripMenuItem";
    258       this.connectionSettingsToolStripMenuItem.Size = new System.Drawing.Size(190, 22);
    259       this.connectionSettingsToolStripMenuItem.Text = "Connection Settings...";
    260       this.connectionSettingsToolStripMenuItem.Click += new System.EventHandler(this.connectionSettingsToolStripMenuItem_Click);
    261       //
    262148      // InstallationManagerForm
    263149      //
     
    267153      this.Controls.Add(this.tabControl);
    268154      this.Controls.Add(this.statusStrip);
    269       this.Controls.Add(this.menuStrip);
    270155      this.Icon = global::HeuristicLab.PluginInfrastructure.Resources.HeuristicLab;
    271       this.MainMenuStrip = this.menuStrip;
    272156      this.Name = "InstallationManagerForm";
    273157      this.Text = "Plugin Manager";
     
    276160      this.tabControl.ResumeLayout(false);
    277161      this.localPluginsTabPage.ResumeLayout(false);
    278       this.availablePluginsTabPage.ResumeLayout(false);
    279       this.uploadPluginsTabPage.ResumeLayout(false);
    280       this.manageProductsTabPage.ResumeLayout(false);
    281162      this.logTabPage.ResumeLayout(false);
    282163      this.logTabPage.PerformLayout();
    283       this.menuStrip.ResumeLayout(false);
    284       this.menuStrip.PerformLayout();
    285164      this.ResumeLayout(false);
    286165      this.PerformLayout();
     
    293172    private System.Windows.Forms.ToolStripProgressBar toolStripProgressBar;
    294173    private System.Windows.Forms.ToolStripStatusLabel toolStripStatusLabel;
    295     private AvailablePluginsView remotePluginInstaller;
    296174    private System.Windows.Forms.TabControl tabControl;
    297175    private System.Windows.Forms.TabPage localPluginsTabPage;
    298     private System.Windows.Forms.TabPage availablePluginsTabPage;
    299176    private System.Windows.Forms.TabPage logTabPage;
    300177    private System.Windows.Forms.TextBox logTextBox;
    301     private System.Windows.Forms.MenuStrip menuStrip;
    302     private System.Windows.Forms.ToolStripMenuItem optionsToolStripMenuItem;
    303     private System.Windows.Forms.ToolStripMenuItem connectionSettingsToolStripMenuItem;
    304     private System.Windows.Forms.TabPage uploadPluginsTabPage;
    305     private System.Windows.Forms.TabPage manageProductsTabPage;
    306     private UploadPluginsView pluginEditor;
    307     private EditProductsView productEditor;
    308178    private InstalledPluginsView localPluginsView;
    309179    private System.Windows.Forms.ToolTip toolTip;
  • branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Advanced/InstallationManagerForm.cs

    r12012 r13333  
    3030namespace HeuristicLab.PluginInfrastructure.Advanced {
    3131  internal partial class InstallationManagerForm : Form, IStatusView {
    32     private InstallationManager installationManager;
    3332    private string pluginDir;
    3433
     
    4544      pluginDir = Application.StartupPath;
    4645
    47       installationManager = new InstallationManager(pluginDir);
    48       installationManager.PluginInstalled += new EventHandler<PluginInfrastructureEventArgs>(installationManager_PluginInstalled);
    49       installationManager.PluginRemoved += new EventHandler<PluginInfrastructureEventArgs>(installationManager_PluginRemoved);
    50       installationManager.PluginUpdated += new EventHandler<PluginInfrastructureEventArgs>(installationManager_PluginUpdated);
    51       installationManager.PreInstallPlugin += new EventHandler<PluginInfrastructureCancelEventArgs>(installationManager_PreInstallPlugin);
    52       installationManager.PreRemovePlugin += new EventHandler<PluginInfrastructureCancelEventArgs>(installationManager_PreRemovePlugin);
    53       installationManager.PreUpdatePlugin += new EventHandler<PluginInfrastructureCancelEventArgs>(installationManager_PreUpdatePlugin);
    54 
    55       // show or hide controls for uploading plugins based on setting
    56       if (!HeuristicLab.PluginInfrastructure.Properties.Settings.Default.ShowPluginUploadControls) {
    57         tabControl.Controls.Remove(uploadPluginsTabPage);
    58         tabControl.Controls.Remove(manageProductsTabPage);
    59       } else {
    60         pluginEditor.PluginManager = pluginManager;
    61       }
    62 
    6346      localPluginsView.StatusView = this;
    6447      localPluginsView.PluginManager = pluginManager;
    65       localPluginsView.InstallationManager = installationManager;
    66 
    67       remotePluginInstaller.StatusView = this;
    68       remotePluginInstaller.InstallationManager = installationManager;
    69       remotePluginInstaller.PluginManager = pluginManager;
    70 
    71       pluginEditor.StatusView = this;
    72       pluginEditor.PluginManager = pluginManager;
    73 
    74       productEditor.StatusView = this;
     48      // localPluginsView.InstallationManager = installationManager;
    7549    }
    7650
     
    9468    #endregion
    9569
    96     #region installation manager event handlers
    97     private void installationManager_PreUpdatePlugin(object sender, PluginInfrastructureCancelEventArgs e) {
    98       if (e.Plugins.Count() > 0) {
    99         e.Cancel = (bool)Invoke((Func<IEnumerable<IPluginDescription>, bool>)ConfirmUpdateAction, e.Plugins) == false;
    100       }
    101     }
    102 
    103     private void installationManager_PreRemovePlugin(object sender, PluginInfrastructureCancelEventArgs e) {
    104       if (e.Plugins.Count() > 0) {
    105         e.Cancel = (bool)Invoke((Func<IEnumerable<IPluginDescription>, bool>)ConfirmRemoveAction, e.Plugins) == false;
    106       }
    107     }
    108 
    109     private void installationManager_PreInstallPlugin(object sender, PluginInfrastructureCancelEventArgs e) {
    110       if (e.Plugins.Count() > 0)
    111         if ((bool)Invoke((Func<IEnumerable<IPluginDescription>, bool>)ConfirmInstallAction, e.Plugins) == true) {
    112           SetStatusStrip("Installing " + e.Plugins.Aggregate("", (a, b) => a.ToString() + "; " + b.ToString()));
    113           e.Cancel = false;
    114         } else {
    115           e.Cancel = true;
    116           SetStatusStrip("Install canceled");
    117         }
    118     }
    119 
    120     private void installationManager_PluginUpdated(object sender, PluginInfrastructureEventArgs e) {
    121       SetStatusStrip("Updated " + e.Entity);
    122     }
    123 
    124     private void installationManager_PluginRemoved(object sender, PluginInfrastructureEventArgs e) {
    125       SetStatusStrip("Removed " + e.Entity);
    126     }
    127 
    128     private void installationManager_PluginInstalled(object sender, PluginInfrastructureEventArgs e) {
    129       SetStatusStrip("Installed " + e.Entity);
    130     }
    131     #endregion
    13270
    13371    #region button events
    134     private void connectionSettingsToolStripMenuItem_Click(object sender, EventArgs e) {
    135       using (var conSetupView = new ConnectionSetupView()) {
    136         conSetupView.ShowDialog(this);
    137       }
    138     }
    13972    private void tabControl_SelectedIndexChanged(object sender, EventArgs e) {
    14073      toolStripStatusLabel.Text = string.Empty;
    14174    }
    142     #endregion
    143 
    144     #region confirmation dialogs
    145     private bool ConfirmRemoveAction(IEnumerable<IPluginDescription> plugins) {
    146       StringBuilder strBuilder = new StringBuilder();
    147       foreach (var plugin in plugins) {
    148         foreach (var file in plugin.Files) {
    149           strBuilder.AppendLine(Path.GetFileName(file.Name));
    150         }
    151       }
    152       using (var confirmationDialog = new ConfirmationDialog("Confirm Delete", "Do you want to delete following files?", strBuilder.ToString())) {
    153         return (confirmationDialog.ShowDialog(this)) == DialogResult.OK;
    154       }
    155     }
    156 
    157     private bool ConfirmUpdateAction(IEnumerable<IPluginDescription> plugins) {
    158       StringBuilder strBuilder = new StringBuilder();
    159       foreach (var plugin in plugins) {
    160         strBuilder.AppendLine(plugin.ToString());
    161       }
    162       using (var confirmationDialog = new ConfirmationDialog("Confirm Update", "Do you want to update following plugins?", strBuilder.ToString())) {
    163         return (confirmationDialog.ShowDialog(this)) == DialogResult.OK;
    164       }
    165     }
    166 
    167     private bool ConfirmInstallAction(IEnumerable<IPluginDescription> plugins) {
    168       foreach (var plugin in plugins) {
    169         if (!string.IsNullOrEmpty(plugin.LicenseText)) {
    170           using (var licenseConfirmationBox = new LicenseConfirmationDialog(plugin)) {
    171             if (licenseConfirmationBox.ShowDialog(this) != DialogResult.OK)
    172               return false;
    173           }
    174         }
    175       }
    176       return true;
    177     }
    178 
    179 
    18075    #endregion
    18176
     
    19186    #endregion
    19287
    193 
    194     protected override void OnClosing(CancelEventArgs e) {
    195       installationManager.PluginInstalled -= new EventHandler<PluginInfrastructureEventArgs>(installationManager_PluginInstalled);
    196       installationManager.PluginRemoved -= new EventHandler<PluginInfrastructureEventArgs>(installationManager_PluginRemoved);
    197       installationManager.PluginUpdated -= new EventHandler<PluginInfrastructureEventArgs>(installationManager_PluginUpdated);
    198       installationManager.PreInstallPlugin -= new EventHandler<PluginInfrastructureCancelEventArgs>(installationManager_PreInstallPlugin);
    199       installationManager.PreRemovePlugin -= new EventHandler<PluginInfrastructureCancelEventArgs>(installationManager_PreRemovePlugin);
    200       installationManager.PreUpdatePlugin -= new EventHandler<PluginInfrastructureCancelEventArgs>(installationManager_PreUpdatePlugin);
    201       base.OnClosing(e);
    202     }
    20388
    20489    #region IStatusView Members
  • branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Advanced/InstalledPluginsView.Designer.cs

    r12012 r13333  
    5454      this.pluginImageList = new System.Windows.Forms.ImageList(this.components);
    5555      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    56       this.refreshButton = new System.Windows.Forms.Button();
    57       this.removeButton = new System.Windows.Forms.Button();
    58       this.updateSelectedButton = new System.Windows.Forms.Button();
    5956      this.SuspendLayout();
    6057      //
     
    8683      this.localPluginsListView.View = System.Windows.Forms.View.Details;
    8784      this.localPluginsListView.ItemActivate += new System.EventHandler(this.localPluginsListView_ItemActivate);
    88       this.localPluginsListView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.pluginsListView_ItemChecked);
    8985      //
    9086      // nameHeader
     
    109105      this.pluginImageList.TransparentColor = System.Drawing.Color.Transparent;
    110106      //
    111       // refreshButton
    112       //
    113       this.refreshButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    114       this.refreshButton.Image = global::HeuristicLab.PluginInfrastructure.Resources.Repeat;
    115       this.refreshButton.Location = new System.Drawing.Point(0, 483);
    116       this.refreshButton.Name = "refreshButton";
    117       this.refreshButton.Size = new System.Drawing.Size(96, 25);
    118       this.refreshButton.TabIndex = 14;
    119       this.refreshButton.Text = "Refresh List";
    120       this.refreshButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
    121       this.toolTip.SetToolTip(this.refreshButton, "Refresh List of Installed Plugins");
    122       this.refreshButton.UseVisualStyleBackColor = true;
    123       this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click);
    124       //
    125       // removeButton
    126       //
    127       this.removeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    128       this.removeButton.Enabled = false;
    129       this.removeButton.Image = global::HeuristicLab.PluginInfrastructure.Resources.Remove;
    130       this.removeButton.Location = new System.Drawing.Point(222, 483);
    131       this.removeButton.Name = "removeButton";
    132       this.removeButton.Size = new System.Drawing.Size(110, 25);
    133       this.removeButton.TabIndex = 12;
    134       this.removeButton.Text = "Delete Selected";
    135       this.removeButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
    136       this.toolTip.SetToolTip(this.removeButton, "Delete all selected plugins from disk");
    137       this.removeButton.UseVisualStyleBackColor = true;
    138       this.removeButton.Click += new System.EventHandler(this.removeButton_Click);
    139       //
    140       // updateSelectedButton
    141       //
    142       this.updateSelectedButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    143       this.updateSelectedButton.Enabled = false;
    144       this.updateSelectedButton.Image = global::HeuristicLab.PluginInfrastructure.Resources.Internet;
    145       this.updateSelectedButton.Location = new System.Drawing.Point(102, 483);
    146       this.updateSelectedButton.Name = "updateSelectedButton";
    147       this.updateSelectedButton.Size = new System.Drawing.Size(114, 25);
    148       this.updateSelectedButton.TabIndex = 6;
    149       this.updateSelectedButton.Text = "Update Selected";
    150       this.updateSelectedButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
    151       this.toolTip.SetToolTip(this.updateSelectedButton, "Update all selected plugins");
    152       this.updateSelectedButton.UseVisualStyleBackColor = true;
    153       this.updateSelectedButton.Click += new System.EventHandler(this.updateSelectedButton_Click);
    154       //
    155107      // LocalPluginsView
    156108      //
    157109      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    158110      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    159       this.Controls.Add(this.refreshButton);
    160111      this.Controls.Add(this.localPluginsListView);
    161       this.Controls.Add(this.removeButton);
    162       this.Controls.Add(this.updateSelectedButton);
    163112      this.Name = "LocalPluginsView";
    164113      this.Size = new System.Drawing.Size(539, 508);
     
    169118    #endregion
    170119
    171     private System.Windows.Forms.Button updateSelectedButton;
    172     private System.Windows.Forms.Button removeButton;
    173120    private MultiSelectListView localPluginsListView;
    174121    private System.Windows.Forms.ColumnHeader nameHeader;
     
    177124    private System.Windows.Forms.ToolTip toolTip;
    178125    private System.Windows.Forms.ImageList pluginImageList;
    179     private System.Windows.Forms.Button refreshButton;
    180126    // private LocalPluginManagerView localPluginManagerView;
    181127  }
  • branches/RefactorPluginInfrastructure-2522/HeuristicLab.PluginInfrastructure/3.3/Advanced/InstalledPluginsView.cs

    r12012 r13333  
    3131    private const string CheckingPluginsMessage = "Checking for updated plugins...";
    3232    private const string NoUpdatesAvailableMessage = "No updates available.";
    33     private BackgroundWorker removePluginsBackgroundWorker;
    34     private BackgroundWorker updatePluginsBackgroundWorker;
    3533
    3634    private ListViewGroup enabledPluginsGroup;
     
    4644    }
    4745
    48     private InstallationManager installationManager;
    49     public InstallationManager InstallationManager {
    50       get { return installationManager; }
    51       set { installationManager = value; }
    52     }
     46    // private InstallationManager installationManager;
     47    // public InstallationManager InstallationManager {
     48    //   get { return installationManager; }
     49    //   set { installationManager = value; }
     50    // }
    5351
    5452    public InstalledPluginsView()
     
    5856      disabledPluginsGroup = localPluginsListView.Groups["disabledPluginsGroup"];
    5957      pluginImageList.Images.Add(HeuristicLab.PluginInfrastructure.Resources.Plugin);
    60       removePluginsBackgroundWorker = new BackgroundWorker();
    61       removePluginsBackgroundWorker.DoWork += new DoWorkEventHandler(removePluginsBackgroundWorker_DoWork);
    62       removePluginsBackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(removePluginsBackgroundWorker_RunWorkerCompleted);
    63       updatePluginsBackgroundWorker = new BackgroundWorker();
    64       updatePluginsBackgroundWorker.DoWork += new DoWorkEventHandler(updatePluginsBackgroundWorker_DoWork);
    65       updatePluginsBackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(updatePluginsBackgroundWorker_RunWorkerCompleted);
    66 
    6758      UpdateControl();
    6859    }
    6960
    7061
    71 
    72     #region event handlers for plugin removal background worker
    73     void removePluginsBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
    74       if (e.Error != null) {
    75         StatusView.ShowError("File Deletion Error", "There was problem while deleting files." + Environment.NewLine + e.Error.Message);
    76       }
    77       UpdateControl();
    78       StatusView.HideProgressIndicator();
    79       StatusView.UnlockUI();
    80     }
    81 
    82     void removePluginsBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) {
    83       IEnumerable<IPluginDescription> pluginsToRemove = (IEnumerable<IPluginDescription>)e.Argument;
    84       if (pluginsToRemove.Count() > 0) {
    85         installationManager.Remove(pluginsToRemove);
    86         pluginManager.DiscoverAndCheckPlugins();
    87       }
    88     }
    89     #endregion
    90 
    9162    #region event handlers for update plugins backgroundworker
    92     void updatePluginsBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
    93       if (e.Error != null) {
    94         StatusView.ShowError("Connection Error",
    95           "There was an error while connecting to the server." + Environment.NewLine +
    96            "Please check your connection settings and user credentials.");
    97       }
    98       StatusView.RemoveMessage(CheckingPluginsMessage);
    99       StatusView.HideProgressIndicator();
    100       UpdateControl();
    101       StatusView.UnlockUI();
    102     }
    103 
    104     void updatePluginsBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) {
    105       IEnumerable<IPluginDescription> selectedPlugins = (IEnumerable<IPluginDescription>)e.Argument;
    106       var remotePlugins = installationManager.GetRemotePluginList();
    107       // if there is a local plugin with same name and same major and minor version then it's an update
    108       var pluginsToUpdate = from remotePlugin in remotePlugins
    109                             let matchingLocalPlugins = from installedPlugin in selectedPlugins
    110                                                        where installedPlugin.Name == remotePlugin.Name
    111                                                        where installedPlugin.Version.Major == remotePlugin.Version.Major
    112                                                        where installedPlugin.Version.Minor == remotePlugin.Version.Minor
    113                                                        where IsNewerThan(remotePlugin, installedPlugin)
    114                                                        select installedPlugin
    115                             where matchingLocalPlugins.Count() > 0
    116                             select remotePlugin;
    117       if (pluginsToUpdate.Count() > 0) {
    118         bool cancelled;
    119         installationManager.Update(pluginsToUpdate, out cancelled);
    120         if (!cancelled) pluginManager.DiscoverAndCheckPlugins();
    121       }
    122     }
    123 
    12463    // compares for two plugins with same major and minor version if plugin1 is newer than plugin2
    12564    private static bool IsNewerThan(IPluginDescription plugin1, IPluginDescription plugin2) {
     
    14584        localPluginsListView.SuppressItemCheckedEvents = false;
    14685      }
    147       removeButton.Enabled = localPluginsListView.CheckedItems.Count > 0;
    148       updateSelectedButton.Enabled = localPluginsListView.CheckedItems.Count > 0;
    14986      Util.ResizeColumns(localPluginsListView.Columns.OfType<ColumnHeader>());
    15087    }
     
    16299    }
    163100
    164     private void pluginsListView_ItemChecked(object sender, ItemCheckedEventArgs e) {
    165       // checked items are marked for removal
    166       if (e.Item.Checked) {
    167         List<ListViewItem> modifiedItems = new List<ListViewItem>();
    168         foreach (ListViewItem item in localPluginsListView.SelectedItems) {
    169           modifiedItems.Add(item);
    170           int oldItemsCount = 0;
    171           while (oldItemsCount < modifiedItems.Count) {
    172             oldItemsCount = modifiedItems.Count;
    173             var oldModifiedItems = new List<ListViewItem>(modifiedItems);
    174             foreach (var modifiedItem in oldModifiedItems) {
    175               var plugin = (IPluginDescription)modifiedItem.Tag;
    176               // also check all dependent plugins
    177               foreach (ListViewItem dependentItem in localPluginsListView.Items) {
    178                 var dependent = (IPluginDescription)dependentItem.Tag;
    179                 if (!modifiedItems.Contains(dependentItem) &&
    180                   !dependentItem.Checked && (from dep in dependent.Dependencies
    181                                              where dep.Name == plugin.Name
    182                                              where dep.Version == plugin.Version
    183                                              select dep).Any()) {
    184                   modifiedItems.Add(dependentItem);
    185                 }
    186               }
    187             }
    188           }
    189         }
    190         localPluginsListView.CheckItems(modifiedItems);
    191       } else {
    192         List<ListViewItem> modifiedItems = new List<ListViewItem>();
    193         foreach (ListViewItem item in localPluginsListView.SelectedItems) {
    194           modifiedItems.Add(item);
    195         }
    196         localPluginsListView.UncheckItems(modifiedItems);
    197       }
    198       OnItemsCheckedChanged(EventArgs.Empty);
    199     }
    200101
    201102    private void localPluginsListView_ItemActivate(object sender, EventArgs e) {
     
    206107      }
    207108    }
    208 
    209     private void OnItemsCheckedChanged(EventArgs eventArgs) {
    210       removeButton.Enabled = localPluginsListView.CheckedItems.Count > 0;
    211       updateSelectedButton.Enabled = localPluginsListView.CheckedItems.Count > 0;
    212     }
    213 
    214     private void updateSelectedButton_Click(object sender, EventArgs e) {
    215       StatusView.LockUI();
    216       StatusView.ShowProgressIndicator();
    217       StatusView.RemoveMessage(NoUpdatesAvailableMessage);
    218       StatusView.ShowMessage(CheckingPluginsMessage);
    219       var checkedPlugins = localPluginsListView.CheckedItems.OfType<ListViewItem>()
    220         .Select(item => item.Tag)
    221         .OfType<IPluginDescription>()
    222         .ToList();
    223       updatePluginsBackgroundWorker.RunWorkerAsync(checkedPlugins);
    224     }
    225 
    226     private void removeButton_Click(object sender, EventArgs e) {
    227       StatusView.LockUI();
    228       StatusView.ShowProgressIndicator();
    229       var checkedPlugins = localPluginsListView.CheckedItems.OfType<ListViewItem>()
    230         .Select(item => item.Tag)
    231         .OfType<IPluginDescription>()
    232         .ToList();
    233       removePluginsBackgroundWorker.RunWorkerAsync(checkedPlugins);
    234     }
    235 
    236     private void refreshButton_Click(object sender, EventArgs e) {
    237       StatusView.LockUI();
    238       StatusView.ShowProgressIndicator();
    239       // refresh = update empty list of plugins (plugins are reloaded)
    240       updatePluginsBackgroundWorker.RunWorkerAsync(new IPluginDescription[0]);
    241     }
    242109  }
    243110}
Note: See TracChangeset for help on using the changeset viewer.