Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/23/10 06:50:25 (14 years ago)
Author:
gkronber
Message:

Worked on review comments by swagner. #989 (Implement review comments in plugin infrastructure)

Location:
trunk/sources/HeuristicLab.PluginInfrastructure/Advanced
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.PluginInfrastructure/Advanced/InstallationManager.cs

    r3474 r3508  
    5858        return plugins;
    5959      }
    60       catch (FaultException) {
    61         client.Abort();
    62         return new IPluginDescription[] { };
     60      catch (TimeoutException e) {
     61        client.Abort();
     62        throw new InstallationManagerException("Time out while connecting to server.", e);
     63      }
     64      catch (FaultException e) {
     65        client.Abort();
     66        throw new InstallationManagerException("Fault in connection to server.", e);
     67      }
     68      catch (CommunicationException e) {
     69        client.Abort();
     70        throw new InstallationManagerException("General communication exception in connection to server.", e);
    6371      }
    6472    }
     
    7583        return products;
    7684      }
    77       catch (FaultException) {
    78         client.Abort();
    79         return new DeploymentService.ProductDescription[] { };
     85      catch (TimeoutException e) {
     86        client.Abort();
     87        throw new InstallationManagerException("Time out while connecting to server.", e);
     88      }
     89      catch (FaultException e) {
     90        client.Abort();
     91        throw new InstallationManagerException("Fault in connection to server.", e);
     92      }
     93      catch (CommunicationException e) {
     94        client.Abort();
     95        throw new InstallationManagerException("General communication exception in connection to server.", e);
    8096      }
    8197    }
     
    98114          client.Close();
    99115        }
    100         catch (FaultException) {
    101           client.Abort();
     116        catch (TimeoutException e) {
     117          client.Abort();
     118          throw new InstallationManagerException("Time out while connecting to server.", e);
     119        }
     120        catch (FaultException e) {
     121          client.Abort();
     122          throw new InstallationManagerException("Fault in connection to server.", e);
     123        }
     124        catch (CommunicationException e) {
     125          client.Abort();
     126          throw new InstallationManagerException("General communication exception in connection to server.", e);
    102127        }
    103128      }
     
    121146          client.Close();
    122147        }
    123         catch (FaultException) {
    124           client.Abort();
     148        catch (TimeoutException e) {
     149          client.Abort();
     150          throw new InstallationManagerException("Time out while connecting to server.", e);
     151        }
     152        catch (FaultException e) {
     153          client.Abort();
     154          throw new InstallationManagerException("Fault in connection to server.", e);
     155        }
     156        catch (CommunicationException e) {
     157          client.Abort();
     158          throw new InstallationManagerException("General communication exception in connection to server.", e);
    125159        }
    126160      }
  • trunk/sources/HeuristicLab.PluginInfrastructure/Advanced/InstallationManagerForm.Designer.cs

    r3474 r3508  
    6565      this.optionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
    6666      this.connectionSettingsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
     67      this.uploadPluginsTabPage = new System.Windows.Forms.TabPage();
     68      this.manageProductsTabPage = new System.Windows.Forms.TabPage();
    6769      this.statusStrip.SuspendLayout();
    6870      this.tabControl.SuspendLayout();
     
    100102      this.removeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    101103      this.removeButton.Enabled = false;
    102       this.removeButton.Location = new System.Drawing.Point(95, 313);
     104      this.removeButton.Image = global::HeuristicLab.PluginInfrastructure.Properties.Resources.VS2008ImageLibrary_CommonElements_Actions_Remove;
     105      this.removeButton.Location = new System.Drawing.Point(103, 305);
    103106      this.removeButton.Name = "removeButton";
    104       this.removeButton.Size = new System.Drawing.Size(106, 23);
     107      this.removeButton.Size = new System.Drawing.Size(110, 31);
    105108      this.removeButton.TabIndex = 11;
    106109      this.removeButton.Text = "Delete Selected";
     110      this.removeButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
    107111      this.removeButton.UseVisualStyleBackColor = true;
    108       this.removeButton.Click += new System.EventHandler(this.removeButton_Click);
     112      this.removeButton.Click += new System.EventHandler(this.removeLocalButton_Click);
    109113      //
    110114      // installButton
     
    112116      this.installButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    113117      this.installButton.Enabled = false;
    114       this.installButton.Location = new System.Drawing.Point(87, 313);
     118      this.installButton.Image = global::HeuristicLab.PluginInfrastructure.Properties.Resources.VS2008ImageLibrary_Objects_Install;
     119      this.installButton.Location = new System.Drawing.Point(84, 305);
    115120      this.installButton.Name = "installButton";
    116       this.installButton.Size = new System.Drawing.Size(132, 23);
     121      this.installButton.Size = new System.Drawing.Size(140, 31);
    117122      this.installButton.TabIndex = 15;
    118123      this.installButton.Text = "Install Selected Items";
     124      this.installButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
    119125      this.installButton.UseVisualStyleBackColor = true;
    120       this.installButton.Click += new System.EventHandler(this.updateButton_Click);
     126      this.installButton.Click += new System.EventHandler(this.updateOrInstallButton_Click);
    121127      //
    122128      // tabControl
     
    127133      this.tabControl.Controls.Add(this.localPluginsTabPage);
    128134      this.tabControl.Controls.Add(this.availablePluginsTabPage);
     135      this.tabControl.Controls.Add(this.uploadPluginsTabPage);
     136      this.tabControl.Controls.Add(this.manageProductsTabPage);
    129137      this.tabControl.Controls.Add(this.logTabPage);
    130138      this.tabControl.Location = new System.Drawing.Point(12, 27);
     
    151159      //
    152160      this.updateButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    153       this.updateButton.Location = new System.Drawing.Point(6, 313);
     161      this.updateButton.Enabled = false;
     162      this.updateButton.Image = global::HeuristicLab.PluginInfrastructure.Properties.Resources.VS2008ImageLibrary_Objects_Internet;
     163      this.updateButton.Location = new System.Drawing.Point(6, 305);
    154164      this.updateButton.Name = "updateButton";
    155       this.updateButton.Size = new System.Drawing.Size(83, 23);
     165      this.updateButton.Size = new System.Drawing.Size(91, 31);
    156166      this.updateButton.TabIndex = 12;
    157167      this.updateButton.Text = "Update All";
     168      this.updateButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
    158169      this.updateButton.UseVisualStyleBackColor = true;
     170      this.updateButton.Click += new System.EventHandler(this.updateAllButton_Click);
    159171      //
    160172      // localPluginManagerView
     
    166178      this.localPluginManagerView.Name = "localPluginManagerView";
    167179      this.localPluginManagerView.Plugins = null;
    168       this.localPluginManagerView.Size = new System.Drawing.Size(569, 301);
     180      this.localPluginManagerView.Size = new System.Drawing.Size(569, 293);
    169181      this.localPluginManagerView.TabIndex = 0;
    170182      this.localPluginManagerView.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.localPluginManager_ItemChecked);
     
    194206      this.remotePluginInstaller.Products = new HeuristicLab.PluginInfrastructure.Advanced.DeploymentService.ProductDescription[0];
    195207      this.remotePluginInstaller.ShowAllPlugins = false;
    196       this.remotePluginInstaller.Size = new System.Drawing.Size(571, 304);
     208      this.remotePluginInstaller.Size = new System.Drawing.Size(571, 293);
    197209      this.remotePluginInstaller.TabIndex = 14;
    198210      this.remotePluginInstaller.ItemChecked += new System.Windows.Forms.ItemCheckedEventHandler(this.remotePluginInstaller_ItemChecked);
     
    201213      //
    202214      this.refreshButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    203       this.refreshButton.Location = new System.Drawing.Point(6, 313);
     215      this.refreshButton.Image = global::HeuristicLab.PluginInfrastructure.Properties.Resources.VS2008ImageLibrary_Objects_Internet;
     216      this.refreshButton.Location = new System.Drawing.Point(6, 305);
    204217      this.refreshButton.Name = "refreshButton";
    205       this.refreshButton.Size = new System.Drawing.Size(75, 23);
     218      this.refreshButton.Size = new System.Drawing.Size(72, 31);
    206219      this.refreshButton.TabIndex = 11;
    207220      this.refreshButton.Text = "Refresh";
     221      this.refreshButton.TextImageRelation = System.Windows.Forms.TextImageRelation.ImageBeforeText;
    208222      this.refreshButton.UseVisualStyleBackColor = true;
    209       this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click);
     223      this.refreshButton.Click += new System.EventHandler(this.refreshRemoteButton_Click);
    210224      //
    211225      // logTabPage
     
    281295      // connectionSettingsToolStripMenuItem
    282296      //
     297      this.connectionSettingsToolStripMenuItem.Image = global::HeuristicLab.PluginInfrastructure.Properties.Resources.VS2008ImageLibrary_Objects_NetworkConnections;
    283298      this.connectionSettingsToolStripMenuItem.Name = "connectionSettingsToolStripMenuItem";
    284299      this.connectionSettingsToolStripMenuItem.Size = new System.Drawing.Size(190, 22);
    285300      this.connectionSettingsToolStripMenuItem.Text = "Connection Settings...";
    286301      this.connectionSettingsToolStripMenuItem.Click += new System.EventHandler(this.connectionSettingsToolStripMenuItem_Click);
     302      //
     303      // uploadPluginsTabPage
     304      //
     305      this.uploadPluginsTabPage.Location = new System.Drawing.Point(4, 22);
     306      this.uploadPluginsTabPage.Name = "uploadPluginsTabPage";
     307      this.uploadPluginsTabPage.Padding = new System.Windows.Forms.Padding(3);
     308      this.uploadPluginsTabPage.Size = new System.Drawing.Size(583, 342);
     309      this.uploadPluginsTabPage.TabIndex = 3;
     310      this.uploadPluginsTabPage.Text = "Upload Plugins";
     311      this.uploadPluginsTabPage.UseVisualStyleBackColor = true;
     312      //
     313      // manageProductsTabPage
     314      //
     315      this.manageProductsTabPage.Location = new System.Drawing.Point(4, 22);
     316      this.manageProductsTabPage.Name = "manageProductsTabPage";
     317      this.manageProductsTabPage.Padding = new System.Windows.Forms.Padding(3);
     318      this.manageProductsTabPage.Size = new System.Drawing.Size(583, 342);
     319      this.manageProductsTabPage.TabIndex = 4;
     320      this.manageProductsTabPage.Text = "Manage Products";
     321      this.manageProductsTabPage.UseVisualStyleBackColor = true;
    287322      //
    288323      // InstallationManagerForm
     
    334369    private System.Windows.Forms.ToolStripMenuItem connectionSettingsToolStripMenuItem;
    335370    private System.Windows.Forms.Button updateButton;
     371    private System.Windows.Forms.TabPage uploadPluginsTabPage;
     372    private System.Windows.Forms.TabPage manageProductsTabPage;
    336373  }
    337374}
  • trunk/sources/HeuristicLab.PluginInfrastructure/Advanced/InstallationManagerForm.cs

    r3474 r3508  
    5151    private BackgroundWorker removePluginsBackgroundWorker;
    5252    private BackgroundWorker refreshLocalPluginsBackgroundWorker;
     53    private BackgroundWorker updateAllPluginsBackgroundWorker;
    5354    private PluginManager pluginManager;
    5455    private string pluginDir;
     
    8081      refreshLocalPluginsBackgroundWorker.DoWork += new DoWorkEventHandler(refreshLocalPluginsBackgroundWorker_DoWork);
    8182      refreshLocalPluginsBackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(refreshLocalPluginsBackgroundWorker_RunWorkerCompleted);
     83
     84      updateAllPluginsBackgroundWorker = new BackgroundWorker();
     85      updateAllPluginsBackgroundWorker.DoWork += new DoWorkEventHandler(updateAllPluginsBackgroundWorker_DoWork);
     86      updateAllPluginsBackgroundWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(updateAllPluginsBackgroundWorker_RunWorkerCompleted);
    8287      #endregion
    8388
     
    9095      installationManager.PreUpdatePlugin += new EventHandler<PluginInfrastructureCancelEventArgs>(installationManager_PreUpdatePlugin);
    9196
    92       RefreshLocalPluginListAsync();
    93     }
     97      // show or hide controls for uploading plugins based on setting
     98      if (!HeuristicLab.PluginInfrastructure.Properties.Settings.Default.ShowPluginUploadControls) {
     99        tabControl.Controls.Remove(uploadPluginsTabPage);
     100        tabControl.Controls.Remove(manageProductsTabPage);
     101      }
     102
     103      UpdateLocalPluginList(pluginManager.Plugins);
     104      UpdateControlsConnected();
     105    }
     106
     107    #region event handlers for update all plugins backgroundworker
     108    void updateAllPluginsBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
     109      if (e.Error != null) {
     110        MessageBox.Show("There was an error while connecting to the server." + Environment.NewLine +
     111           "Please check your connection settings and user credentials.");
     112        UpdateControlsDisconnected();
     113      } else {
     114        RefreshLocalPluginListAsync();
     115        UpdateControlsConnected();
     116      }
     117    }
     118
     119    void updateAllPluginsBackgroundWorker_DoWork(object sender, DoWorkEventArgs e) {
     120      IEnumerable<IPluginDescription> installedPlugins = (IEnumerable<IPluginDescription>)e.Argument;
     121      var remotePlugins = installationManager.GetRemotePluginList();
     122      // if there is a local plugin with same name and same major and minor version then it's an update
     123      var pluginsToUpdate = from remotePlugin in remotePlugins
     124                            let matchingLocalPlugins = from installedPlugin in installedPlugins
     125                                                       where installedPlugin.Name == remotePlugin.Name
     126                                                       where installedPlugin.Version.Major == remotePlugin.Version.Major
     127                                                       where installedPlugin.Version.Minor == remotePlugin.Version.Minor
     128                                                       where installedPlugin.Version.Build <= remotePlugin.Version.Build ||
     129                                                         installedPlugin.Version.Revision < remotePlugin.Version.Revision
     130                                                       select installedPlugin
     131                            where matchingLocalPlugins.Count() > 0
     132                            select remotePlugin;
     133      installationManager.Update(pluginsToUpdate);
     134    }
     135    #endregion
    94136
    95137    #region event handlers for refresh local plugin list backgroundworker
     
    109151    #region event handlers for plugin removal background worker
    110152    void removePluginsBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
    111       if (!e.Cancelled && e.Error == null) {
     153      if (e.Error != null) {
     154        MessageBox.Show("There was problem while deleting files." + Environment.NewLine +
     155              e.Error.Message);
     156        UpdateControlsDisconnected();
     157      } else {
    112158        RefreshLocalPluginListAsync();
    113159        UpdateControlsConnected();
     
    123169    #region event handlers for plugin update background worker
    124170    void updateOrInstallPluginsBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
    125       if (!e.Cancelled && e.Error == null) {
     171      if (e.Error != null) {
     172        MessageBox.Show("There was an error while connecting to the server." + Environment.NewLine +
     173          "Please check your connection settings and user credentials.");
     174        UpdateControlsDisconnected();
     175      } else {
    126176        RefreshLocalPluginListAsync();
    127177        RefreshRemotePluginListAsync();
    128178        UpdateControlsConnected();
    129       } else {
    130         UpdateControlsDisconnected();
    131179      }
    132180    }
     
    141189    #region event handlers for refresh server plugins background worker
    142190    void refreshServerPluginsBackgroundWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
    143       if (!e.Cancelled && e.Result != null) {
     191      if (e.Error != null) {
     192        MessageBox.Show("There was an error while connecting to the server." + Environment.NewLine +
     193          "Please check your connection settings and user credentials.");
     194        UpdateControlsDisconnected();
     195      } else {
    144196        RefreshBackgroundWorkerResult refreshResult = (RefreshBackgroundWorkerResult)e.Result;
    145197        UpdateRemotePluginList(refreshResult.RemoteProducts, refreshResult.RemotePlugins);
    146198        UpdateControlsConnected();
    147       } else {
    148         UpdateControlsDisconnected();
    149199      }
    150200    }
     
    217267    #endregion
    218268
    219     private void SetStatusStrip(string msg) {
    220       if (InvokeRequired) Invoke((Action<string>)SetStatusStrip, msg);
    221       else {
    222         toolStripStatusLabel.Text = msg;
    223         logTextBox.Text += DateTime.Now + ": " + msg + Environment.NewLine;
    224       }
    225     }
     269
    226270
    227271    #region button events
    228272
    229     private void refreshButton_Click(object sender, EventArgs e) {
     273    private void refreshRemoteButton_Click(object sender, EventArgs e) {
     274      Cursor = Cursors.AppStarting;
    230275      RefreshRemotePluginListAsync();
    231     }
    232 
    233     private void updateButton_Click(object sender, EventArgs e) {
     276      toolStripProgressBar.Visible = true;
     277      DisableControls();
     278    }
     279
     280    private void updateOrInstallButton_Click(object sender, EventArgs e) {
    234281      Cursor = Cursors.AppStarting;
    235282      toolStripProgressBar.Visible = true;
     
    254301    }
    255302
    256     private void removeButton_Click(object sender, EventArgs e) {
     303    private void removeLocalButton_Click(object sender, EventArgs e) {
    257304      Cursor = Cursors.AppStarting;
    258305      toolStripProgressBar.Visible = true;
     
    261308    }
    262309
     310    private void updateAllButton_Click(object sender, EventArgs e) {
     311      Cursor = Cursors.AppStarting;
     312      toolStripProgressBar.Visible = true;
     313      updateButton.Enabled = false;
     314      var installedPlugins = pluginManager.Plugins.OfType<IPluginDescription>();
     315      updateAllPluginsBackgroundWorker.RunWorkerAsync(installedPlugins);
     316    }
     317
     318    private void connectionSettingsToolStripMenuItem_Click(object sender, EventArgs e) {
     319      new ConnectionSetupView().ShowDialog();
     320    }
     321
     322    private void tabControl_Selected(object sender, TabControlEventArgs e) {
     323      viewToolStripMenuItem.Enabled = e.TabPage == availablePluginsTabPage;
     324    }
     325
     326    private void simpleToolStripMenuItem_Click(object sender, EventArgs e) {
     327      remotePluginInstaller.ShowAllPlugins = false;
     328      advancedToolStripMenuItem.Checked = false;
     329    }
     330
     331    private void advancedToolStripMenuItem_Click(object sender, EventArgs e) {
     332      remotePluginInstaller.ShowAllPlugins = true;
     333      simpleToolStripMenuItem.Checked = false;
     334    }
    263335    #endregion
    264336
     
    297369
    298370    #region helper methods
     371    private void SetStatusStrip(string msg) {
     372      if (InvokeRequired) Invoke((Action<string>)SetStatusStrip, msg);
     373      else {
     374        toolStripStatusLabel.Text = msg;
     375        logTextBox.Text += DateTime.Now + ": " + msg + Environment.NewLine;
     376      }
     377    }
    299378
    300379    private void UpdateLocalPluginList(IEnumerable<PluginDescription> plugins) {
     
    347426    private void UpdateControlsConnected() {
    348427      refreshButton.Enabled = true;
     428      updateButton.Enabled = true;
    349429      toolStripProgressBar.Visible = false;
    350430      Cursor = Cursors.Default;
     
    363443    private void remotePluginInstaller_ItemChecked(object sender, ItemCheckedEventArgs e) {
    364444      installButton.Enabled = remotePluginInstaller.CheckedPlugins.Count() > 0;
    365     }
    366 
    367     private void editConnectionButton_Click(object sender, EventArgs e) {
    368445    }
    369446
     
    378455    }
    379456
    380     private void connectionSettingsToolStripMenuItem_Click(object sender, EventArgs e) {
    381       new ConnectionSetupView().ShowDialog();
    382     }
    383 
    384     private void tabControl_Selected(object sender, TabControlEventArgs e) {
    385       viewToolStripMenuItem.Enabled = e.TabPage == availablePluginsTabPage;
    386     }
    387 
    388     private void simpleToolStripMenuItem_Click(object sender, EventArgs e) {
    389 
    390     }
    391 
    392     private void advancedToolStripMenuItem_Click(object sender, EventArgs e) {
    393 
    394     }
     457
     458
     459
    395460  }
    396461}
Note: See TracChangeset for help on using the changeset viewer.