Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveHiveEngine/HeuristicLab.HiveEngine.Views/3.3/HiveEngineView.cs @ 10207

Last change on this file since 10207 was 7417, checked in by ascheibe, 13 years ago

#1744 added an option so that the parent task can also wait on the slave for the child tasks to finish

File size: 4.6 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 HeuristicLab.Core.Views;
24using HeuristicLab.MainForm;
25
26namespace HeuristicLab.HiveEngine.Views {
27  [View("Hive Engine View")]
28  [Content(typeof(HiveEngine), IsDefaultView = true)]
29  public sealed partial class HiveEngineView : ItemView {
30    public new HiveEngine Content {
31      get { return (HiveEngine)base.Content; }
32      set { base.Content = value; }
33    }
34
35    public HiveEngineView() {
36      InitializeComponent();
37    }
38
39    protected override void DeregisterContentEvents() {
40      Content.ExecutionTimeOnHiveChanged -= new EventHandler(Content_ExecutionTimeOnHiveChanged);
41      Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged);
42      base.DeregisterContentEvents();
43    }
44
45    protected override void RegisterContentEvents() {
46      base.RegisterContentEvents();
47      Content.ExecutionTimeOnHiveChanged += new EventHandler(Content_ExecutionTimeOnHiveChanged);
48      Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged);
49    }
50
51    #region Event Handlers (Content)
52    private void Content_ExecutionTimeChanged(object sender, EventArgs e) {
53      if (InvokeRequired) {
54        Invoke(new EventHandler(Content_ExecutionTimeChanged), sender, e);
55      } else {
56        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
57      }
58    }
59
60    private void Content_ExecutionTimeOnHiveChanged(object sender, EventArgs e) {
61      if (InvokeRequired) {
62        Invoke(new EventHandler(Content_ExecutionTimeOnHiveChanged), sender, e);
63      } else {
64        executionTimeOnHiveTextBox.Text = Content.ExecutionTimeOnHive.ToString();
65      }
66    }
67    #endregion
68
69    protected override void OnContentChanged() {
70      base.OnContentChanged();
71      if (Content == null) {
72        resourceIdsTextBox.Text = string.Empty;
73        priorityTextBox.Text = string.Empty;
74        executionTimeOnHiveTextBox.Text = string.Empty;
75        isPrivilegedCheckBox.Checked = false;
76        pauseOnWaitCheckbox.Checked = true;
77        hiveExperimentListView.Content = null;
78        logView.Content = null;
79      } else {
80        resourceIdsTextBox.Text = Content.ResourceNames;
81        priorityTextBox.Text = Content.Priority.ToString();
82        executionTimeOnHiveTextBox.Text = Content.ExecutionTimeOnHive.ToString();
83        isPrivilegedCheckBox.Checked = Content.IsPrivileged;
84        hiveExperimentListView.Content = Content.Jobs;
85        logView.Content = Content.Log;
86        pauseOnWaitCheckbox.Checked = Content.PauseWhileCalculatingChilds;
87      }
88    }
89
90    protected override void SetEnabledStateOfControls() {
91      base.SetEnabledStateOfControls();
92      // Enable or disable controls based on whether the content is null or the view is set readonly
93      if (Content != null) {
94        resourceIdsTextBox.ReadOnly = this.ReadOnly;
95        priorityTextBox.ReadOnly = this.ReadOnly;
96        isPrivilegedCheckBox.Enabled = Content.IsAllowedPrivileged;
97      } else {
98        resourceIdsTextBox.ReadOnly = false;
99        priorityTextBox.ReadOnly = false;
100        isPrivilegedCheckBox.Enabled = false;
101      }
102    }
103
104    #region Event Handlers (child controls)
105    private void resourceIdsTextBox_Validated(object sender, EventArgs e) {
106      Content.ResourceNames = resourceIdsTextBox.Text;
107    }
108
109    private void priorityTextBox_Validated(object sender, EventArgs e) {
110      Content.Priority = int.Parse(priorityTextBox.Text);
111    }
112
113    private void isPrivilegedCheckBox_Validated(object sender, EventArgs e) {
114      Content.IsPrivileged = isPrivilegedCheckBox.Checked;
115    }
116
117    private void pauseOnWaitCheckbox_Validated(object sender, EventArgs e) {
118      Content.PauseWhileCalculatingChilds = pauseOnWaitCheckbox.Checked;
119    }
120    #endregion
121  }
122}
Note: See TracBrowser for help on using the repository browser.