Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/16/13 13:13:41 (11 years ago)
Author:
spimming
Message:

#1888:

  • Merged revisions from trunk
Location:
branches/OaaS
Files:
13 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/OaaS

  • branches/OaaS/HeuristicLab.Clients.Hive.JobManager/3.3/HeuristicLab.Clients.Hive.JobManager-3.3.csproj

    r9253 r9363  
    9999  <ItemGroup>
    100100    <Compile Include="ExtensionMethods\TreeNodeExtensions.cs" />
     101    <Compile Include="ListViewItemDateComparer.cs" />
    101102    <Compile Include="Plugin.cs" />
    102103    <Compile Include="Views\HiveJobManagerView.cs">
     
    233234  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    234235  <PropertyGroup>
    235     <PreBuildEvent>set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
     236    <PreBuildEvent Condition=" '$(OS)' == 'Windows_NT' ">set Path=%25Path%25;$(ProjectDir);$(SolutionDir)
    236237set ProjectDir=$(ProjectDir)
    237238set SolutionDir=$(SolutionDir)
     
    239240
    240241call PreBuildEvent.cmd</PreBuildEvent>
     242    <PreBuildEvent Condition=" '$(OS)' != 'Windows_NT' ">
     243export ProjectDir=$(ProjectDir)
     244export SolutionDir=$(SolutionDir)
     245
     246$SolutionDir/PreBuildEvent.sh
     247</PreBuildEvent>
    241248  </PropertyGroup>
    242249  <PropertyGroup>
  • branches/OaaS/HeuristicLab.Clients.Hive.JobManager/3.3/Plugin.cs.frame

    r7259 r9363  
    2323
    2424namespace HeuristicLab.Clients.Hive.JobManager {
    25   [Plugin("HeuristicLab.Clients.Hive.JobManager", "3.3.6.$WCREV$")]
     25  [Plugin("HeuristicLab.Clients.Hive.JobManager", "3.3.7.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Clients.Hive.JobManager-3.3.dll", PluginFileType.Assembly)]
    2727  [PluginDependency("HeuristicLab.Clients.Hive", "3.3")]
  • branches/OaaS/HeuristicLab.Clients.Hive.JobManager/3.3/Properties/AssemblyInfo.cs.frame

    r7260 r9363  
    5555// [assembly: AssemblyVersion("1.0.*")]
    5656[assembly: AssemblyVersion("3.3.0.0")]
    57 [assembly: AssemblyFileVersion("3.3.6.$WCREV$")]
     57[assembly: AssemblyFileVersion("3.3.7.$WCREV$")]
  • branches/OaaS/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobManagerView.cs

    r7259 r9363  
    2525using System.Windows.Forms;
    2626using HeuristicLab.Clients.Hive.Views;
    27 using HeuristicLab.Collections;
    2827using HeuristicLab.MainForm;
    2928using HeuristicLab.MainForm.WindowsForms;
     
    5453      Content.Refreshing += new EventHandler(Content_Refreshing);
    5554      Content.Refreshed += new EventHandler(Content_Refreshed);
    56       Content.HiveExperimentsChanged += new EventHandler(Content_HiveExperimentsChanged);
    57 
    5855    }
    5956
     
    6158      Content.Refreshing -= new EventHandler(Content_Refreshing);
    6259      Content.Refreshed -= new EventHandler(Content_Refreshed);
    63       Content.HiveExperimentsChanged -= new EventHandler(Content_HiveExperimentsChanged);
    6460      base.DeregisterContentEvents();
    6561    }
     
    123119
    124120    protected override void OnClosing(FormClosingEventArgs e) {
    125       base.OnClosing(e);
    126       if (Content != null && Content.Jobs != null) {
    127         foreach (var exp in Content.Jobs.OfType<RefreshableJob>()) {
    128           if (exp.RefreshAutomatically) {
    129             exp.RefreshAutomatically = false; // stop result polling
    130           }
     121      if (Content != null && Content.Jobs.Any(x => x.IsProgressing)) {
     122        DialogResult result = MessageBox.Show("There are still unfinished down/uploads. Are you sure you want to close the window?", "HeuristicLab Hive Job Manager", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
     123
     124        if (result == DialogResult.No) {
     125          e.Cancel = true;
    131126        }
     127      } else {
     128        base.OnClosing(e);
    132129      }
    133130    }
    134131
    135     private void HiveExperiments_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<RefreshableJob> e) {
    136       foreach (var item in e.Items) {
    137         HiveClient.Delete(item);
     132    protected override void OnClosed(FormClosedEventArgs e) {
     133      if (Content != null) {
     134        Content.ClearHiveClient();
     135        Content = null;
    138136      }
    139     }
    140 
    141     private void Content_HiveExperimentsChanged(object sender, EventArgs e) {
    142       Content.Jobs.ItemsRemoved += new CollectionItemsChangedEventHandler<RefreshableJob>(HiveExperiments_ItemsRemoved);
     137      base.OnClosed(e);
    143138    }
    144139  }
  • branches/OaaS/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobPermissionListView.Designer.cs

    r7967 r9363  
    1 namespace HeuristicLab.Clients.Hive.JobManager.Views {
     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
     22namespace HeuristicLab.Clients.Hive.JobManager.Views {
    223  partial class HiveJobPermissionListView {
    324    /// <summary>
  • branches/OaaS/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobPermissionView.Designer.cs

    r7967 r9363  
    1 namespace HeuristicLab.Clients.Hive.JobManager.Views {
     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
     22namespace HeuristicLab.Clients.Hive.JobManager.Views {
    223  partial class HiveJobPermissionView {
    324    /// <summary>
  • branches/OaaS/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.Designer.cs

    r7967 r9363  
    1 namespace HeuristicLab.Clients.Hive.JobManager.Views {
     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
     22namespace HeuristicLab.Clients.Hive.JobManager.Views {
    223  partial class HiveResourceSelector {
    324    /// <summary>
  • branches/OaaS/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelectorDialog.Designer.cs

    r8165 r9363  
    1 namespace HeuristicLab.Clients.Hive.JobManager.Views {
     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
     22namespace HeuristicLab.Clients.Hive.JobManager.Views {
    223  partial class HiveResourceSelectorDialog {
    324    /// <summary>
  • branches/OaaS/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.Designer.cs

    r7967 r9363  
    1 namespace HeuristicLab.Clients.Hive.JobManager.Views {
     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
     22namespace HeuristicLab.Clients.Hive.JobManager.Views {
    223  partial class RefreshableHiveJobListView {
    324    /// <summary>
     
    627    private System.ComponentModel.IContainer components = null;
    728
    8     /// <summary>
    9     /// Clean up any resources being used.
    10     /// </summary>
    11     /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
    12     protected override void Dispose(bool disposing) {
    13       if (disposing) {
    14         if (components != null) components.Dispose();
    15       }
    16       base.Dispose(disposing);
    17     }
    1829
    1930    #region Component Designer generated code
  • branches/OaaS/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.cs

    r7259 r9363  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Threading.Tasks;
    2325using System.Windows.Forms;
    2426using HeuristicLab.Collections;
    2527using HeuristicLab.Core;
    2628using HeuristicLab.MainForm;
     29using HeuristicLab.MainForm.WindowsForms;
     30using HeuristicLab.PluginInfrastructure;
    2731
    2832namespace HeuristicLab.Clients.Hive.JobManager.Views {
     
    3034  [Content(typeof(ItemCollection<RefreshableJob>), false)]
    3135  public partial class RefreshableHiveJobListView : HeuristicLab.Core.Views.ItemCollectionView<RefreshableJob> {
     36    private Progress progress;
     37    private ProgressView progressView;
    3238
    3339    public RefreshableHiveJobListView() {
    3440      InitializeComponent();
    3541      itemsGroupBox.Text = "Jobs";
    36       this.itemsListView.View = View.Details;
     42      this.itemsListView.View = System.Windows.Forms.View.Details;
    3743      this.itemsListView.Columns.Clear();
    3844      this.itemsListView.Columns.Add(new ColumnHeader("Date") { Text = "Date" });
     
    4349      this.itemsListView.HeaderStyle = ColumnHeaderStyle.Clickable;
    4450      this.itemsListView.FullRowSelect = true;
     51
     52      this.itemsListView.ListViewItemSorter = new ListViewItemDateComparer(0, SortOrder.Ascending);
    4553      this.itemsListView.Sorting = SortOrder.Ascending;
    4654      this.itemsListView.Sort();
     55
     56      progress = new Progress() {
     57        CanBeCanceled = false,
     58        ProgressState = ProgressState.Finished
     59      };
     60      progressView = new ProgressView(this, progress);
    4761    }
    4862
    4963    protected override RefreshableJob CreateItem() {
    50       var refreshableJob = new RefreshableJob() { IsAllowedPrivileged = HiveClient.Instance.IsAllowedPrivileged };
     64      var refreshableJob = new RefreshableJob();
    5165      refreshableJob.Job.Name = "New Hive Job";
    5266      return refreshableJob;
     67    }
     68
     69    protected override void OnLockedChanged() {
     70      base.OnLockedChanged();
     71
     72      itemsListView.Enabled = !Locked;
     73      addButton.Enabled = !Locked;
     74      sortAscendingButton.Enabled = !Locked;
     75      sortDescendingButton.Enabled = !Locked;
     76      removeButton.Enabled = !Locked;
     77    }
     78
     79    protected override void SetEnabledStateOfControls() {
     80      // if the view is locked, a job is currently beeing deleted and everything should be disabled
     81      if (!Locked)
     82        base.SetEnabledStateOfControls();
    5383    }
    5484
     
    5888        System.Windows.Forms.ListView.SelectedListViewItemCollection selectedItems = itemsListView.SelectedItems;
    5989        bool inProgress = false;
    60         foreach (ListViewItem item in selectedItems) {                                 
     90        foreach (ListViewItem item in selectedItems) {
    6191          RefreshableJob job = item.Tag as RefreshableJob;
    6292          if (job != null && job.IsProgressing) {
     
    70100          return;
    71101        } else {
    72           base.removeButton_Click(sender, e);
    73         }
    74       }
     102          DeleteHiveJobs(e);
     103        }
     104      }
     105    }
     106
     107    private void DeleteHiveJobs(EventArgs e) {
     108      if (itemsListView.SelectedItems.Count > 0) {
     109        List<RefreshableJob> items = new List<RefreshableJob>();
     110        foreach (ListViewItem item in itemsListView.SelectedItems)
     111          items.Add((RefreshableJob)item.Tag);
     112
     113        var task = System.Threading.Tasks.Task.Factory.StartNew(DeleteHiveJobsAsync, items);
     114
     115        task.ContinueWith((t) => {
     116          progress.Finish();
     117          ErrorHandling.ShowErrorDialog("An error occured while deleting the job. ", t.Exception);
     118        }, TaskContinuationOptions.OnlyOnFaulted);
     119
     120        task.ContinueWith((t) => {
     121          itemsListView.Invoke(new Action(() => itemsListView.SelectedItems.Clear()));
     122        }, TaskContinuationOptions.OnlyOnRanToCompletion);
     123      }
     124    }
     125
     126    private void DeleteHiveJobsAsync(object items) {
     127      progress.Status = "Deleting job...";
     128      progress.ProgressState = ProgressState.Started;
     129      progress.ProgressValue = 0.0;
     130      foreach (RefreshableJob item in (List<RefreshableJob>)items) {
     131        Content.Remove(item);
     132      }
     133      progress.Finish();
    75134    }
    76135
     
    126185      ListViewItem listViewItem = base.CreateListViewItem(item);
    127186      listViewItem.SubItems.Clear();
    128       listViewItem.SubItems.Insert(0, new ListViewItem.ListViewSubItem(listViewItem, item.Job.DateCreated.ToString("dd.MM.yyyy HH:mm")));
     187      listViewItem.SubItems.Insert(0, new ListViewItem.ListViewSubItem(listViewItem, item.Job.DateCreated.ToString()));
    129188      listViewItem.SubItems.Insert(1, new ListViewItem.ListViewSubItem(listViewItem, item.Job.Name));
    130189      listViewItem.Group = GetListViewGroup(item.Job.OwnerUsername);
     
    156215      return newGroup;
    157216    }
     217
     218    /// <summary>
     219    /// Clean up any resources being used.
     220    /// </summary>
     221    /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
     222    protected override void Dispose(bool disposing) {
     223      if (disposing) {
     224        if (components != null) components.Dispose();
     225        progressView.Content = null;
     226        progressView.Dispose();
     227      }
     228      base.Dispose(disposing);
     229    }
    158230  }
    159231}
  • branches/OaaS/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.Designer.cs

    r8090 r9363  
    1 namespace HeuristicLab.Clients.Hive.JobManager.Views {
     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
     22namespace HeuristicLab.Clients.Hive.JobManager.Views {
    223  partial class RefreshableHiveJobView {
    324    /// <summary>
     
    5071      this.refreshButton = new System.Windows.Forms.Button();
    5172      this.isPrivilegedCheckBox = new System.Windows.Forms.CheckBox();
     73      this.UnloadButton = new System.Windows.Forms.Button();
    5274      this.refreshAutomaticallyCheckBox = new System.Windows.Forms.CheckBox();
    5375      this.infoGroupBox = new System.Windows.Forms.GroupBox();
     
    7092      // tabControl
    7193      //
     94      this.tabControl.AllowDrop = true;
    7295      this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    7396            | System.Windows.Forms.AnchorStyles.Left)
     
    354377      this.toolTip.SetToolTip(this.isPrivilegedCheckBox, "If checked, the task will be executed in a privileged sandbox on the slave.");
    355378      this.isPrivilegedCheckBox.UseVisualStyleBackColor = true;
    356       this.isPrivilegedCheckBox.Validated += new System.EventHandler(this.isPrivilegedCheckBox_Validated);
     379      this.isPrivilegedCheckBox.CheckedChanged += new System.EventHandler(this.isPrivilegedCheckBox_CheckChanged);
     380      //
     381      // UnloadButton
     382      //
     383      this.UnloadButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Disconnect;
     384      this.UnloadButton.Location = new System.Drawing.Point(30, 0);
     385      this.UnloadButton.Name = "UnloadButton";
     386      this.UnloadButton.Size = new System.Drawing.Size(24, 24);
     387      this.UnloadButton.TabIndex = 27;
     388      this.toolTip.SetToolTip(this.UnloadButton, "Unload Job");
     389      this.UnloadButton.UseVisualStyleBackColor = true;
     390      this.UnloadButton.Click += new System.EventHandler(this.UnloadButton_Click);
    357391      //
    358392      // refreshAutomaticallyCheckBox
    359393      //
    360394      this.refreshAutomaticallyCheckBox.AutoSize = true;
    361       this.refreshAutomaticallyCheckBox.Location = new System.Drawing.Point(30, 5);
     395      this.refreshAutomaticallyCheckBox.Location = new System.Drawing.Point(70, 3);
    362396      this.refreshAutomaticallyCheckBox.Name = "refreshAutomaticallyCheckBox";
    363397      this.refreshAutomaticallyCheckBox.Size = new System.Drawing.Size(127, 17);
     
    450484      // RefreshableHiveJobView
    451485      //
    452       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    453486      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
     487      this.Controls.Add(this.UnloadButton);
    454488      this.Controls.Add(this.searchButton);
    455489      this.Controls.Add(this.isPrivilegedCheckBox);
     
    484518    #endregion
    485519
    486     private System.Windows.Forms.TabControl tabControl;
    487520    private System.Windows.Forms.Button startButton;
    488521    private System.Windows.Forms.Button stopButton;
     
    518551    private MainForm.WindowsForms.ViewHost runCollectionViewHost;
    519552    private System.Windows.Forms.Button searchButton;
     553    private MainForm.WindowsForms.DragOverTabControl tabControl;
     554    private System.Windows.Forms.Button UnloadButton;
    520555
    521556  }
  • branches/OaaS/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r8186 r9363  
    4545    private ProgressView progressView;
    4646    private HiveResourceSelectorDialog hiveResourceSelectorDialog;
     47    private bool SuppressEvents { get; set; }
     48    private object runCollectionViewLocker = new object();
    4749
    4850    public new RefreshableJob Content {
     
    98100        progressView = null;
    99101      }
     102      DeregisterHiveExperimentEvents();
     103      DeregisterHiveTasksEvents();
    100104      base.DeregisterContentEvents();
    101105    }
     
    109113    }
    110114
    111     private void RegisterHiveJobEvents() {
     115    private void RegisterHiveTasksEvents() {
    112116      Content.HiveTasks.ItemsAdded += new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_ItemsAdded);
    113117      Content.HiveTasks.ItemsRemoved += new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_ItemsRemoved);
    114118      Content.HiveTasks.CollectionReset += new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_CollectionReset);
    115119    }
    116     private void DeregisterHiveJobEvents() {
     120    private void DeregisterHiveTasksEvents() {
    117121      Content.HiveTasks.ItemsAdded -= new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_ItemsAdded);
    118122      Content.HiveTasks.ItemsRemoved -= new CollectionItemsChangedEventHandler<HiveTask>(HiveTasks_ItemsRemoved);
     
    122126    protected override void OnContentChanged() {
    123127      base.OnContentChanged();
    124       if (Content == null) {
    125         nameTextBox.Text = string.Empty;
    126         executionTimeTextBox.Text = string.Empty;
    127         resourceNamesTextBox.Text = string.Empty;
    128         isPrivilegedCheckBox.Checked = false;
    129         logView.Content = null;
    130         refreshAutomaticallyCheckBox.Checked = false;
    131         runCollectionViewHost.Content = null;
    132       } else {
    133         nameTextBox.Text = Content.Job.Name;
    134         executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    135         resourceNamesTextBox.Text = Content.Job.ResourceNames;
    136         isPrivilegedCheckBox.Checked = Content.Job.IsPrivileged;
    137         refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically;
    138         logView.Content = Content.Log;
    139         runCollectionViewHost.Content = GetAllRunsFromJob(Content);
     128      SuppressEvents = true;
     129      try {
     130        if (Content == null) {
     131          nameTextBox.Text = string.Empty;
     132          executionTimeTextBox.Text = string.Empty;
     133          resourceNamesTextBox.Text = string.Empty;
     134          isPrivilegedCheckBox.Checked = false;
     135          refreshAutomaticallyCheckBox.Checked = false;
     136          lock (runCollectionViewLocker) {
     137            runCollectionViewHost.Content = null;
     138          }
     139          logView.Content = null;
     140          jobsTreeView.Content = null;
     141          hiveExperimentPermissionListView.Content = null;
     142          stateLogViewHost.Content = null;
     143        } else {
     144          nameTextBox.Text = Content.Job.Name;
     145          executionTimeTextBox.Text = Content.ExecutionTime.ToString();
     146          resourceNamesTextBox.Text = Content.Job.ResourceNames;
     147          isPrivilegedCheckBox.Checked = Content.IsAllowedPrivileged;
     148          refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically;
     149          logView.Content = Content.Log;
     150          lock (runCollectionViewLocker) {
     151            runCollectionViewHost.Content = GetAllRunsFromJob(Content);
     152          }
     153        }
     154      }
     155      finally {
     156        SuppressEvents = false;
    140157      }
    141158      hiveExperimentPermissionListView.Content = null; // has to be filled by refresh button
     
    149166    }
    150167
     168    protected override void OnLockedChanged() {
     169      base.OnLockedChanged();
     170      executionTimeTextBox.Enabled = !Locked;
     171      jobsTextBox.Enabled = !Locked;
     172      calculatingTextBox.Enabled = !Locked;
     173      finishedTextBox.Enabled = !Locked;
     174      tabControl.Enabled = !Locked;
     175      nameTextBox.Enabled = !Locked;
     176      resourceNamesTextBox.Enabled = !Locked;
     177      searchButton.Enabled = !Locked;
     178      jobsTreeView.Enabled = !Locked;
     179      isPrivilegedCheckBox.Enabled = !Locked;
     180      refreshAutomaticallyCheckBox.Enabled = !Locked;
     181      refreshButton.Enabled = !Locked;
     182      UnloadButton.Enabled = !Locked;
     183      startButton.Enabled = !Locked;
     184      pauseButton.Enabled = !Locked;
     185      stopButton.Enabled = !Locked;
     186      resetButton.Enabled = !Locked;
     187    }
     188
    151189    protected override void SetEnabledStateOfControls() {
    152190      base.SetEnabledStateOfControls();
    153       executionTimeTextBox.Enabled = Content != null;
    154       jobsTextBox.ReadOnly = true;
    155       calculatingTextBox.ReadOnly = true;
    156       finishedTextBox.ReadOnly = true;
    157 
    158       if (Content != null) {
    159         bool alreadyUploaded = Content.Id != Guid.Empty;
    160         bool jobsLoaded = Content.HiveTasks != null && Content.HiveTasks.All(x => x.Task.Id != Guid.Empty);
    161         tabControl.Enabled = !Content.IsProgressing;
    162 
    163         this.nameTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
    164         this.resourceNamesTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
    165         this.searchButton.Enabled = (Content.IsControllable && !(Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded)) || !Content.IsProgressing;
    166         this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
    167 
    168         this.isPrivilegedCheckBox.Enabled = Content.IsAllowedPrivileged && Content.IsControllable && !(Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded) && !Content.IsProgressing;
    169         this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
    170         this.refreshButton.Enabled = Content.IsDownloadable && alreadyUploaded && !Content.IsProgressing;
    171         this.Locked = !Content.IsControllable || Content.ExecutionState == ExecutionState.Started || Content.IsProgressing;
    172       }
    173       SetEnabledStateOfExecutableButtons();
    174       tabControl_SelectedIndexChanged(this, EventArgs.Empty); // ensure sharing tabpage is disabled
     191      if (!Locked) {
     192        executionTimeTextBox.Enabled = Content != null;
     193        jobsTextBox.ReadOnly = true;
     194        calculatingTextBox.ReadOnly = true;
     195        finishedTextBox.ReadOnly = true;
     196
     197        if (Content != null) {
     198          bool alreadyUploaded = Content.Id != Guid.Empty;
     199          bool jobsLoaded = Content.HiveTasks != null && Content.HiveTasks.All(x => x.Task.Id != Guid.Empty);
     200          tabControl.Enabled = !Content.IsProgressing;
     201
     202          this.nameTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
     203          this.resourceNamesTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
     204          this.searchButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Prepared && !alreadyUploaded && !Content.IsProgressing;
     205          this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
     206
     207          this.isPrivilegedCheckBox.Enabled = HiveClient.Instance.IsAllowedPrivileged && Content.IsControllable && !(Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded) && !Content.IsProgressing;
     208          this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
     209          this.refreshButton.Enabled = Content.IsDownloadable && alreadyUploaded && !Content.IsProgressing;
     210
     211          this.UnloadButton.Enabled = Content.HiveTasks != null && Content.HiveTasks.Count > 0 && alreadyUploaded && !Content.IsProgressing;
     212        }
     213        SetEnabledStateOfExecutableButtons();
     214        tabControl_SelectedIndexChanged(this, EventArgs.Empty); // ensure sharing tabpage is disabled
     215      }
    175216    }
    176217
     
    185226    #region Content Events
    186227    void Content_TaskReceived(object sender, EventArgs e) {
    187       runCollectionViewHost.Content = GetAllRunsFromJob(Content);
     228      lock (runCollectionViewLocker) {
     229        runCollectionViewHost.Content = GetAllRunsFromJob(Content);
     230      }
    188231    }
    189232
     
    272315        if (Content != null && Content.HiveTasks != null) {
    273316          jobsTreeView.Content = Content.HiveTasks;
    274           RegisterHiveJobEvents();
     317          RegisterHiveTasksEvents();
    275318        } else {
    276319          jobsTreeView.Content = null;
     
    281324
    282325    void Content_Loaded(object sender, EventArgs e) {
    283       runCollectionViewHost.Content = GetAllRunsFromJob(Content);
     326      lock (runCollectionViewLocker) {
     327        runCollectionViewHost.Content = GetAllRunsFromJob(Content);
     328      }
    284329    }
    285330
     
    329374        Invoke(new EventHandler(Content_IsAllowedPrivilegedChanged), sender, e);
    330375      else {
     376        isPrivilegedCheckBox.Checked = Content.IsAllowedPrivileged;
    331377        SetEnabledStateOfControls();
    332378      }
     
    357403        }
    358404        resourceNamesTextBox.Text = sb.ToString();
     405        if (Content.Job.ResourceNames != resourceNamesTextBox.Text)
     406          Content.Job.ResourceNames = resourceNamesTextBox.Text;
    359407      }
    360408    }
     
    416464
    417465    private void nameTextBox_Validated(object sender, EventArgs e) {
    418       if (Content.Job.Name != nameTextBox.Text)
     466      if (!SuppressEvents && Content.Job != null && Content.Job.Name != nameTextBox.Text)
    419467        Content.Job.Name = nameTextBox.Text;
    420468    }
    421469
    422470    private void resourceNamesTextBox_Validated(object sender, EventArgs e) {
    423       if (Content.Job.ResourceNames != resourceNamesTextBox.Text)
     471      if (!SuppressEvents && Content.Job != null && Content.Job.ResourceNames != resourceNamesTextBox.Text)
    424472        Content.Job.ResourceNames = resourceNamesTextBox.Text;
    425473    }
    426474
    427475    private void refreshAutomaticallyCheckBox_CheckedChanged(object sender, EventArgs e) {
    428       if (Content != null) Content.RefreshAutomatically = refreshAutomaticallyCheckBox.Checked;
    429     }
    430 
    431     private void isPrivilegedCheckBox_Validated(object sender, EventArgs e) {
    432       if (Content != null) Content.Job.IsPrivileged = isPrivilegedCheckBox.Checked;
     476      if (Content != null && !SuppressEvents) Content.RefreshAutomatically = refreshAutomaticallyCheckBox.Checked;
     477    }
     478
     479    private void isPrivilegedCheckBox_CheckChanged(object sender, EventArgs e) {
     480      if (Content != null && !SuppressEvents) Content.IsAllowedPrivileged = isPrivilegedCheckBox.Checked;
    433481    }
    434482
     
    505553          if (e.Effect.HasFlag(DragDropEffects.Copy)) {
    506554            newOptimizer = (IOptimizer)optimizer.Clone();
     555            newOptimizer.Runs.Clear();
    507556          } else {
    508557            newOptimizer = optimizer;
     
    529578    private RunCollection GetAllRunsFromJob(RefreshableJob job) {
    530579      if (job != null) {
    531         RunCollection runs = new RunCollection();
     580        RunCollection runs = new RunCollection() { OptimizerName = job.ItemName };
    532581
    533582        foreach (HiveTask subTask in job.HiveTasks) {
    534583          if (subTask is OptimizerHiveTask) {
    535584            OptimizerHiveTask ohTask = subTask as OptimizerHiveTask;
    536             runs.AddRange(ohTask.ItemTask.Item.Runs);
     585            ohTask.ExecuteReadActionOnItemTask(new Action(delegate() {
     586              runs.AddRange(ohTask.ItemTask.Item.Runs);
     587            }));
    537588          }
    538589        }
     
    542593      }
    543594    }
     595
     596    private void UnloadButton_Click(object sender, EventArgs e) {
     597      Content.Unload();
     598      runCollectionViewHost.Content = null;
     599      stateLogViewHost.Content = null;
     600      hiveExperimentPermissionListView.Content = null;
     601      jobsTreeView.Content = null;
     602
     603      SetEnabledStateOfControls();
     604    }
    544605  }
    545606}
Note: See TracChangeset for help on using the changeset viewer.