Free cookie consent management tool by TermsFeed Policy Generator

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

#2522: removed classes for plugin uploading and updating

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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
Note: See TracChangeset for help on using the changeset viewer.