Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/21/10 20:05:33 (14 years ago)
Author:
gkronber
Message:

Incorporated review comments by swagner into plugin infrastructure. #989 (Implement review comments in plugin infrastructure)

File:
1 copied

Legend:

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

    r3461 r3474  
    2828using System.Text;
    2929using System.Windows.Forms;
    30 using HeuristicLab.MainForm;
    31 using PluginDeploymentService = HeuristicLab.PluginInfrastructure.Advanced.DeploymentService;
    3230using System.ServiceModel;
    3331using HeuristicLab.PluginInfrastructure;
    3432
    35 namespace HeuristicLab.PluginAdministrator {
    36   internal partial class ProductEditor : HeuristicLab.MainForm.WindowsForms.View {
     33namespace HeuristicLab.PluginInfrastructure.Advanced {
     34  internal partial class ProductEditor : UserControl {
    3735    private BackgroundWorker refreshProductsWorker;
    3836    private BackgroundWorker uploadChangedProductsWorker;
    39     private List<PluginDeploymentService.ProductDescription> products;
    40     private List<PluginDeploymentService.PluginDescription> plugins;
    41     private HashSet<PluginDeploymentService.ProductDescription> dirtyProducts;
     37    private List<DeploymentService.ProductDescription> products;
     38    private List<DeploymentService.PluginDescription> plugins;
     39    private HashSet<DeploymentService.ProductDescription> dirtyProducts;
    4240
    4341    public ProductEditor() {
    4442      InitializeComponent();
    45       Caption = "Products";
    46 
    47       productImageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.Assembly);
    48       productImageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.ArrowUp);
    49       pluginImageList.Images.Add(HeuristicLab.Common.Resources.VS2008ImageLibrary.Assembly);
    50 
    51       dirtyProducts = new HashSet<PluginDeploymentService.ProductDescription>();
     43
     44      productImageList.Images.Add(HeuristicLab.PluginInfrastructure.Resources.Resources.Assembly);
     45      productImageList.Images.Add(HeuristicLab.PluginInfrastructure.Resources.Resources.ArrowUp);
     46      pluginImageList.Images.Add(HeuristicLab.PluginInfrastructure.Resources.Resources.Assembly);
     47
     48      dirtyProducts = new HashSet<DeploymentService.ProductDescription>();
    5249      refreshProductsWorker = new BackgroundWorker();
    5350      refreshProductsWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(refreshProductsWorker_RunWorkerCompleted);
     
    6158    #region event handlers for upload products background worker
    6259    private void uploadChangedProductsWorker_DoWork(object sender, DoWorkEventArgs e) {
    63       var products = (IEnumerable<PluginDeploymentService.ProductDescription>)e.Argument;
    64       var adminClient = PluginDeploymentService.AdminClientFactory.CreateClient();
     60      var products = (IEnumerable<DeploymentService.ProductDescription>)e.Argument;
     61      var adminClient = DeploymentService.AdminClientFactory.CreateClient();
    6562      try {
    6663        foreach (var product in products) {
     
    8178    #region event handlers for refresh products background worker
    8279    private void refreshProductsWorker_DoWork(object sender, DoWorkEventArgs e) {
    83       var updateClient = PluginDeploymentService.UpdateClientFactory.CreateClient();
     80      var updateClient = DeploymentService.UpdateClientFactory.CreateClient();
    8481      try {
    8582        e.Result = new object[] { updateClient.GetProducts(), updateClient.GetPlugins() };
     
    9289    private void refreshProductsWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) {
    9390      if (!e.Cancelled && e.Result != null) {
    94         this.products = new List<PluginDeploymentService.ProductDescription>(
    95           (PluginDeploymentService.ProductDescription[])((object[])e.Result)[0]);
    96         this.plugins = new List<PluginDeploymentService.PluginDescription>(
    97           (PluginDeploymentService.PluginDescription[])((object[])e.Result)[1]);
     91        this.products = new List<DeploymentService.ProductDescription>(
     92          (DeploymentService.ProductDescription[])((object[])e.Result)[0]);
     93        this.plugins = new List<DeploymentService.PluginDescription>(
     94          (DeploymentService.PluginDescription[])((object[])e.Result)[1]);
    9895
    9996        UpdateProductsList();
     
    123120        return;
    124121      }
    125       PluginDeploymentService.ProductDescription activeProduct = (PluginDeploymentService.ProductDescription)((ListViewItem)productsListView.SelectedItems[0]).Tag;
     122      DeploymentService.ProductDescription activeProduct = (DeploymentService.ProductDescription)((ListViewItem)productsListView.SelectedItems[0]).Tag;
    126123      UpdateProductDetails(activeProduct);
    127124    }
     
    133130    }
    134131
    135     private void UpdateProductDetails(PluginDeploymentService.ProductDescription activeProduct) {
     132    private void UpdateProductDetails(DeploymentService.ProductDescription activeProduct) {
    136133      nameTextBox.Text = activeProduct.Name;
    137134      versionTextBox.Text = activeProduct.Version.ToString();
     
    140137    }
    141138
    142     private ListViewItem CreateListViewItem(PluginDeploymentService.ProductDescription productDescription) {
     139    private ListViewItem CreateListViewItem(DeploymentService.ProductDescription productDescription) {
    143140      ListViewItem item = new ListViewItem(new string[] { productDescription.Name, productDescription.Version.ToString() });
    144141      item.Tag = productDescription;
     
    162159    #region button event handlers
    163160    private void newProductButton_Click(object sender, EventArgs e) {
    164       var newProduct = new PluginDeploymentService.ProductDescription("New product", new Version("0.0.0.0"));
     161      var newProduct = new DeploymentService.ProductDescription("New product", new Version("0.0.0.0"));
    165162      ListViewItem item = CreateListViewItem(newProduct);
    166163      productsListView.Items.Add(item);
     
    183180    private void nameTextBox_TextChanged(object sender, EventArgs e) {
    184181      ListViewItem activeItem = (ListViewItem)productsListView.SelectedItems[0];
    185       PluginDeploymentService.ProductDescription activeProduct = (PluginDeploymentService.ProductDescription)activeItem.Tag;
     182      DeploymentService.ProductDescription activeProduct = (DeploymentService.ProductDescription)activeItem.Tag;
    186183      if (string.IsNullOrEmpty(nameTextBox.Name)) {
    187184        errorProvider.SetError(nameTextBox, "Invalid value");
     
    199196    private void versionTextBox_TextChanged(object sender, EventArgs e) {
    200197      ListViewItem activeItem = (ListViewItem)productsListView.SelectedItems[0];
    201       PluginDeploymentService.ProductDescription activeProduct = (PluginDeploymentService.ProductDescription)activeItem.Tag;
     198      DeploymentService.ProductDescription activeProduct = (DeploymentService.ProductDescription)activeItem.Tag;
    202199      try {
    203200        var newVersion = new Version(versionTextBox.Text);
     
    226223    private void UpdatePluginsListView() {
    227224      ListViewItem activeItem = (ListViewItem)productsListView.SelectedItems[0];
    228       PluginDeploymentService.ProductDescription activeProduct = (PluginDeploymentService.ProductDescription)activeItem.Tag;
     225      DeploymentService.ProductDescription activeProduct = (DeploymentService.ProductDescription)activeItem.Tag;
    229226      pluginListView.Plugins = plugins.OfType<IPluginDescription>();
    230227      foreach (var plugin in activeProduct.Plugins) pluginListView.CheckPlugin(plugin);
     
    233230    private void pluginListView_ItemChecked(object sender, ItemCheckedEventArgs e) {
    234231      ListViewItem activeItem = (ListViewItem)productsListView.SelectedItems[0];
    235       PluginDeploymentService.ProductDescription activeProduct = (PluginDeploymentService.ProductDescription)activeItem.Tag;
    236       activeProduct.Plugins = pluginListView.CheckedPlugins.Cast<PluginDeploymentService.PluginDescription>().ToArray();
     232      DeploymentService.ProductDescription activeProduct = (DeploymentService.ProductDescription)activeItem.Tag;
     233      activeProduct.Plugins = pluginListView.CheckedPlugins.Cast<DeploymentService.PluginDescription>().ToArray();
    237234      MarkProductDirty(activeProduct);
    238235    }
     
    248245    private ListViewItem FindItemForProduct(HeuristicLab.PluginInfrastructure.Advanced.DeploymentService.ProductDescription activeProduct) {
    249246      return (from item in productsListView.Items.OfType<ListViewItem>()
    250               let product = item.Tag as PluginDeploymentService.ProductDescription
     247              let product = item.Tag as DeploymentService.ProductDescription
    251248              where product != null
    252249              where product == activeProduct
Note: See TracChangeset for help on using the changeset viewer.