Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 6033 was 6033, checked in by cneumuel, 13 years ago

#1233

  • created baseclass for jobs (ItemJob) which derives OperatorJobs and EngineJobs
  • created special view for OptimizerJobs which derives from a more general view
  • removed logic from domain class HiveExperiment and moved it into RefreshableHiveExperiment
  • improved ItemTreeView
  • corrected plugin dependencies
  • fixed bug in database trigger when deleting HiveExperiments
  • added delete cascade for Plugin and PluginData
  • lots of fixes
File size: 4.2 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.ExperimentManager;
26using HeuristicLab.Clients.Hive.Jobs;
27using HeuristicLab.Clients.Hive.Views.ExperimentManager.TreeView;
28using HeuristicLab.Core;
29using HeuristicLab.MainForm;
30using HeuristicLab.MainForm.WindowsForms;
31using HeuristicLab.Optimization;
32
33namespace HeuristicLab.Clients.Hive.Views.ExperimentManager {
34  [View("HiveJob ItemTreeView")]
35  //[Content(typeof(ItemCollection<HiveJob>), IsDefaultView = false)]
36  [Content(typeof(ItemCollection<HiveJob>), IsDefaultView = false)]
37  public partial class HiveJobItemTreeView : ItemTreeView<HiveJob> {
38    public new ItemCollection<HiveJob> Content {
39      get { return (ItemCollection<HiveJob>)base.Content; }
40      set { base.Content = value; }
41    }
42
43    public HiveJobItemTreeView() {
44      InitializeComponent();
45    }
46
47    #region Register Content Events
48    protected override void DeregisterContentEvents() {
49      // TODO: Deregister your event handlers on the Content here
50      base.DeregisterContentEvents();
51    }
52    protected override void RegisterContentEvents() {
53      base.RegisterContentEvents();
54      // TODO: Register your event handlers on the Content here
55    }
56    #endregion
57
58    protected override void OnContentChanged() {
59      base.OnContentChanged();
60      if (Content == null) {
61        // TODO: Put code here when content is null
62      } else {
63        // TODO: Put code here when content has been changed and is not null
64      }
65    }
66
67    protected override void SetEnabledStateOfControls() {
68      base.SetEnabledStateOfControls();
69      // TODO: Put code here to enable or disable controls based on whether the Content is/not null or the view is ReadOnly
70    }
71
72    #region Event Handlers
73    // TODO: Put event handlers here
74    #endregion
75
76    #region Child Control Events
77    protected override void addButton_Click(object sender, EventArgs e) {
78      IOptimizer optimizer = CreateItem<IOptimizer>();
79      if (optimizer != null) {
80        if (treeView.SelectedNode == null) {
81          Content.Add(new OptimizerHiveJob(optimizer));
82        } else {
83          var experiment = ((HiveJob)treeView.SelectedNode.Tag).JobItem.Item as Experiment;
84          if (experiment != null) {
85            experiment.Optimizers.Add(optimizer);
86          }
87        }
88      }
89    }
90
91    protected override void removeButton_Click(object sender, EventArgs e) {
92      if (treeView.SelectedNode != null) {
93        var selectedItem = (HiveJob)treeView.SelectedNode.Tag;
94        var parentItem = GetParentItem(selectedItem);
95        if (parentItem == null) {
96          Content.Remove((HiveJob)treeView.SelectedNode.Tag);
97        } else {
98          var experiment = parentItem.JobItem.Item as Experiment;
99          if (experiment != null) {
100            experiment.Optimizers.Remove(((OptimizerJob)selectedItem.JobItem).Item);
101          }
102        }       
103      }
104    }
105    #endregion
106
107    protected override ICollection<IItemTreeNodeAction<HiveJob>> GetTreeNodeItemActions(HiveJob selectedItem) {
108      var actions = base.GetTreeNodeItemActions(selectedItem);
109      if (selectedItem != null) {
110        if (selectedItem.JobItem.Item is Experiment) {
111
112        }
113        actions.Add(new DeleteJobTreeNodeAction(Content));
114      }
115     
116      return actions;
117    }
118  }
119}
Note: See TracBrowser for help on using the repository browser.