Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HiveHiveEngine/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs @ 11235

Last change on this file since 11235 was 7259, checked in by swagner, 13 years ago

Updated year of copyrights to 2012 (#1716)

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