[4905] | 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 |
|
---|
| 22 | using System;
|
---|
[5597] | 23 | using System.Linq;
|
---|
[4905] | 24 | using System.Windows.Forms;
|
---|
| 25 | using HeuristicLab.Core.Views;
|
---|
| 26 | using HeuristicLab.MainForm;
|
---|
| 27 |
|
---|
| 28 | namespace HeuristicLab.Clients.Hive.Views {
|
---|
| 29 | [View("HiveJob View")]
|
---|
| 30 | [Content(typeof(HiveJob), true)]
|
---|
[6033] | 31 | [Content(typeof(HiveJob<>), false)]
|
---|
[4905] | 32 | public partial class HiveJobView : ItemView {
|
---|
| 33 | public new HiveJob Content {
|
---|
| 34 | get { return (HiveJob)base.Content; }
|
---|
| 35 | set {
|
---|
| 36 | if (base.Content != value) {
|
---|
| 37 | base.Content = value;
|
---|
| 38 | }
|
---|
| 39 | }
|
---|
| 40 | }
|
---|
| 41 |
|
---|
| 42 | public HiveJobView() {
|
---|
| 43 | InitializeComponent();
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | protected override void RegisterContentEvents() {
|
---|
| 47 | base.RegisterContentEvents();
|
---|
[6200] | 48 | Content.ItemJobChanged += new EventHandler(Content_JobItemChanged);
|
---|
[4905] | 49 | Content.JobChanged += new EventHandler(Content_JobChanged);
|
---|
| 50 | Content.JobStateChanged += new EventHandler(Content_JobStateChanged);
|
---|
| 51 | }
|
---|
| 52 |
|
---|
| 53 | protected override void DeregisterContentEvents() {
|
---|
[6200] | 54 | Content.ItemJobChanged -= new EventHandler(Content_JobItemChanged);
|
---|
[4905] | 55 | Content.JobChanged -= new EventHandler(Content_JobChanged);
|
---|
| 56 | Content.JobStateChanged -= new EventHandler(Content_JobStateChanged);
|
---|
| 57 | base.DeregisterContentEvents();
|
---|
| 58 | }
|
---|
| 59 |
|
---|
| 60 | protected override void OnContentChanged() {
|
---|
| 61 | base.OnContentChanged();
|
---|
| 62 | if (Content != null && Content.Job != null) {
|
---|
[6178] | 63 | computeInParallelCheckBox.Checked = Content.ItemJob.ComputeInParallel;
|
---|
[4905] | 64 | } else {
|
---|
| 65 | computeInParallelCheckBox.Checked = false;
|
---|
| 66 | }
|
---|
[6033] | 67 | Content_JobItemChanged(this, EventArgs.Empty);
|
---|
[4905] | 68 | Content_JobChanged(this, EventArgs.Empty);
|
---|
| 69 | Content_JobStateChanged(this, EventArgs.Empty);
|
---|
| 70 | }
|
---|
| 71 |
|
---|
[6033] | 72 | protected virtual void RegisterJobEvents() {
|
---|
[4905] | 73 | if (Content != null && Content.Job != null) {
|
---|
[6178] | 74 | Content.ItemJob.ComputeInParallelChanged += new EventHandler(OptimizerJob_ComputeInParallelChanged);
|
---|
| 75 | Content.ItemJob.ItemChanged += new EventHandler(Job_ItemChanged);
|
---|
[4905] | 76 | }
|
---|
| 77 | }
|
---|
| 78 |
|
---|
[6033] | 79 | protected virtual void DeregisterJobEvents() {
|
---|
[4905] | 80 | if (Content != null && Content.Job != null) {
|
---|
[6178] | 81 | Content.ItemJob.ComputeInParallelChanged -= new EventHandler(OptimizerJob_ComputeInParallelChanged);
|
---|
| 82 | Content.ItemJob.ItemChanged -= new EventHandler(Job_ItemChanged);
|
---|
[4905] | 83 | }
|
---|
| 84 | }
|
---|
| 85 |
|
---|
| 86 | #region Content Events
|
---|
[6033] | 87 | protected virtual void Content_JobChanged(object sender, EventArgs e) {
|
---|
[4905] | 88 | if (InvokeRequired) {
|
---|
| 89 | Invoke(new EventHandler(Content_JobChanged), sender, e);
|
---|
| 90 | } else {
|
---|
| 91 | if (Content != null && Content.Job != null) {
|
---|
| 92 | this.jobIdTextBox.Text = Content.Job.Id.ToString();
|
---|
[5779] | 93 | this.dateCreatedTextBox.Text = Content.Job.DateCreated.HasValue ? Content.Job.DateCreated.ToString() : string.Empty;
|
---|
[4905] | 94 | this.priorityTextBox.Text = Content.Job.Priority.ToString();
|
---|
| 95 | this.coresNeededTextBox.Text = Content.Job.CoresNeeded.ToString();
|
---|
| 96 | this.memoryNeededTextBox.Text = Content.Job.MemoryNeeded.ToString();
|
---|
| 97 | } else {
|
---|
| 98 | this.jobIdTextBox.Text = string.Empty;
|
---|
| 99 | this.dateCreatedTextBox.Text = string.Empty;
|
---|
| 100 | this.priorityTextBox.Text = string.Empty;
|
---|
| 101 | this.coresNeededTextBox.Text = string.Empty;
|
---|
| 102 | this.memoryNeededTextBox.Text = string.Empty;
|
---|
| 103 | }
|
---|
| 104 | }
|
---|
| 105 | }
|
---|
| 106 |
|
---|
[6033] | 107 | protected virtual void Content_JobItemChanged(object sender, EventArgs e) {
|
---|
| 108 | RegisterJobEvents();
|
---|
| 109 | Job_ItemChanged(this, e);
|
---|
| 110 | }
|
---|
| 111 |
|
---|
| 112 | protected virtual void Job_ItemChanged(object sender, EventArgs e) {
|
---|
[6178] | 113 | if (Content != null && Content.Job != null && Content.ItemJob.Item != null) {
|
---|
| 114 | optimizerItemView.Content = Content.ItemJob.Item;
|
---|
[6033] | 115 | } else {
|
---|
| 116 | optimizerItemView.Content = null;
|
---|
| 117 | }
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | protected virtual void Content_JobStateChanged(object sender, EventArgs e) {
|
---|
[4905] | 121 | if (InvokeRequired) {
|
---|
| 122 | Invoke(new EventHandler(Content_JobStateChanged), sender, e);
|
---|
| 123 | } else {
|
---|
| 124 | if (Content != null && Content.Job != null) {
|
---|
[5511] | 125 | this.stateTextBox.Text = Content.Job.State.ToString();
|
---|
[6168] | 126 | this.commandTextBox.Text = Content.Job.Command.ToString();
|
---|
[4905] | 127 | this.executionTimeTextBox.Text = Content.Job.ExecutionTime.ToString();
|
---|
| 128 | this.dateFinishedTextBox.Text = Content.Job.DateFinished.ToString();
|
---|
[5779] | 129 | this.exceptionTextBox.Text = Content.Job.CurrentStateLog != null ? Content.Job.CurrentStateLog.Exception : string.Empty;
|
---|
[5793] | 130 | this.lastUpdatedTextBox.Text = Content.Job.LastJobDataUpdate.ToString();
|
---|
[6178] | 131 | if (Content.ItemJob.ComputeInParallel) {
|
---|
[5718] | 132 | this.stateLogViewHost.Content = new StateLogListList(
|
---|
[5636] | 133 | this.Content.ChildHiveJobs.Select(child => new StateLogList(child.Job.StateLog)
|
---|
[5597] | 134 | ));
|
---|
| 135 | } else {
|
---|
[5636] | 136 | this.stateLogViewHost.Content = new StateLogList(Content.Job.StateLog);
|
---|
[5597] | 137 | }
|
---|
[4905] | 138 | } else {
|
---|
| 139 | this.stateTextBox.Text = string.Empty;
|
---|
[6168] | 140 | this.commandTextBox.Text = string.Empty;
|
---|
[4905] | 141 | this.executionTimeTextBox.Text = string.Empty;
|
---|
| 142 | this.dateCalculatedText.Text = string.Empty;
|
---|
| 143 | this.dateFinishedTextBox.Text = string.Empty;
|
---|
| 144 | this.exceptionTextBox.Text = string.Empty;
|
---|
[5597] | 145 | this.stateLogViewHost.Content = null;
|
---|
[5793] | 146 | this.lastUpdatedTextBox.Text = string.Empty;
|
---|
[4905] | 147 | }
|
---|
[5779] | 148 | SetEnabledStateOfControls();
|
---|
[4905] | 149 | }
|
---|
| 150 | }
|
---|
| 151 |
|
---|
[6033] | 152 | protected virtual void OptimizerJob_ComputeInParallelChanged(object sender, EventArgs e) {
|
---|
[4905] | 153 | if (InvokeRequired) {
|
---|
| 154 | Invoke(new EventHandler(OptimizerJob_ComputeInParallelChanged), sender, e);
|
---|
| 155 | } else {
|
---|
[6178] | 156 | computeInParallelCheckBox.Checked = Content.ItemJob.ComputeInParallel;
|
---|
[4905] | 157 | }
|
---|
| 158 | }
|
---|
| 159 | #endregion
|
---|
| 160 |
|
---|
[6033] | 161 | #region Child Control Events
|
---|
| 162 | protected virtual void computeInParallelCheckBox_CheckedChanged(object sender, EventArgs e) {
|
---|
[6178] | 163 | if (Content != null && Content.ItemJob != null) {
|
---|
| 164 | this.Content.ItemJob.ComputeInParallel = this.computeInParallelCheckBox.Checked;
|
---|
[4905] | 165 | }
|
---|
| 166 | }
|
---|
[5779] | 167 |
|
---|
[6033] | 168 | protected virtual void exceptionTextBox_DoubleClick(object sender, EventArgs e) {
|
---|
[5779] | 169 | using (TextDialog dialog = new TextDialog("Exception", exceptionTextBox.Text, ReadOnly || !Content.CanChangeDescription)) {
|
---|
| 170 | if (dialog.ShowDialog(this) == DialogResult.OK)
|
---|
| 171 | Content.Description = dialog.Content;
|
---|
| 172 | }
|
---|
| 173 | }
|
---|
| 174 |
|
---|
[6033] | 175 | protected virtual void modifyItemButton_Click(object sender, EventArgs e) {
|
---|
[6178] | 176 | MainFormManager.MainForm.ShowContent(Content.ItemJob.Item);
|
---|
[5779] | 177 | }
|
---|
[6033] | 178 | #endregion
|
---|
[6267] | 179 |
|
---|
| 180 | protected override void SetEnabledStateOfControls() {
|
---|
| 181 | base.SetEnabledStateOfControls();
|
---|
| 182 | this.jobIdTextBox.ReadOnly = true;
|
---|
| 183 | this.stateTextBox.ReadOnly = true;
|
---|
| 184 | this.commandTextBox.ReadOnly = true;
|
---|
| 185 | this.executionTimeTextBox.ReadOnly = true;
|
---|
| 186 | this.dateCreatedTextBox.ReadOnly = true;
|
---|
| 187 | this.dateCalculatedText.ReadOnly = true;
|
---|
| 188 | this.dateFinishedTextBox.ReadOnly = true;
|
---|
| 189 | this.exceptionTextBox.ReadOnly = true;
|
---|
| 190 | this.lastUpdatedTextBox.ReadOnly = true;
|
---|
| 191 |
|
---|
| 192 | this.priorityTextBox.ReadOnly = this.ReadOnly;
|
---|
| 193 | this.coresNeededTextBox.ReadOnly = this.ReadOnly;
|
---|
| 194 | this.memoryNeededTextBox.ReadOnly = this.ReadOnly;
|
---|
| 195 | this.computeInParallelCheckBox.Enabled = !this.ReadOnly && this.Content != null && this.Content.ItemJob != null && this.Content.ItemJob.IsParallelizable;
|
---|
| 196 |
|
---|
| 197 | this.modifyItemButton.Enabled = (Content != null && Content.ItemJob.Item != null && (Content.Job.State == JobState.Paused || Content.Job.State == JobState.Offline || Content.Job.State == JobState.Finished || Content.Job.State == JobState.Failed || Content.Job.State == JobState.Aborted));
|
---|
| 198 |
|
---|
| 199 | optimizerItemView.ReadOnly = true;
|
---|
| 200 | }
|
---|
[4905] | 201 | }
|
---|
| 202 | }
|
---|