Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Clients.Hive.Views/3.3/TreeView/HiveTaskItemTreeView.cs @ 6976

Last change on this file since 6976 was 6976, checked in by ascheibe, 12 years ago

#1672 integrate the Hive client projects into trunk (Hive Job Manager and Administrator)

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("HiveTask ItemTreeView")]
33  [Content(typeof(ItemCollection<HiveTask>), IsDefaultView = false)]
34  public partial class HiveTaskItemTreeView : ItemTreeView<HiveTask> {
35    public new ItemCollection<HiveTask> Content {
36      get { return (ItemCollection<HiveTask>)base.Content; }
37      set { base.Content = value; }
38    }
39
40    public HiveTaskItemTreeView() {
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 OptimizerHiveTask(optimizer));
79        } else {
80          var experiment = ((HiveTask)treeView.SelectedNode.Tag).ItemTask.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 = (HiveTask)treeView.SelectedNode.Tag;
91        var parentItem = GetParentItem(selectedItem);
92        if (parentItem == null) {
93          Content.Remove((HiveTask)treeView.SelectedNode.Tag);
94        } else {
95          var experiment = parentItem.ItemTask.Item as Experiment;
96          if (experiment != null) {
97            experiment.Optimizers.Remove(((OptimizerTask)selectedItem.ItemTask).Item);
98          }
99        }
100      }
101    }
102    #endregion
103
104    protected override ICollection<IItemTreeNodeAction<HiveTask>> GetTreeNodeItemActions(HiveTask selectedItem) {
105      return base.GetTreeNodeItemActions(selectedItem);
106    }
107  }
108}
Note: See TracBrowser for help on using the repository browser.