Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/HiveExperimentManagerView.cs @ 6004

Last change on this file since 6004 was 5955, checked in by cneumuel, 14 years ago

#1233

  • seperated ExperimentMangerClient (OKB-Style, contains business logic) and HiveExperiment (mainly only contains information)
  • fixed redundant cloning methods in dtos
  • added simple statistics in HiveExperiment which the user can see before downloading an experiment
  • added db-delete cascade for slaves and statelogs - now slaves can be safely deleted
File size: 3.9 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2010 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.Windows.Forms;
24using HeuristicLab.MainForm;
25using HeuristicLab.MainForm.WindowsForms;
26using HeuristicLab.PluginInfrastructure;
27
28namespace HeuristicLab.Clients.Hive.Views {
29  /// <summary>
30  /// The base class for visual representations of items.
31  /// </summary>
32  [View("Hive Experiment Manager View")]
33  [Content(typeof(ExperimentManagerClient), true)]
34  public partial class HiveExperimentManagerView : AsynchronousContentView {
35
36    public new ExperimentManagerClient Content {
37      get { return (ExperimentManagerClient)base.Content; }
38      set { base.Content = value; }
39    }
40
41    /// <summary>
42    /// Initializes a new instance of <see cref="ItemBaseView"/>.
43    /// </summary>
44    public HiveExperimentManagerView() {
45      InitializeComponent();
46    }
47
48    protected override void RegisterContentEvents() {
49      base.RegisterContentEvents();
50      Content.Refreshing += new EventHandler(Content_Refreshing);
51      Content.Refreshed += new EventHandler(Content_Refreshed);
52    }
53
54    protected override void DeregisterContentEvents() {
55      Content.Refreshing -= new EventHandler(Content_Refreshing);
56      Content.Refreshed -= new EventHandler(Content_Refreshed);
57      base.DeregisterContentEvents();
58    }
59
60    protected override void OnContentChanged() {
61      base.OnContentChanged();
62      if (Content == null) {
63        hiveExperimentListView.Content = null;
64      } else {
65        hiveExperimentListView.Content = Content.HiveExperiments;
66        if(Content != null)
67          Content.RefreshAsync(new Action<Exception>((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Refresh failed.", ex)));
68      }
69    }
70
71    protected override void SetEnabledStateOfControls() {
72      base.SetEnabledStateOfControls();
73      refreshButton.Enabled = Content != null;
74      hiveExperimentListView.Enabled = Content != null;
75    }
76
77    private void Content_Refreshing(object sender, EventArgs e) {
78      if (InvokeRequired) {
79        Invoke(new EventHandler(Content_Refreshing), sender, e);
80      } else {
81        Cursor = Cursors.AppStarting;
82        refreshButton.Enabled = false;
83        hiveExperimentListView.Enabled = false;
84      }
85    }
86    private void Content_Refreshed(object sender, EventArgs e) {
87      if (InvokeRequired) {
88        Invoke(new EventHandler(Content_Refreshed), sender, e);
89      } else {
90        hiveExperimentListView.Content = Content.HiveExperiments;
91        refreshButton.Enabled = true;
92        hiveExperimentListView.Enabled = true;
93        Cursor = Cursors.Default;
94      }
95    }
96
97    private void refreshButton_Click(object sender, EventArgs e) {
98      Content.RefreshAsync(new Action<Exception>((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Refresh failed.", ex)));
99    }
100
101    protected override void OnClosing(FormClosingEventArgs e) {
102      base.OnClosing(e);
103      if (Content != null) {
104        foreach (var exp in Content.HiveExperiments) {
105          if (exp.RefreshAutomatically) {
106            exp.RefreshAutomatically = false; // stop result polling
107          }
108        }
109      }
110    }
111  }
112}
Note: See TracBrowser for help on using the repository browser.