Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/15/18 12:36:08 (6 years ago)
Author:
gkronber
Message:

#2892: Merging r15750:16382 (HEAD) from trunk to branch, resolving conflicts

Location:
branches/2892_LR-prediction-intervals
Files:
14 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/2892_LR-prediction-intervals

  • branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Hive.JobManager

  • branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Hive.JobManager/3.3/HeuristicLab.Clients.Hive.JobManager-3.3.csproj

    r14125 r16388  
    105105    <Compile Include="ExtensionMethods\TreeNodeExtensions.cs" />
    106106    <Compile Include="ListViewItemDateComparer.cs" />
     107    <Compile Include="ListViewItemComparer.cs" />
    107108    <Compile Include="MenuItems\CreateHiveJobMenuItem.cs" />
    108109    <Compile Include="MenuItems\RunInHiveMenuItem.cs" />
     
    159160  </ItemGroup>
    160161  <ItemGroup>
     162    <ProjectReference Include="..\..\HeuristicLab.Clients.Access\3.3\HeuristicLab.Clients.Access-3.3.csproj">
     163      <Project>{494f87f4-0f25-4d33-a382-10cdb2174d48}</Project>
     164      <Name>HeuristicLab.Clients.Access-3.3</Name>
     165      <Private>False</Private>
     166    </ProjectReference>
     167    <ProjectReference Include="..\..\HeuristicLab.Clients.Common\3.3\HeuristicLab.Clients.Common-3.3.csproj">
     168      <Project>{730a9104-d4d1-4360-966b-e49b7571dda3}</Project>
     169      <Name>HeuristicLab.Clients.Common-3.3</Name>
     170      <Private>False</Private>
     171    </ProjectReference>
    161172    <ProjectReference Include="..\..\HeuristicLab.Clients.Hive.Views\3.3\HeuristicLab.Clients.Hive.Views-3.3.csproj">
    162173      <Project>{E1D6C801-892A-406A-B606-F158E36DD3C3}</Project>
  • branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Hive.JobManager/3.3/MenuItems/JobManagerMenuItem.cs

    r15583 r16388  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Windows.Forms;
     25using HeuristicLab.Clients.Access;
    2426using HeuristicLab.MainForm;
    2527using HeuristicLab.Optimizer;
    2628
    2729namespace HeuristicLab.Clients.Hive.JobManager {
    28   public class JobManagerMenuItem : HeuristicLab.MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {
     30  public class JobManagerMenuItem : MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {
    2931    public override string Name {
    3032      get { return "&Job Manager"; }
    3133    }
     34
    3235    public override IEnumerable<string> Structure {
    3336      get { return new string[] { "&Services", "&Hive" }; }
    3437    }
     38
    3539    public override void Execute() {
    36       MainFormManager.MainForm.ShowContent(HiveClient.Instance);
     40      if (HiveRoles.CheckHiveUserPermissions()) {
     41        MainFormManager.MainForm.ShowContent(HiveClient.Instance);
     42      } else if (!UserInformation.Instance.UserExists) {
     43        MessageBox.Show(
     44          "Couldn't fetch user information from the server." + Environment.NewLine +
     45          "Please verify that you have an existing user and that your user name and password is correct.",
     46          "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
     47      } else {
     48        MessageBox.Show(
     49          "You do not seem to have the permissions to use the Hive Job Manager." + Environment.NewLine +
     50          "If that's not the case or you have any questions please write an email to support@heuristiclab.com",
     51          "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
     52      }
    3753    }
     54
    3855    public override int Position {
    3956      get { return 10000; }
    4057    }
     58
    4159    public override Keys ShortCutKeys {
    4260      get { return Keys.Control | Keys.H; }
  • branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Hive.JobManager/3.3/MenuItems/RunInHiveMenuItem.cs

    r15583 r16388  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using System.Threading;
     26using System.Windows.Forms;
     27using HeuristicLab.Clients.Hive.JobManager.Views;
    2528using HeuristicLab.Core;
    2629using HeuristicLab.MainForm;
     
    8285      task.ItemTask.ComputeInParallel = content is Experiment || content is BatchRun;
    8386
    84       progress = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToContent(this.content, "Uploading to Hive...");
    85       rJob.Progress = progress;
    86       progress.ProgressStateChanged += progress_ProgressStateChanged;
     87      var hiveResourceSelectorDialog = new HiveResourceSelectorDialog(rJob.Job.Id, rJob.Job.ProjectId);
    8788
    88       HiveClient.StartJob(new Action<Exception>(HandleEx), rJob, new CancellationToken());
     89      if (HiveClient.Instance.Projects.Count == 1) {
     90        var project = HiveClient.Instance.Projects.FirstOrDefault();
     91        if (project != null && project.Id != Guid.Empty)
     92          hiveResourceSelectorDialog.SelectedProjectId = project.Id;
     93      }
     94
     95      if (hiveResourceSelectorDialog.ShowDialog((UserControl)activeView) == DialogResult.OK) {
     96        var selectedProject = hiveResourceSelectorDialog.SelectedProject;
     97        if (selectedProject != null) {
     98          rJob.Job.ProjectId = selectedProject.Id;
     99          rJob.Job.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList();
     100
     101          progress = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToContent(this.content, "Uploading to Hive...");
     102          rJob.Progress = progress;
     103          progress.ProgressStateChanged += progress_ProgressStateChanged;
     104
     105          HiveClient.StartJob(new Action<Exception>(HandleEx), rJob, new CancellationToken());
     106        }
     107      }
    89108    }
    90109
  • branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Hive.JobManager/3.3/Plugin.cs.frame

    r15589 r16388  
    2525  [Plugin("HeuristicLab.Clients.Hive.JobManager", "3.3.15.$WCREV$")]
    2626  [PluginFile("HeuristicLab.Clients.Hive.JobManager-3.3.dll", PluginFileType.Assembly)]
     27  [PluginDependency("HeuristicLab.Clients.Access", "3.3")]
     28  [PluginDependency("HeuristicLab.Clients.Common", "3.3")]
    2729  [PluginDependency("HeuristicLab.Clients.Hive", "3.3")]
    2830  [PluginDependency("HeuristicLab.Clients.Hive.Views", "3.3")]
  • branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobManagerView.Designer.cs

    r15583 r16388  
    4545    /// </summary>
    4646    private void InitializeComponent() {
     47      this.components = new System.ComponentModel.Container();
    4748      this.hiveExperimentListView = new RefreshableHiveJobListView();
    4849      this.refreshButton = new System.Windows.Forms.Button();
     50      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    4951      this.SuspendLayout();
    5052      //
     
    6971      this.refreshButton.Size = new System.Drawing.Size(24, 24);
    7072      this.refreshButton.TabIndex = 1;
     73      this.toolTip.SetToolTip(this.refreshButton, "Refresh data");
    7174      this.refreshButton.UseVisualStyleBackColor = true;
    7275      this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click);
     
    8790    private RefreshableHiveJobListView hiveExperimentListView;
    8891    private System.Windows.Forms.Button refreshButton;
    89 
     92    private System.Windows.Forms.ToolTip toolTip;
    9093
    9194  }
  • branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.Designer.cs

    r15583 r16388  
    2121
    2222namespace HeuristicLab.Clients.Hive.JobManager.Views {
    23   partial class HiveResourceSelector {
     23  partial class HiveProjectSelector {
    2424    /// <summary>
    2525    /// Required designer variable.
     
    4646    private void InitializeComponent() {
    4747      this.components = new System.ComponentModel.Container();
    48       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HiveResourceSelector));
    49       this.resourcesGroupBox = new System.Windows.Forms.GroupBox();
    50       this.splitContainer = new System.Windows.Forms.SplitContainer();
    51       this.resourcesTreeView = new System.Windows.Forms.TreeView();
    52       this.imageList = new System.Windows.Forms.ImageList(this.components);
     48      this.projectsGroupBox = new System.Windows.Forms.GroupBox();
     49      this.projectsImageList = new System.Windows.Forms.ImageList(this.components);
     50      this.resourcesImageList = new System.Windows.Forms.ImageList(this.components);
    5351      this.searchLabel = new System.Windows.Forms.Label();
    5452      this.searchTextBox = new System.Windows.Forms.TextBox();
    55       this.descriptionTextBox = new System.Windows.Forms.TextBox();
    5653      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    57       this.resourcesGroupBox.SuspendLayout();
    58       ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    59       this.splitContainer.Panel1.SuspendLayout();
    60       this.splitContainer.Panel2.SuspendLayout();
    61       this.splitContainer.SuspendLayout();
     54      this.splitContainer2 = new System.Windows.Forms.SplitContainer();
     55      this.projectsTreeView = new System.Windows.Forms.TreeView();
     56      this.resourcesTreeView = new HeuristicLab.Clients.Hive.Views.TreeView.NoDoubleClickTreeView();
     57      this.summaryGroupBox = new System.Windows.Forms.GroupBox();
     58      this.coresLabel = new System.Windows.Forms.Label();
     59      this.coresSummaryLabel = new System.Windows.Forms.Label();
     60      this.memoryLabel = new System.Windows.Forms.Label();
     61      this.memorySummaryLabel = new System.Windows.Forms.Label();
     62      this.projectsGroupBox.SuspendLayout();
     63      ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit();
     64      this.splitContainer2.Panel1.SuspendLayout();
     65      this.splitContainer2.Panel2.SuspendLayout();
     66      this.splitContainer2.SuspendLayout();
     67      this.summaryGroupBox.SuspendLayout();
    6268      this.SuspendLayout();
    6369      //
    64       // resourcesGroupBox
    65       //
    66       this.resourcesGroupBox.Controls.Add(this.splitContainer);
    67       this.resourcesGroupBox.Dock = System.Windows.Forms.DockStyle.Fill;
    68       this.resourcesGroupBox.Location = new System.Drawing.Point(0, 0);
    69       this.resourcesGroupBox.Name = "resourcesGroupBox";
    70       this.resourcesGroupBox.Size = new System.Drawing.Size(308, 365);
    71       this.resourcesGroupBox.TabIndex = 0;
    72       this.resourcesGroupBox.TabStop = false;
    73       this.resourcesGroupBox.Text = "Available Resources";
    74       //
    75       // splitContainer
    76       //
    77       this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill;
    78       this.splitContainer.Location = new System.Drawing.Point(3, 16);
    79       this.splitContainer.Name = "splitContainer";
    80       this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal;
    81       //
    82       // splitContainer.Panel1
    83       //
    84       this.splitContainer.Panel1.Controls.Add(this.resourcesTreeView);
    85       this.splitContainer.Panel1.Controls.Add(this.searchLabel);
    86       this.splitContainer.Panel1.Controls.Add(this.searchTextBox);
    87       //
    88       // splitContainer.Panel2
    89       //
    90       this.splitContainer.Panel2.Controls.Add(this.descriptionTextBox);
    91       this.splitContainer.Size = new System.Drawing.Size(302, 346);
    92       this.splitContainer.SplitterDistance = 219;
    93       this.splitContainer.TabIndex = 0;
    94       //
    95       // resourcesTreeView
    96       //
    97       this.resourcesTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    98             | System.Windows.Forms.AnchorStyles.Left)
    99             | System.Windows.Forms.AnchorStyles.Right)));
    100       this.resourcesTreeView.CheckBoxes = true;
    101       this.resourcesTreeView.HideSelection = false;
    102       this.resourcesTreeView.ImageIndex = 0;
    103       this.resourcesTreeView.ImageList = this.imageList;
    104       this.resourcesTreeView.Location = new System.Drawing.Point(3, 29);
    105       this.resourcesTreeView.Name = "resourcesTreeView";
    106       this.resourcesTreeView.SelectedImageIndex = 0;
    107       this.resourcesTreeView.ShowNodeToolTips = true;
    108       this.resourcesTreeView.Size = new System.Drawing.Size(296, 196);
    109       this.resourcesTreeView.TabIndex = 2;
    110       this.resourcesTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.resourcesTreeView_AfterCheck);
    111       this.resourcesTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.resourcesTreeView_AfterSelect);
    112       //
    113       // imageList
    114       //
    115       this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
    116       this.imageList.ImageSize = new System.Drawing.Size(16, 16);
    117       this.imageList.TransparentColor = System.Drawing.Color.Transparent;
     70      // projectsGroupBox
     71      //
     72      this.projectsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     73            | System.Windows.Forms.AnchorStyles.Left)
     74            | System.Windows.Forms.AnchorStyles.Right)));
     75      this.projectsGroupBox.Controls.Add(this.searchLabel);
     76      this.projectsGroupBox.Controls.Add(this.splitContainer2);
     77      this.projectsGroupBox.Controls.Add(this.searchTextBox);
     78      this.projectsGroupBox.Location = new System.Drawing.Point(3, 3);
     79      this.projectsGroupBox.Name = "projectsGroupBox";
     80      this.projectsGroupBox.Size = new System.Drawing.Size(426, 461);
     81      this.projectsGroupBox.TabIndex = 0;
     82      this.projectsGroupBox.TabStop = false;
     83      this.projectsGroupBox.Text = "Available Projects";
     84      //
     85      // projectsImageList
     86      //
     87      this.projectsImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
     88      this.projectsImageList.ImageSize = new System.Drawing.Size(16, 16);
     89      this.projectsImageList.TransparentColor = System.Drawing.Color.Transparent;
     90      //
     91      // resourcesImageList
     92      //
     93      this.resourcesImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit;
     94      this.resourcesImageList.ImageSize = new System.Drawing.Size(16, 16);
     95      this.resourcesImageList.TransparentColor = System.Drawing.Color.Transparent;
    11896      //
    11997      // searchLabel
    12098      //
    12199      this.searchLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Zoom;
    122       this.searchLabel.Location = new System.Drawing.Point(3, 3);
     100      this.searchLabel.Location = new System.Drawing.Point(6, 19);
    123101      this.searchLabel.Name = "searchLabel";
    124102      this.searchLabel.Size = new System.Drawing.Size(20, 20);
     
    128106      // searchTextBox
    129107      //
    130       this.searchTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    131             | System.Windows.Forms.AnchorStyles.Right)));
    132       this.searchTextBox.Location = new System.Drawing.Point(29, 3);
     108      this.searchTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     109            | System.Windows.Forms.AnchorStyles.Right)));
     110      this.searchTextBox.Location = new System.Drawing.Point(32, 19);
    133111      this.searchTextBox.Name = "searchTextBox";
    134       this.searchTextBox.Size = new System.Drawing.Size(270, 20);
     112      this.searchTextBox.Size = new System.Drawing.Size(388, 20);
    135113      this.searchTextBox.TabIndex = 1;
    136114      this.toolTip.SetToolTip(this.searchTextBox, "Enter string to search for resources");
    137115      this.searchTextBox.TextChanged += new System.EventHandler(this.searchTextBox_TextChanged);
    138116      //
    139       // descriptionTextBox
    140       //
    141       this.descriptionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    142             | System.Windows.Forms.AnchorStyles.Left)
    143             | System.Windows.Forms.AnchorStyles.Right)));
    144       this.descriptionTextBox.Font = new System.Drawing.Font("Courier New", 8.25F);
    145       this.descriptionTextBox.Location = new System.Drawing.Point(3, 3);
    146       this.descriptionTextBox.Multiline = true;
    147       this.descriptionTextBox.Name = "descriptionTextBox";
    148       this.descriptionTextBox.ReadOnly = true;
    149       this.descriptionTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both;
    150       this.descriptionTextBox.Size = new System.Drawing.Size(296, 108);
    151       this.descriptionTextBox.TabIndex = 0;
    152       this.descriptionTextBox.WordWrap = false;
    153       //
    154       // HiveResourceSelector
    155       //
    156       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
     117      // splitContainer2
     118      //
     119      this.splitContainer2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     120            | System.Windows.Forms.AnchorStyles.Left)
     121            | System.Windows.Forms.AnchorStyles.Right)));
     122      this.splitContainer2.Location = new System.Drawing.Point(6, 45);
     123      this.splitContainer2.Name = "splitContainer2";
     124      //
     125      // splitContainer2.Panel1
     126      //
     127      this.splitContainer2.Panel1.Controls.Add(this.projectsTreeView);
     128      //
     129      // splitContainer2.Panel2
     130      //
     131      this.splitContainer2.Panel2.Controls.Add(this.resourcesTreeView);
     132      this.splitContainer2.Size = new System.Drawing.Size(414, 410);
     133      this.splitContainer2.SplitterDistance = 204;
     134      this.splitContainer2.TabIndex = 4;
     135      //
     136      // projectsTreeView
     137      //
     138      this.projectsTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
     139      this.projectsTreeView.HideSelection = false;
     140      this.projectsTreeView.ImageIndex = 0;
     141      this.projectsTreeView.ImageList = this.projectsImageList;
     142      this.projectsTreeView.Location = new System.Drawing.Point(0, 0);
     143      this.projectsTreeView.Name = "projectsTreeView";
     144      this.projectsTreeView.SelectedImageIndex = 0;
     145      this.projectsTreeView.ShowNodeToolTips = true;
     146      this.projectsTreeView.Size = new System.Drawing.Size(204, 410);
     147      this.projectsTreeView.TabIndex = 3;
     148      this.projectsTreeView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.projectsTreeView_MouseDoubleClick);
     149      this.projectsTreeView.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.projectsTreeView_BeforeSelect);
     150      this.projectsTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.projectsTreeView_AfterSelect);
     151      //
     152      // resourcesTreeView
     153      //
     154      this.resourcesTreeView.CheckBoxes = true;
     155      this.resourcesTreeView.Dock = System.Windows.Forms.DockStyle.Fill;
     156      this.resourcesTreeView.ImageIndex = 0;
     157      this.resourcesTreeView.ImageList = this.resourcesImageList;
     158      this.resourcesTreeView.Location = new System.Drawing.Point(0, 0);
     159      this.resourcesTreeView.Name = "resourcesTreeView";
     160      this.resourcesTreeView.SelectedImageIndex = 0;
     161      this.resourcesTreeView.Size = new System.Drawing.Size(206, 410);
     162      this.resourcesTreeView.TabIndex = 0;
     163      this.resourcesTreeView.NodeMouseDoubleClick += new System.Windows.Forms.TreeNodeMouseClickEventHandler(this.resourcesTreeView_NodeMouseDoubleClick);
     164      this.resourcesTreeView.BeforeCheck += new System.Windows.Forms.TreeViewCancelEventHandler(this.resourcesTreeView_BeforeCheck);
     165      this.resourcesTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.resourcesTreeView_AfterCheck);
     166      this.resourcesTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.resourcesTreeView_MouseDown);
     167      this.resourcesTreeView.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.resourcesTreeView_BeforeSelect);
     168      //
     169      // summaryGroupBox
     170      //
     171      this.summaryGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
     172            | System.Windows.Forms.AnchorStyles.Right)));
     173      this.summaryGroupBox.Controls.Add(this.memorySummaryLabel);
     174      this.summaryGroupBox.Controls.Add(this.memoryLabel);
     175      this.summaryGroupBox.Controls.Add(this.coresSummaryLabel);
     176      this.summaryGroupBox.Controls.Add(this.coresLabel);
     177      this.summaryGroupBox.Location = new System.Drawing.Point(3, 470);
     178      this.summaryGroupBox.Name = "summaryGroupBox";
     179      this.summaryGroupBox.Size = new System.Drawing.Size(426, 71);
     180      this.summaryGroupBox.TabIndex = 1;
     181      this.summaryGroupBox.TabStop = false;
     182      this.summaryGroupBox.Text = "Computing Resources";
     183      //
     184      // coresLabel
     185      //
     186      this.coresLabel.AutoSize = true;
     187      this.coresLabel.Location = new System.Drawing.Point(6, 22);
     188      this.coresLabel.Name = "coresLabel";
     189      this.coresLabel.Size = new System.Drawing.Size(37, 13);
     190      this.coresLabel.TabIndex = 1;
     191      this.coresLabel.Text = "Cores:";
     192      //
     193      // coresSummaryLabel
     194      //
     195      this.coresSummaryLabel.AutoSize = true;
     196      this.coresSummaryLabel.Location = new System.Drawing.Point(59, 22);
     197      this.coresSummaryLabel.Name = "coresSummaryLabel";
     198      this.coresSummaryLabel.Size = new System.Drawing.Size(124, 13);
     199      this.coresSummaryLabel.TabIndex = 5;
     200      this.coresSummaryLabel.Text = "0 Total (0 Free / 0 Used)";
     201      //
     202      // memoryLabel
     203      //
     204      this.memoryLabel.AutoSize = true;
     205      this.memoryLabel.Location = new System.Drawing.Point(6, 48);
     206      this.memoryLabel.Name = "memoryLabel";
     207      this.memoryLabel.Size = new System.Drawing.Size(47, 13);
     208      this.memoryLabel.TabIndex = 7;
     209      this.memoryLabel.Text = "Memory:";
     210      //
     211      // memorySummaryLabel
     212      //
     213      this.memorySummaryLabel.AutoSize = true;
     214      this.memorySummaryLabel.Location = new System.Drawing.Point(59, 48);
     215      this.memorySummaryLabel.Name = "memorySummaryLabel";
     216      this.memorySummaryLabel.Size = new System.Drawing.Size(223, 13);
     217      this.memorySummaryLabel.TabIndex = 8;
     218      this.memorySummaryLabel.Text = "0.00 GB Total (0.00 GB Free / 0.00 GB Used)";
     219      //
     220      // HiveProjectSelector
     221      //
    157222      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    158       this.Controls.Add(this.resourcesGroupBox);
    159       this.Name = "HiveResourceSelector";
    160       this.Size = new System.Drawing.Size(308, 365);
    161       this.resourcesGroupBox.ResumeLayout(false);
    162       this.splitContainer.Panel1.ResumeLayout(false);
    163       this.splitContainer.Panel1.PerformLayout();
    164       this.splitContainer.Panel2.ResumeLayout(false);
    165       this.splitContainer.Panel2.PerformLayout();
    166       ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit();
    167       this.splitContainer.ResumeLayout(false);
     223      this.Controls.Add(this.summaryGroupBox);
     224      this.Controls.Add(this.projectsGroupBox);
     225      this.Name = "HiveProjectSelector";
     226      this.Size = new System.Drawing.Size(432, 544);
     227      this.Load += new System.EventHandler(this.HiveProjectSelector_Load);
     228      this.projectsGroupBox.ResumeLayout(false);
     229      this.projectsGroupBox.PerformLayout();
     230      this.splitContainer2.Panel1.ResumeLayout(false);
     231      this.splitContainer2.Panel2.ResumeLayout(false);
     232      ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit();
     233      this.splitContainer2.ResumeLayout(false);
     234      this.summaryGroupBox.ResumeLayout(false);
     235      this.summaryGroupBox.PerformLayout();
    168236      this.ResumeLayout(false);
    169237
     
    172240    #endregion
    173241
    174     protected System.Windows.Forms.GroupBox resourcesGroupBox;
    175     protected System.Windows.Forms.SplitContainer splitContainer;
     242    protected System.Windows.Forms.GroupBox projectsGroupBox;
    176243    protected System.Windows.Forms.Label searchLabel;
    177244    protected System.Windows.Forms.TextBox searchTextBox;
    178     protected System.Windows.Forms.TreeView resourcesTreeView;
    179     protected System.Windows.Forms.TextBox descriptionTextBox;
    180     protected System.Windows.Forms.ImageList imageList;
     245    protected System.Windows.Forms.ImageList projectsImageList;
    181246    protected System.Windows.Forms.ToolTip toolTip;
    182 
     247    private System.Windows.Forms.ImageList resourcesImageList;
     248    private System.Windows.Forms.SplitContainer splitContainer2;
     249    protected System.Windows.Forms.TreeView projectsTreeView;
     250    protected HeuristicLab.Clients.Hive.Views.TreeView.NoDoubleClickTreeView resourcesTreeView;
     251    private System.Windows.Forms.GroupBox summaryGroupBox;
     252    protected System.Windows.Forms.Label coresLabel;
     253    protected System.Windows.Forms.Label memorySummaryLabel;
     254    protected System.Windows.Forms.Label memoryLabel;
     255    protected System.Windows.Forms.Label coresSummaryLabel;
    183256  }
    184257}
  • branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs

    r15583 r16388  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2424using System.Drawing;
    2525using System.Linq;
    26 using System.Text;
    2726using System.Windows.Forms;
    28 using HeuristicLab.Clients.Hive.JobManager.ExtensionMethods;
     27using HeuristicLab.Collections;
     28using HeuristicLab.Common;
     29using HeuristicLab.Common.Resources;
    2930using HeuristicLab.Core;
    3031using HeuristicLab.Core.Views;
     
    3334
    3435namespace HeuristicLab.Clients.Hive.JobManager.Views {
    35   [View("Hive Resource Selector View")]
    36   [Content(typeof(IItemList<Resource>), true)]
    37   public partial class HiveResourceSelector : ItemView, IDisposable {
     36  [View("Hive Project Selector View")]
     37  [Content(typeof(IItemList<Project>), true)]
     38  public partial class HiveProjectSelector : ItemView, IDisposable {
     39    private const int greenFlagImageIndex = 0;
     40    private const int redFlagImageIndex = 1;
    3841    private const int slaveImageIndex = 0;
    3942    private const int slaveGroupImageIndex = 1;
     43    public const string additionalSlavesGroupName = "Additional Slaves";
     44    public const string additionalSlavesGroupDescription = "Contains additional slaves which are either ungrouped or the parenting slave group is not assigned to the selected project.";
     45
     46    private const string CURRENT_SELECTION_TAG = " [current assignment]";
     47    private const string NEW_SELECTION_TAG = " [new assignment]";
     48    private const string CHANGED_SELECTION_TAG = " [changed assignment]";
     49    private const string ADDED_SELECTION_TAG = " [added assignment]";
     50    private const string REMOVED_SELECTION_TAG = " [removed assignment]";
     51    private const string SELECTED_TAG = " [assigned]";
     52    private const string INCLUDED_TAG = " [included]";
     53    private const string ADDED_INCLUDE_TAG = " [added include]";
     54    private const string REMOVED_INCLUDE_TAG = " [removed include]";
     55
     56    private TreeNode additionalNode;
     57
     58    private readonly HashSet<TreeNode> mainTreeNodes = new HashSet<TreeNode>();
     59    private readonly HashSet<TreeNode> filteredTreeNodes = new HashSet<TreeNode>();
     60
     61    private readonly HashSet<Resource> availableResources = new HashSet<Resource>();
     62    private readonly HashSet<Resource> assignedResources = new HashSet<Resource>();
     63    private readonly HashSet<Resource> includedResources = new HashSet<Resource>();
     64    private readonly HashSet<Resource> newAssignedResources = new HashSet<Resource>();
     65    private readonly HashSet<Resource> newIncludedResources = new HashSet<Resource>();
     66
     67    private readonly Color addedAssignmentColor = Color.FromArgb(255, 87, 191, 193); // #57bfc1
     68    private readonly Color removedAssignmentColor = Color.FromArgb(255, 236, 159, 72); // #ec9f48
     69    private readonly Color addedIncludeColor = Color.FromArgb(25, 169, 221, 221); // #a9dddd
     70    private readonly Color removedIncludeColor = Color.FromArgb(25, 249, 210, 145); // #f9d291
     71    private readonly Color selectedBackColor = Color.DodgerBlue;
     72    private readonly Color selectedForeColor = Color.White;
     73    private readonly Color controlTextColor = SystemColors.ControlText;
     74    private readonly Color grayTextColor = SystemColors.GrayText;
     75
    4076    private string currentSearchString;
    41     private ISet<TreeNode> mainTreeNodes;
    42     private ISet<TreeNode> filteredTreeNodes;
    43     private ISet<TreeNode> nodeStore;
    44    
    45     private ISet<Resource> selectedResources;
    46     public ISet<Resource> SelectedResources {
    47       get { return selectedResources; }
    48       set { selectedResources = value; }
    49     }
    50 
    51     public new IItemList<Resource> Content {
    52       get { return (IItemList<Resource>)base.Content; }
     77
     78    private void resetHiveResourceSelector() {
     79      lastSelectedProject = null;
     80      selectedProject = null;
     81      projectId = null;
     82    }
     83
     84    private Guid jobId;
     85    public Guid JobId {
     86      get { return jobId; }
     87      set {
     88        if (jobId == value) return;
     89        jobId = value;
     90        resetHiveResourceSelector();
     91      }
     92    }
     93
     94    private Guid? projectId;
     95    public Guid? ProjectId {
     96      get { return projectId; }
     97      set {
     98        if (projectId == value) return;
     99        projectId = value;
     100      }
     101    }
     102
     103    private Guid? selectedProjectId;
     104    public Guid? SelectedProjectId {
     105      get { return selectedProjectId; }
     106      set {
     107        if (selectedProjectId == value) return;
     108        selectedProjectId = value;
     109      }
     110    }
     111
     112    private IEnumerable<Guid> selectedResourceIds;
     113    public IEnumerable<Guid> SelectedResourceIds {
     114      get { return selectedResourceIds; }
     115      set {
     116        if (selectedResourceIds == value) return;
     117        selectedResourceIds = value;
     118      }
     119    }
     120
     121    public bool ChangedProjectSelection {
     122      get {
     123        if ((lastSelectedProject == null && selectedProject != null)
     124          || (lastSelectedProject != null && selectedProject == null)
     125          || (lastSelectedProject != null && selectedProject != null && lastSelectedProject.Id != selectedProject.Id))
     126          return true;
     127        else return false;
     128      }
     129    }
     130
     131    public bool ChangedResources {
     132      get { return !assignedResources.SetEquals(newAssignedResources); }
     133    }
     134
     135    private Project lastSelectedProject;
     136    private Project selectedProject;
     137    public Project SelectedProject {
     138      get { return selectedProject; }
     139      set {
     140        if (selectedProject == value) return;
     141
     142        if ((JobId == Guid.Empty || JobId == null)
     143          && (value == null || SelectedProject == null || value.Id != SelectedProject.Id)) selectedResourceIds = null;
     144        lastSelectedProject = selectedProject;
     145        selectedProject = value;
     146
     147        UpdateResourceTree();
     148        ExtractStatistics();
     149        OnSelectedProjectChanged();
     150      }
     151    }
     152
     153    public int AssignedCores {
     154      get {
     155        HashSet<Slave> newAssignedSlaves = new HashSet<Slave>(newAssignedResources.OfType<Slave>());
     156        foreach(var slaveGroup in newAssignedResources.OfType<SlaveGroup>()) {
     157          foreach(var slave in HiveClient.Instance.GetAvailableResourceDescendants(slaveGroup.Id).OfType<Slave>()) {
     158            newAssignedSlaves.Add(slave);
     159          }
     160        }
     161        return newAssignedSlaves.Sum(x => x.Cores.GetValueOrDefault());
     162      }
     163    }
     164
     165    public IEnumerable<Resource> AssignedResources {
     166      get { return newAssignedResources; }
     167      set {
     168        if (newAssignedResources == value) return;
     169        newAssignedResources.Clear();
     170        foreach(var resource in value) {
     171          newAssignedResources.Add(resource);
     172        }
     173      }
     174    }
     175
     176
     177    public new IItemList<Project> Content {
     178      get { return (IItemList<Project>)base.Content; }
    53179      set { base.Content = value; }
    54180    }
    55181
    56     public HiveResourceSelector() {
     182    public HiveProjectSelector() {
    57183      InitializeComponent();
    58       mainTreeNodes = new HashSet<TreeNode>();
    59       filteredTreeNodes = new HashSet<TreeNode>();
    60       nodeStore = new HashSet<TreeNode>();
    61       selectedResources = new HashSet<Resource>();
    62       imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.MonitorLarge);
    63       imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.NetworkCenterLarge);
    64     }
    65  
    66     public void StartProgressView() {
    67       if (InvokeRequired) {
    68         Invoke(new Action(StartProgressView));
    69       } else {
    70         var message = "Downloading resources. Please be patient.";
    71         MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message);
    72       }
    73     }
    74 
    75     public void FinishProgressView() {
    76       if (InvokeRequired) {
    77         Invoke(new Action(FinishProgressView));
    78       } else {
    79         MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
    80       }
    81     }
    82 
     184
     185      projectsImageList.Images.Add(VSImageLibrary.FlagGreen);
     186      projectsImageList.Images.Add(VSImageLibrary.FlagRed);
     187      resourcesImageList.Images.Add(VSImageLibrary.MonitorLarge);
     188      resourcesImageList.Images.Add(VSImageLibrary.NetworkCenterLarge);
     189    }
     190
     191    #region Overrides
    83192    protected override void OnContentChanged() {
    84193      base.OnContentChanged();
    85194
    86       if (Content != null) {
    87         selectedResources = new HashSet<Resource>(Content.Where(x => selectedResources.Any(y => x.Id == y.Id)));
    88         UpdateMainTree();
     195      if (Content != null) {               
     196        if (SelectedProjectId.HasValue && SelectedProjectId.Value != Guid.Empty) {
     197          SelectedProject = GetSelectedProjectById(SelectedProjectId.Value);
     198        } else {
     199          SelectedProject = null;
     200        }
     201        //ExtractStatistics();
     202        UpdateProjectTree();
     203
     204      } else {
     205        lastSelectedProject = null;
     206        selectedProject = null;
     207        selectedProjectId = null;
     208        projectsTreeView.Nodes.Clear();
     209        resourcesTreeView.Nodes.Clear();
     210      }
     211    }
     212
     213    #endregion
     214
     215    #region Event Handlers
     216    private void HiveProjectSelector_Load(object sender, EventArgs e) {
     217      projectsTreeView.Nodes.Clear();
     218      resourcesTreeView.Nodes.Clear();
     219    }
     220
     221    private void searchTextBox_TextChanged(object sender, EventArgs e) {
     222      currentSearchString = searchTextBox.Text.ToLower();
     223      //UpdateFilteredTree();
     224      UpdateProjectTree();
     225    }
     226
     227    private void projectsTreeView_MouseDoubleClick(object sender, MouseEventArgs e) {
     228      OnProjectsTreeViewDoubleClicked();
     229    }
     230
     231    private void projectsTreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e) {
     232      var node = (Project)e.Node.Tag;
     233      if (HiveClient.Instance.DisabledParentProjects.Contains(node)) {
     234        e.Cancel = true;
     235      }
     236    }
     237
     238    private void projectsTreeView_AfterSelect(object sender, TreeViewEventArgs e) {
     239      var node = (Project)e.Node.Tag;
     240
     241      if (node == null) {
     242        projectsTreeView.SelectedNode = null;
     243      } else if (HiveClient.Instance.DisabledParentProjects.Contains(node)) {
     244        return;
     245      } else {
     246        ResetTreeNodes(projectsTreeView.Nodes);
     247        e.Node.BackColor = selectedBackColor;
     248        e.Node.ForeColor = selectedForeColor;
     249
     250        if (node.Id == projectId) {
     251          e.Node.Text += CURRENT_SELECTION_TAG;
     252        } else if (projectId == null || projectId == Guid.Empty) {
     253          e.Node.Text += NEW_SELECTION_TAG;
     254        } else {
     255          e.Node.Text += CHANGED_SELECTION_TAG;
     256        }
     257
     258
     259      }
     260      SelectedProject = node;
     261    }
     262
     263    private void resourcesTreeView_MouseDown(object sender, MouseEventArgs e) {
     264      var node = resourcesTreeView.GetNodeAt(new Point(e.X, e.Y));
     265
     266      if (node == null && e.Button == MouseButtons.Left) {
     267        resourcesTreeView.SelectedNode = null;
    89268        ExtractStatistics();
     269      }
     270    }
     271
     272    private void resourcesTreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e) {
     273      if(e.Node == null) {
     274        e.Cancel = true;
     275        resourcesTreeView.SelectedNode = null;
     276        ExtractStatistics();
     277      } else if (e.Node == additionalNode) {
     278        e.Cancel = true;
    90279      } else {
    91         mainTreeNodes.Clear();
    92         UpdateFilteredTree();
    93       }
    94     }
    95 
    96     #region MainTree Methods
    97     private void UpdateMainTree() {
    98       mainTreeNodes.Clear();
    99 
    100       foreach (Resource g in Content) {
    101         if (g.GetType() == typeof(SlaveGroup)) {
    102           //root node
    103           if (g.ParentResourceId == null) {
    104             TreeNode tn = new TreeNode();
    105             tn.ImageIndex = slaveGroupImageIndex;
    106             tn.SelectedImageIndex = tn.ImageIndex;
    107 
    108             tn.Tag = g;
    109             tn.Text = g.Name;
    110             tn.Checked = selectedResources.Any(x => x.Id == g.Id);
    111 
    112             BuildMainTree(tn);
    113             mainTreeNodes.Add(tn);
    114           }
    115         }
    116       }
    117       UpdateFilteredTree();
    118     }
    119 
    120     private void BuildMainTree(TreeNode tn) {
    121       foreach (Resource r in Content.Where(s => s.ParentResourceId != null && s.ParentResourceId == ((Resource)tn.Tag).Id)) {
    122         TreeNode stn = new TreeNode(r.Name);
    123         if (r is Slave) stn.ImageIndex = slaveImageIndex;
    124         else if (r is SlaveGroup) stn.ImageIndex = slaveGroupImageIndex;
    125         stn.SelectedImageIndex = stn.ImageIndex;
    126         stn.Tag = r;
    127         stn.Checked = selectedResources.Any(x => x.Id == r.Id);
    128         tn.Nodes.Add(stn);
    129         mainTreeNodes.Add(stn);
    130 
    131         BuildMainTree(stn);
    132       }
     280        var r = (Resource)e.Node.Tag;
     281        if(r != null && !HiveClient.Instance.DisabledParentResources.Contains(r)) {
     282          ExtractStatistics(r);
     283        } else {
     284          e.Cancel = true;
     285        }
     286      }
     287    }
     288
     289    private void resourcesTreeView_BeforeCheck(object sender, TreeViewCancelEventArgs e) {
     290      if(e.Node == null || e.Node == additionalNode) {
     291        e.Cancel = true;
     292      } else {
     293        var checkedResource = (Resource)e.Node.Tag;
     294        if (checkedResource == null
     295          || checkedResource.Id == Guid.Empty
     296          || HiveClient.Instance.DisabledParentResources.Contains(checkedResource)
     297          || newIncludedResources.Contains(checkedResource)) {
     298          e.Cancel = true;
     299        }
     300      }
     301    }
     302
     303    private void resourcesTreeView_AfterCheck(object sender, TreeViewEventArgs e) {
     304      var checkedResource = (Resource)e.Node.Tag;
     305      if (e.Node.Checked) {
     306        newAssignedResources.Add(checkedResource);
     307      } else {
     308        newAssignedResources.Remove(checkedResource);
     309      }
     310
     311      UpdateResourceTreeAfterCheck();
     312      if(resourcesTreeView.SelectedNode == null)
     313        ExtractStatistics();
     314      OnAssignedResourcesChanged();
     315    }
     316
     317    private void resourcesTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) {
     318      return;
    133319    }
    134320    #endregion
    135321
    136     #region FilteredTree Methods
    137     private void UpdateFilteredTree() {
    138       filteredTreeNodes.Clear();
    139       foreach (TreeNode n in mainTreeNodes) {
    140         n.BackColor = SystemColors.Window;
    141         if (currentSearchString == null || ((Resource)n.Tag).Name.ToLower().Contains(currentSearchString)) {
    142           n.BackColor = string.IsNullOrEmpty(currentSearchString) ? SystemColors.Window : Color.LightBlue;
    143           filteredTreeNodes.Add(n);
    144           TraverseParentNodes(n);
    145         }
    146       }
    147       UpdateResourceTree();
    148     }
    149 
    150     private void TraverseParentNodes(TreeNode node) {
    151       if (node != null) {
    152         for (TreeNode parent = node.Parent; parent != null; parent = parent.Parent)
    153           filteredTreeNodes.Add(parent);
    154       }
    155     }
     322    #region Helpers
     323
     324    private Project GetSelectedProjectById(Guid projectId) {
     325      return Content.Where(x => x.Id == projectId).SingleOrDefault();
     326    }
     327
     328    private void UpdateProjectTree() {
     329
     330      if (string.IsNullOrEmpty(currentSearchString)) {
     331        BuildProjectTree(Content);
     332      } else {
     333        HashSet<Project> filteredProjects = new HashSet<Project>();
     334        foreach(var project in Content) {
     335          if(project.Name.ToLower().Contains(currentSearchString.ToLower())) {
     336            filteredProjects.Add(project);
     337            filteredProjects.UnionWith(Content.Where(p => HiveClient.Instance.GetAvailableProjectAncestors(project.Id).Select(x => x.Id).Contains(p.Id)));
     338          }
     339        }
     340        BuildProjectTree(filteredProjects);
     341      }
     342    }
     343
     344    private void BuildProjectTree(IEnumerable<Project> projects) {
     345      projectsTreeView.Nodes.Clear();
     346      if (!projects.Any()) return;
     347
     348      var disabledParentProjects = HiveClient.Instance.DisabledParentProjects;
     349      // select all top level projects (withouth parent, or without any ancestor within current project collection)
     350      var mainProjects = new HashSet<Project>(projects.Where(x => x.ParentProjectId == null));
     351      //var parentedMainProjects = new HashSet<Project>(projects
     352      //  .Where(x => x.ParentProjectId.HasValue
     353      //  && !projects.Select(y => y.Id).Contains(x.ParentProjectId.Value)
     354      //  && !projects.SelectMany(y => HiveClient.Instance.ProjectAncestors[y.Id]).Contains(x.ParentProjectId.Value)));
     355      //mainProjects.UnionWith(parentedMainProjects);
     356      var mainDisabledParentProjects = new HashSet<Project>(disabledParentProjects.Where(x => x.ParentProjectId == null || x.ParentProjectId == Guid.Empty));
     357      mainProjects.UnionWith(mainDisabledParentProjects);
     358      var subProbjects = new HashSet<Project>(projects.Union(disabledParentProjects).Except(mainProjects));
     359      //foreach (var p in subProbjects) {
     360      //  p.ParentProjectId = HiveClient.Instance.ProjectAncestors[p.Id].Where(x => projects.Select(y => y.Id).Contains(x)).FirstOrDefault();
     361      //}
     362
     363      var stack = new Stack<Project>(mainProjects.OrderByDescending(x => x.Name));
     364
     365      TreeNode currentNode = null;
     366      Project currentProject = null;
     367
     368      while(stack.Any()) {
     369        var newProject = stack.Pop();
     370        var newNode = new TreeNode(newProject.Name) { Tag = newProject };
     371
     372        while (currentNode != null && newProject.ParentProjectId != currentProject.Id) {
     373          currentNode = currentNode.Parent;
     374          currentProject = currentNode == null ? null : (Project)currentNode.Tag;
     375        }
     376
     377        if (currentNode == null) {
     378          projectsTreeView.Nodes.Add(newNode);
     379          newNode.ImageIndex = greenFlagImageIndex;
     380        } else {
     381          currentNode.Nodes.Add(newNode);
     382          newNode.ImageIndex = redFlagImageIndex;
     383        }
     384
     385        newNode.SelectedImageIndex = newNode.ImageIndex;
     386
     387        if(disabledParentProjects.Contains(newProject)) {
     388          newNode.Checked = false;
     389          newNode.ForeColor = grayTextColor;
     390        }
     391        else if (SelectedProject != null && SelectedProject.Id.Equals(newProject.Id)) {
     392          newNode.BackColor = selectedBackColor;
     393          newNode.ForeColor = selectedForeColor;
     394          if(SelectedProject.Id == projectId) {
     395            newNode.Text += CURRENT_SELECTION_TAG;
     396          } else if (projectId == null || projectId == Guid.Empty) {
     397            newNode.Text += NEW_SELECTION_TAG;
     398          } else {
     399            newNode.Text += CHANGED_SELECTION_TAG;
     400          }
     401        }
     402
     403        if (!string.IsNullOrEmpty(currentSearchString) && newProject.Name.ToLower().Contains(currentSearchString.ToLower())) {
     404          newNode.BackColor = Color.LightBlue;
     405        }
     406
     407        var childProjects = subProbjects.Where(x => x.ParentProjectId == newProject.Id);
     408        if (childProjects.Any()) {
     409          foreach (var project in childProjects.OrderByDescending(x => x.Name)) {
     410            subProbjects.Remove(project);
     411            stack.Push(project);
     412          }
     413          currentNode = newNode;
     414          currentProject = newProject;
     415        }
     416      }
     417
     418      projectsTreeView.ExpandAll();
     419    }
     420
     421    private static IEnumerable<Resource> GetAssignedResourcesForProject(Guid projectId) {
     422      var assignedProjectResources = HiveServiceLocator.Instance.CallHiveService(s => s.GetAssignedResourcesForProject(projectId));
     423      return HiveClient.Instance.Resources.Where(x => assignedProjectResources.Select(y => y.ResourceId).Contains(x.Id));
     424    }
     425
     426    private static IEnumerable<Resource> GetAssignedResourcesForJob(Guid jobId) {
     427      var assignedJobResources = HiveServiceLocator.Instance.CallHiveService(s => s.GetAssignedResourcesForJob(jobId));
     428      return HiveClient.Instance.Resources.Where(x => assignedJobResources.Select(y => y.ResourceId).Contains(x.Id));
     429    }
     430
     431    private void UpdateResourceTree() {
     432      UpdateAvailableResources();
     433      UpdateAssignedResources();
     434      UpdateIncludedResources();
     435      BuildResourceTree(availableResources);
     436    }
     437
     438    private void UpdateResourceTreeAfterCheck() {
     439      resourcesTreeView.BeforeCheck -= resourcesTreeView_BeforeCheck;
     440      resourcesTreeView.AfterCheck -= resourcesTreeView_AfterCheck;
     441      UpdateNewAssignedResources();
     442      UpdateNewIncludedResources();
     443      SetTreeNodes(resourcesTreeView.Nodes);
     444      resourcesTreeView.BeforeCheck += resourcesTreeView_BeforeCheck;
     445      resourcesTreeView.AfterCheck += resourcesTreeView_AfterCheck;
     446    }
     447
     448    private void UpdateAvailableResources() {
     449      availableResources.Clear();
     450      if (selectedProject != null) {
     451        var assignedProjectResources = GetAssignedResourcesForProject(selectedProject.Id);
     452        foreach (var resource in assignedProjectResources) {
     453          availableResources.Add(resource);
     454          foreach(var descendant in HiveClient.Instance.Resources.Where(x => HiveClient.Instance.ResourceDescendants[resource.Id].Contains(x.Id))) {
     455            availableResources.Add(descendant);
     456          }
     457        }
     458      }
     459      //ExtractStatistics();
     460      //OnAssignedResourcesChanged();
     461    }
     462
     463    private void UpdateAssignedResources() {
     464      assignedResources.Clear();
     465      newAssignedResources.Clear();
     466
     467      if (JobId == Guid.Empty || JobId == null) { // new, unchanged jobs get all avaialable resources
     468        // update new assigned resources
     469        if(selectedResourceIds == null) {
     470          foreach (var resource in availableResources
     471            .Where(x => !x.ParentResourceId.HasValue
     472            || !availableResources.Select(y => y.Id).Contains(x.ParentResourceId.Value))) {
     473            newAssignedResources.Add(resource);
     474          }
     475        } else {
     476          foreach(var resource in availableResources.Where(x => selectedResourceIds.Contains(x.Id))) {
     477            newAssignedResources.Add(resource);
     478          }
     479        }
     480      } else if(selectedProject.Id == projectId) { // existent, unchanged jobs get all assigned resources
     481        // update assigned resources
     482        var assignedJobResources = GetAssignedResourcesForJob(JobId);
     483        foreach (var resource in assignedJobResources) {
     484          assignedResources.Add(resource);
     485          if (selectedResourceIds == null) {
     486            newAssignedResources.Add(resource);
     487          }
     488        }
     489
     490        if(selectedResourceIds != null) {
     491          foreach (var resource in availableResources.Where(x => selectedResourceIds.Contains(x.Id))) {
     492            newAssignedResources.Add(resource);
     493          }
     494        }
     495      }
     496
     497      //ExtractStatistics();
     498      OnAssignedResourcesChanged();
     499    }
     500
     501    private void UpdateNewAssignedResources() {
     502      for(int i = newAssignedResources.Count-1; i>=0; i--) {
     503        if(newAssignedResources.Intersect(HiveClient.Instance.GetAvailableResourceAncestors(newAssignedResources.ElementAt(i).Id)).Any()) {
     504          newAssignedResources.Remove(newAssignedResources.ElementAt(i));
     505        }
     506      }
     507    }
     508
     509    private void UpdateIncludedResources() {
     510      includedResources.Clear();
     511      newIncludedResources.Clear();
     512
     513      if (JobId != Guid.Empty) {
     514        foreach (var item in assignedResources) {
     515          foreach (var descendant in HiveClient.Instance.GetAvailableResourceDescendants(item.Id)) {
     516            includedResources.Add(descendant);
     517          }
     518        }
     519      }
     520
     521      foreach (var item in newAssignedResources) {
     522        foreach (var descendant in HiveClient.Instance.GetAvailableResourceDescendants(item.Id)) {
     523          newIncludedResources.Add(descendant);
     524        }
     525      }
     526    }
     527
     528    private void UpdateNewIncludedResources() {
     529      newIncludedResources.Clear();
     530      foreach (var item in newAssignedResources) {
     531        foreach (var descendant in HiveClient.Instance.GetAvailableResourceDescendants(item.Id)) {
     532          newIncludedResources.Add(descendant);
     533        }
     534      }
     535    }
     536
     537    private void BuildResourceTree(IEnumerable<Resource> resources) {
     538      resourcesTreeView.Nodes.Clear();
     539      if (!resources.Any()) return;
     540
     541      resourcesTreeView.BeforeCheck -= resourcesTreeView_BeforeCheck;
     542      resourcesTreeView.AfterCheck -= resourcesTreeView_AfterCheck;
     543
     544      //var disabledParentResources = HiveClient.Instance.DisabledParentResources;
     545      var disabledParentResources = HiveClient.Instance.GetDisabledResourceAncestors(resources);
     546      var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>().Where(x => x.ParentResourceId == null));
     547      //var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>()
     548      //  .Where(x => x.ParentResourceId.HasValue && !resources.Select(y => y.Id).Contains(x.ParentResourceId.Value)));
     549      //mainResources.UnionWith(parentedMainResources);
     550      //var subResources = new HashSet<Resource>(resources.Except(mainResources));
     551      var mainDisabledParentResources = new HashSet<Resource>(disabledParentResources.Where(x => x.ParentResourceId == null || x.ParentResourceId == Guid.Empty));
     552      mainResources.UnionWith(mainDisabledParentResources);
     553      var subResources = new HashSet<Resource>(resources.Union(disabledParentResources).Except(mainResources).OrderByDescending(x => x.Name));
     554
     555      var addedAssignments = newAssignedResources.Except(assignedResources);
     556      var removedAssignments = assignedResources.Except(newAssignedResources);
     557      var addedIncludes = newIncludedResources.Except(includedResources);
     558      var removedIncludes = includedResources.Except(newIncludedResources);
     559
     560      TreeNode currentNode = null;
     561      Resource currentResource = null;
     562
     563      var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name));
     564
     565      while (stack.Any()) {
     566        var newResource = stack.Pop();
     567        var newNode = new TreeNode(newResource.Name) { Tag = newResource };
     568
     569        // search for parent node of newNode and save in currentNode
     570        // necessary since newNodes (stack top items) might be siblings
     571        // or grand..grandparents of previous node (currentNode)
     572        while (currentNode != null && newResource.ParentResourceId != currentResource.Id) {
     573          currentNode = currentNode.Parent;
     574          currentResource = currentNode == null ? null : (Resource)currentNode.Tag;
     575        }
     576
     577        if (currentNode == null) {
     578          resourcesTreeView.Nodes.Add(newNode);
     579        } else {
     580          currentNode.Nodes.Add(newNode);
     581        }
     582
     583        if (disabledParentResources.Contains(newResource)) {
     584          newNode.Checked = false;
     585          newNode.ForeColor = grayTextColor;
     586        } else if (newAssignedResources.Select(x => x.Id).Contains(newResource.Id)) {
     587          newNode.Checked = true;
     588          if(!addedAssignments.Select(x => x.Id).Contains(newResource.Id) && !removedAssignments.Select(x => x.Id).Contains(newResource.Id)) {
     589            newNode.Text += SELECTED_TAG;
     590          }
     591        } else if (newIncludedResources.Select(x => x.Id).Contains(newResource.Id)) {
     592          newNode.Checked = true;
     593          newNode.ForeColor = grayTextColor;
     594        }
     595
     596        if (includedResources.Select(x => x.Id).Contains(newResource.Id) && newIncludedResources.Select(x => x.Id).Contains(newResource.Id)) {
     597          newNode.Text += INCLUDED_TAG;
     598        } else if (addedIncludes.Select(x => x.Id).Contains(newResource.Id)) {
     599          newNode.BackColor = addedIncludeColor;
     600          newNode.ForeColor = grayTextColor;
     601          newNode.Text += ADDED_INCLUDE_TAG;
     602        } else if (removedIncludes.Select(x => x.Id).Contains(newResource.Id)) {
     603          newNode.BackColor = removedIncludeColor;
     604          newNode.Text += REMOVED_INCLUDE_TAG;
     605        }
     606
     607        if (addedAssignments.Select(x => x.Id).Contains(newResource.Id)) {
     608          newNode.BackColor = addedAssignmentColor;
     609          newNode.ForeColor = controlTextColor;
     610          newNode.Text += ADDED_SELECTION_TAG;
     611        } else if (removedAssignments.Select(x => x.Id).Contains(newResource.Id)) {
     612          newNode.BackColor = removedAssignmentColor;
     613          newNode.ForeColor = controlTextColor;
     614          newNode.Text += REMOVED_SELECTION_TAG;
     615        }
     616
     617        if (newResource is Slave) {
     618          newNode.ImageIndex = slaveImageIndex;
     619        } else {
     620          newNode.ImageIndex = slaveGroupImageIndex;
     621
     622          var childResources = subResources.Where(x => x.ParentResourceId == newResource.Id);
     623          if (childResources.Any()) {
     624            foreach (var resource in childResources.OrderByDescending(x => x.Name)) {
     625              subResources.Remove(resource);
     626              stack.Push(resource);
     627            }
     628            currentNode = newNode;
     629            currentResource = newResource;
     630          }
     631        }
     632        newNode.SelectedImageIndex = newNode.ImageIndex;
     633      }
     634
     635      var singleSlaves = subResources.OfType<Slave>();
     636      if (singleSlaves.Any()) {
     637
     638        additionalNode = new TreeNode(additionalSlavesGroupName) {
     639          ForeColor = SystemColors.GrayText,
     640          ImageIndex = slaveGroupImageIndex,
     641          Tag = new SlaveGroup() {
     642            Name = additionalSlavesGroupName,
     643            Description = additionalSlavesGroupDescription
     644          }
     645        };
     646
     647        foreach (var slave in singleSlaves.OrderBy(x => x.Name)) {
     648          var slaveNode = new TreeNode(slave.Name) { Tag = slave };
     649
     650          if (newAssignedResources.Select(x => x.Id).Contains(slave.Id)) {
     651            slaveNode.Checked = true;
     652            if (!addedAssignments.Select(x => x.Id).Contains(slave.Id) &&
     653                !removedAssignments.Select(x => x.Id).Contains(slave.Id)) {
     654              slaveNode.Text += SELECTED_TAG;
     655            }
     656          }
     657
     658          if (addedAssignments.Select(x => x.Id).Contains(slave.Id)) {
     659            slaveNode.BackColor = addedAssignmentColor;
     660            slaveNode.ForeColor = controlTextColor;
     661            slaveNode.Text += ADDED_SELECTION_TAG;
     662          } else if (removedAssignments.Select(x => x.Id).Contains(slave.Id)) {
     663            slaveNode.BackColor = removedAssignmentColor;
     664            slaveNode.ForeColor = controlTextColor;
     665            slaveNode.Text += REMOVED_SELECTION_TAG;
     666          }
     667
     668          additionalNode.Nodes.Add(slaveNode);
     669        }
     670
     671        resourcesTreeView.Nodes.Add(additionalNode);
     672      }
     673
     674      ExpandResourceNodesOfInterest(resourcesTreeView.Nodes);
     675
     676      resourcesTreeView.BeforeCheck += resourcesTreeView_BeforeCheck;
     677      resourcesTreeView.AfterCheck += resourcesTreeView_AfterCheck;
     678    }
     679
     680    private void ExpandResourceNodesOfInterest(TreeNodeCollection nodes) {
     681      foreach(TreeNode n in nodes) {
     682        Resource r = (Resource)n.Tag;
     683        if(n.Nodes.Count > 0) {
     684          if(HiveClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any()           
     685            || HiveClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<Slave>().Intersect(assignedResources.Union(newAssignedResources)).Any()
     686            || (n == additionalNode && additionalNode.Nodes.Count > 0 && additionalNode.Nodes.Cast<TreeNode>().Any(x => x.Checked))) {
     687            n.Expand();
     688            ExpandResourceNodesOfInterest(n.Nodes);
     689          } else {
     690            n.Collapse();
     691          }   
     692        } else {
     693          n.Collapse();
     694        }
     695      }
     696    }
     697
     698    private void CollapseSlaveOnlyNodes(TreeNode tn) {
     699      if (!(tn.Tag is Resource)) return;
     700
     701      Resource r = (Resource)tn.Tag;
     702      if (HiveClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any()) {
     703        tn.Expand();
     704        foreach (TreeNode n in tn.Nodes) CollapseSlaveOnlyNodes(n);
     705      } else {
     706        tn.Collapse();
     707      }
     708    }
     709
     710    private void ExtractStatistics(Resource resource = null) {
     711      HashSet<Slave> newAssignedSlaves = new HashSet<Slave>(newAssignedResources.OfType<Slave>());
     712      foreach (var slaveGroup in newAssignedResources.OfType<SlaveGroup>()) {
     713        foreach (var slave in HiveClient.Instance.GetAvailableResourceDescendants(slaveGroup.Id).OfType<Slave>()) {
     714          newAssignedSlaves.Add(slave);
     715        }
     716      }
     717
     718      HashSet<Slave> selectedSlaves = null;
     719
     720      if (resource != null) {
     721        var slaveGroup = resource as SlaveGroup;
     722        if (slaveGroup != null) {
     723          selectedSlaves = new HashSet<Slave>(HiveClient.Instance.GetAvailableResourceDescendants(slaveGroup.Id).OfType<Slave>());
     724        } else {
     725          selectedSlaves = new HashSet<Slave>(new[] { resource as Slave });
     726        }
     727      } else {
     728        selectedSlaves = newAssignedSlaves;
     729      }
     730
     731      int sumCores = selectedSlaves.Sum(x => x.Cores.GetValueOrDefault());
     732      int sumFreeCores = selectedSlaves.Sum(x => x.FreeCores.GetValueOrDefault());
     733      double sumMemory = selectedSlaves.Sum(x => x.Memory.GetValueOrDefault()) / 1024.0;
     734      double sumFreeMemory = selectedSlaves.Sum(x => x.FreeMemory.GetValueOrDefault()) / 1024.0;
     735
     736      coresSummaryLabel.Text = string.Format("{0} Total ({1} Free / {2} Used)", sumCores, sumFreeCores, sumCores - sumFreeCores);
     737      memorySummaryLabel.Text = string.Format("{0:0.00} GB Total ({1:0.00} GB Free / {2:0.00} GB Used)", sumMemory, sumFreeMemory, sumMemory - sumFreeMemory);
     738    }
     739
     740    private void StyleTreeNode(TreeNode n, string name) {
     741      n.Text = name;
     742      n.BackColor = Color.Transparent;
     743      n.ForeColor = Color.Black;
     744
     745      if(n.Tag is Project) {
     746        var p = (Project)n.Tag;
     747        if(HiveClient.Instance.DisabledParentProjects.Select(x => x.Id).Contains(p.Id)) {
     748          n.Checked = false;
     749          n.ForeColor = grayTextColor;
     750        }
     751      } else if(n.Tag is Resource) {
     752        var r = (Resource)n.Tag;
     753        if(HiveClient.Instance.DisabledParentResources.Select(x => x.Id).Contains(r.Id) || n == additionalNode) {
     754          n.Checked = false;
     755          n.ForeColor = grayTextColor;
     756        }
     757      }
     758    }
     759
     760    private void ResetTreeNodes(TreeNodeCollection nodes) {
     761      foreach (TreeNode n in nodes) {
     762        string name = "";
     763        if (n.Tag is Project) name = ((Project)n.Tag).Name;
     764        else if (n.Tag is Resource) name = ((Resource)n.Tag).Name;
     765        StyleTreeNode(n, name);
     766        if (n.Nodes.Count > 0) {
     767          ResetTreeNodes(n.Nodes);
     768        }
     769      }
     770    }
     771
     772    private void SetTreeNodes(TreeNodeCollection nodes) {
     773      var addedAssignments = newAssignedResources.Except(assignedResources);
     774      var removedAssignments = assignedResources.Except(newAssignedResources);
     775      var addedIncludes = newIncludedResources.Except(includedResources);
     776      var removedIncludes = includedResources.Except(newIncludedResources);
     777
     778      foreach (TreeNode n in nodes) {
     779
     780        if(n.Tag is Resource) {
     781          // reset
     782          var resource = (Resource)n.Tag;
     783          n.Text = resource.Name;
     784          n.BackColor = Color.Transparent;
     785          n.ForeColor = Color.Black;
     786          n.Checked = false;
     787
     788          if (HiveClient.Instance.DisabledParentResources.Select(x => x.Id).Contains(resource.Id) || n == additionalNode) {
     789            n.ForeColor = grayTextColor;
     790          }
     791
     792          // add additional info
     793          if (newAssignedResources.Select(x => x.Id).Contains(resource.Id)) {
     794            n.Checked = true;
     795            if (!addedAssignments.Select(x => x.Id).Contains(resource.Id) && !removedAssignments.Select(x => x.Id).Contains(resource.Id)) {
     796              n.Text += SELECTED_TAG;
     797            }
     798          } else if (newIncludedResources.Select(x => x.Id).Contains(resource.Id)) {
     799            n.Checked = true;
     800            n.ForeColor = grayTextColor;
     801          }
     802
     803          if (includedResources.Select(x => x.Id).Contains(resource.Id) && newIncludedResources.Select(x => x.Id).Contains(resource.Id)) {
     804            n.Text += INCLUDED_TAG;
     805          } else if (addedIncludes.Select(x => x.Id).Contains(resource.Id)) {
     806            n.BackColor = addedIncludeColor;
     807            n.ForeColor = grayTextColor;
     808            n.Text += ADDED_INCLUDE_TAG;
     809          } else if (removedIncludes.Select(x => x.Id).Contains(resource.Id)) {
     810            n.BackColor = removedIncludeColor;
     811            n.Text += REMOVED_INCLUDE_TAG;
     812          }
     813
     814          if (addedAssignments.Select(x => x.Id).Contains(resource.Id)) {
     815            n.BackColor = addedAssignmentColor;
     816            n.ForeColor = controlTextColor;
     817            n.Text += ADDED_SELECTION_TAG;
     818          } else if (removedAssignments.Select(x => x.Id).Contains(resource.Id)) {
     819            n.BackColor = removedAssignmentColor;
     820            n.ForeColor = controlTextColor;
     821            n.Text += REMOVED_SELECTION_TAG;
     822          }
     823        }
     824
     825        if(n.Nodes.Count > 0) {
     826          SetTreeNodes(n.Nodes);
     827        }
     828      }
     829    }
     830
    156831    #endregion
    157832
    158     #region ResourceTree Methods
    159     private void UpdateResourceTree() {
    160       resourcesTreeView.Nodes.Clear();
    161       nodeStore.Clear();
    162 
    163       foreach (TreeNode node in filteredTreeNodes) {
    164         var clone = nodeStore.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)node.Tag).Id);
    165         if (clone == null) {
    166           clone = (TreeNode)node.Clone();
    167           nodeStore.Add(clone);
    168           clone.Nodes.Clear();
    169         }
    170         foreach (TreeNode child in node.Nodes)
    171           if (filteredTreeNodes.Any(x => ((Resource)x.Tag).Id == ((Resource)child.Tag).Id)) {
    172             var childClone = nodeStore.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)child.Tag).Id);
    173             if (childClone == null) {
    174               childClone = (TreeNode)child.Clone();
    175               nodeStore.Add(childClone);
    176               childClone.Nodes.Clear();
    177             }
    178             clone.Nodes.Add(childClone);
    179           }
    180       }
    181       resourcesTreeView.Nodes.AddRange(nodeStore.Where(x => ((Resource)x.Tag).ParentResourceId == null).ToArray());
    182       if (string.IsNullOrEmpty(currentSearchString)) ExpandSlaveGroupNodes();
    183       else resourcesTreeView.ExpandAll();
    184     }
    185     #endregion
    186 
    187833    #region Events
    188     private void resourcesTreeView_AfterCheck(object sender, TreeViewEventArgs e) {
    189       if (e.Action != TreeViewAction.Unknown) {
    190         if (e.Node.Checked) {
    191           IncludeChildNodes(mainTreeNodes.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)e.Node.Tag).Id));
    192           IncludeParentNodes(mainTreeNodes.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)e.Node.Tag).Id));
    193         } else {
    194           ExcludeChildNodes(mainTreeNodes.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)e.Node.Tag).Id));
    195           ExcludeParentNodes(mainTreeNodes.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)e.Node.Tag).Id));
    196         }
    197         ExtractStatistics();
    198       }
    199     }
    200 
    201     private void resourcesTreeView_AfterSelect(object sender, TreeViewEventArgs e) {
    202       if (e.Action != TreeViewAction.Unknown) {
    203         ExtractStatistics(e.Node);
    204       }
    205     }
    206 
    207     private void searchTextBox_TextChanged(object sender, System.EventArgs e) {
    208       currentSearchString = searchTextBox.Text.ToLower();
    209       UpdateFilteredTree();
    210     }
    211     #endregion
    212 
    213     #region Helpers
    214     private void IncludeChildNodes(TreeNode node) {
    215       if (node != null) {
    216         node.Checked = true;
    217         selectedResources.Add((Resource)node.Tag);
    218         AdjustNodeCheckedState(node);
    219         foreach (TreeNode n in node.Nodes) IncludeChildNodes(n);
    220       }
    221     }
    222 
    223     private void IncludeParentNodes(TreeNode node) {
    224       if (node != null && node.Parent != null) {
    225         TreeNode parent = node.Parent;
    226         if (parent.Nodes.OfType<TreeNode>().All(x => x.Checked)) {
    227           parent.Checked = true;
    228           selectedResources.Add((Resource)parent.Tag);
    229           AdjustNodeCheckedState(parent);
    230           IncludeParentNodes(parent);
    231         }
    232       }
    233     }
    234 
    235     private void ExcludeChildNodes(TreeNode node) {
    236       if (node != null) {
    237         node.Checked = false;
    238         selectedResources.Remove((Resource)node.Tag);
    239         AdjustNodeCheckedState(node);
    240         foreach (TreeNode n in node.Nodes) ExcludeChildNodes(n);
    241       }
    242     }
    243 
    244     private void ExcludeParentNodes(TreeNode node) {
    245       if (node != null) {
    246         node.Checked = false;
    247         selectedResources.Remove((Resource)node.Tag);
    248         AdjustNodeCheckedState(node);
    249         ExcludeParentNodes(node.Parent);
    250       }
    251     }
    252 
    253     private void AdjustNodeCheckedState(TreeNode node) {
    254       var filterdNode = filteredTreeNodes.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)node.Tag).Id);
    255       var storedNode = nodeStore.SingleOrDefault(x => ((Resource)x.Tag).Id == ((Resource)node.Tag).Id);
    256       if (filterdNode != null) filterdNode.Checked = node.Checked;
    257       if (storedNode != null) storedNode.Checked = node.Checked;
    258     }
    259 
    260     private void ExpandSlaveGroupNodes() {
    261       foreach (TreeNode n in nodeStore.Where(x => x.Tag is SlaveGroup)) {
    262         TreeNode[] children = new TreeNode[n.Nodes.Count];
    263         n.Nodes.CopyTo(children, 0);
    264         if (children.Any(x => x.Tag is SlaveGroup)) n.Expand();
    265       }
    266     }
    267 
    268     private void ExtractStatistics(TreeNode treeNode = null) {
    269       StringBuilder sb = new StringBuilder();
    270       Resource resource = treeNode == null ? null : treeNode.Tag as Resource;
    271       ISet<Resource> resources = treeNode == null ? selectedResources : new HashSet<Resource>(treeNode.DescendantNodes().Select(x => x.Tag as Resource)); ;
    272       IEnumerable<SlaveGroup> slaveGroups = resources.OfType<SlaveGroup>();
    273       IEnumerable<Slave> slaves = resources.OfType<Slave>();
    274       int cpuSpeed = 0, cores = 0, freeCores = 0, memory = 0, freeMemory = 0;
    275       string contextString = treeNode == null ? "Selected" : "Included";
    276 
    277       if (resources.Any() || resource != null) {
    278         foreach (Slave s in slaves) {
    279           cpuSpeed += s.CpuSpeed.GetValueOrDefault();
    280           cores += s.Cores.GetValueOrDefault();
    281           freeCores += s.FreeCores.GetValueOrDefault();
    282           memory += s.Memory.GetValueOrDefault();
    283           freeMemory += s.FreeMemory.GetValueOrDefault();
    284         }
    285         if (resource != null) {
    286           if (resource is SlaveGroup) sb.Append("Slave group: ");
    287           else if (resource is Slave) {
    288             sb.Append("Slave: ");
    289             if (!resources.Any()) {
    290               Slave s = resource as Slave;
    291               cpuSpeed = s.CpuSpeed.GetValueOrDefault();
    292               cores = s.Cores.GetValueOrDefault();
    293               freeCores = s.FreeCores.GetValueOrDefault();
    294               memory = s.Memory.GetValueOrDefault();
    295               freeMemory = s.FreeMemory.GetValueOrDefault();
    296             }
    297           }
    298           sb.AppendLine(string.Format("{0}", resource.Name));
    299         }
    300         if (resource == null || resource is SlaveGroup) {
    301           if (resources.Any()) {
    302             sb.AppendFormat("{0} slave groups ({1}): ", contextString, slaveGroups.Count());
    303             foreach (SlaveGroup sg in slaveGroups) sb.AppendFormat("{0}; ", sg.Name);
    304             sb.AppendLine();
    305             sb.AppendFormat("{0} slaves ({1}): ", contextString, slaves.Count());
    306             foreach (Slave s in slaves) sb.AppendFormat("{0}; ", s.Name);
    307             sb.AppendLine();
    308           } else {
    309             sb.Append("The selection does not inlcude any further resources.");
    310           }
    311         }
    312         sb.AppendLine();
    313         sb.AppendLine(string.Format("CPU speed: {0} MHz", cpuSpeed));
    314         if (resources.Any()) sb.AppendLine(string.Format("Avg. CPU speed: {0:0.00} MHz", (double)cpuSpeed / resources.Count()));
    315         sb.AppendLine(string.Format("Cores: {0}", cores));
    316         sb.AppendLine(string.Format("Free cores: {0}", freeCores));
    317         if (resources.Any()) sb.AppendLine(string.Format("Avg. free cores: {0:0.00}", (double)freeCores / resources.Count()));
    318         sb.AppendLine(string.Format("Memory: {0} MB", memory));
    319         sb.AppendFormat("Free memory: {0} MB", freeMemory);
    320         if (resources.Any()) sb.Append(string.Format("{0}Avg. free memory: {1:0.00} MB", Environment.NewLine, (double)freeMemory / resources.Count()));
    321       } else {
    322         sb.Append("No resources selected.");
    323       }
    324 
    325       descriptionTextBox.Text = sb.ToString();
     834    public event EventHandler SelectedProjectChanged;
     835    private void OnSelectedProjectChanged() {
     836      var handler = SelectedProjectChanged;
     837      if (handler != null) handler(this, EventArgs.Empty);
     838    }
     839
     840    public event EventHandler AssignedResourcesChanged;
     841    private void OnAssignedResourcesChanged() {
     842      var handler = AssignedResourcesChanged;
     843      if (handler != null) handler(this, EventArgs.Empty);
     844    }
     845
     846    public event EventHandler ProjectsTreeViewDoubleClicked;
     847    private void OnProjectsTreeViewDoubleClicked() {
     848      var handler = ProjectsTreeViewDoubleClicked;
     849      if (handler != null) handler(this, EventArgs.Empty);
    326850    }
    327851    #endregion
  • branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelectorDialog.Designer.cs

    r15583 r16388  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HiveResourceSelectorDialog));
     47      this.components = new System.ComponentModel.Container();
    4848      this.okButton = new System.Windows.Forms.Button();
    4949      this.cancelButton = new System.Windows.Forms.Button();
    5050      this.refreshButton = new System.Windows.Forms.Button();
    51       this.hiveResourceSelector = new HeuristicLab.Clients.Hive.JobManager.Views.HiveResourceSelector();
     51      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
     52      this.errorProvider = new System.Windows.Forms.ErrorProvider(this.components);
     53      this.hiveResourceSelector = new HeuristicLab.Clients.Hive.JobManager.Views.HiveProjectSelector();
     54      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    5255      this.SuspendLayout();
    5356      //
     
    5659      this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    5760      this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK;
     61      this.okButton.Enabled = false;
    5862      this.okButton.Location = new System.Drawing.Point(405, 609);
    5963      this.okButton.Name = "okButton";
     
    6266      this.okButton.Text = "&OK";
    6367      this.okButton.UseVisualStyleBackColor = true;
     68      this.errorProvider.SetIconAlignment(this.okButton, System.Windows.Forms.ErrorIconAlignment.MiddleLeft);
     69      this.errorProvider.SetIconPadding(this.okButton, 2);
    6470      //
    6571      // cancelButton
     
    8288      this.refreshButton.Size = new System.Drawing.Size(24, 24);
    8389      this.refreshButton.TabIndex = 3;
     90      this.toolTip.SetToolTip(this.refreshButton, "Refresh data");
    8491      this.refreshButton.UseVisualStyleBackColor = true;
    8592      this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click);
    8693      //
     94      // errorProvider
     95      //
     96      this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink;
     97      this.errorProvider.ContainerControl = this;
     98      //
    8799      // hiveResourceSelector
    88100      //
    89       this.hiveResourceSelector.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    90             | System.Windows.Forms.AnchorStyles.Left)
     101      this.hiveResourceSelector.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     102            | System.Windows.Forms.AnchorStyles.Left) 
    91103            | System.Windows.Forms.AnchorStyles.Right)));
    92104      this.hiveResourceSelector.Caption = "View";
    93105      this.hiveResourceSelector.Content = null;
     106      this.hiveResourceSelector.JobId = new System.Guid("00000000-0000-0000-0000-000000000000");
    94107      this.hiveResourceSelector.Location = new System.Drawing.Point(12, 12);
    95108      this.hiveResourceSelector.Name = "hiveResourceSelector";
     109      this.hiveResourceSelector.ProjectId = null;
    96110      this.hiveResourceSelector.ReadOnly = false;
     111      this.hiveResourceSelector.SelectedProject = null;
     112      this.hiveResourceSelector.SelectedProjectId = null;
     113      this.hiveResourceSelector.SelectedResourceIds = null;
    97114      this.hiveResourceSelector.Size = new System.Drawing.Size(549, 591);
    98115      this.hiveResourceSelector.TabIndex = 0;
     116      this.hiveResourceSelector.SelectedProjectChanged += new System.EventHandler(this.hiveResourceSelector_SelectedProjectChanged);
     117      this.hiveResourceSelector.AssignedResourcesChanged += new System.EventHandler(this.hiveResourceSelector_SelectedResourcesChanged);
     118      this.hiveResourceSelector.ProjectsTreeViewDoubleClicked += new System.EventHandler(this.hiveResourceSelector_ProjectsTreeViewDoubleClicked);
    99119      //
    100120      // HiveResourceSelectorDialog
    101121      //
    102122      this.AcceptButton = this.okButton;
    103       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    104123      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    105124      this.CancelButton = this.cancelButton;
     
    115134      this.ShowInTaskbar = false;
    116135      this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
    117       this.Text = "Select Resources";
    118       this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HiveResourceSelectorDialog_FormClosing);
     136      this.Text = "Select Project";
    119137      this.Load += new System.EventHandler(this.HiveResourceSelectorDialog_Load);
     138      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    120139      this.ResumeLayout(false);
    121140
     
    126145    protected System.Windows.Forms.Button okButton;
    127146    protected System.Windows.Forms.Button cancelButton;
    128     protected HiveResourceSelector hiveResourceSelector;
    129147    protected System.Windows.Forms.Button refreshButton;
     148    protected System.Windows.Forms.ToolTip toolTip;
     149    protected System.Windows.Forms.ErrorProvider errorProvider;
     150    protected HiveProjectSelector hiveResourceSelector;
    130151  }
    131152}
  • branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelectorDialog.cs

    r15583 r16388  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    23 using System.Threading.Tasks;
     24using System.ComponentModel;
     25using System.Linq;
    2426using System.Windows.Forms;
    25 using HeuristicLab.PluginInfrastructure;
     27using HeuristicLab.Clients.Hive.Views;
     28using HeuristicLab.MainForm;
     29using HeuristicLab.Core;
    2630
    2731namespace HeuristicLab.Clients.Hive.JobManager.Views {
    2832  public partial class HiveResourceSelectorDialog : Form {
    29     public HiveResourceSelectorDialog() {
     33    private readonly object locker = new object();
     34    private bool updatingProjects = false;
     35
     36    public Project SelectedProject {
     37      get { return hiveResourceSelector.SelectedProject; }
     38    }
     39
     40    public IEnumerable<Resource> SelectedResources {
     41      get { return hiveResourceSelector.AssignedResources; }
     42    }
     43
     44    private Guid jobId;
     45    public Guid JobId {
     46      get { return hiveResourceSelector.JobId; }
     47      set { jobId = value; }
     48    }
     49
     50    // persisted projectId
     51    private Guid? projectId;
     52    public Guid? ProjectId {
     53      get { return hiveResourceSelector.ProjectId; }
     54      set { projectId = value; }
     55    }
     56
     57    // currently selected projectId (initially the persisted projectId)
     58    private Guid? selectedProjectId;
     59    public Guid? SelectedProjectId {
     60      get { return selectedProjectId; }
     61      set { selectedProjectId = value; }
     62    }
     63
     64    // currently selected resourceIds (if null, perform lookup in HiveResourceSelector)
     65    private IEnumerable<Guid> selectedResourceIds;
     66    public IEnumerable<Guid> SelectedResourceIds {
     67      get { return selectedResourceIds; }
     68      set { selectedResourceIds = value; }
     69    }
     70
     71
     72
     73    public HiveResourceSelectorDialog(Guid jobId, Guid projectId) {
     74      this.jobId = jobId;
     75      this.projectId = projectId;
     76      this.selectedProjectId = projectId;
    3077      InitializeComponent();
    3178    }
    3279
    33     public ISet<Resource> GetSelectedResources() { return hiveResourceSelector.SelectedResources; }
    34 
    35     private void HiveResourceSelectorDialog_Load(object sender, System.EventArgs e) {
    36       HiveAdminClient.Instance.Refreshed += new System.EventHandler(Instance_Refreshed);
    37       DownloadResources();
     80    #region Overrides
     81    protected override void OnLoad(EventArgs e) {
     82      HiveClient.Instance.Refreshing += HiveClient_Instance_Refreshing;
     83      HiveClient.Instance.Refreshed += HiveClient_Instance_Refreshed;
     84      base.OnLoad(e);
    3885    }
    3986
    40     private void HiveResourceSelectorDialog_FormClosing(object sender, FormClosingEventArgs e) {
    41       HiveAdminClient.Instance.Refreshed -= new System.EventHandler(Instance_Refreshed);
     87    protected override void OnClosing(CancelEventArgs e) {
     88      HiveClient.Instance.Refreshed -= HiveClient_Instance_Refreshed;
     89      HiveClient.Instance.Refreshing -= HiveClient_Instance_Refreshing;
     90      base.OnClosing(e);
     91    }
     92    #endregion
     93
     94    #region Event Handlers
     95    private void HiveClient_Instance_Refreshing(object sender, EventArgs e) {
     96      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveClient_Instance_Refreshing, sender, e);
     97      else {
     98        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     99        mainForm.AddOperationProgressToView(this, "Refreshing ...");
     100        refreshButton.Enabled = false;
     101      }
    42102    }
    43103
    44     void Instance_Refreshed(object sender, System.EventArgs e) {
    45       hiveResourceSelector.Content = HiveAdminClient.Instance.Resources;
     104    private void HiveClient_Instance_Refreshed(object sender, EventArgs e) {
     105      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveClient_Instance_Refreshed, sender, e);
     106      else {
     107        var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
     108        mainForm.RemoveOperationProgressFromView(this);
     109        refreshButton.Enabled = true;
     110      }
    46111    }
    47112
    48     private void refreshButton_Click(object sender, System.EventArgs e) {
    49       DownloadResources();
     113    private async void HiveResourceSelectorDialog_Load(object sender, EventArgs e) {
     114      lock (locker) {
     115        if (updatingProjects) return;
     116        updatingProjects = true;
     117      }
     118
     119      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     120        action: () => UpdateProjects(),
     121        finallyCallback: () => updatingProjects = false);
    50122    }
    51123
    52     private void DownloadResources() {
    53       var task = System.Threading.Tasks.Task.Factory.StartNew(DownloadResourcesAsync);
    54       task.ContinueWith(t => {
    55         hiveResourceSelector.FinishProgressView();
    56         ErrorHandling.ShowErrorDialog(this, "An error occurred while downloading the tasks.", t.Exception);
    57       }, TaskContinuationOptions.OnlyOnFaulted);
     124    private async void refreshButton_Click(object sender, EventArgs e) {
     125      lock (locker) {
     126        if (updatingProjects) return;
     127        updatingProjects = true;
     128      }
     129
     130      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     131        action: () => UpdateProjects(),
     132        finallyCallback: () => updatingProjects = false);
    58133    }
    59134
    60     private void DownloadResourcesAsync() {
    61       hiveResourceSelector.StartProgressView();
    62       HiveAdminClient.Instance.Refresh();
    63       hiveResourceSelector.FinishProgressView();
     135    private void hiveResourceSelector_SelectedProjectChanged(object sender, EventArgs e) {
     136      okButton.Enabled = hiveResourceSelector.SelectedProject != null && hiveResourceSelector.AssignedResources.Any();
    64137    }
     138
     139    private void hiveResourceSelector_SelectedResourcesChanged(object sender, EventArgs e) {
     140      okButton.Enabled = hiveResourceSelector.AssignedResources.Any();
     141
     142      if(!hiveResourceSelector.AssignedResources.Any()) {
     143        errorProvider.SetError(okButton, "Note: currently no resources are assigned");
     144      } else if(hiveResourceSelector.AssignedCores == 0) {
     145        errorProvider.SetError(okButton, "Note: currently no resources with cores are assigned");
     146      } else {
     147        errorProvider.SetError(okButton, string.Empty);
     148      }
     149    }
     150
     151    private void hiveResourceSelector_ProjectsTreeViewDoubleClicked(object sender, EventArgs e) {
     152      if (hiveResourceSelector.SelectedProject == null) return;
     153      if (!hiveResourceSelector.AssignedResources.Any()) return;
     154
     155      DialogResult = DialogResult.OK;
     156      Close();
     157    }
     158    #endregion
     159
     160    #region Helpers
     161    private void UpdateProjects() {
     162      HiveClient.Instance.RefreshProjectsAndResources();
     163      hiveResourceSelector.JobId = jobId;
     164      hiveResourceSelector.ProjectId = projectId;
     165      hiveResourceSelector.SelectedProjectId = selectedProjectId;
     166      hiveResourceSelector.SelectedResourceIds = selectedResourceIds;
     167      hiveResourceSelector.Content = HiveClient.Instance.Projects;
     168    }
     169
     170    private void ShowHiveInformationDialog() {
     171      if (InvokeRequired) Invoke((Action)ShowHiveInformationDialog);
     172      else {
     173        using (HiveInformationDialog dialog = new HiveInformationDialog()) {
     174          dialog.ShowDialog(this);
     175        }
     176      }
     177    }
     178    #endregion
    65179  }
    66180}
  • branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.cs

    r15583 r16388  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using System.Threading.Tasks;
    2526using System.Windows.Forms;
     
    4142      this.itemsListView.Columns.Add(new ColumnHeader("Date") { Text = "Date" });
    4243      this.itemsListView.Columns.Add(new ColumnHeader("Name") { Text = "Name" });
     44      this.itemsListView.Columns.Add(new ColumnHeader("Project") { Text = "Project" });
    4345
    4446      this.itemsListView.HeaderStyle = ColumnHeaderStyle.Clickable;
    4547      this.itemsListView.FullRowSelect = true;
    4648
    47       this.itemsListView.ListViewItemSorter = new ListViewItemDateComparer(0, SortOrder.Ascending);
     49      this.itemsListView.ListViewItemSorter = new ListViewItemComparer(new int[] { 2, 0 }, new SortOrder[] { SortOrder.Ascending, SortOrder.Ascending });     
     50
     51      foreach (ColumnHeader c in this.itemsListView.Columns) {
     52        c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
     53        int w = c.Width;
     54        c.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
     55        if(w > c.Width) {
     56          c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
     57        }
     58      }
    4859    }
    4960
    5061    protected override void SortItemsListView(SortOrder sortOrder) {
    5162      if (itemsListView.Sorting == sortOrder || sortOrder == SortOrder.None) return;
    52       ((ListViewItemDateComparer)itemsListView.ListViewItemSorter).Order = sortOrder;
     63      ((ListViewItemComparer)itemsListView.ListViewItemSorter).Orders[1] = sortOrder;
    5364      itemsListView.Sorting = sortOrder;
    5465      itemsListView.Sort();
     
    133144        base.Content_ItemsAdded(sender, e);
    134145        foreach (ColumnHeader c in this.itemsListView.Columns) {
     146          c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
     147          int w = c.Width;
    135148          c.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
     149          if (w > c.Width) {
     150            c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
     151          }
    136152        }
    137153        foreach (var item in e.Items) {
     
    180196      listViewItem.SubItems.Insert(0, new ListViewItem.ListViewSubItem(listViewItem, item.Job.DateCreated.ToString()));
    181197      listViewItem.SubItems.Insert(1, new ListViewItem.ListViewSubItem(listViewItem, item.Job.Name));
     198      listViewItem.SubItems.Insert(2, new ListViewItem.ListViewSubItem(listViewItem, HiveClient.Instance.GetProjectAncestry(item.Job.ProjectId)));
     199     
    182200      listViewItem.Group = GetListViewGroup(item.Job.OwnerUsername);
    183201      return listViewItem;
     
    189207      listViewItem.SubItems[0].Text = item == null ? "null" : item.Job.DateCreated.ToString("dd.MM.yyyy HH:mm");
    190208      listViewItem.SubItems[1].Text = item == null ? "null" : item.Job.Name;
     209      listViewItem.SubItems[2].Text = item == null ? "null" : HiveClient.Instance.GetProjectAncestry(item.Job.ProjectId);
    191210      listViewItem.Group = GetListViewGroup(item.Job.OwnerUsername);
    192211      listViewItem.ToolTipText = item == null ? string.Empty : item.ItemName + ": " + item.ItemDescription;
  • branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.Designer.cs

    r15583 r16388  
    6363      this.executionTimeTextBox = new System.Windows.Forms.TextBox();
    6464      this.pauseButton = new System.Windows.Forms.Button();
    65       this.resourceIdsLabel = new System.Windows.Forms.Label();
    66       this.resourceNamesTextBox = new System.Windows.Forms.TextBox();
     65      this.projectLabel = new System.Windows.Forms.Label();
     66      this.projectNameTextBox = new System.Windows.Forms.TextBox();
    6767      this.nameLabel = new System.Windows.Forms.Label();
    6868      this.nameTextBox = new System.Windows.Forms.TextBox();
     69      this.descriptionLabel = new System.Windows.Forms.Label();
     70      this.descriptionTextBox = new System.Windows.Forms.TextBox();
    6971      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    7072      this.refreshButton = new System.Windows.Forms.Button();
     73      this.updateButton = new System.Windows.Forms.Button();
    7174      this.UnloadButton = new System.Windows.Forms.Button();
     75      this.searchButton = new System.Windows.Forms.Button();
    7276      this.refreshAutomaticallyCheckBox = new System.Windows.Forms.CheckBox();
    7377      this.infoGroupBox = new System.Windows.Forms.GroupBox();
     
    7882      this.calculatingLabel = new System.Windows.Forms.Label();
    7983      this.jobsLabel = new System.Windows.Forms.Label();
    80       this.searchButton = new System.Windows.Forms.Button();
    8184      this.tabControl.SuspendLayout();
    8285      this.tasksTabPage.SuspendLayout();
     
    9194      //
    9295      this.tabControl.AllowDrop = true;
    93       this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    94             | System.Windows.Forms.AnchorStyles.Left)
     96      this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     97            | System.Windows.Forms.AnchorStyles.Left) 
    9598            | System.Windows.Forms.AnchorStyles.Right)));
    9699      this.tabControl.Controls.Add(this.tasksTabPage);
     
    99102      this.tabControl.Controls.Add(this.stateTabPage);
    100103      this.tabControl.Controls.Add(this.logTabPage);
    101       this.tabControl.Location = new System.Drawing.Point(0, 78);
     104      this.tabControl.Location = new System.Drawing.Point(0, 106);
    102105      this.tabControl.Name = "tabControl";
    103106      this.tabControl.SelectedIndex = 0;
     
    119122      //
    120123      this.jobsTreeView.AllowDrop = true;
    121       this.jobsTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    122             | System.Windows.Forms.AnchorStyles.Left)
     124      this.jobsTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     125            | System.Windows.Forms.AnchorStyles.Left) 
    123126            | System.Windows.Forms.AnchorStyles.Right)));
    124127      this.jobsTreeView.Caption = "ItemTree View";
     
    151154      this.refreshPermissionsButton.Size = new System.Drawing.Size(24, 24);
    152155      this.refreshPermissionsButton.TabIndex = 23;
    153       this.toolTip.SetToolTip(this.refreshPermissionsButton, "Refresh Data");
     156      this.toolTip.SetToolTip(this.refreshPermissionsButton, "Refresh data");
    154157      this.refreshPermissionsButton.UseVisualStyleBackColor = true;
    155158      this.refreshPermissionsButton.Click += new System.EventHandler(this.refreshPermissionsButton_Click);
     
    157160      // hiveExperimentPermissionListView
    158161      //
    159       this.hiveExperimentPermissionListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    160             | System.Windows.Forms.AnchorStyles.Left)
     162      this.hiveExperimentPermissionListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     163            | System.Windows.Forms.AnchorStyles.Left) 
    161164            | System.Windows.Forms.AnchorStyles.Right)));
    162165      this.hiveExperimentPermissionListView.Caption = "HiveExperimentPermissionList View";
     
    183186      // runCollectionViewHost
    184187      //
    185       this.runCollectionViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    186             | System.Windows.Forms.AnchorStyles.Left)
     188      this.runCollectionViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     189            | System.Windows.Forms.AnchorStyles.Left) 
    187190            | System.Windows.Forms.AnchorStyles.Right)));
    188191      this.runCollectionViewHost.Caption = "View";
     
    209212      // stateLogViewHost
    210213      //
    211       this.stateLogViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    212             | System.Windows.Forms.AnchorStyles.Left)
     214      this.stateLogViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     215            | System.Windows.Forms.AnchorStyles.Left) 
    213216            | System.Windows.Forms.AnchorStyles.Right)));
    214217      this.stateLogViewHost.Caption = "StateLog View";
     
    235238      // logView
    236239      //
    237       this.logView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    238             | System.Windows.Forms.AnchorStyles.Left)
     240      this.logView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     241            | System.Windows.Forms.AnchorStyles.Left) 
    239242            | System.Windows.Forms.AnchorStyles.Right)));
    240243      this.logView.Caption = "Log View";
     
    250253      this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    251254      this.startButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Play;
    252       this.startButton.Location = new System.Drawing.Point(0, 536);
     255      this.startButton.Location = new System.Drawing.Point(0, 564);
    253256      this.startButton.Name = "startButton";
    254257      this.startButton.Size = new System.Drawing.Size(24, 24);
    255       this.startButton.TabIndex = 5;
     258      this.startButton.TabIndex = 4;
    256259      this.toolTip.SetToolTip(this.startButton, "Start/Resume Experiment");
    257260      this.startButton.UseVisualStyleBackColor = true;
     
    262265      this.stopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
    263266      this.stopButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Stop;
    264       this.stopButton.Location = new System.Drawing.Point(60, 536);
     267      this.stopButton.Location = new System.Drawing.Point(60, 564);
    265268      this.stopButton.Name = "stopButton";
    266269      this.stopButton.Size = new System.Drawing.Size(24, 24);
    267       this.stopButton.TabIndex = 7;
     270      this.stopButton.TabIndex = 6;
    268271      this.toolTip.SetToolTip(this.stopButton, "Stop Experiment");
    269272      this.stopButton.UseVisualStyleBackColor = true;
     
    274277      this.executionTimeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    275278      this.executionTimeLabel.AutoSize = true;
    276       this.executionTimeLabel.Location = new System.Drawing.Point(491, 543);
     279      this.executionTimeLabel.Location = new System.Drawing.Point(491, 571);
    277280      this.executionTimeLabel.Name = "executionTimeLabel";
    278281      this.executionTimeLabel.Size = new System.Drawing.Size(83, 13);
    279       this.executionTimeLabel.TabIndex = 9;
     282      this.executionTimeLabel.TabIndex = 100;
    280283      this.executionTimeLabel.Text = "&Execution Time:";
    281284      //
     
    283286      //
    284287      this.executionTimeTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    285       this.executionTimeTextBox.Location = new System.Drawing.Point(580, 540);
     288      this.executionTimeTextBox.Location = new System.Drawing.Point(580, 568);
    286289      this.executionTimeTextBox.Name = "executionTimeTextBox";
    287290      this.executionTimeTextBox.ReadOnly = true;
    288291      this.executionTimeTextBox.Size = new System.Drawing.Size(137, 20);
    289       this.executionTimeTextBox.TabIndex = 10;
     292      this.executionTimeTextBox.TabIndex = 100;
    290293      //
    291294      // pauseButton
     
    294297      this.pauseButton.Enabled = false;
    295298      this.pauseButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Pause;
    296       this.pauseButton.Location = new System.Drawing.Point(30, 536);
     299      this.pauseButton.Location = new System.Drawing.Point(30, 564);
    297300      this.pauseButton.Name = "pauseButton";
    298301      this.pauseButton.Size = new System.Drawing.Size(24, 24);
    299       this.pauseButton.TabIndex = 6;
     302      this.pauseButton.TabIndex = 5;
    300303      this.toolTip.SetToolTip(this.pauseButton, "Pause Experiment");
    301304      this.pauseButton.UseVisualStyleBackColor = true;
    302305      this.pauseButton.Click += new System.EventHandler(this.pauseButton_Click);
    303306      //
    304       // resourceIdsLabel
    305       //
    306       this.resourceIdsLabel.AutoSize = true;
    307       this.resourceIdsLabel.Location = new System.Drawing.Point(3, 56);
    308       this.resourceIdsLabel.Name = "resourceIdsLabel";
    309       this.resourceIdsLabel.Size = new System.Drawing.Size(61, 13);
    310       this.resourceIdsLabel.TabIndex = 12;
    311       this.resourceIdsLabel.Text = "Resources:";
    312       //
    313       // resourceNamesTextBox
    314       //
    315       this.resourceNamesTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    316             | System.Windows.Forms.AnchorStyles.Right)));
    317       this.resourceNamesTextBox.Location = new System.Drawing.Point(70, 52);
    318       this.resourceNamesTextBox.Name = "resourceNamesTextBox";
    319       this.resourceNamesTextBox.Size = new System.Drawing.Size(471, 20);
    320       this.resourceNamesTextBox.TabIndex = 2;
    321       this.resourceNamesTextBox.Validated += new System.EventHandler(this.resourceNamesTextBox_Validated);
     307      // projectLabel
     308      //
     309      this.projectLabel.AutoSize = true;
     310      this.projectLabel.Location = new System.Drawing.Point(3, 83);
     311      this.projectLabel.Name = "projectLabel";
     312      this.projectLabel.Size = new System.Drawing.Size(43, 13);
     313      this.projectLabel.TabIndex = 100;
     314      this.projectLabel.Text = "Project:";
     315      //
     316      // projectNameTextBox
     317      //
     318      this.projectNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     319            | System.Windows.Forms.AnchorStyles.Right)));
     320      this.projectNameTextBox.Location = new System.Drawing.Point(100, 80);
     321      this.projectNameTextBox.Name = "projectNameTextBox";
     322      this.projectNameTextBox.ReadOnly = true;
     323      this.projectNameTextBox.Size = new System.Drawing.Size(471, 20);
     324      this.projectNameTextBox.TabIndex = 100;
     325      this.projectNameTextBox.Validated += new System.EventHandler(this.resourceNamesTextBox_Validated);
    322326      //
    323327      // nameLabel
    324328      //
    325329      this.nameLabel.AutoSize = true;
    326       this.nameLabel.Location = new System.Drawing.Point(3, 30);
     330      this.nameLabel.Location = new System.Drawing.Point(3, 35);
    327331      this.nameLabel.Name = "nameLabel";
    328332      this.nameLabel.Size = new System.Drawing.Size(38, 13);
    329       this.nameLabel.TabIndex = 20;
     333      this.nameLabel.TabIndex = 100;
    330334      this.nameLabel.Text = "Name:";
    331335      //
    332336      // nameTextBox
    333337      //
    334       this.nameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    335             | System.Windows.Forms.AnchorStyles.Right)));
    336       this.nameTextBox.Location = new System.Drawing.Point(70, 27);
     338      this.nameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
     339            | System.Windows.Forms.AnchorStyles.Right)));
     340      this.nameTextBox.Location = new System.Drawing.Point(71, 32);
    337341      this.nameTextBox.Name = "nameTextBox";
    338       this.nameTextBox.Size = new System.Drawing.Size(501, 20);
     342      this.nameTextBox.Size = new System.Drawing.Size(500, 20);
    339343      this.nameTextBox.TabIndex = 1;
    340344      this.nameTextBox.Validated += new System.EventHandler(this.nameTextBox_Validated);
     345      //
     346      // descriptionLabel
     347      //
     348      this.descriptionLabel.AutoSize = true;
     349      this.descriptionLabel.Location = new System.Drawing.Point(3, 59);
     350      this.descriptionLabel.Name = "descriptionLabel";
     351      this.descriptionLabel.Size = new System.Drawing.Size(63, 13);
     352      this.descriptionLabel.TabIndex = 100;
     353      this.descriptionLabel.Text = "Description:";
     354      //
     355      // descriptionTextBox
     356      //
     357      this.descriptionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     358            | System.Windows.Forms.AnchorStyles.Right)));
     359      this.descriptionTextBox.Location = new System.Drawing.Point(71, 56);
     360      this.descriptionTextBox.Name = "descriptionTextBox";
     361      this.descriptionTextBox.Size = new System.Drawing.Size(500, 20);
     362      this.descriptionTextBox.TabIndex = 2;
     363      this.descriptionTextBox.Validated += new System.EventHandler(this.descriptionTextBox_Validated);
    341364      //
    342365      // refreshButton
     
    346369      this.refreshButton.Name = "refreshButton";
    347370      this.refreshButton.Size = new System.Drawing.Size(24, 24);
    348       this.refreshButton.TabIndex = 22;
     371      this.refreshButton.TabIndex = 7;
    349372      this.toolTip.SetToolTip(this.refreshButton, "Refresh Data");
    350373      this.refreshButton.UseVisualStyleBackColor = true;
    351374      this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click);
    352375      //
     376      // updateButton
     377      //
     378      this.updateButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Save;
     379      this.updateButton.Location = new System.Drawing.Point(30, 0);
     380      this.updateButton.Name = "updateButton";
     381      this.updateButton.Size = new System.Drawing.Size(24, 24);
     382      this.updateButton.TabIndex = 8;
     383      this.toolTip.SetToolTip(this.updateButton, "Update Job (Name, Project, Resources)");
     384      this.updateButton.UseVisualStyleBackColor = true;
     385      this.updateButton.Click += new System.EventHandler(this.updateButton_Click);
     386      //
    353387      // UnloadButton
    354388      //
    355389      this.UnloadButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Disconnect;
    356       this.UnloadButton.Location = new System.Drawing.Point(30, 0);
     390      this.UnloadButton.Location = new System.Drawing.Point(57, 0);
    357391      this.UnloadButton.Name = "UnloadButton";
    358392      this.UnloadButton.Size = new System.Drawing.Size(24, 24);
    359       this.UnloadButton.TabIndex = 27;
     393      this.UnloadButton.TabIndex = 9;
    360394      this.toolTip.SetToolTip(this.UnloadButton, "Unload Job");
    361395      this.UnloadButton.UseVisualStyleBackColor = true;
    362396      this.UnloadButton.Click += new System.EventHandler(this.UnloadButton_Click);
    363397      //
     398      // searchButton
     399      //
     400      this.searchButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Zoom;
     401      this.searchButton.Location = new System.Drawing.Point(71, 79);
     402      this.searchButton.Name = "searchButton";
     403      this.searchButton.Size = new System.Drawing.Size(24, 24);
     404      this.searchButton.TabIndex = 3;
     405      this.toolTip.SetToolTip(this.searchButton, "Select project and resources");
     406      this.searchButton.UseVisualStyleBackColor = true;
     407      this.searchButton.Click += new System.EventHandler(this.searchButton_Click);
     408      //
    364409      // refreshAutomaticallyCheckBox
    365410      //
    366411      this.refreshAutomaticallyCheckBox.AutoSize = true;
    367       this.refreshAutomaticallyCheckBox.Location = new System.Drawing.Point(70, 3);
     412      this.refreshAutomaticallyCheckBox.Location = new System.Drawing.Point(100, 3);
    368413      this.refreshAutomaticallyCheckBox.Name = "refreshAutomaticallyCheckBox";
    369414      this.refreshAutomaticallyCheckBox.Size = new System.Drawing.Size(127, 17);
    370       this.refreshAutomaticallyCheckBox.TabIndex = 24;
     415      this.refreshAutomaticallyCheckBox.TabIndex = 100;
    371416      this.refreshAutomaticallyCheckBox.Text = "&Refresh automatically";
    372417      this.refreshAutomaticallyCheckBox.UseVisualStyleBackColor = true;
     
    382427      this.infoGroupBox.Controls.Add(this.calculatingLabel);
    383428      this.infoGroupBox.Controls.Add(this.jobsLabel);
    384       this.infoGroupBox.Location = new System.Drawing.Point(580, 5);
     429      this.infoGroupBox.Location = new System.Drawing.Point(578, 16);
    385430      this.infoGroupBox.Name = "infoGroupBox";
    386431      this.infoGroupBox.Size = new System.Drawing.Size(133, 89);
     
    391436      // finishedTextBox
    392437      //
    393       this.finishedTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     438      this.finishedTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    394439            | System.Windows.Forms.AnchorStyles.Right)));
    395440      this.finishedTextBox.Location = new System.Drawing.Point(74, 64);
    396441      this.finishedTextBox.Name = "finishedTextBox";
    397442      this.finishedTextBox.Size = new System.Drawing.Size(53, 20);
    398       this.finishedTextBox.TabIndex = 5;
     443      this.finishedTextBox.TabIndex = 100;
    399444      //
    400445      // calculatingTextBox
    401446      //
    402       this.calculatingTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     447      this.calculatingTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    403448            | System.Windows.Forms.AnchorStyles.Right)));
    404449      this.calculatingTextBox.Location = new System.Drawing.Point(74, 40);
    405450      this.calculatingTextBox.Name = "calculatingTextBox";
    406451      this.calculatingTextBox.Size = new System.Drawing.Size(53, 20);
    407       this.calculatingTextBox.TabIndex = 4;
     452      this.calculatingTextBox.TabIndex = 100;
    408453      //
    409454      // jobsTextBox
    410455      //
    411       this.jobsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     456      this.jobsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 
    412457            | System.Windows.Forms.AnchorStyles.Right)));
    413458      this.jobsTextBox.Location = new System.Drawing.Point(74, 16);
    414459      this.jobsTextBox.Name = "jobsTextBox";
    415460      this.jobsTextBox.Size = new System.Drawing.Size(53, 20);
    416       this.jobsTextBox.TabIndex = 3;
     461      this.jobsTextBox.TabIndex = 100;
    417462      //
    418463      // finishedLabel
     
    422467      this.finishedLabel.Name = "finishedLabel";
    423468      this.finishedLabel.Size = new System.Drawing.Size(49, 13);
    424       this.finishedLabel.TabIndex = 2;
     469      this.finishedLabel.TabIndex = 100;
    425470      this.finishedLabel.Text = "Finished:";
    426471      //
     
    431476      this.calculatingLabel.Name = "calculatingLabel";
    432477      this.calculatingLabel.Size = new System.Drawing.Size(62, 13);
    433       this.calculatingLabel.TabIndex = 1;
     478      this.calculatingLabel.TabIndex = 100;
    434479      this.calculatingLabel.Text = "Calculating:";
    435480      //
     
    440485      this.jobsLabel.Name = "jobsLabel";
    441486      this.jobsLabel.Size = new System.Drawing.Size(46, 13);
    442       this.jobsLabel.TabIndex = 0;
     487      this.jobsLabel.TabIndex = 100;
    443488      this.jobsLabel.Text = "Waiting:";
    444489      //
    445       // searchButton
    446       //
    447       this.searchButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    448       this.searchButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Zoom;
    449       this.searchButton.Location = new System.Drawing.Point(547, 50);
    450       this.searchButton.Name = "searchButton";
    451       this.searchButton.Size = new System.Drawing.Size(24, 24);
    452       this.searchButton.TabIndex = 26;
    453       this.searchButton.UseVisualStyleBackColor = true;
    454       this.searchButton.Click += new System.EventHandler(this.searchButton_Click);
    455       //
    456490      // RefreshableHiveJobView
    457491      //
    458492      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    459       this.Controls.Add(this.UnloadButton);
    460493      this.Controls.Add(this.searchButton);
    461494      this.Controls.Add(this.infoGroupBox);
    462495      this.Controls.Add(this.refreshAutomaticallyCheckBox);
    463496      this.Controls.Add(this.refreshButton);
     497      this.Controls.Add(this.updateButton);
     498      this.Controls.Add(this.UnloadButton);
    464499      this.Controls.Add(this.nameTextBox);
    465500      this.Controls.Add(this.nameLabel);
     501      this.Controls.Add(this.descriptionTextBox);
     502      this.Controls.Add(this.descriptionLabel);
    466503      this.Controls.Add(this.tabControl);
    467504      this.Controls.Add(this.startButton);
    468505      this.Controls.Add(this.executionTimeTextBox);
    469506      this.Controls.Add(this.executionTimeLabel);
    470       this.Controls.Add(this.resourceNamesTextBox);
     507      this.Controls.Add(this.projectNameTextBox);
    471508      this.Controls.Add(this.pauseButton);
    472       this.Controls.Add(this.resourceIdsLabel);
     509      this.Controls.Add(this.projectLabel);
    473510      this.Controls.Add(this.stopButton);
    474511      this.Name = "RefreshableHiveJobView";
    475       this.Size = new System.Drawing.Size(717, 560);
     512      this.Size = new System.Drawing.Size(717, 588);
    476513      this.tabControl.ResumeLayout(false);
    477514      this.tasksTabPage.ResumeLayout(false);
     
    493530    private System.Windows.Forms.TextBox executionTimeTextBox;
    494531    private System.Windows.Forms.Button pauseButton;
    495     private System.Windows.Forms.Label resourceIdsLabel;
    496     private System.Windows.Forms.TextBox resourceNamesTextBox;
     532    private System.Windows.Forms.Label projectLabel;
     533    private System.Windows.Forms.TextBox projectNameTextBox;
    497534    private System.Windows.Forms.TabPage logTabPage;
    498535    private Core.Views.LogView logView;
     
    501538    private System.Windows.Forms.Label nameLabel;
    502539    private System.Windows.Forms.TextBox nameTextBox;
     540    private System.Windows.Forms.Label descriptionLabel;
     541    private System.Windows.Forms.TextBox descriptionTextBox;
    503542    private System.Windows.Forms.ToolTip toolTip;
    504543    private System.Windows.Forms.Button refreshButton;
     544    private System.Windows.Forms.Button updateButton;
     545    private System.Windows.Forms.Button UnloadButton;
    505546    private System.Windows.Forms.CheckBox refreshAutomaticallyCheckBox;
    506547    private System.Windows.Forms.GroupBox infoGroupBox;
     
    520561    private System.Windows.Forms.Button searchButton;
    521562    private MainForm.WindowsForms.DragOverTabControl tabControl;
    522     private System.Windows.Forms.Button UnloadButton;
    523 
    524563  }
    525564}
  • branches/2892_LR-prediction-intervals/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r15583 r16388  
    2323using System.ComponentModel;
    2424using System.Linq;
    25 using System.Text;
    2625using System.Threading;
    2726using System.Threading.Tasks;
     
    3433using HeuristicLab.Optimization;
    3534using HeuristicLab.PluginInfrastructure;
     35using System.Collections.Generic;
    3636
    3737namespace HeuristicLab.Clients.Hive.JobManager.Views {
     
    4545    private bool SuppressEvents { get; set; }
    4646    private object runCollectionViewLocker = new object();
     47    private Project selectedProject;
     48    private Dictionary<Guid, Guid> originalJobProjectAssignment = new Dictionary<Guid, Guid>();
    4749
    4850    public new RefreshableJob Content {
    4951      get { return (RefreshableJob)base.Content; }
    50       set { base.Content = value; }
     52      set {
     53        base.Content = value;
     54      }
    5155    }
    5256
     
    117121        if (Content == null) {
    118122          nameTextBox.Text = string.Empty;
     123          descriptionTextBox.Text = string.Empty;
    119124          executionTimeTextBox.Text = string.Empty;
    120           resourceNamesTextBox.Text = string.Empty;
     125          projectNameTextBox.Text = string.Empty;
    121126          refreshAutomaticallyCheckBox.Checked = false;
    122127          lock (runCollectionViewLocker) {
     
    128133          stateLogViewHost.Content = null;
    129134        } else {
     135          if(Content.Job != null
     136            && Content.Job.Id != Guid.Empty
     137            && !originalJobProjectAssignment.ContainsKey(Content.Job.Id)) {
     138            originalJobProjectAssignment.Add(Content.Job.Id, Content.Job.ProjectId);
     139          }
     140
     141          // project look up
     142          if (Content.Job != null && Content.Job.ProjectId == Guid.Empty) {
     143            projectNameTextBox.Text = string.Empty;
     144            if (HiveClient.Instance != null && HiveClient.Instance.Projects != null && HiveClient.Instance.Projects.Count == 1) {
     145              var p = HiveClient.Instance.Projects.FirstOrDefault();
     146              if (p != null && p.Id != Guid.Empty) {
     147                hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId);
     148                Content.Job.ProjectId = p.Id;
     149                var resources = HiveClient.Instance.GetAvailableResourcesForProject(p.Id).ToList();
     150                Content.Job.ResourceIds = resources.Select(x => x.Id).ToList();
     151                hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
     152                hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     153
     154                var cores = resources.Union(resources.SelectMany(x => HiveClient.Instance.GetAvailableResourceDescendants(x.Id)))
     155                  .OfType<Slave>()
     156                  .Distinct()
     157                  .Sum(x => x.Cores);
     158
     159                projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(Content.Job.ProjectId);
     160                projectNameTextBox.Text += "   (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)";
     161              }               
     162            }
     163          } else if (Content.Job != null && Content.Job.ProjectId != Guid.Empty) {
     164            if (selectedProject == null || selectedProject.Id != Content.Job.ProjectId) {
     165              selectedProject = GetProject(Content.Job.ProjectId);
     166              hiveResourceSelectorDialog = null;
     167            }
     168
     169            if(hiveResourceSelectorDialog == null)
     170              hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId);
     171
     172            if (selectedProject != null) {
     173              projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(selectedProject.Id);
     174            } else {
     175              projectNameTextBox.Text = string.Empty;
     176            }
     177
     178            List<Resource> resources = null;
     179            if (Content.Job.ResourceIds == null)
     180              resources = HiveClient.Instance.GetAssignedResourcesForJob(Content.Job.Id).ToList();
     181            else
     182              resources = HiveClient.Instance.Resources.Where(x => Content.Job.ResourceIds.Contains(x.Id)).ToList();
     183
     184            Content.Job.ResourceIds = resources.Select(x => x.Id).ToList();
     185            hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     186
     187            var cores = resources.Union(resources.SelectMany(x => HiveClient.Instance.GetAvailableResourceDescendants(x.Id)))
     188              .OfType<Slave>()
     189              .Distinct()
     190              .Sum(x => x.Cores);
     191
     192            projectNameTextBox.Text += "   (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)";
     193
     194          } else {
     195            selectedProject = null;
     196            projectNameTextBox.Text = string.Empty;
     197            Content.Job.ResourceIds = null;
     198          }
     199
     200
    130201          nameTextBox.Text = Content.Job.Name;
     202          descriptionTextBox.Text = Content.Job.Description;
    131203          executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    132           resourceNamesTextBox.Text = Content.Job.ResourceNames;
    133204          refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically;
     205         
    134206          logView.Content = Content.Log;
    135207          lock (runCollectionViewLocker) {
     
    137209          }
    138210        }
    139       }
    140       finally {
     211      } finally {
    141212        SuppressEvents = false;
    142213      }
    143       hiveExperimentPermissionListView.Content = null; // has to be filled by refresh button
     214      hiveExperimentPermissionListView.Content = null; // has to be filled by refresh
    144215      Content_JobStatisticsChanged(this, EventArgs.Empty);
    145216      Content_HiveExperimentChanged(this, EventArgs.Empty);
     
    158229      tabControl.Enabled = !Locked;
    159230      nameTextBox.Enabled = !Locked;
    160       resourceNamesTextBox.Enabled = !Locked;
     231      descriptionTextBox.Enabled = !Locked;
     232      projectNameTextBox.Enabled = !Locked;
    161233      searchButton.Enabled = !Locked;
    162234      jobsTreeView.Enabled = !Locked;
     
    182254          tabControl.Enabled = !Content.IsProgressing;
    183255
    184           this.nameTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
    185           this.resourceNamesTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
    186           this.searchButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Prepared && !alreadyUploaded && !Content.IsProgressing;
     256          this.nameTextBox.ReadOnly = Content.IsProgressing;
     257          this.descriptionTextBox.ReadOnly = Content.IsProgressing;
     258          this.searchButton.Enabled = !Content.IsProgressing && Content.ExecutionState != ExecutionState.Stopped;
    187259          this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
    188260
    189261          this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && (Content.ExecutionState == ExecutionState.Started || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
    190262          this.refreshButton.Enabled = Content.IsDownloadable && alreadyUploaded && !Content.IsProgressing;
     263          this.updateButton.Enabled = Content.ExecutionState != ExecutionState.Prepared && Content.ExecutionState != ExecutionState.Stopped && !Content.IsProgressing;
    191264
    192265          this.UnloadButton.Enabled = Content.HiveTasks != null && Content.HiveTasks.Count > 0 && alreadyUploaded && !Content.IsProgressing;
     
    333406    #region Control events
    334407    private void searchButton_Click(object sender, EventArgs e) {
    335       if (hiveResourceSelectorDialog == null)
    336         hiveResourceSelectorDialog = new HiveResourceSelectorDialog();
     408      if (hiveResourceSelectorDialog == null) {
     409        hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId);
     410      } else if(hiveResourceSelectorDialog.JobId != Content.Job.Id) {
     411        hiveResourceSelectorDialog.JobId = Content.Job.Id;
     412        hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
     413        hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     414
     415        if (originalJobProjectAssignment.ContainsKey(Content.Job.Id)) {
     416          hiveResourceSelectorDialog.ProjectId = originalJobProjectAssignment[Content.Job.Id];
     417        } else {
     418          hiveResourceSelectorDialog.ProjectId = Guid.Empty;
     419        }
     420      } else if(hiveResourceSelectorDialog.JobId == Guid.Empty && Content.Job.Id == Guid.Empty) {
     421        hiveResourceSelectorDialog.JobId = Content.Job.Id;
     422        hiveResourceSelectorDialog.ProjectId = Guid.Empty;
     423        hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
     424        hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     425      } else {
     426        hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
     427        hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     428      }
     429
    337430      if (hiveResourceSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    338         StringBuilder sb = new StringBuilder();
    339         foreach (Resource resource in hiveResourceSelectorDialog.GetSelectedResources()) {
    340           sb.Append(resource.Name);
    341           sb.Append(";");
    342         }
    343         resourceNamesTextBox.Text = sb.ToString();
    344         if (Content.Job.ResourceNames != resourceNamesTextBox.Text)
    345           Content.Job.ResourceNames = resourceNamesTextBox.Text;
     431        selectedProject = hiveResourceSelectorDialog.SelectedProject;
     432        if(selectedProject != null) {       
     433          Content.Job.ProjectId = selectedProject.Id;
     434          Content.Job.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList();
     435
     436          var cores = hiveResourceSelectorDialog.SelectedResources
     437            .Union(hiveResourceSelectorDialog.SelectedResources
     438              .SelectMany(x => HiveClient.Instance.GetAvailableResourceDescendants(x.Id)))
     439            .OfType<Slave>()
     440            .Distinct()
     441            .Sum(x => x.Cores);
     442
     443          projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(selectedProject.Id) + "";
     444          projectNameTextBox.Text += "   (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)";
     445
     446        } else {
     447          selectedProject = null;
     448          projectNameTextBox.Text = string.Empty;
     449          Content.Job.ProjectId = Guid.Empty;
     450          Content.Job.ResourceIds = null;
     451        }
     452        SetEnabledStateOfExecutableButtons();
    346453      }
    347454    }
     
    350457      if (nameTextBox.Text.Trim() == string.Empty) {
    351458        MessageBox.Show("Please enter a name for the job before uploading it!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     459      } else if (Content.Job.ProjectId == null || Content.Job.ProjectId == Guid.Empty) {
     460        MessageBox.Show("Please select a project before uploading the job!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     461      } else if (Content.Job.ResourceIds == null || !Content.Job.ResourceIds.Any()) {
     462        MessageBox.Show("Please select resources before uploading the job!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
    352463      } else if (Content.ExecutionState == ExecutionState.Paused) {
    353464        var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobAsync, Content);
     
    359470      } else {
    360471        HiveClient.StartJob((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Start failed.", ex), Content, new CancellationToken());
     472        UpdateSelectorDialog();
    361473      }
    362474    }
     
    403515    }
    404516
     517    private void descriptionTextBox_Validated(object sender, EventArgs e) {
     518      if (!SuppressEvents && Content.Job != null && Content.Job.Description != descriptionTextBox.Text)
     519        Content.Job.Description = descriptionTextBox.Text;
     520    }
     521
    405522    private void resourceNamesTextBox_Validated(object sender, EventArgs e) {
    406       if (!SuppressEvents && Content.Job != null && Content.Job.ResourceNames != resourceNamesTextBox.Text)
    407         Content.Job.ResourceNames = resourceNamesTextBox.Text;
     523      //if (!SuppressEvents && Content.Job != null && Content.Job.ResourceNames != resourceNamesTextBox.Text)
     524      //  Content.Job.ResourceNames = resourceNamesTextBox.Text;
    408525    }
    409526
     
    417534        try {
    418535          invoker.EndInvoke(ar);
    419         }
    420         catch (Exception ex) {
    421           ThreadPool.QueueUserWorkItem(delegate(object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex);
     536        } catch (Exception ex) {
     537          ThreadPool.QueueUserWorkItem(delegate (object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex);
    422538        }
    423539      }, null);
    424     }
    425 
    426     private void refreshPermissionsButton_Click(object sender, EventArgs e) {
    427       if (this.Content.Job.Id == Guid.Empty) {
    428         MessageBox.Show("You have to upload the Job first before you can share it.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
    429       } else {
    430         hiveExperimentPermissionListView.Content = HiveClient.GetJobPermissions(this.Content.Job.Id);
    431       }
    432     }
    433     #endregion
    434 
    435     #region Helpers
    436     private void SetEnabledStateOfExecutableButtons() {
    437       if (Content == null) {
    438         startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = false;
    439       } else {
    440         startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
    441         pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
    442         stopButton.Enabled = Content.IsControllable && (Content.ExecutionState == ExecutionState.Started || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
    443       }
    444     }
    445     #endregion
    446 
    447     #region Drag & Drop
    448     private void jobsTreeView_DragOver(object sender, DragEventArgs e) {
    449       jobsTreeView_DragEnter(sender, e);
    450     }
    451 
    452     private void jobsTreeView_DragEnter(object sender, DragEventArgs e) {
    453       e.Effect = DragDropEffects.None;
    454       var obj = (IDeepCloneable)e.Data.GetData(Constants.DragDropDataFormat);
    455 
    456       Type objType = obj.GetType();
    457       if (ItemTask.IsTypeSupported(objType)) {
    458         if (Content.Id != Guid.Empty) e.Effect = DragDropEffects.None;
    459         else if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
    460         else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
    461       }
    462     }
    463 
    464     private void jobsTreeView_DragDrop(object sender, DragEventArgs e) {
    465       if (e.Effect != DragDropEffects.None) {
    466         var obj = (IItem)e.Data.GetData(Constants.DragDropDataFormat);
    467 
    468         IItem newObj = null;
    469         if (e.Effect.HasFlag(DragDropEffects.Copy)) {
    470           newObj = (IItem)obj.Clone();
    471         } else {
    472           newObj = obj;
    473         }
    474 
    475         //IOptimizer and IExecutables need some special care
    476         if (newObj is IOptimizer) {
    477           ((IOptimizer)newObj).Runs.Clear();
    478         }
    479         if (newObj is IExecutable) {
    480           IExecutable exec = (IExecutable)newObj;
    481           if (exec.ExecutionState != ExecutionState.Prepared) {
    482             exec.Prepare();
    483           }
    484         }
    485 
    486         ItemTask hiveTask = ItemTask.GetItemTaskForItem(newObj);
    487         Content.HiveTasks.Add(hiveTask.CreateHiveTask());
    488       }
    489     }
    490     #endregion
    491 
    492     private void tabControl_SelectedIndexChanged(object sender, EventArgs e) {
    493       if (tabControl.SelectedTab == permissionTabPage) {
    494         if (!Content.IsSharable) {
    495           MessageBox.Show("Unable to load permissions. You have insufficient access privileges.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
    496           tabControl.SelectedTab = tasksTabPage;
    497         }
    498       }
    499     }
    500 
    501     private RunCollection GetAllRunsFromJob(RefreshableJob job) {
    502       if (job != null) {
    503         RunCollection runs = new RunCollection() { OptimizerName = job.ItemName };
    504 
    505         foreach (HiveTask subTask in job.HiveTasks) {
    506           if (subTask is OptimizerHiveTask) {
    507             OptimizerHiveTask ohTask = subTask as OptimizerHiveTask;
    508             ohTask.ExecuteReadActionOnItemTask(new Action(delegate() {
    509               runs.AddRange(ohTask.ItemTask.Item.Runs);
    510             }));
    511           }
    512         }
    513         return runs;
    514       } else {
    515         return null;
    516       }
     540      UpdateSelectorDialog();
     541    }
     542
     543    private void updateButton_Click(object sender, EventArgs e) {
     544      if (Content.ExecutionState == ExecutionState.Stopped) {
     545        MessageBox.Show("Job cannot be updated once it stopped.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     546        return;
     547      }
     548
     549      var invoker = new Action<RefreshableJob>(HiveClient.UpdateJob);
     550      invoker.BeginInvoke(Content, (ar) => {
     551        try {
     552          invoker.EndInvoke(ar);
     553        } catch (Exception ex) {
     554          ThreadPool.QueueUserWorkItem(delegate (object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex);
     555        }
     556      }, null);
     557      UpdateSelectorDialog();
    517558    }
    518559
     
    526567      SetEnabledStateOfControls();
    527568    }
     569
     570    private void refreshPermissionsButton_Click(object sender, EventArgs e) {
     571      if (this.Content.Job.Id == Guid.Empty) {
     572        MessageBox.Show("You have to upload the Job first before you can share it.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     573      } else {
     574        hiveExperimentPermissionListView.Content = HiveClient.GetJobPermissions(this.Content.Job.Id);
     575      }
     576    }
     577    #endregion
     578
     579    #region Helpers
     580    private void SetEnabledStateOfExecutableButtons() {
     581      if (Content == null) {
     582        startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = false;
     583      } else {
     584        startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0
     585          && Content.Job.ProjectId != Guid.Empty && Content.Job.ResourceIds != null  && Content.Job.ResourceIds.Any()
     586          && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
     587        pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
     588        stopButton.Enabled = Content.IsControllable && (Content.ExecutionState == ExecutionState.Started || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
     589      }
     590    }
     591   
     592    private Project GetProject(Guid projectId) {
     593      return HiveServiceLocator.Instance.CallHiveService(s => s.GetProject(projectId));
     594    }
     595
     596    private void UpdateSelectorDialog() {
     597      if(hiveResourceSelectorDialog != null) {
     598        hiveResourceSelectorDialog = null;
     599        //hiveResourceSelectorDialog.JobId = Content.Job.Id;
     600        //hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
     601        //hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     602      }
     603    }
     604    #endregion
     605
     606    #region Drag & Drop
     607    private void jobsTreeView_DragOver(object sender, DragEventArgs e) {
     608      jobsTreeView_DragEnter(sender, e);
     609    }
     610
     611    private void jobsTreeView_DragEnter(object sender, DragEventArgs e) {
     612      e.Effect = DragDropEffects.None;
     613      var obj = (IDeepCloneable)e.Data.GetData(Constants.DragDropDataFormat);
     614
     615      Type objType = obj.GetType();
     616      if (ItemTask.IsTypeSupported(objType)) {
     617        if (Content.Id != Guid.Empty) e.Effect = DragDropEffects.None;
     618        else if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
     619        else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
     620      }
     621    }
     622
     623    private void jobsTreeView_DragDrop(object sender, DragEventArgs e) {
     624      if (e.Effect != DragDropEffects.None) {
     625        var obj = (IItem)e.Data.GetData(Constants.DragDropDataFormat);
     626
     627        IItem newObj = null;
     628        if (e.Effect.HasFlag(DragDropEffects.Copy)) {
     629          newObj = (IItem)obj.Clone();
     630        } else {
     631          newObj = obj;
     632        }
     633
     634        //IOptimizer and IExecutables need some special care
     635        if (newObj is IOptimizer) {
     636          ((IOptimizer)newObj).Runs.Clear();
     637        }
     638        if (newObj is IExecutable) {
     639          IExecutable exec = (IExecutable)newObj;
     640          if (exec.ExecutionState != ExecutionState.Prepared) {
     641            exec.Prepare();
     642          }
     643        }
     644
     645        ItemTask hiveTask = ItemTask.GetItemTaskForItem(newObj);
     646        Content.HiveTasks.Add(hiveTask.CreateHiveTask());
     647      }
     648    }
     649    #endregion
     650
     651    private void tabControl_SelectedIndexChanged(object sender, EventArgs e) {
     652      if (tabControl.SelectedTab == permissionTabPage) {
     653        if (!Content.IsSharable) {
     654          MessageBox.Show("Unable to load permissions. You have insufficient access privileges.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     655          tabControl.SelectedTab = tasksTabPage;
     656        }
     657      }
     658    }
     659
     660    private RunCollection GetAllRunsFromJob(RefreshableJob job) {
     661      if (job != null) {
     662        RunCollection runs = new RunCollection() { OptimizerName = job.ItemName };
     663
     664        foreach (HiveTask subTask in job.HiveTasks) {
     665          if (subTask is OptimizerHiveTask) {
     666            OptimizerHiveTask ohTask = subTask as OptimizerHiveTask;
     667            ohTask.ExecuteReadActionOnItemTask(new Action(delegate () {
     668              runs.AddRange(ohTask.ItemTask.Item.Runs);
     669            }));
     670          }
     671        }
     672        return runs;
     673      } else {
     674        return null;
     675      }
     676    }
     677
    528678  }
    529679}
Note: See TracChangeset for help on using the changeset viewer.