Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/12/11 13:43:05 (14 years ago)
Author:
cneumuel
Message:

#1233

  • changed relationship between Job and HiveExperiment. There is no more HiveExperiment.RootJobId, instead there is Job.HiveExperimentId.
  • One HiveExperiment can now have multiple Experiments.
  • TreeView supports multiple root nodes
  • HiveEngine creates a HiveExperiment for each set of jobs, so jobs cannot be without an parent experiment anymore (no more loose jobs)
  • updated ExperimentManager binaries
Location:
branches/HeuristicLab.Hive-3.4/sources
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive-3.4/sources

    • Property svn:ignore
      •  

        old new  
        44PrecompiledWeb
        55CreateEventLogSources
         6WindowsFormsTestProject
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/HiveExperimentView.Designer.cs

    r5955 r6006  
    5454      this.viewExperimentButton = new System.Windows.Forms.Button();
    5555      this.jobsTabPage = new System.Windows.Forms.TabPage();
    56       this.jobsTreeView = new HeuristicLab.Clients.Hive.Views.ItemTreeView();
     56      this.jobsTreeView = new HeuristicLab.Clients.Hive.Views.ItemTreeView<HiveJob>();
    5757      this.logTabPage = new System.Windows.Forms.TabPage();
    5858      this.logView = new HeuristicLab.Core.Views.LogView();
     
    465465    private System.Windows.Forms.CheckBox useLocalPluginsCheckBox;
    466466    private System.Windows.Forms.TabPage jobsTabPage;
    467     private ItemTreeView jobsTreeView;
     467    private ItemTreeView<HiveJob> jobsTreeView;
    468468    private System.Windows.Forms.Label nameLabel;
    469469    private System.Windows.Forms.TextBox nameTextBox;
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/HiveExperimentView.cs

    r5955 r6006  
    2222using System;
    2323using System.ComponentModel;
     24using System.Linq;
    2425using System.Threading;
    2526using System.Windows.Forms;
     27using HeuristicLab.Collections;
    2628using HeuristicLab.Common;
    2729using HeuristicLab.Core;
     
    3436  /// The base class for visual representations of items.
    3537  /// </summary>
    36   [View("Experiment View")]
     38  [View("Hive Experiment View")]
    3739  [Content(typeof(HiveExperiment), true)]
    3840  public sealed partial class HiveExperimentView : ItemView {
     
    5254
    5355    protected override void DeregisterContentEvents() {
    54       //Content.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);
    5556      Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged);
    5657      Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged);
    57       //Content.Prepared -= new EventHandler(Content_Prepared);
    58       //Content.Started -= new EventHandler(Content_Started);
    59       //Content.Paused -= new EventHandler(Content_Paused);
    60       //Content.Stopped -= new EventHandler(Content_Stopped);
    6158      Content.RefreshAutomaticallyChanged -= new EventHandler(Content_RefreshAutomaticallyChanged);
    62       Content.HiveJobChanged -= new EventHandler(Content_HiveJobChanged);
     59      Content.HiveJobsChanged -= new EventHandler(Content_HiveJobChanged);
    6360      Content.IsProgressingChanged -= new EventHandler(Content_IsProgressingChanged);
    6461      Content.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(Content_PropertyChanged);
     
    6865    protected override void RegisterContentEvents() {
    6966      base.RegisterContentEvents();
    70       //Content.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);
    7167      Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged);
    7268      Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged);
    73       //Content.Prepared += new EventHandler(Content_Prepared);
    74       //Content.Started += new EventHandler(Content_Started);
    75       //Content.Paused += new EventHandler(Content_Paused);
    76       //Content.Stopped += new EventHandler(Content_Stopped);
    7769      Content.RefreshAutomaticallyChanged += new EventHandler(Content_RefreshAutomaticallyChanged);
    78       Content.HiveJobChanged += new EventHandler(Content_HiveJobChanged);
     70      Content.HiveJobsChanged += new EventHandler(Content_HiveJobChanged);
    7971      Content.IsProgressingChanged += new EventHandler(Content_IsProgressingChanged);
    8072      Content.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Content_PropertyChanged);
     
    119111
    120112      if (Content != null) {
    121         bool alreadyUploaded = Content.RootJobId != null && Content.Id != Guid.Empty;
    122         bool jobsLoaded = Content.HiveJob != null && Content.HiveJob.Job.Id != Guid.Empty;
     113        bool alreadyUploaded = Content.Id != Guid.Empty;
     114        bool jobsLoaded = Content.HiveJobs != null && Content.HiveJobs.All(x => x.Job.Id != Guid.Empty);
    123115
    124116        this.nameTextBox.ReadOnly = Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded;
     
    127119        this.useLocalPluginsCheckBox.Enabled = !(Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded);
    128120        this.refreshAutomaticallyCheckBox.Enabled = alreadyUploaded && jobsLoaded && Content.ExecutionState == ExecutionState.Started;
    129         this.viewExperimentButton.Enabled = Content.GetExperiment() != null;
     121        this.viewExperimentButton.Enabled = Content.GetExperiment(0) != null;
    130122        this.openExperimentButton.Enabled = !alreadyUploaded && Content.ExecutionState == ExecutionState.Prepared;
    131123        this.newExperimentButton.Enabled = !alreadyUploaded && Content.ExecutionState == ExecutionState.Prepared;
     
    146138
    147139    #region Content Events
     140    private void HiveJobs_ItemsAdded_Removed_Reset(object sender, CollectionItemsChangedEventArgs<HiveJob> e) {
     141      if (InvokeRequired)
     142        Invoke(new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset), sender, e);
     143      else {
     144        SetEnabledStateOfControls();
     145      }
     146    }
    148147    private void Content_ExecutionStateChanged(object sender, EventArgs e) {
    149148      if (InvokeRequired)
     
    192191        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    193192    }
    194     private void Content_ExceptionOccurred(object sender, EventArgs<Exception> e) {
    195       if (InvokeRequired)
    196         Invoke(new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred), sender, e);
    197       else
    198         ErrorHandling.ShowErrorDialog(this, e.Value);
    199     }
    200193    private void Content_RefreshAutomaticallyChanged(object sender, EventArgs e) {
    201194      if (InvokeRequired)
     
    210203        Invoke(new EventHandler(Content_HiveJobChanged), sender, e);
    211204      else {
    212         if (Content != null) {
    213           jobsTreeView.Content = Content.HiveJob;
    214           experimentNamedItemView.Content = Content.GetExperiment();
     205        if (Content != null && Content.HiveJobs != null) {
     206          jobsTreeView.Content = Content.HiveJobs;
     207          experimentNamedItemView.Content = Content.GetExperiment(0);
     208          RegisterHiveJobEvents();
    215209        } else {
    216210          jobsTreeView.Content = null;
     
    220214      }
    221215    }
     216
     217    private void RegisterHiveJobEvents() {
     218      Content.HiveJobs.ItemsAdded += new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     219      Content.HiveJobs.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     220      Content.HiveJobs.CollectionReset += new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     221    }
     222    private void DeregisterHiveJobEvents() {
     223      Content.HiveJobs.ItemsAdded -= new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     224      Content.HiveJobs.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     225      Content.HiveJobs.CollectionReset -= new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset);
     226    }
     227
    222228    private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) {
    223229      if (InvokeRequired)
     
    241247      ExperimentManagerClient.StopExperiment(Content);
    242248    }
    243     private void resetButton_Click(object sender, EventArgs e) {  }
     249    private void resetButton_Click(object sender, EventArgs e) { }
    244250
    245251    private void nameTextBox_Validated(object sender, EventArgs e) {
     
    271277
    272278    private void showExperimentButton_Click(object sender, EventArgs e) {
    273       MainFormManager.MainForm.ShowContent(Content.GetExperiment());
     279      MainFormManager.MainForm.ShowContent(Content.GetExperiment(0));
    274280    }
    275281
    276282    private void viewExperimentButton_Click(object sender, EventArgs e) {
    277       MainFormManager.MainForm.ShowContent(Content.GetExperiment());
     283      MainFormManager.MainForm.ShowContent(Content.GetExperiment(0));
    278284    }
    279285
     
    310316        startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;
    311317      } else {
    312         startButton.Enabled = Content.GetExperiment() != null && Content.ExecutionState == ExecutionState.Prepared;
     318        startButton.Enabled = Content.GetExperiment(0) != null && Content.ExecutionState == ExecutionState.Prepared;
    313319        pauseButton.Enabled = Content.ExecutionState == ExecutionState.Started;
    314320        stopButton.Enabled = Content.ExecutionState == ExecutionState.Started;
     
    346352    }
    347353    #endregion
    348  
     354
    349355  }
    350356}
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/ItemTreeView.cs

    r5797 r6006  
    2424using HeuristicLab.Collections;
    2525using HeuristicLab.Common;
     26using HeuristicLab.Core;
    2627using HeuristicLab.Core.Views;
    2728using HeuristicLab.MainForm;
     
    3031namespace HeuristicLab.Clients.Hive.Views {
    3132  [View("ItemTree View")]
    32   [Content(typeof(IItemTree), IsDefaultView = false)]
    33   public sealed partial class ItemTreeView : ItemView {
    34     public new IItemTree Content {
    35       get { return (IItemTree)base.Content; }
     33  [Content(typeof(ItemCollection<>), IsDefaultView = false)]
     34  [Content(typeof(ItemCollection<IItemTree>), IsDefaultView = true)]
     35  public sealed partial class ItemTreeView<T> : ItemView where T : class, IItemTree {
     36    public new ItemCollection<T> Content {
     37      get { return (ItemCollection<T>)base.Content; }
    3638      set { base.Content = value; }
     39    }
     40
     41    public T SelectedItem {
     42      get {
     43        if (treeView.SelectedNode != null)
     44          return (T)treeView.SelectedNode.Tag;
     45        return null;
     46      }
    3747    }
    3848
     
    4252
    4353    protected override void DeregisterContentEvents() {
     54      Content.ItemsAdded -= new CollectionItemsChangedEventHandler<T>(Content_ItemsAdded);
     55      Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<T>(Content_ItemsRemoved);
     56      Content.CollectionReset -= new CollectionItemsChangedEventHandler<T>(Content_CollectionReset);
    4457      foreach (TreeNode node in treeView.Nodes) {
    45         DeregisterContentEvents((IItemTree)node.Tag, node);
     58        DeregisterContentEvents((T)node.Tag, node);
    4659      }
    4760      base.DeregisterContentEvents();
    4861    }
    4962
    50     private void DeregisterContentEvents(IItemTree item, TreeNode node) {
     63    private void DeregisterContentEvents(T item, TreeNode node) {
    5164      item.ItemsAdded -= new CollectionItemsChangedEventHandler<IItemTree>(item_ItemsAdded);
    5265      item.ItemsRemoved -= new CollectionItemsChangedEventHandler<IItemTree>(item_ItemsRemoved);
     
    5568      item.ItemImageChanged -= new EventHandler(item_ItemImageChanged);
    5669      foreach (TreeNode childNode in node.Nodes) {
    57         DeregisterContentEvents((IItemTree)childNode.Tag, childNode);
     70        DeregisterContentEvents((T)childNode.Tag, childNode);
    5871      }
    5972    }
     
    6174    protected override void RegisterContentEvents() {
    6275      base.RegisterContentEvents();
     76      Content.ItemsAdded += new CollectionItemsChangedEventHandler<T>(Content_ItemsAdded);
     77      Content.ItemsRemoved += new CollectionItemsChangedEventHandler<T>(Content_ItemsRemoved);
     78      Content.CollectionReset += new CollectionItemsChangedEventHandler<T>(Content_CollectionReset);
    6379      foreach (TreeNode node in treeView.Nodes) {
    64         RegisterContentEvents((IItemTree)node.Tag, node);
    65       }
    66     }
    67 
    68     private void RegisterContentEvents(IItemTree item, TreeNode node) {
     80        RegisterContentEvents((T)node.Tag, node);
     81      }
     82    }
     83
     84    private void RegisterContentEvents(T item, TreeNode node) {
    6985      item.ItemsAdded += new CollectionItemsChangedEventHandler<IItemTree>(item_ItemsAdded);
    7086      item.ItemsRemoved += new CollectionItemsChangedEventHandler<IItemTree>(item_ItemsRemoved);
     
    7389      item.ItemImageChanged += new EventHandler(item_ItemImageChanged);
    7490      foreach (TreeNode childNode in node.Nodes) {
    75         RegisterContentEvents((IItemTree)childNode.Tag, childNode);
     91        RegisterContentEvents((T)childNode.Tag, childNode);
    7692      }
    7793    }
    7894
    7995    #region Event Handlers (Content)
     96    private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<T> e) {
     97      if (InvokeRequired) {
     98        Invoke(new CollectionItemsChangedEventHandler<T>(Content_ItemsAdded), sender, e);
     99      } else {
     100        foreach (T item in e.Items) {
     101          var node = AddChildNodes(item, treeView.Nodes, true);
     102          UpdateNodeItemImage(node);
     103        }
     104      }
     105    }
     106    private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<T> e) {
     107      if (InvokeRequired) {
     108        Invoke(new CollectionItemsChangedEventHandler<T>(Content_ItemsRemoved), sender, e);
     109      } else {
     110        foreach (T item in e.Items) {
     111          RemoveChildNodes(item, treeView.Nodes);
     112        }
     113        RebuildImageList();
     114      }
     115    }
     116    private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<T> e) {
     117      if (InvokeRequired) {
     118        Invoke(new CollectionItemsChangedEventHandler<T>(Content_CollectionReset), sender, e);
     119      } else {
     120        foreach (T item in e.OldItems) {
     121          RemoveChildNodes(item, treeView.Nodes);
     122        }
     123        RebuildImageList();
     124        foreach (T item in e.Items) {
     125          AddChildNodes(item, treeView.Nodes, true);
     126        }
     127      }
     128    }
     129
    80130    private void item_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IItemTree> e) {
    81131      if (InvokeRequired) {
    82132        Invoke(new CollectionItemsChangedEventHandler<IItemTree>(item_ItemsAdded), sender, e);
    83133      } else {
    84         TreeNode node = GetNodeByItem(sender as IItemTree);
     134        TreeNode node = GetNodeByItem(sender as T);
    85135        if (node != null) {
    86           foreach (IItemTree item in e.Items) {
     136          foreach (T item in e.Items) {
    87137            AddChildNodes(item, node.Nodes, true);
    88138            node.ExpandAll();
     
    97147        Invoke(new CollectionItemsChangedEventHandler<IItemTree>(item_ItemsRemoved), sender, e);
    98148      } else {
    99         TreeNode node = GetNodeByItem(sender as IItemTree);
     149        TreeNode node = GetNodeByItem(sender as T);
    100150        if (node != null) {
    101           foreach (IItemTree item in e.Items) {
     151          foreach (T item in e.Items) {
    102152            RemoveChildNodes(item, node.Nodes);
    103153          }
     
    111161        Invoke(new CollectionItemsChangedEventHandler<IItemTree>(item_CollectionReset), sender, e);
    112162      } else {
    113         TreeNode node = GetNodeByItem(sender as IItemTree);
     163        TreeNode node = GetNodeByItem(sender as T);
    114164        if (node != null) {
    115           foreach (IItemTree item in e.OldItems) {
     165          foreach (T item in e.OldItems) {
    116166            RemoveChildNodes(item, node.Nodes);
    117167          }
    118168          RebuildImageList();
    119           foreach (IItemTree item in e.Items) {
     169          foreach (T item in e.Items) {
    120170            AddChildNodes(item, node.Nodes, true);
    121171          }
     
    128178        Invoke(new EventHandler(item_ToStringChanged), sender, e);
    129179      } else {
    130         var item = sender as IItemTree;
     180        var item = sender as T;
    131181        TreeNode node = GetNodeByItem(item);
    132182        if(node != null)
     
    139189        Invoke(new EventHandler(item_ItemImageChanged), sender, e);
    140190      } else {
    141         var item = sender as IItemTree;
     191        var item = sender as T;
    142192        TreeNode node = GetNodeByItem(item);
    143193        if(node != null)
     
    151201      } else {
    152202        if (treeView.SelectedNode != null) {
    153           var item = treeView.SelectedNode.Tag as IItemTree;
     203          var item = treeView.SelectedNode.Tag as T;
    154204          if (item != null) {
    155205            IContentView view = MainFormManager.MainForm.ShowContent(item);
     
    167217      base.OnContentChanged();
    168218      if (Content == null) {
    169         // Add code when content has been changed and is null
    170219        ClearNodes();
    171220        detailsViewHost.Content = null;
    172221      } else {
    173         // Add code when content has been changed and is not null
    174222        ClearNodes();
    175         AddChildNodes(Content, treeView.Nodes, false);
     223        foreach (T itemTree in Content) {
     224          AddChildNodes(itemTree, treeView.Nodes, false);
     225        }
    176226        foreach (TreeNode node in treeView.Nodes) {
    177227          UpdateNodeItemImage(node);
    178228        }
     229        detailsViewHost.Content = null;
    179230      }
    180231    }
     
    184235    }
    185236
    186     private void AddChildNodes(IItemTree item, TreeNodeCollection nodes, bool registerEvents) {
     237    private TreeNode AddChildNodes(T item, TreeNodeCollection nodes, bool registerEvents) {
    187238      TreeNode node = CreateTreeViewNode(item);
    188239      nodes.Add(node);
     
    190241      RegisterContentEvents(item, node);
    191242      var childItems = item.GetChildItems();
    192       foreach (var childItem in childItems) {
     243      foreach (T childItem in childItems) {
    193244        AddChildNodes(childItem, node.Nodes, registerEvents);
    194245      }
    195246      node.ExpandAll();
    196     }
    197 
    198     private void RemoveChildNodes(IItemTree item, TreeNodeCollection treeNodeCollection) {
     247      return node;
     248    }
     249
     250    private void RemoveChildNodes(T item, TreeNodeCollection treeNodeCollection) {
    199251      int idx = -1;
    200252      for (int i = 0; i < treeNodeCollection.Count; i++) {
     
    207259    }
    208260   
    209     private TreeNode GetNodeByItem(IItemTree item) {
     261    private TreeNode GetNodeByItem(T item) {
    210262      TreeNode found = null;
    211263      foreach (TreeNode node in treeView.Nodes) {
     
    217269    }
    218270
    219     private TreeNode GetNodeByItem(TreeNode node, IItemTree item) {
     271    private TreeNode GetNodeByItem(TreeNode node, T item) {
    220272      if (node.Tag == item)
    221273        return node;
     
    229281    }
    230282
    231     private TreeNode CreateTreeViewNode(IItemTree item) {
     283    private TreeNode CreateTreeViewNode(T item) {
    232284      var node = new TreeNode(item.ToString());
    233285      node.Tag = item;
     
    237289    private void UpdateNodeItemImage(TreeNode node) {
    238290      if (node == null) throw new ArgumentNullException();
    239       var item = node.Tag as IItemTree;
     291      var item = node.Tag as T;
    240292      int i = node.ImageIndex;
    241293      this.imageList.Images[i] = item == null ? HeuristicLab.Common.Resources.VSImageLibrary.Nothing : item.ItemImage;
     
    268320
    269321    private void RebuildImageList(TreeNode node) {
    270       var item = node.Tag as IItemTree;
     322      var item = node.Tag as T;
    271323      treeView.ImageList.Images.Add(item == null ? HeuristicLab.Common.Resources.VSImageLibrary.Nothing : item.ItemImage);
    272324      node.ImageIndex = treeView.ImageList.Images.Count - 1;
  • branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/ItemTreeView.designer.cs

    r5793 r6006  
    11namespace HeuristicLab.Clients.Hive.Views {
    2   partial class ItemTreeView {
     2  partial class ItemTreeView<T> {
    33    /// <summary>
    44    /// Required designer variable.
Note: See TracChangeset for help on using the changeset viewer.