Free cookie consent management tool by TermsFeed Policy Generator

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

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

#1827 fixed bug where deleting the last job doesn't update the details view

File size: 3.9 KB
RevLine 
[6976]1#region License Information
2/* HeuristicLab
[7259]3 * Copyright (C) 2002-2012 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[6976]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
[7103]31namespace HeuristicLab.Clients.Hive.Views {
[6976]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);
[7056]83          } else {
84            Content.Add(new OptimizerHiveTask(optimizer));
[6976]85          }
86        }
87      }
88    }
89
90    protected override void removeButton_Click(object sender, EventArgs e) {
[8069]91      base.removeButton_Click(sender, e);
92
[6976]93      if (treeView.SelectedNode != null) {
94        var selectedItem = (HiveTask)treeView.SelectedNode.Tag;
95        var parentItem = GetParentItem(selectedItem);
96        if (parentItem == null) {
97          Content.Remove((HiveTask)treeView.SelectedNode.Tag);
98        } else {
99          var experiment = parentItem.ItemTask.Item as Experiment;
100          if (experiment != null) {
101            experiment.Optimizers.Remove(((OptimizerTask)selectedItem.ItemTask).Item);
102          }
103        }
104      }
105    }
106    #endregion
107
108    protected override ICollection<IItemTreeNodeAction<HiveTask>> GetTreeNodeItemActions(HiveTask selectedItem) {
109      return base.GetTreeNodeItemActions(selectedItem);
110    }
111  }
112}
Note: See TracBrowser for help on using the repository browser.