Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs @ 7513

Last change on this file since 7513 was 7409, checked in by ascheibe, 13 years ago

#1766 fixed crash when the hive job manager can't deserialize a task

File size: 23.4 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.ComponentModel;
24using System.Linq;
25using System.Threading;
26using System.Threading.Tasks;
27using System.Windows.Forms;
28using HeuristicLab.Clients.Hive.Views;
29using HeuristicLab.Collections;
30using HeuristicLab.Common;
31using HeuristicLab.Core;
32using HeuristicLab.MainForm;
33using HeuristicLab.Optimization;
34using HeuristicLab.PluginInfrastructure;
35
36namespace HeuristicLab.Clients.Hive.JobManager.Views {
37  /// <summary>
38  /// The base class for visual representations of items.
39  /// </summary>
40  [View("Hive Job View")]
41  [Content(typeof(RefreshableJob), true)]
42  public partial class RefreshableHiveJobView : HeuristicLab.Core.Views.ItemView {
43    private ProgressView progressView;
44
45    public new RefreshableJob Content {
46      get { return (RefreshableJob)base.Content; }
47      set { base.Content = value; }
48    }
49
50    /// <summary>
51    /// Initializes a new instance of <see cref="ItemBaseView"/>.
52    /// </summary>
53    public RefreshableHiveJobView() {
54      InitializeComponent();
55    }
56
57    protected override void RegisterContentEvents() {
58      base.RegisterContentEvents();
59      Content.RefreshAutomaticallyChanged += new EventHandler(Content_RefreshAutomaticallyChanged);
60      Content.JobChanged += new EventHandler(Content_HiveExperimentChanged);
61      Content.IsControllableChanged += new EventHandler(Content_IsControllableChanged);
62      Content.JobStatisticsChanged += new EventHandler(Content_JobStatisticsChanged);
63      Content.ExceptionOccured += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccured);
64      Content.StateLogListChanged += new EventHandler(Content_StateLogListChanged);
65      Content.IsProgressingChanged += new EventHandler(Content_IsProgressingChanged);
66      Content.HiveTasksChanged += new EventHandler(Content_HiveTasksChanged);
67      Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged);
68      Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged);
69      Content.IsAllowedPrivilegedChanged += new EventHandler(Content_IsAllowedPrivilegedChanged);
70      Content.Loaded += new EventHandler(Content_Loaded);
71    }
72
73    protected override void DeregisterContentEvents() {
74      Content.RefreshAutomaticallyChanged -= new EventHandler(Content_RefreshAutomaticallyChanged);
75      Content.JobChanged -= new EventHandler(Content_HiveExperimentChanged);
76      Content.IsControllableChanged -= new EventHandler(Content_IsControllableChanged);
77      Content.JobStatisticsChanged -= new EventHandler(Content_JobStatisticsChanged);
78      Content.ExceptionOccured -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccured);
79      Content.StateLogListChanged -= new EventHandler(Content_StateLogListChanged);
80      Content.IsProgressingChanged -= new EventHandler(Content_IsProgressingChanged);
81      Content.HiveTasksChanged -= new EventHandler(Content_HiveTasksChanged);
82      Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged);
83      Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged);
84      Content.Loaded -= new EventHandler(Content_Loaded);
85      base.DeregisterContentEvents();
86    }
87
88    private void RegisterHiveExperimentEvents() {
89      Content.Job.PropertyChanged += new PropertyChangedEventHandler(HiveExperiment_PropertyChanged);
90    }
91
92    private void DeregisterHiveExperimentEvents() {
93      Content.Job.PropertyChanged -= new PropertyChangedEventHandler(HiveExperiment_PropertyChanged);
94    }
95
96    private void RegisterHiveJobEvents() {
97      Content.HiveTasks.ItemsAdded += new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_ItemsAdded);
98      Content.HiveTasks.ItemsRemoved += new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_ItemsRemoved);
99      Content.HiveTasks.CollectionReset += new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_CollectionReset);
100    }
101    private void DeregisterHiveJobEvents() {
102      Content.HiveTasks.ItemsAdded -= new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_ItemsAdded);
103      Content.HiveTasks.ItemsRemoved -= new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_ItemsRemoved);
104      Content.HiveTasks.CollectionReset -= new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_CollectionReset);
105    }
106
107    protected override void OnContentChanged() {
108      base.OnContentChanged();
109      if (Content == null) {
110        nameTextBox.Text = string.Empty;
111        executionTimeTextBox.Text = string.Empty;
112        resourceNamesTextBox.Text = string.Empty;
113        isPrivilegedCheckBox.Checked = false;
114        logView.Content = null;
115        refreshAutomaticallyCheckBox.Checked = false;
116        runCollectionViewHost.Content = null;
117      } else {
118        nameTextBox.Text = Content.Job.Name;
119        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
120        resourceNamesTextBox.Text = Content.Job.ResourceNames;
121        isPrivilegedCheckBox.Checked = Content.Job.IsPrivileged;
122        refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically;
123        logView.Content = Content.Log;
124        runCollectionViewHost.Content = GetAllRunsFromJob(Content);
125      }
126      hiveExperimentPermissionListView.Content = null; // has to be filled by refresh button
127      Content_JobStatisticsChanged(this, EventArgs.Empty);
128      Content_HiveExperimentChanged(this, EventArgs.Empty);
129      Content_HiveTasksChanged(this, EventArgs.Empty);
130      Content_IsProgressingChanged(this, EventArgs.Empty);
131      Content_StateLogListChanged(this, EventArgs.Empty);
132      HiveExperiment_PropertyChanged(this, new PropertyChangedEventArgs("Id"));
133      SetEnabledStateOfControls();
134    }
135
136    protected override void SetEnabledStateOfControls() {
137      base.SetEnabledStateOfControls();
138      executionTimeTextBox.Enabled = Content != null;
139      jobsTextBox.ReadOnly = true;
140      calculatingTextBox.ReadOnly = true;
141      finishedTextBox.ReadOnly = true;
142
143      if (Content != null) {
144        bool alreadyUploaded = Content.Id != Guid.Empty;
145        bool jobsLoaded = Content.HiveTasks != null && Content.HiveTasks.All(x => x.Task.Id != Guid.Empty);
146
147        this.nameTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded;
148        this.resourceNamesTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded;
149        this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded;
150
151        this.isPrivilegedCheckBox.Enabled = Content.IsAllowedPrivileged && Content.IsControllable && !(Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded); // TODO: check if user has the rights to do this       
152        this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && Content.ExecutionState == ExecutionState.Started;
153        this.refreshButton.Enabled = Content.IsDownloadable && alreadyUploaded;
154        this.Locked = !Content.IsControllable || Content.ExecutionState == ExecutionState.Started;
155      }
156      SetEnabledStateOfExecutableButtons();
157      tabControl_SelectedIndexChanged(this, EventArgs.Empty); // ensure sharing tabpage is disabled
158    }
159
160    protected override void OnClosed(FormClosedEventArgs e) {
161      if (Content != null) {
162        if (Content.RefreshAutomatically)
163          Content.StopResultPolling();
164      }
165      base.OnClosed(e);
166    }
167
168    #region Content Events
169    private void HiveTasks_ItemsAdded(object sender, CollectionItemsChangedEventArgs<HiveTask> e) {
170      if (InvokeRequired)
171        Invoke(new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_ItemsAdded), sender, e);
172      else {
173        foreach (HiveTask t in e.Items) {
174          t.TaskStateChanged += new EventHandler(HiveTask_TaskStateChanged);
175        }
176        SetEnabledStateOfControls();
177      }
178    }
179
180    private void HiveTasks_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<HiveTask> e) {
181      if (InvokeRequired)
182        Invoke(new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_ItemsRemoved), sender, e);
183      else {
184        foreach (HiveTask t in e.Items) {
185          t.TaskStateChanged -= new EventHandler(HiveTask_TaskStateChanged);
186        }
187        SetEnabledStateOfControls();
188      }
189    }
190
191    private void HiveTasks_CollectionReset(object sender, CollectionItemsChangedEventArgs<HiveTask> e) {
192      if (InvokeRequired)
193        Invoke(new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_CollectionReset), sender, e);
194      else {
195        foreach (HiveTask t in e.Items) {
196          t.TaskStateChanged -= new EventHandler(HiveTask_TaskStateChanged);
197        }
198        SetEnabledStateOfControls();
199      }
200    }
201
202    void HiveTask_TaskStateChanged(object sender, EventArgs e) {
203      runCollectionViewHost.Content = GetAllRunsFromJob(Content);
204    }
205
206    private void Content_ExecutionStateChanged(object sender, EventArgs e) {
207      if (InvokeRequired)
208        Invoke(new EventHandler(Content_ExecutionStateChanged), sender, e);
209      else
210        SetEnabledStateOfControls();
211    }
212    private void Content_Prepared(object sender, EventArgs e) {
213      if (InvokeRequired)
214        Invoke(new EventHandler(Content_Prepared), sender, e);
215      else {
216        nameTextBox.Enabled = true;
217        Locked = false;
218        SetEnabledStateOfControls();
219      }
220    }
221    private void Content_Started(object sender, EventArgs e) {
222      if (InvokeRequired)
223        Invoke(new EventHandler(Content_Started), sender, e);
224      else {
225        nameTextBox.Enabled = false;
226        SetEnabledStateOfControls();
227      }
228    }
229    private void Content_Paused(object sender, EventArgs e) {
230      if (InvokeRequired)
231        Invoke(new EventHandler(Content_Paused), sender, e);
232      else {
233        nameTextBox.Enabled = true;
234        SetEnabledStateOfControls();
235      }
236    }
237    private void Content_Stopped(object sender, EventArgs e) {
238      if (InvokeRequired)
239        Invoke(new EventHandler(Content_Stopped), sender, e);
240      else {
241        nameTextBox.Enabled = true;
242        Locked = false;
243        SetEnabledStateOfControls();
244      }
245    }
246    private void Content_ExecutionTimeChanged(object sender, EventArgs e) {
247      if (InvokeRequired)
248        Invoke(new EventHandler(Content_ExecutionTimeChanged), sender, e);
249      else
250        executionTimeTextBox.Text = Content.ExecutionTime.ToString();
251    }
252    private void Content_RefreshAutomaticallyChanged(object sender, EventArgs e) {
253      if (InvokeRequired)
254        Invoke(new EventHandler(Content_RefreshAutomaticallyChanged), sender, e);
255      else {
256        refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically;
257        SetEnabledStateOfControls();
258      }
259    }
260    private void Content_HiveTasksChanged(object sender, EventArgs e) {
261      if (InvokeRequired)
262        Invoke(new EventHandler(Content_HiveTasksChanged), sender, e);
263      else {
264        if (Content != null && Content.HiveTasks != null) {
265          jobsTreeView.Content = Content.HiveTasks;
266          RegisterHiveJobEvents();
267        } else {
268          jobsTreeView.Content = null;
269        }
270        SetEnabledStateOfControls();
271      }
272    }
273
274    void Content_Loaded(object sender, EventArgs e) {
275      runCollectionViewHost.Content = GetAllRunsFromJob(Content);
276    }
277
278    private void Content_HiveExperimentChanged(object sender, EventArgs e) {
279      if (Content != null && Content.Job != null) {
280        RegisterHiveExperimentEvents();
281        Content_IsProgressingChanged(sender, e);
282      }
283    }
284    private void Content_IsControllableChanged(object sender, EventArgs e) {
285      SetEnabledStateOfControls();
286    }
287    private void Content_JobStatisticsChanged(object sender, EventArgs e) {
288      if (InvokeRequired)
289        Invoke(new EventHandler(Content_JobStatisticsChanged), sender, e);
290      else {
291        if (Content != null) {
292          jobsTextBox.Text = (Content.Job.JobCount - Content.Job.CalculatingCount - Content.Job.FinishedCount).ToString();
293          calculatingTextBox.Text = Content.Job.CalculatingCount.ToString();
294          finishedTextBox.Text = Content.Job.FinishedCount.ToString();
295        } else {
296          jobsTextBox.Text = "0";
297          calculatingTextBox.Text = "0";
298          finishedTextBox.Text = "0";
299        }
300      }
301    }
302    private void Content_ExceptionOccured(object sender, EventArgs<Exception> e) {
303      if (InvokeRequired)
304        Invoke(new EventHandler<EventArgs<Exception>>(Content_ExceptionOccured), sender, e);
305      else {
306        //don't show the error dialog when downloading tasks, the HiveClient will throw an exception and the dialog will be shown then
307        if (sender.GetType() != typeof(ConcurrentTaskDownloader<ItemTask>) && sender.GetType() != typeof(TaskDownloader)) {
308          ErrorHandling.ShowErrorDialog(this, e.Value);
309        }
310      }
311    }
312    private void Content_StateLogListChanged(object sender, EventArgs e) {
313      if (InvokeRequired)
314        Invoke(new EventHandler(Content_StateLogListChanged), sender, e);
315      else {
316        UpdateStateLogList();
317      }
318    }
319    private void Content_IsAllowedPrivilegedChanged(object sender, EventArgs e) {
320      if (InvokeRequired)
321        Invoke(new EventHandler(Content_IsAllowedPrivilegedChanged), sender, e);
322      else {
323        SetEnabledStateOfControls();
324      }
325    }
326
327    private void UpdateStateLogList() {
328      if (Content != null && this.Content.Job != null) {
329        stateLogViewHost.Content = this.Content.StateLogList;
330      } else {
331        stateLogViewHost.Content = null;
332      }
333    }
334
335    private void HiveExperiment_PropertyChanged(object sender, PropertyChangedEventArgs e) {
336      if (this.Content != null && e.PropertyName == "Id") this.hiveExperimentPermissionListView.HiveExperimentId = this.Content.Job.Id;
337    }
338    #endregion
339
340    #region Control events
341    private void startButton_Click(object sender, EventArgs e) {
342      if (nameTextBox.Text.Trim() == string.Empty) {
343        MessageBox.Show("Please enter a name for the job before uploading it!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
344      } else if (Content.ExecutionState == ExecutionState.Paused) {
345        var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobAsync, Content);
346        task.ContinueWith((t) => {
347          FinishProgressView();
348          MessageBox.Show("An error occured resuming the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
349          Content.Log.LogException(t.Exception);
350        }, TaskContinuationOptions.OnlyOnFaulted);
351      } else {
352        HiveClient.StartJob((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Start failed.", ex), Content, new CancellationToken());
353      }
354    }
355
356    private void pauseButton_Click(object sender, EventArgs e) {
357      var task = System.Threading.Tasks.Task.Factory.StartNew(PauseJobAsync, Content);
358      task.ContinueWith((t) => {
359        FinishProgressView();
360        MessageBox.Show("An error occured pausing the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
361        Content.Log.LogException(t.Exception);
362      }, TaskContinuationOptions.OnlyOnFaulted);
363    }
364
365    private void stopButton_Click(object sender, EventArgs e) {
366      var task = System.Threading.Tasks.Task.Factory.StartNew(StopJobAsync, Content);
367      task.ContinueWith((t) => {
368        FinishProgressView();
369        MessageBox.Show("An error occured stopping the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
370        Content.Log.LogException(t.Exception);
371      }, TaskContinuationOptions.OnlyOnFaulted);
372    }
373    private void resetButton_Click(object sender, EventArgs e) { }
374
375    private void PauseJobAsync(object job) {
376      IProgress prog = new Progress();
377      prog.Status = "Pausing job...";
378      SetProgressView(prog);
379      HiveClient.PauseJob((RefreshableJob)job);
380      FinishProgressView();
381    }
382
383    private void StopJobAsync(object job) {
384      IProgress prog = new Progress();
385      prog.Status = "Stopping job...";
386      SetProgressView(prog);
387      HiveClient.StopJob((RefreshableJob)job);
388      FinishProgressView();
389    }
390
391    private void ResumeJobAsync(object job) {
392      IProgress prog = new Progress();
393      prog.Status = "Resuming job...";
394      SetProgressView(prog);
395      HiveClient.ResumeJob((RefreshableJob)job);
396      FinishProgressView();
397    }
398
399    private void nameTextBox_Validated(object sender, EventArgs e) {
400      if (Content.Job.Name != nameTextBox.Text)
401        Content.Job.Name = nameTextBox.Text;
402    }
403
404    private void resourceNamesTextBox_Validated(object sender, EventArgs e) {
405      if (Content.Job.ResourceNames != resourceNamesTextBox.Text)
406        Content.Job.ResourceNames = resourceNamesTextBox.Text;
407    }
408
409    private void refreshAutomaticallyCheckBox_Validated(object sender, EventArgs e) {
410      if (Content != null) Content.RefreshAutomatically = refreshAutomaticallyCheckBox.Checked;
411    }
412
413    private void isPrivilegedCheckBox_Validated(object sender, EventArgs e) {
414      if (Content != null) Content.Job.IsPrivileged = isPrivilegedCheckBox.Checked;
415    }
416
417    private void refreshButton_Click(object sender, EventArgs e) {
418      var invoker = new Action<RefreshableJob>(HiveClient.LoadJob);
419      invoker.BeginInvoke(Content, (ar) => {
420        try {
421          invoker.EndInvoke(ar);
422        }
423        catch (Exception ex) {
424          ThreadPool.QueueUserWorkItem(delegate(object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex);
425        }
426      }, null);
427    }
428
429    private void refreshPermissionsButton_Click(object sender, EventArgs e) {
430      if (this.Content.Job.Id == Guid.Empty) {
431        MessageBox.Show("You have to upload the Job first before you can share it.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
432      } else {
433        hiveExperimentPermissionListView.Content = HiveClient.GetJobPermissions(this.Content.Job.Id);
434      }
435    }
436    #endregion
437
438    #region Helpers
439    private void SetEnabledStateOfExecutableButtons() {
440      if (Content == null) {
441        startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;
442      } else {
443        startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused);
444        pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started;
445        stopButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started;
446        resetButton.Enabled = false;
447      }
448    }
449    #endregion
450
451    #region Progress reporting
452    private void Content_IsProgressingChanged(object sender, EventArgs e) {
453      if (this.InvokeRequired) {
454        Invoke(new EventHandler(Content_IsProgressingChanged), sender, e);
455      } else {
456        if (Content != null && Content.IsProgressing) {
457          SetProgressView();
458        } else {
459          FinishProgressView();
460        }
461      }
462    }
463
464    private void SetProgressView() {
465      if (InvokeRequired) {
466        Invoke(new Action(SetProgressView));
467      } else {
468        if (progressView == null) {
469          progressView = new ProgressView(this, Content.Progress);
470        } else {
471          progressView.Progress = Content.Progress;
472        }
473      }
474    }
475
476    private void SetProgressView(IProgress progress) {
477      if (InvokeRequired) {
478        Invoke(new Action<IProgress>(SetProgressView), progress);
479      } else {
480        if (progressView == null) {
481          progressView = new ProgressView(this, progress);
482        } else {
483          progressView.Progress = progress;
484        }
485      }
486    }
487
488    private void FinishProgressView() {
489      if (InvokeRequired) {
490        Invoke(new Action(FinishProgressView));
491      } else {
492        if (progressView != null) {
493          progressView.Finish();
494          progressView = null;
495          SetEnabledStateOfControls();
496        }
497      }
498    }
499    #endregion
500
501    #region Drag & Drop
502    private void jobsTreeView_DragOver(object sender, DragEventArgs e) {
503      jobsTreeView_DragEnter(sender, e);
504    }
505
506    private void jobsTreeView_DragEnter(object sender, DragEventArgs e) {
507      e.Effect = DragDropEffects.None;
508      var obj = e.Data.GetData(Constants.DragDropDataFormat);
509      if (obj is IOptimizer) {
510        if (Content.Id != Guid.Empty) e.Effect = DragDropEffects.None;
511        else if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
512        else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
513      }
514    }
515
516    private void jobsTreeView_DragDrop(object sender, DragEventArgs e) {
517      if (e.Effect != DragDropEffects.None) {
518        var obj = e.Data.GetData(Constants.DragDropDataFormat);
519
520        var optimizer = obj as IOptimizer;
521        if (optimizer != null) {
522          IOptimizer newOptimizer = null;
523          if (e.Effect.HasFlag(DragDropEffects.Copy)) {
524            newOptimizer = (IOptimizer)optimizer.Clone();
525          } else {
526            newOptimizer = optimizer;
527          }
528          if (newOptimizer.ExecutionState != ExecutionState.Prepared) {
529            newOptimizer.Prepare();
530          }
531
532          Content.HiveTasks.Add(new OptimizerHiveTask(newOptimizer));
533        }
534      }
535    }
536    #endregion
537
538    private void tabControl_SelectedIndexChanged(object sender, EventArgs e) {
539      if (tabControl.SelectedTab == permissionTabPage) {
540        if (!Content.IsSharable) {
541          MessageBox.Show("Unable to load permissions. You have insufficient access privileges.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
542          tabControl.SelectedTab = tasksTabPage;
543        }
544      }
545    }
546
547    private RunCollection GetAllRunsFromJob(RefreshableJob job) {
548      if (job != null) {
549        RunCollection runs = new RunCollection();
550
551        foreach (HiveTask subTask in job.HiveTasks) {
552          if (subTask is OptimizerHiveTask) {
553            OptimizerHiveTask ohTask = subTask as OptimizerHiveTask;
554            runs.AddRange(ohTask.ItemTask.Item.Runs);
555          }
556        }
557        return runs;
558      } else {
559        return null;
560      }
561    }
562  }
563}
Note: See TracBrowser for help on using the repository browser.