Free cookie consent management tool by TermsFeed Policy Generator

source: branches/ScatterSearch (trunk integration)/HeuristicLab.Clients.Hive.Views/3.3/TreeView/HiveTaskItemTreeView.cs @ 8086

Last change on this file since 8086 was 8086, checked in by jkarder, 12 years ago

#1331:

  • synced branch with trunk
  • added custom interface (ISimilarityBasedOperator) to mark operators that conduct similarity calculation
  • similarity calculators are now parameterized by the algorithm
  • deleted SolutionPool2TierUpdateMethod
  • deleted KnapsackMultipleGuidesPathRelinker
  • moved IImprovementOperator, IPathRelinker and ISimilarityCalculator to HeuristicLab.Optimization
  • added parameter descriptions
  • fixed plugin references
  • fixed count of EvaluatedSolutions
  • fixed check for duplicate solutions
  • minor code improvements
File size: 3.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2012 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 {
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          } else {
84            Content.Add(new OptimizerHiveTask(optimizer));
85          }
86        }
87      }
88    }
89
90    protected override void removeButton_Click(object sender, EventArgs e) {
91      base.removeButton_Click(sender, e);
92
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.