source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/TreeView/HiveJobItemTreeView.cs @ 6479

Last change on this file since 6479 was 6479, checked in by cneumuel, 8 years ago

#1233

  • finished experiment sharing
  • added role for executing privileged jobs
  • refreshing experiments in experimentManager does not delete already downloaded jobs
  • moved some properties from HiveExperiment into RefreshableHiveExperiment
File size: 3.8 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Collections.Generic;
24using System.Windows.Forms;
25using HeuristicLab.Clients.Hive.Jobs;
26using HeuristicLab.Core;
27using HeuristicLab.MainForm;
28using HeuristicLab.MainForm.WindowsForms;
29using HeuristicLab.Optimization;
30
31namespace HeuristicLab.Clients.Hive.Views.ExperimentManager {
32  [View("HiveJob ItemTreeView")]
33  [Content(typeof(ItemCollection<HiveJob>), IsDefaultView = false)]
34  public partial class HiveJobItemTreeView : ItemTreeView<HiveJob> {
35    public new ItemCollection<HiveJob> Content {
36      get { return (ItemCollection<HiveJob>)base.Content; }
37      set { base.Content = value; }
38    }
39
40    public HiveJobItemTreeView() {
41      InitializeComponent();
42    }
43
44    #region Register Content Events
45    protected override void DeregisterContentEvents() {
46      // TODO: Deregister your event handlers on the Content here
47      base.DeregisterContentEvents();
48    }
49    protected override void RegisterContentEvents() {
50      base.RegisterContentEvents();
51      // TODO: Register your event handlers on the Content here
52    }
53    #endregion
54
55    protected override void OnContentChanged() {
56      base.OnContentChanged();
57      if (Content == null) {
58        // TODO: Put code here when content is null
59      } else {
60        // TODO: Put code here when content has been changed and is not null
61      }
62    }
63
64    protected override void SetEnabledStateOfControls() {
65      base.SetEnabledStateOfControls();
66      // TODO: Put code here to enable or disable controls based on whether the Content is/not null or the view is ReadOnly
67    }
68
69    #region Event Handlers
70    // TODO: Put event handlers here
71    #endregion
72
73    #region Child Control Events
74    protected override void addButton_Click(object sender, EventArgs e) {
75      IOptimizer optimizer = CreateItem<IOptimizer>();
76      if (optimizer != null) {
77        if (treeView.SelectedNode == null) {
78          Content.Add(new OptimizerHiveJob(optimizer));
79        } else {
80          var experiment = ((HiveJob)treeView.SelectedNode.Tag).ItemJob.Item as Experiment;
81          if (experiment != null) {
82            experiment.Optimizers.Add(optimizer);
83          }
84        }
85      }
86    }
87
88    protected override void removeButton_Click(object sender, EventArgs e) {
89      if (treeView.SelectedNode != null) {
90        var selectedItem = (HiveJob)treeView.SelectedNode.Tag;
91        var parentItem = GetParentItem(selectedItem);
92        if (parentItem == null) {
93          Content.Remove((HiveJob)treeView.SelectedNode.Tag);
94        } else {
95          var experiment = parentItem.ItemJob.Item as Experiment;
96          if (experiment != null) {
97            experiment.Optimizers.Remove(((OptimizerJob)selectedItem.ItemJob).Item);
98          }
99        }
100      }
101    }
102    #endregion
103
104    protected override ICollection<IItemTreeNodeAction<HiveJob>> GetTreeNodeItemActions(HiveJob selectedItem) {
105      return base.GetTreeNodeItemActions(selectedItem);
106    }
107  }
108}
Note: See TracBrowser for help on using the repository browser.