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 |
|
---|
22 | using System;
|
---|
23 | using System.Collections.Generic;
|
---|
24 | using System.Windows.Forms;
|
---|
25 | using HeuristicLab.Clients.Hive.ExperimentManager;
|
---|
26 | using HeuristicLab.Clients.Hive.Jobs;
|
---|
27 | using HeuristicLab.Clients.Hive.Views.ExperimentManager.TreeView;
|
---|
28 | using HeuristicLab.Core;
|
---|
29 | using HeuristicLab.MainForm;
|
---|
30 | using HeuristicLab.MainForm.WindowsForms;
|
---|
31 | using HeuristicLab.Optimization;
|
---|
32 |
|
---|
33 | namespace 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).ItemJob.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.ItemJob.Item as Experiment;
|
---|
99 | if (experiment != null) {
|
---|
100 | experiment.Optimizers.Remove(((OptimizerJob)selectedItem.ItemJob).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.ItemJob.Item is Experiment) {
|
---|
111 |
|
---|
112 | }
|
---|
113 | actions.Add(new DeleteJobTreeNodeAction(Content));
|
---|
114 | }
|
---|
115 |
|
---|
116 | return actions;
|
---|
117 | }
|
---|
118 | }
|
---|
119 | }
|
---|