Changeset 16117 for trunk/HeuristicLab.Clients.Hive.JobManager/3.3
- Timestamp:
- 08/30/18 11:32:56 (6 years ago)
- Location:
- trunk
- Files:
-
- 14 edited
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk
- Property svn:mergeinfo changed
-
trunk/HeuristicLab.Clients.Hive.JobManager
- Property svn:mergeinfo changed
-
trunk/HeuristicLab.Clients.Hive.JobManager/3.3/HeuristicLab.Clients.Hive.JobManager-3.3.csproj
r14125 r16117 105 105 <Compile Include="ExtensionMethods\TreeNodeExtensions.cs" /> 106 106 <Compile Include="ListViewItemDateComparer.cs" /> 107 <Compile Include="ListViewItemComparer.cs" /> 107 108 <Compile Include="MenuItems\CreateHiveJobMenuItem.cs" /> 108 109 <Compile Include="MenuItems\RunInHiveMenuItem.cs" /> … … 159 160 </ItemGroup> 160 161 <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> 161 172 <ProjectReference Include="..\..\HeuristicLab.Clients.Hive.Views\3.3\HeuristicLab.Clients.Hive.Views-3.3.csproj"> 162 173 <Project>{E1D6C801-892A-406A-B606-F158E36DD3C3}</Project> -
trunk/HeuristicLab.Clients.Hive.JobManager/3.3/MenuItems/JobManagerMenuItem.cs
r15583 r16117 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Windows.Forms; 25 using HeuristicLab.Clients.Access; 24 26 using HeuristicLab.MainForm; 25 27 using HeuristicLab.Optimizer; 26 28 27 29 namespace HeuristicLab.Clients.Hive.JobManager { 28 public class JobManagerMenuItem : HeuristicLab.MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {30 public class JobManagerMenuItem : MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider { 29 31 public override string Name { 30 32 get { return "&Job Manager"; } 31 33 } 34 32 35 public override IEnumerable<string> Structure { 33 36 get { return new string[] { "&Services", "&Hive" }; } 34 37 } 38 35 39 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 } 37 53 } 54 38 55 public override int Position { 39 56 get { return 10000; } 40 57 } 58 41 59 public override Keys ShortCutKeys { 42 60 get { return Keys.Control | Keys.H; } -
trunk/HeuristicLab.Clients.Hive.JobManager/3.3/MenuItems/RunInHiveMenuItem.cs
r15583 r16117 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Linq; 24 25 using System.Threading; 26 using System.Windows.Forms; 27 using HeuristicLab.Clients.Hive.JobManager.Views; 25 28 using HeuristicLab.Core; 26 29 using HeuristicLab.MainForm; … … 82 85 task.ItemTask.ComputeInParallel = content is Experiment || content is BatchRun; 83 86 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); 87 88 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 } 89 108 } 90 109 -
trunk/HeuristicLab.Clients.Hive.JobManager/3.3/Plugin.cs.frame
r15589 r16117 25 25 [Plugin("HeuristicLab.Clients.Hive.JobManager", "3.3.15.$WCREV$")] 26 26 [PluginFile("HeuristicLab.Clients.Hive.JobManager-3.3.dll", PluginFileType.Assembly)] 27 [PluginDependency("HeuristicLab.Clients.Access", "3.3")] 28 [PluginDependency("HeuristicLab.Clients.Common", "3.3")] 27 29 [PluginDependency("HeuristicLab.Clients.Hive", "3.3")] 28 30 [PluginDependency("HeuristicLab.Clients.Hive.Views", "3.3")] -
trunk/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobManagerView.Designer.cs
r15583 r16117 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.components = new System.ComponentModel.Container(); 47 48 this.hiveExperimentListView = new RefreshableHiveJobListView(); 48 49 this.refreshButton = new System.Windows.Forms.Button(); 50 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 49 51 this.SuspendLayout(); 50 52 // … … 69 71 this.refreshButton.Size = new System.Drawing.Size(24, 24); 70 72 this.refreshButton.TabIndex = 1; 73 this.toolTip.SetToolTip(this.refreshButton, "Refresh data"); 71 74 this.refreshButton.UseVisualStyleBackColor = true; 72 75 this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click); … … 87 90 private RefreshableHiveJobListView hiveExperimentListView; 88 91 private System.Windows.Forms.Button refreshButton; 89 92 private System.Windows.Forms.ToolTip toolTip; 90 93 91 94 } -
trunk/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.Designer.cs
r15583 r16117 21 21 22 22 namespace HeuristicLab.Clients.Hive.JobManager.Views { 23 partial class Hive ResourceSelector {23 partial class HiveProjectSelector { 24 24 /// <summary> 25 25 /// Required designer variable. … … 46 46 private void InitializeComponent() { 47 47 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); 53 51 this.searchLabel = new System.Windows.Forms.Label(); 54 52 this.searchTextBox = new System.Windows.Forms.TextBox(); 55 this.descriptionTextBox = new System.Windows.Forms.TextBox();56 53 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(); 62 68 this.SuspendLayout(); 63 69 // 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; 118 96 // 119 97 // searchLabel 120 98 // 121 99 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); 123 101 this.searchLabel.Name = "searchLabel"; 124 102 this.searchLabel.Size = new System.Drawing.Size(20, 20); … … 128 106 // searchTextBox 129 107 // 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); 133 111 this.searchTextBox.Name = "searchTextBox"; 134 this.searchTextBox.Size = new System.Drawing.Size( 270, 20);112 this.searchTextBox.Size = new System.Drawing.Size(388, 20); 135 113 this.searchTextBox.TabIndex = 1; 136 114 this.toolTip.SetToolTip(this.searchTextBox, "Enter string to search for resources"); 137 115 this.searchTextBox.TextChanged += new System.EventHandler(this.searchTextBox_TextChanged); 138 116 // 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 // 157 222 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(); 168 236 this.ResumeLayout(false); 169 237 … … 172 240 #endregion 173 241 174 protected System.Windows.Forms.GroupBox resourcesGroupBox; 175 protected System.Windows.Forms.SplitContainer splitContainer; 242 protected System.Windows.Forms.GroupBox projectsGroupBox; 176 243 protected System.Windows.Forms.Label searchLabel; 177 244 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; 181 246 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; 183 256 } 184 257 } -
trunk/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs
r15583 r16117 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 8Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 24 24 using System.Drawing; 25 25 using System.Linq; 26 using System.Text;27 26 using System.Windows.Forms; 28 using HeuristicLab.Clients.Hive.JobManager.ExtensionMethods; 27 using HeuristicLab.Collections; 28 using HeuristicLab.Common.Resources; 29 29 using HeuristicLab.Core; 30 30 using HeuristicLab.Core.Views; … … 33 33 34 34 namespace HeuristicLab.Clients.Hive.JobManager.Views { 35 [View("Hive Resource Selector View")] 36 [Content(typeof(IItemList<Resource>), true)] 37 public partial class HiveResourceSelector : ItemView, IDisposable { 35 [View("Hive Project Selector View")] 36 [Content(typeof(IItemList<Project>), true)] 37 public partial class HiveProjectSelector : ItemView, IDisposable { 38 private const int greenFlagImageIndex = 0; 39 private const int redFlagImageIndex = 1; 38 40 private const int slaveImageIndex = 0; 39 41 private const int slaveGroupImageIndex = 1; 42 public const string additionalSlavesGroupName = "Additional Slaves"; 43 public const string additionalSlavesGroupDescription = "Contains additional slaves which are either ungrouped or the parenting slave group is not assigned to the selected project."; 44 45 private const string CURRENT_SELECTION_TAG = " [current assignment]"; 46 private const string NEW_SELECTION_TAG = " [new assignment]"; 47 private const string CHANGED_SELECTION_TAG = " [changed assignment]"; 48 private const string ADDED_SELECTION_TAG = " [added assignment]"; 49 private const string REMOVED_SELECTION_TAG = " [removed assignment]"; 50 private const string SELECTED_TAG = " [assigned]"; 51 private const string INCLUDED_TAG = " [included]"; 52 private const string ADDED_INCLUDE_TAG = " [added include]"; 53 private const string REMOVED_INCLUDE_TAG = " [removed include]"; 54 55 private TreeNode additionalNode; 56 57 private readonly HashSet<TreeNode> mainTreeNodes = new HashSet<TreeNode>(); 58 private readonly HashSet<TreeNode> filteredTreeNodes = new HashSet<TreeNode>(); 59 60 private readonly HashSet<Resource> availableResources = new HashSet<Resource>(); 61 private readonly HashSet<Resource> assignedResources = new HashSet<Resource>(); 62 private readonly HashSet<Resource> includedResources = new HashSet<Resource>(); 63 private readonly HashSet<Resource> newAssignedResources = new HashSet<Resource>(); 64 private readonly HashSet<Resource> newIncludedResources = new HashSet<Resource>(); 65 66 private readonly Color addedAssignmentColor = Color.FromArgb(255, 87, 191, 193); // #57bfc1 67 private readonly Color removedAssignmentColor = Color.FromArgb(255, 236, 159, 72); // #ec9f48 68 private readonly Color addedIncludeColor = Color.FromArgb(25, 169, 221, 221); // #a9dddd 69 private readonly Color removedIncludeColor = Color.FromArgb(25, 249, 210, 145); // #f9d291 70 private readonly Color selectedBackColor = Color.DodgerBlue; 71 private readonly Color selectedForeColor = Color.White; 72 private readonly Color controlTextColor = SystemColors.ControlText; 73 private readonly Color grayTextColor = SystemColors.GrayText; 74 40 75 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; } 76 77 private void resetHiveResourceSelector() { 78 lastSelectedProject = null; 79 selectedProject = null; 80 projectId = null; 81 } 82 83 private Guid jobId; 84 public Guid JobId { 85 get { return jobId; } 86 set { 87 if (jobId == value) return; 88 jobId = value; 89 resetHiveResourceSelector(); 90 } 91 } 92 93 private Guid? projectId; 94 public Guid? ProjectId { 95 get { return projectId; } 96 set { 97 if (projectId == value) return; 98 projectId = value; 99 } 100 } 101 102 private Guid? selectedProjectId; 103 public Guid? SelectedProjectId { 104 get { return selectedProjectId; } 105 set { 106 if (selectedProjectId == value) return; 107 selectedProjectId = value; 108 } 109 } 110 111 private IEnumerable<Guid> selectedResourceIds; 112 public IEnumerable<Guid> SelectedResourceIds { 113 get { return selectedResourceIds; } 114 set { 115 if (selectedResourceIds == value) return; 116 selectedResourceIds = value; 117 } 118 } 119 120 public bool ChangedProjectSelection { 121 get { 122 if ((lastSelectedProject == null && selectedProject != null) 123 || (lastSelectedProject != null && selectedProject == null) 124 || (lastSelectedProject != null && selectedProject != null && lastSelectedProject.Id != selectedProject.Id)) 125 return true; 126 else return false; 127 } 128 } 129 130 public bool ChangedResources { 131 get { return !assignedResources.SetEquals(newAssignedResources); } 132 } 133 134 private Project lastSelectedProject; 135 private Project selectedProject; 136 public Project SelectedProject { 137 get { return selectedProject; } 138 set { 139 if (selectedProject == value) return; 140 141 if ((JobId == Guid.Empty || JobId == null) 142 && (value == null || SelectedProject == null || value.Id != SelectedProject.Id)) selectedResourceIds = null; 143 lastSelectedProject = selectedProject; 144 selectedProject = value; 145 146 UpdateResourceTree(); 147 ExtractStatistics(); 148 OnSelectedProjectChanged(); 149 } 150 } 151 152 public int AssignedCores { 153 get { 154 HashSet<Slave> newAssignedSlaves = new HashSet<Slave>(newAssignedResources.OfType<Slave>()); 155 foreach(var slaveGroup in newAssignedResources.OfType<SlaveGroup>()) { 156 foreach(var slave in HiveClient.Instance.GetAvailableResourceDescendants(slaveGroup.Id).OfType<Slave>()) { 157 newAssignedSlaves.Add(slave); 158 } 159 } 160 return newAssignedSlaves.Sum(x => x.Cores.GetValueOrDefault()); 161 } 162 } 163 164 public IEnumerable<Resource> AssignedResources { 165 get { return newAssignedResources; } 166 set { 167 if (newAssignedResources == value) return; 168 newAssignedResources.Clear(); 169 foreach(var resource in value) { 170 newAssignedResources.Add(resource); 171 } 172 } 173 } 174 175 176 public new IItemList<Project> Content { 177 get { return (IItemList<Project>)base.Content; } 53 178 set { base.Content = value; } 54 179 } 55 180 56 public Hive ResourceSelector() {181 public HiveProjectSelector() { 57 182 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 183 184 projectsImageList.Images.Add(VSImageLibrary.FlagGreen); 185 projectsImageList.Images.Add(VSImageLibrary.FlagRed); 186 resourcesImageList.Images.Add(VSImageLibrary.MonitorLarge); 187 resourcesImageList.Images.Add(VSImageLibrary.NetworkCenterLarge); 188 } 189 190 #region Overrides 83 191 protected override void OnContentChanged() { 84 192 base.OnContentChanged(); 85 193 86 if (Content != null) { 87 selectedResources = new HashSet<Resource>(Content.Where(x => selectedResources.Any(y => x.Id == y.Id))); 88 UpdateMainTree(); 194 if (Content != null) { 195 if (SelectedProjectId.HasValue && SelectedProjectId.Value != Guid.Empty) { 196 SelectedProject = GetSelectedProjectById(SelectedProjectId.Value); 197 } else { 198 SelectedProject = null; 199 } 200 //ExtractStatistics(); 201 UpdateProjectTree(); 202 203 } else { 204 lastSelectedProject = null; 205 selectedProject = null; 206 selectedProjectId = null; 207 projectsTreeView.Nodes.Clear(); 208 resourcesTreeView.Nodes.Clear(); 209 } 210 } 211 212 #endregion 213 214 #region Event Handlers 215 private void HiveProjectSelector_Load(object sender, EventArgs e) { 216 projectsTreeView.Nodes.Clear(); 217 resourcesTreeView.Nodes.Clear(); 218 } 219 220 private void searchTextBox_TextChanged(object sender, EventArgs e) { 221 currentSearchString = searchTextBox.Text.ToLower(); 222 //UpdateFilteredTree(); 223 UpdateProjectTree(); 224 } 225 226 private void projectsTreeView_MouseDoubleClick(object sender, MouseEventArgs e) { 227 OnProjectsTreeViewDoubleClicked(); 228 } 229 230 private void projectsTreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e) { 231 var node = (Project)e.Node.Tag; 232 if (HiveClient.Instance.DisabledParentProjects.Contains(node)) { 233 e.Cancel = true; 234 } 235 } 236 237 private void projectsTreeView_AfterSelect(object sender, TreeViewEventArgs e) { 238 var node = (Project)e.Node.Tag; 239 240 if (node == null) { 241 projectsTreeView.SelectedNode = null; 242 } else if (HiveClient.Instance.DisabledParentProjects.Contains(node)) { 243 return; 244 } else { 245 ResetTreeNodes(projectsTreeView.Nodes); 246 e.Node.BackColor = selectedBackColor; 247 e.Node.ForeColor = selectedForeColor; 248 249 if (node.Id == projectId) { 250 e.Node.Text += CURRENT_SELECTION_TAG; 251 } else if (projectId == null || projectId == Guid.Empty) { 252 e.Node.Text += NEW_SELECTION_TAG; 253 } else { 254 e.Node.Text += CHANGED_SELECTION_TAG; 255 } 256 257 258 } 259 SelectedProject = node; 260 } 261 262 private void resourcesTreeView_MouseDown(object sender, MouseEventArgs e) { 263 var node = resourcesTreeView.GetNodeAt(new Point(e.X, e.Y)); 264 265 if (node == null || node == additionalNode) { 266 resourcesTreeView.SelectedNode = null; 89 267 ExtractStatistics(); 90 268 } 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 } 269 var r = (Resource)node.Tag; 270 if (!HiveClient.Instance.DisabledParentResources.Contains(r)) { 271 ExtractStatistics((Resource)node.Tag); 272 } else { 273 resourcesTreeView.SelectedNode = null; 274 ExtractStatistics(); 275 } 276 } 277 } 278 279 private void resourcesTreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e) { 280 if(e.Node == null || e.Node == additionalNode) { 281 e.Cancel = true; 282 } else { 283 var r = (Resource)e.Node.Tag; 284 if(r == null || HiveClient.Instance.DisabledParentResources.Contains(r)) { 285 e.Cancel = true; 286 } 287 } 288 289 } 290 291 private void resourcesTreeView_BeforeCheck(object sender, TreeViewCancelEventArgs e) { 292 if(e.Node == null || e.Node == additionalNode) { 293 e.Cancel = true; 294 } else { 295 var checkedResource = (Resource)e.Node.Tag; 296 if (checkedResource == null 297 || checkedResource.Id == Guid.Empty 298 || HiveClient.Instance.DisabledParentResources.Contains(checkedResource) 299 || newIncludedResources.Contains(checkedResource)) { 300 e.Cancel = true; 301 302 var selectedNode = resourcesTreeView.SelectedNode; 303 var selectedResource = (Resource)(selectedNode != null ? selectedNode.Tag : null); 304 305 ExtractStatistics(selectedResource); 306 } 307 } 308 } 309 310 private void resourcesTreeView_AfterCheck(object sender, TreeViewEventArgs e) { 311 var checkedResource = (Resource)e.Node.Tag; 312 if (e.Node.Checked) { 313 newAssignedResources.Add(checkedResource); 314 } else { 315 newAssignedResources.Remove(checkedResource); 316 } 317 318 UpdateResourceTreeAfterCheck(); 319 ExtractStatistics(); 320 OnAssignedResourcesChanged(); 321 } 322 323 private void resourcesTreeView_NodeMouseDoubleClick(object sender, TreeNodeMouseClickEventArgs e) { 324 return; 133 325 } 134 326 #endregion 135 327 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 } 328 #region Helpers 329 330 private Project GetSelectedProjectById(Guid projectId) { 331 return Content.Where(x => x.Id == projectId).SingleOrDefault(); 332 } 333 334 private void UpdateProjectTree() { 335 336 if (string.IsNullOrEmpty(currentSearchString)) { 337 BuildProjectTree(Content); 338 } else { 339 HashSet<Project> filteredProjects = new HashSet<Project>(); 340 foreach(var project in Content) { 341 if(project.Name.ToLower().Contains(currentSearchString.ToLower())) { 342 filteredProjects.Add(project); 343 filteredProjects.UnionWith(Content.Where(p => HiveClient.Instance.GetAvailableProjectAncestors(project.Id).Select(x => x.Id).Contains(p.Id))); 344 } 345 } 346 BuildProjectTree(filteredProjects); 347 } 348 } 349 350 private void BuildProjectTree(IEnumerable<Project> projects) { 351 projectsTreeView.Nodes.Clear(); 352 if (!projects.Any()) return; 353 354 var disabledParentProjects = HiveClient.Instance.DisabledParentProjects; 355 // select all top level projects (withouth parent, or without any ancestor within current project collection) 356 var mainProjects = new HashSet<Project>(projects.Where(x => x.ParentProjectId == null)); 357 //var parentedMainProjects = new HashSet<Project>(projects 358 // .Where(x => x.ParentProjectId.HasValue 359 // && !projects.Select(y => y.Id).Contains(x.ParentProjectId.Value) 360 // && !projects.SelectMany(y => HiveClient.Instance.ProjectAncestors[y.Id]).Contains(x.ParentProjectId.Value))); 361 //mainProjects.UnionWith(parentedMainProjects); 362 var mainDisabledParentProjects = new HashSet<Project>(disabledParentProjects.Where(x => x.ParentProjectId == null || x.ParentProjectId == Guid.Empty)); 363 mainProjects.UnionWith(mainDisabledParentProjects); 364 var subProbjects = new HashSet<Project>(projects.Union(disabledParentProjects).Except(mainProjects)); 365 //foreach (var p in subProbjects) { 366 // p.ParentProjectId = HiveClient.Instance.ProjectAncestors[p.Id].Where(x => projects.Select(y => y.Id).Contains(x)).FirstOrDefault(); 367 //} 368 369 var stack = new Stack<Project>(mainProjects.OrderByDescending(x => x.Name)); 370 371 TreeNode currentNode = null; 372 Project currentProject = null; 373 374 while(stack.Any()) { 375 var newProject = stack.Pop(); 376 var newNode = new TreeNode(newProject.Name) { Tag = newProject }; 377 378 while (currentNode != null && newProject.ParentProjectId != currentProject.Id) { 379 currentNode = currentNode.Parent; 380 currentProject = currentNode == null ? null : (Project)currentNode.Tag; 381 } 382 383 if (currentNode == null) { 384 projectsTreeView.Nodes.Add(newNode); 385 newNode.ImageIndex = greenFlagImageIndex; 386 } else { 387 currentNode.Nodes.Add(newNode); 388 newNode.ImageIndex = redFlagImageIndex; 389 } 390 391 newNode.SelectedImageIndex = newNode.ImageIndex; 392 393 if(disabledParentProjects.Contains(newProject)) { 394 newNode.Checked = false; 395 newNode.ForeColor = grayTextColor; 396 } 397 else if (SelectedProject != null && SelectedProject.Id.Equals(newProject.Id)) { 398 newNode.BackColor = selectedBackColor; 399 newNode.ForeColor = selectedForeColor; 400 if(SelectedProject.Id == projectId) { 401 newNode.Text += CURRENT_SELECTION_TAG; 402 } else if (projectId == null || projectId == Guid.Empty) { 403 newNode.Text += NEW_SELECTION_TAG; 404 } else { 405 newNode.Text += CHANGED_SELECTION_TAG; 406 } 407 } 408 409 if (!string.IsNullOrEmpty(currentSearchString) && newProject.Name.ToLower().Contains(currentSearchString.ToLower())) { 410 newNode.BackColor = Color.LightBlue; 411 } 412 413 var childProjects = subProbjects.Where(x => x.ParentProjectId == newProject.Id); 414 if (childProjects.Any()) { 415 foreach (var project in childProjects.OrderByDescending(x => x.Name)) { 416 subProbjects.Remove(project); 417 stack.Push(project); 418 } 419 currentNode = newNode; 420 currentProject = newProject; 421 } 422 } 423 424 projectsTreeView.ExpandAll(); 425 } 426 427 private static IEnumerable<Resource> GetAssignedResourcesForProject(Guid projectId) { 428 var assignedProjectResources = HiveServiceLocator.Instance.CallHiveService(s => s.GetAssignedResourcesForProject(projectId)); 429 return HiveClient.Instance.Resources.Where(x => assignedProjectResources.Select(y => y.ResourceId).Contains(x.Id)); 430 } 431 432 private static IEnumerable<Resource> GetAssignedResourcesForJob(Guid jobId) { 433 var assignedJobResources = HiveServiceLocator.Instance.CallHiveService(s => s.GetAssignedResourcesForJob(jobId)); 434 return HiveClient.Instance.Resources.Where(x => assignedJobResources.Select(y => y.ResourceId).Contains(x.Id)); 435 } 436 437 private void UpdateResourceTree() { 438 UpdateAvailableResources(); 439 UpdateAssignedResources(); 440 UpdateIncludedResources(); 441 BuildResourceTree(availableResources); 442 } 443 444 private void UpdateResourceTreeAfterCheck() { 445 resourcesTreeView.BeforeCheck -= resourcesTreeView_BeforeCheck; 446 resourcesTreeView.AfterCheck -= resourcesTreeView_AfterCheck; 447 UpdateNewAssignedResources(); 448 UpdateNewIncludedResources(); 449 SetTreeNodes(resourcesTreeView.Nodes); 450 resourcesTreeView.BeforeCheck += resourcesTreeView_BeforeCheck; 451 resourcesTreeView.AfterCheck += resourcesTreeView_AfterCheck; 452 } 453 454 private void UpdateAvailableResources() { 455 availableResources.Clear(); 456 if (selectedProject != null) { 457 var assignedProjectResources = GetAssignedResourcesForProject(selectedProject.Id); 458 foreach (var resource in assignedProjectResources) { 459 availableResources.Add(resource); 460 foreach(var descendant in HiveClient.Instance.Resources.Where(x => HiveClient.Instance.ResourceDescendants[resource.Id].Contains(x.Id))) { 461 availableResources.Add(descendant); 462 } 463 } 464 } 465 //ExtractStatistics(); 466 //OnAssignedResourcesChanged(); 467 } 468 469 private void UpdateAssignedResources() { 470 assignedResources.Clear(); 471 newAssignedResources.Clear(); 472 473 if (JobId == Guid.Empty || JobId == null) { // new, unchanged jobs get all avaialable resources 474 // update new assigned resources 475 if(selectedResourceIds == null) { 476 foreach (var resource in availableResources 477 .Where(x => !x.ParentResourceId.HasValue 478 || !availableResources.Select(y => y.Id).Contains(x.ParentResourceId.Value))) { 479 newAssignedResources.Add(resource); 480 } 481 } else { 482 foreach(var resource in availableResources.Where(x => selectedResourceIds.Contains(x.Id))) { 483 newAssignedResources.Add(resource); 484 } 485 } 486 } else if(selectedProject.Id == projectId) { // existent, unchanged jobs get all assigned resources 487 // update assigned resources 488 var assignedJobResources = GetAssignedResourcesForJob(JobId); 489 foreach (var resource in assignedJobResources) { 490 assignedResources.Add(resource); 491 if (selectedResourceIds == null) { 492 newAssignedResources.Add(resource); 493 } 494 } 495 496 if(selectedResourceIds != null) { 497 foreach (var resource in availableResources.Where(x => selectedResourceIds.Contains(x.Id))) { 498 newAssignedResources.Add(resource); 499 } 500 } 501 } 502 503 //ExtractStatistics(); 504 OnAssignedResourcesChanged(); 505 } 506 507 private void UpdateNewAssignedResources() { 508 for(int i = newAssignedResources.Count-1; i>=0; i--) { 509 if(newAssignedResources.Intersect(HiveClient.Instance.GetAvailableResourceAncestors(newAssignedResources.ElementAt(i).Id)).Any()) { 510 newAssignedResources.Remove(newAssignedResources.ElementAt(i)); 511 } 512 } 513 } 514 515 private void UpdateIncludedResources() { 516 includedResources.Clear(); 517 newIncludedResources.Clear(); 518 519 if (JobId != Guid.Empty) { 520 foreach (var item in assignedResources) { 521 foreach (var descendant in HiveClient.Instance.GetAvailableResourceDescendants(item.Id)) { 522 includedResources.Add(descendant); 523 } 524 } 525 } 526 527 foreach (var item in newAssignedResources) { 528 foreach (var descendant in HiveClient.Instance.GetAvailableResourceDescendants(item.Id)) { 529 newIncludedResources.Add(descendant); 530 } 531 } 532 } 533 534 private void UpdateNewIncludedResources() { 535 newIncludedResources.Clear(); 536 foreach (var item in newAssignedResources) { 537 foreach (var descendant in HiveClient.Instance.GetAvailableResourceDescendants(item.Id)) { 538 newIncludedResources.Add(descendant); 539 } 540 } 541 } 542 543 private void BuildResourceTree(IEnumerable<Resource> resources) { 544 resourcesTreeView.Nodes.Clear(); 545 if (!resources.Any()) return; 546 547 resourcesTreeView.BeforeCheck -= resourcesTreeView_BeforeCheck; 548 resourcesTreeView.AfterCheck -= resourcesTreeView_AfterCheck; 549 550 var disabledParentResources = HiveClient.Instance.DisabledParentResources; 551 var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>().Where(x => x.ParentResourceId == null)); 552 //var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>() 553 // .Where(x => x.ParentResourceId.HasValue && !resources.Select(y => y.Id).Contains(x.ParentResourceId.Value))); 554 //mainResources.UnionWith(parentedMainResources); 555 //var subResources = new HashSet<Resource>(resources.Except(mainResources)); 556 var mainDisabledParentResources = new HashSet<Resource>(disabledParentResources.Where(x => x.ParentResourceId == null || x.ParentResourceId == Guid.Empty)); 557 mainResources.UnionWith(mainDisabledParentResources); 558 var subResources = new HashSet<Resource>(resources.Union(disabledParentResources).Except(mainResources).OrderByDescending(x => x.Name)); 559 560 var addedAssignments = newAssignedResources.Except(assignedResources); 561 var removedAssignments = assignedResources.Except(newAssignedResources); 562 var addedIncludes = newIncludedResources.Except(includedResources); 563 var removedIncludes = includedResources.Except(newIncludedResources); 564 565 TreeNode currentNode = null; 566 Resource currentResource = null; 567 568 var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name)); 569 570 while (stack.Any()) { 571 var newResource = stack.Pop(); 572 var newNode = new TreeNode(newResource.Name) { Tag = newResource }; 573 574 // search for parent node of newNode and save in currentNode 575 // necessary since newNodes (stack top items) might be siblings 576 // or grand..grandparents of previous node (currentNode) 577 while (currentNode != null && newResource.ParentResourceId != currentResource.Id) { 578 currentNode = currentNode.Parent; 579 currentResource = currentNode == null ? null : (Resource)currentNode.Tag; 580 } 581 582 if (currentNode == null) { 583 resourcesTreeView.Nodes.Add(newNode); 584 } else { 585 currentNode.Nodes.Add(newNode); 586 } 587 588 if (disabledParentResources.Contains(newResource)) { 589 newNode.Checked = false; 590 newNode.ForeColor = grayTextColor; 591 } else if (newAssignedResources.Select(x => x.Id).Contains(newResource.Id)) { 592 newNode.Checked = true; 593 if(!addedAssignments.Select(x => x.Id).Contains(newResource.Id) && !removedAssignments.Select(x => x.Id).Contains(newResource.Id)) { 594 newNode.Text += SELECTED_TAG; 595 } 596 } else if (newIncludedResources.Select(x => x.Id).Contains(newResource.Id)) { 597 newNode.Checked = true; 598 newNode.ForeColor = grayTextColor; 599 } 600 601 if (includedResources.Select(x => x.Id).Contains(newResource.Id) && newIncludedResources.Select(x => x.Id).Contains(newResource.Id)) { 602 newNode.Text += INCLUDED_TAG; 603 } else if (addedIncludes.Select(x => x.Id).Contains(newResource.Id)) { 604 newNode.BackColor = addedIncludeColor; 605 newNode.ForeColor = grayTextColor; 606 newNode.Text += ADDED_INCLUDE_TAG; 607 } else if (removedIncludes.Select(x => x.Id).Contains(newResource.Id)) { 608 newNode.BackColor = removedIncludeColor; 609 newNode.Text += REMOVED_INCLUDE_TAG; 610 } 611 612 if (addedAssignments.Select(x => x.Id).Contains(newResource.Id)) { 613 newNode.BackColor = addedAssignmentColor; 614 newNode.ForeColor = controlTextColor; 615 newNode.Text += ADDED_SELECTION_TAG; 616 } else if (removedAssignments.Select(x => x.Id).Contains(newResource.Id)) { 617 newNode.BackColor = removedAssignmentColor; 618 newNode.ForeColor = controlTextColor; 619 newNode.Text += REMOVED_SELECTION_TAG; 620 } 621 622 if (newResource is Slave) { 623 newNode.ImageIndex = slaveImageIndex; 624 } else { 625 newNode.ImageIndex = slaveGroupImageIndex; 626 627 var childResources = subResources.Where(x => x.ParentResourceId == newResource.Id); 628 if (childResources.Any()) { 629 foreach (var resource in childResources.OrderByDescending(x => x.Name)) { 630 subResources.Remove(resource); 631 stack.Push(resource); 632 } 633 currentNode = newNode; 634 currentResource = newResource; 635 } 636 } 637 newNode.SelectedImageIndex = newNode.ImageIndex; 638 } 639 640 var singleSlaves = subResources.OfType<Slave>(); 641 if (singleSlaves.Any()) { 642 643 additionalNode = new TreeNode(additionalSlavesGroupName) { 644 ForeColor = SystemColors.GrayText, 645 Tag = new SlaveGroup() { 646 Name = additionalSlavesGroupName, 647 Description = additionalSlavesGroupDescription 648 } 649 }; 650 651 foreach (var slave in singleSlaves.OrderBy(x => x.Name)) { 652 var slaveNode = new TreeNode(slave.Name) { Tag = slave }; 653 additionalNode.Nodes.Add(slaveNode); 654 } 655 656 resourcesTreeView.Nodes.Add(additionalNode); 657 } 658 659 ExpandResourceNodesOfInterest(resourcesTreeView.Nodes); 660 661 resourcesTreeView.BeforeCheck += resourcesTreeView_BeforeCheck; 662 resourcesTreeView.AfterCheck += resourcesTreeView_AfterCheck; 663 } 664 665 private void ExpandResourceNodesOfInterest(TreeNodeCollection nodes) { 666 foreach(TreeNode n in nodes) { 667 Resource r = (Resource)n.Tag; 668 if(n.Nodes.Count > 0) { 669 if(HiveClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any() 670 || HiveClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<Slave>().Intersect(assignedResources.Union(newAssignedResources)).Any()) { 671 n.Expand(); 672 ExpandResourceNodesOfInterest(n.Nodes); 673 } else { 674 n.Collapse(); 675 } 676 } else { 677 n.Collapse(); 678 } 679 } 680 } 681 682 private void CollapseSlaveOnlyNodes(TreeNode tn) { 683 if (!(tn.Tag is Resource)) return; 684 685 Resource r = (Resource)tn.Tag; 686 if (HiveClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any()) { 687 tn.Expand(); 688 foreach (TreeNode n in tn.Nodes) CollapseSlaveOnlyNodes(n); 689 } else { 690 tn.Collapse(); 691 } 692 } 693 694 private void ExtractStatistics(Resource resource = null) { 695 HashSet<Slave> newAssignedSlaves = new HashSet<Slave>(newAssignedResources.OfType<Slave>()); 696 foreach (var slaveGroup in newAssignedResources.OfType<SlaveGroup>()) { 697 foreach (var slave in HiveClient.Instance.GetAvailableResourceDescendants(slaveGroup.Id).OfType<Slave>()) { 698 newAssignedSlaves.Add(slave); 699 } 700 } 701 702 HashSet<Slave> selectedSlaves = null; 703 704 if (resource != null) { 705 var slaveGroup = resource as SlaveGroup; 706 if (slaveGroup != null) { 707 selectedSlaves = new HashSet<Slave>(HiveClient.Instance.GetAvailableResourceDescendants(slaveGroup.Id).OfType<Slave>()); 708 } else { 709 selectedSlaves = new HashSet<Slave>(new[] { resource as Slave }); 710 } 711 } else { 712 selectedSlaves = newAssignedSlaves; 713 } 714 715 int sumCores = selectedSlaves.Sum(x => x.Cores.GetValueOrDefault()); 716 int sumFreeCores = selectedSlaves.Sum(x => x.FreeCores.GetValueOrDefault()); 717 double sumMemory = selectedSlaves.Sum(x => x.Memory.GetValueOrDefault()) / 1024.0; 718 double sumFreeMemory = selectedSlaves.Sum(x => x.FreeMemory.GetValueOrDefault()) / 1024.0; 719 720 coresSummaryLabel.Text = string.Format("{0} Total ({1} Free / {2} Used)", sumCores, sumFreeCores, sumCores - sumFreeCores); 721 memorySummaryLabel.Text = string.Format("{0:0.00} GB Total ({1:0.00} GB Free / {2:0.00} GB Used)", sumMemory, sumFreeMemory, sumMemory - sumFreeMemory); 722 } 723 724 private void StyleTreeNode(TreeNode n, string name) { 725 n.Text = name; 726 n.BackColor = Color.Transparent; 727 n.ForeColor = Color.Black; 728 729 if(n.Tag is Project) { 730 var p = (Project)n.Tag; 731 if(HiveClient.Instance.DisabledParentProjects.Select(x => x.Id).Contains(p.Id)) { 732 n.Checked = false; 733 n.ForeColor = grayTextColor; 734 } 735 } else if(n.Tag is Resource) { 736 var r = (Resource)n.Tag; 737 if(HiveClient.Instance.DisabledParentResources.Select(x => x.Id).Contains(r.Id) || n == additionalNode) { 738 n.Checked = false; 739 n.ForeColor = grayTextColor; 740 } 741 } 742 } 743 744 private void ResetTreeNodes(TreeNodeCollection nodes) { 745 foreach (TreeNode n in nodes) { 746 string name = ""; 747 if (n.Tag is Project) name = ((Project)n.Tag).Name; 748 else if (n.Tag is Resource) name = ((Resource)n.Tag).Name; 749 StyleTreeNode(n, name); 750 if (n.Nodes.Count > 0) { 751 ResetTreeNodes(n.Nodes); 752 } 753 } 754 } 755 756 private void SetTreeNodes(TreeNodeCollection nodes) { 757 var addedAssignments = newAssignedResources.Except(assignedResources); 758 var removedAssignments = assignedResources.Except(newAssignedResources); 759 var addedIncludes = newIncludedResources.Except(includedResources); 760 var removedIncludes = includedResources.Except(newIncludedResources); 761 762 foreach (TreeNode n in nodes) { 763 764 if(n.Tag is Resource) { 765 // reset 766 var resource = (Resource)n.Tag; 767 n.Text = resource.Name; 768 n.BackColor = Color.Transparent; 769 n.ForeColor = Color.Black; 770 n.Checked = false; 771 772 if (HiveClient.Instance.DisabledParentResources.Select(x => x.Id).Contains(resource.Id) || n == additionalNode) { 773 n.ForeColor = grayTextColor; 774 } 775 776 // add additional info 777 if (newAssignedResources.Select(x => x.Id).Contains(resource.Id)) { 778 n.Checked = true; 779 if (!addedAssignments.Select(x => x.Id).Contains(resource.Id) && !removedAssignments.Select(x => x.Id).Contains(resource.Id)) { 780 n.Text += SELECTED_TAG; 781 } 782 } else if (newIncludedResources.Select(x => x.Id).Contains(resource.Id)) { 783 n.Checked = true; 784 n.ForeColor = grayTextColor; 785 } 786 787 if (includedResources.Select(x => x.Id).Contains(resource.Id) && newIncludedResources.Select(x => x.Id).Contains(resource.Id)) { 788 n.Text += INCLUDED_TAG; 789 } else if (addedIncludes.Select(x => x.Id).Contains(resource.Id)) { 790 n.BackColor = addedIncludeColor; 791 n.ForeColor = grayTextColor; 792 n.Text += ADDED_INCLUDE_TAG; 793 } else if (removedIncludes.Select(x => x.Id).Contains(resource.Id)) { 794 n.BackColor = removedIncludeColor; 795 n.Text += REMOVED_INCLUDE_TAG; 796 } 797 798 if (addedAssignments.Select(x => x.Id).Contains(resource.Id)) { 799 n.BackColor = addedAssignmentColor; 800 n.ForeColor = controlTextColor; 801 n.Text += ADDED_SELECTION_TAG; 802 } else if (removedAssignments.Select(x => x.Id).Contains(resource.Id)) { 803 n.BackColor = removedAssignmentColor; 804 n.ForeColor = controlTextColor; 805 n.Text += REMOVED_SELECTION_TAG; 806 } 807 } 808 809 if(n.Nodes.Count > 0) { 810 SetTreeNodes(n.Nodes); 811 } 812 } 813 } 814 156 815 #endregion 157 816 158 #region ResourceTree Methods159 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 #endregion186 187 817 #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(); 818 public event EventHandler SelectedProjectChanged; 819 private void OnSelectedProjectChanged() { 820 var handler = SelectedProjectChanged; 821 if (handler != null) handler(this, EventArgs.Empty); 822 } 823 824 public event EventHandler AssignedResourcesChanged; 825 private void OnAssignedResourcesChanged() { 826 var handler = AssignedResourcesChanged; 827 if (handler != null) handler(this, EventArgs.Empty); 828 } 829 830 public event EventHandler ProjectsTreeViewDoubleClicked; 831 private void OnProjectsTreeViewDoubleClicked() { 832 var handler = ProjectsTreeViewDoubleClicked; 833 if (handler != null) handler(this, EventArgs.Empty); 326 834 } 327 835 #endregion -
trunk/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelectorDialog.Designer.cs
r15583 r16117 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(HiveResourceSelectorDialog));47 this.components = new System.ComponentModel.Container(); 48 48 this.okButton = new System.Windows.Forms.Button(); 49 49 this.cancelButton = new System.Windows.Forms.Button(); 50 50 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(); 52 55 this.SuspendLayout(); 53 56 // … … 56 59 this.okButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 57 60 this.okButton.DialogResult = System.Windows.Forms.DialogResult.OK; 61 this.okButton.Enabled = false; 58 62 this.okButton.Location = new System.Drawing.Point(405, 609); 59 63 this.okButton.Name = "okButton"; … … 62 66 this.okButton.Text = "&OK"; 63 67 this.okButton.UseVisualStyleBackColor = true; 68 this.errorProvider.SetIconAlignment(this.okButton, System.Windows.Forms.ErrorIconAlignment.MiddleLeft); 69 this.errorProvider.SetIconPadding(this.okButton, 2); 64 70 // 65 71 // cancelButton … … 82 88 this.refreshButton.Size = new System.Drawing.Size(24, 24); 83 89 this.refreshButton.TabIndex = 3; 90 this.toolTip.SetToolTip(this.refreshButton, "Refresh data"); 84 91 this.refreshButton.UseVisualStyleBackColor = true; 85 92 this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click); 86 93 // 94 // errorProvider 95 // 96 this.errorProvider.BlinkStyle = System.Windows.Forms.ErrorBlinkStyle.NeverBlink; 97 this.errorProvider.ContainerControl = this; 98 // 87 99 // hiveResourceSelector 88 100 // 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) 91 103 | System.Windows.Forms.AnchorStyles.Right))); 92 104 this.hiveResourceSelector.Caption = "View"; 93 105 this.hiveResourceSelector.Content = null; 106 this.hiveResourceSelector.JobId = new System.Guid("00000000-0000-0000-0000-000000000000"); 94 107 this.hiveResourceSelector.Location = new System.Drawing.Point(12, 12); 95 108 this.hiveResourceSelector.Name = "hiveResourceSelector"; 109 this.hiveResourceSelector.ProjectId = null; 96 110 this.hiveResourceSelector.ReadOnly = false; 111 this.hiveResourceSelector.SelectedProject = null; 112 this.hiveResourceSelector.SelectedProjectId = null; 113 this.hiveResourceSelector.SelectedResourceIds = null; 97 114 this.hiveResourceSelector.Size = new System.Drawing.Size(549, 591); 98 115 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); 99 119 // 100 120 // HiveResourceSelectorDialog 101 121 // 102 122 this.AcceptButton = this.okButton; 103 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);104 123 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 105 124 this.CancelButton = this.cancelButton; … … 115 134 this.ShowInTaskbar = false; 116 135 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"; 119 137 this.Load += new System.EventHandler(this.HiveResourceSelectorDialog_Load); 138 ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit(); 120 139 this.ResumeLayout(false); 121 140 … … 126 145 protected System.Windows.Forms.Button okButton; 127 146 protected System.Windows.Forms.Button cancelButton; 128 protected HiveResourceSelector hiveResourceSelector;129 147 protected System.Windows.Forms.Button refreshButton; 148 protected System.Windows.Forms.ToolTip toolTip; 149 protected System.Windows.Forms.ErrorProvider errorProvider; 150 protected HiveProjectSelector hiveResourceSelector; 130 151 } 131 152 } -
trunk/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelectorDialog.cs
r15583 r16117 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 using System.Threading.Tasks; 24 using System.ComponentModel; 25 using System.Linq; 24 26 using System.Windows.Forms; 25 using HeuristicLab.PluginInfrastructure; 27 using HeuristicLab.Clients.Hive.Views; 28 using HeuristicLab.MainForm; 29 using HeuristicLab.Core; 26 30 27 31 namespace HeuristicLab.Clients.Hive.JobManager.Views { 28 32 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; 30 77 InitializeComponent(); 31 78 } 32 79 33 public ISet<Resource> GetSelectedResources() { return hiveResourceSelector.SelectedResources; }34 35 private void HiveResourceSelectorDialog_Load(object sender, System.EventArgs e) {36 Hive AdminClient.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); 38 85 } 39 86 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 } 42 102 } 43 103 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 } 46 111 } 47 112 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); 50 122 } 51 123 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); 58 133 } 59 134 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(); 64 137 } 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 65 179 } 66 180 } -
trunk/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.cs
r15583 r16117 41 41 this.itemsListView.Columns.Add(new ColumnHeader("Date") { Text = "Date" }); 42 42 this.itemsListView.Columns.Add(new ColumnHeader("Name") { Text = "Name" }); 43 this.itemsListView.Columns.Add(new ColumnHeader("Project") { Text = "Project" }); 43 44 44 45 this.itemsListView.HeaderStyle = ColumnHeaderStyle.Clickable; 45 46 this.itemsListView.FullRowSelect = true; 46 47 47 this.itemsListView.ListViewItemSorter = new ListViewItemDateComparer(0, SortOrder.Ascending); 48 this.itemsListView.ListViewItemSorter = new ListViewItemComparer(new int[] { 2, 0 }, new SortOrder[] { SortOrder.Ascending, SortOrder.Ascending }); 49 50 foreach (ColumnHeader c in this.itemsListView.Columns) { 51 c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); 52 int w = c.Width; 53 c.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 54 if(w > c.Width) { 55 c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); 56 } 57 } 48 58 } 49 59 50 60 protected override void SortItemsListView(SortOrder sortOrder) { 51 61 if (itemsListView.Sorting == sortOrder || sortOrder == SortOrder.None) return; 52 ((ListViewItem DateComparer)itemsListView.ListViewItemSorter).Order= sortOrder;62 ((ListViewItemComparer)itemsListView.ListViewItemSorter).Orders[1] = sortOrder; 53 63 itemsListView.Sorting = sortOrder; 54 64 itemsListView.Sort(); 55 AdjustListViewColumnSizes();65 //AdjustListViewColumnSizes(); 56 66 } 57 67 … … 133 143 base.Content_ItemsAdded(sender, e); 134 144 foreach (ColumnHeader c in this.itemsListView.Columns) { 145 c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); 146 int w = c.Width; 135 147 c.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent); 148 if (w > c.Width) { 149 c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize); 150 } 136 151 } 137 152 foreach (var item in e.Items) { … … 180 195 listViewItem.SubItems.Insert(0, new ListViewItem.ListViewSubItem(listViewItem, item.Job.DateCreated.ToString())); 181 196 listViewItem.SubItems.Insert(1, new ListViewItem.ListViewSubItem(listViewItem, item.Job.Name)); 197 listViewItem.SubItems.Insert(2, new ListViewItem.ListViewSubItem(listViewItem, HiveClient.Instance.GetProjectAncestry(item.Job.ProjectId))); 198 182 199 listViewItem.Group = GetListViewGroup(item.Job.OwnerUsername); 183 200 return listViewItem; … … 189 206 listViewItem.SubItems[0].Text = item == null ? "null" : item.Job.DateCreated.ToString("dd.MM.yyyy HH:mm"); 190 207 listViewItem.SubItems[1].Text = item == null ? "null" : item.Job.Name; 208 listViewItem.SubItems[2].Text = item == null ? "null" : HiveClient.Instance.GetProjectAncestry(item.Job.ProjectId); 191 209 listViewItem.Group = GetListViewGroup(item.Job.OwnerUsername); 192 210 listViewItem.ToolTipText = item == null ? string.Empty : item.ItemName + ": " + item.ItemDescription; -
trunk/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.Designer.cs
r15583 r16117 63 63 this.executionTimeTextBox = new System.Windows.Forms.TextBox(); 64 64 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(); 67 67 this.nameLabel = new System.Windows.Forms.Label(); 68 68 this.nameTextBox = new System.Windows.Forms.TextBox(); 69 this.descriptionLabel = new System.Windows.Forms.Label(); 70 this.descriptionTextBox = new System.Windows.Forms.TextBox(); 69 71 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 70 72 this.refreshButton = new System.Windows.Forms.Button(); 73 this.updateButton = new System.Windows.Forms.Button(); 71 74 this.UnloadButton = new System.Windows.Forms.Button(); 75 this.searchButton = new System.Windows.Forms.Button(); 72 76 this.refreshAutomaticallyCheckBox = new System.Windows.Forms.CheckBox(); 73 77 this.infoGroupBox = new System.Windows.Forms.GroupBox(); … … 78 82 this.calculatingLabel = new System.Windows.Forms.Label(); 79 83 this.jobsLabel = new System.Windows.Forms.Label(); 80 this.searchButton = new System.Windows.Forms.Button();81 84 this.tabControl.SuspendLayout(); 82 85 this.tasksTabPage.SuspendLayout(); … … 91 94 // 92 95 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) 95 98 | System.Windows.Forms.AnchorStyles.Right))); 96 99 this.tabControl.Controls.Add(this.tasksTabPage); … … 99 102 this.tabControl.Controls.Add(this.stateTabPage); 100 103 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); 102 105 this.tabControl.Name = "tabControl"; 103 106 this.tabControl.SelectedIndex = 0; … … 119 122 // 120 123 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) 123 126 | System.Windows.Forms.AnchorStyles.Right))); 124 127 this.jobsTreeView.Caption = "ItemTree View"; … … 151 154 this.refreshPermissionsButton.Size = new System.Drawing.Size(24, 24); 152 155 this.refreshPermissionsButton.TabIndex = 23; 153 this.toolTip.SetToolTip(this.refreshPermissionsButton, "Refresh Data");156 this.toolTip.SetToolTip(this.refreshPermissionsButton, "Refresh data"); 154 157 this.refreshPermissionsButton.UseVisualStyleBackColor = true; 155 158 this.refreshPermissionsButton.Click += new System.EventHandler(this.refreshPermissionsButton_Click); … … 157 160 // hiveExperimentPermissionListView 158 161 // 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) 161 164 | System.Windows.Forms.AnchorStyles.Right))); 162 165 this.hiveExperimentPermissionListView.Caption = "HiveExperimentPermissionList View"; … … 183 186 // runCollectionViewHost 184 187 // 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) 187 190 | System.Windows.Forms.AnchorStyles.Right))); 188 191 this.runCollectionViewHost.Caption = "View"; … … 209 212 // stateLogViewHost 210 213 // 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) 213 216 | System.Windows.Forms.AnchorStyles.Right))); 214 217 this.stateLogViewHost.Caption = "StateLog View"; … … 235 238 // logView 236 239 // 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) 239 242 | System.Windows.Forms.AnchorStyles.Right))); 240 243 this.logView.Caption = "Log View"; … … 250 253 this.startButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 251 254 this.startButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Play; 252 this.startButton.Location = new System.Drawing.Point(0, 5 36);255 this.startButton.Location = new System.Drawing.Point(0, 564); 253 256 this.startButton.Name = "startButton"; 254 257 this.startButton.Size = new System.Drawing.Size(24, 24); 255 this.startButton.TabIndex = 5;258 this.startButton.TabIndex = 4; 256 259 this.toolTip.SetToolTip(this.startButton, "Start/Resume Experiment"); 257 260 this.startButton.UseVisualStyleBackColor = true; … … 262 265 this.stopButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); 263 266 this.stopButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Stop; 264 this.stopButton.Location = new System.Drawing.Point(60, 5 36);267 this.stopButton.Location = new System.Drawing.Point(60, 564); 265 268 this.stopButton.Name = "stopButton"; 266 269 this.stopButton.Size = new System.Drawing.Size(24, 24); 267 this.stopButton.TabIndex = 7;270 this.stopButton.TabIndex = 6; 268 271 this.toolTip.SetToolTip(this.stopButton, "Stop Experiment"); 269 272 this.stopButton.UseVisualStyleBackColor = true; … … 274 277 this.executionTimeLabel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right))); 275 278 this.executionTimeLabel.AutoSize = true; 276 this.executionTimeLabel.Location = new System.Drawing.Point(491, 5 43);279 this.executionTimeLabel.Location = new System.Drawing.Point(491, 571); 277 280 this.executionTimeLabel.Name = "executionTimeLabel"; 278 281 this.executionTimeLabel.Size = new System.Drawing.Size(83, 13); 279 this.executionTimeLabel.TabIndex = 9;282 this.executionTimeLabel.TabIndex = 100; 280 283 this.executionTimeLabel.Text = "&Execution Time:"; 281 284 // … … 283 286 // 284 287 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, 5 40);288 this.executionTimeTextBox.Location = new System.Drawing.Point(580, 568); 286 289 this.executionTimeTextBox.Name = "executionTimeTextBox"; 287 290 this.executionTimeTextBox.ReadOnly = true; 288 291 this.executionTimeTextBox.Size = new System.Drawing.Size(137, 20); 289 this.executionTimeTextBox.TabIndex = 10 ;292 this.executionTimeTextBox.TabIndex = 100; 290 293 // 291 294 // pauseButton … … 294 297 this.pauseButton.Enabled = false; 295 298 this.pauseButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Pause; 296 this.pauseButton.Location = new System.Drawing.Point(30, 5 36);299 this.pauseButton.Location = new System.Drawing.Point(30, 564); 297 300 this.pauseButton.Name = "pauseButton"; 298 301 this.pauseButton.Size = new System.Drawing.Size(24, 24); 299 this.pauseButton.TabIndex = 6;302 this.pauseButton.TabIndex = 5; 300 303 this.toolTip.SetToolTip(this.pauseButton, "Pause Experiment"); 301 304 this.pauseButton.UseVisualStyleBackColor = true; 302 305 this.pauseButton.Click += new System.EventHandler(this.pauseButton_Click); 303 306 // 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); 322 326 // 323 327 // nameLabel 324 328 // 325 329 this.nameLabel.AutoSize = true; 326 this.nameLabel.Location = new System.Drawing.Point(3, 3 0);330 this.nameLabel.Location = new System.Drawing.Point(3, 35); 327 331 this.nameLabel.Name = "nameLabel"; 328 332 this.nameLabel.Size = new System.Drawing.Size(38, 13); 329 this.nameLabel.TabIndex = 20;333 this.nameLabel.TabIndex = 100; 330 334 this.nameLabel.Text = "Name:"; 331 335 // 332 336 // nameTextBox 333 337 // 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(7 0, 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); 337 341 this.nameTextBox.Name = "nameTextBox"; 338 this.nameTextBox.Size = new System.Drawing.Size(50 1, 20);342 this.nameTextBox.Size = new System.Drawing.Size(500, 20); 339 343 this.nameTextBox.TabIndex = 1; 340 344 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); 341 364 // 342 365 // refreshButton … … 346 369 this.refreshButton.Name = "refreshButton"; 347 370 this.refreshButton.Size = new System.Drawing.Size(24, 24); 348 this.refreshButton.TabIndex = 22;371 this.refreshButton.TabIndex = 7; 349 372 this.toolTip.SetToolTip(this.refreshButton, "Refresh Data"); 350 373 this.refreshButton.UseVisualStyleBackColor = true; 351 374 this.refreshButton.Click += new System.EventHandler(this.refreshButton_Click); 352 375 // 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 // 353 387 // UnloadButton 354 388 // 355 389 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); 357 391 this.UnloadButton.Name = "UnloadButton"; 358 392 this.UnloadButton.Size = new System.Drawing.Size(24, 24); 359 this.UnloadButton.TabIndex = 27;393 this.UnloadButton.TabIndex = 9; 360 394 this.toolTip.SetToolTip(this.UnloadButton, "Unload Job"); 361 395 this.UnloadButton.UseVisualStyleBackColor = true; 362 396 this.UnloadButton.Click += new System.EventHandler(this.UnloadButton_Click); 363 397 // 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 // 364 409 // refreshAutomaticallyCheckBox 365 410 // 366 411 this.refreshAutomaticallyCheckBox.AutoSize = true; 367 this.refreshAutomaticallyCheckBox.Location = new System.Drawing.Point( 70, 3);412 this.refreshAutomaticallyCheckBox.Location = new System.Drawing.Point(100, 3); 368 413 this.refreshAutomaticallyCheckBox.Name = "refreshAutomaticallyCheckBox"; 369 414 this.refreshAutomaticallyCheckBox.Size = new System.Drawing.Size(127, 17); 370 this.refreshAutomaticallyCheckBox.TabIndex = 24;415 this.refreshAutomaticallyCheckBox.TabIndex = 100; 371 416 this.refreshAutomaticallyCheckBox.Text = "&Refresh automatically"; 372 417 this.refreshAutomaticallyCheckBox.UseVisualStyleBackColor = true; … … 382 427 this.infoGroupBox.Controls.Add(this.calculatingLabel); 383 428 this.infoGroupBox.Controls.Add(this.jobsLabel); 384 this.infoGroupBox.Location = new System.Drawing.Point(5 80, 5);429 this.infoGroupBox.Location = new System.Drawing.Point(578, 16); 385 430 this.infoGroupBox.Name = "infoGroupBox"; 386 431 this.infoGroupBox.Size = new System.Drawing.Size(133, 89); … … 391 436 // finishedTextBox 392 437 // 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) 394 439 | System.Windows.Forms.AnchorStyles.Right))); 395 440 this.finishedTextBox.Location = new System.Drawing.Point(74, 64); 396 441 this.finishedTextBox.Name = "finishedTextBox"; 397 442 this.finishedTextBox.Size = new System.Drawing.Size(53, 20); 398 this.finishedTextBox.TabIndex = 5;443 this.finishedTextBox.TabIndex = 100; 399 444 // 400 445 // calculatingTextBox 401 446 // 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) 403 448 | System.Windows.Forms.AnchorStyles.Right))); 404 449 this.calculatingTextBox.Location = new System.Drawing.Point(74, 40); 405 450 this.calculatingTextBox.Name = "calculatingTextBox"; 406 451 this.calculatingTextBox.Size = new System.Drawing.Size(53, 20); 407 this.calculatingTextBox.TabIndex = 4;452 this.calculatingTextBox.TabIndex = 100; 408 453 // 409 454 // jobsTextBox 410 455 // 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) 412 457 | System.Windows.Forms.AnchorStyles.Right))); 413 458 this.jobsTextBox.Location = new System.Drawing.Point(74, 16); 414 459 this.jobsTextBox.Name = "jobsTextBox"; 415 460 this.jobsTextBox.Size = new System.Drawing.Size(53, 20); 416 this.jobsTextBox.TabIndex = 3;461 this.jobsTextBox.TabIndex = 100; 417 462 // 418 463 // finishedLabel … … 422 467 this.finishedLabel.Name = "finishedLabel"; 423 468 this.finishedLabel.Size = new System.Drawing.Size(49, 13); 424 this.finishedLabel.TabIndex = 2;469 this.finishedLabel.TabIndex = 100; 425 470 this.finishedLabel.Text = "Finished:"; 426 471 // … … 431 476 this.calculatingLabel.Name = "calculatingLabel"; 432 477 this.calculatingLabel.Size = new System.Drawing.Size(62, 13); 433 this.calculatingLabel.TabIndex = 1 ;478 this.calculatingLabel.TabIndex = 100; 434 479 this.calculatingLabel.Text = "Calculating:"; 435 480 // … … 440 485 this.jobsLabel.Name = "jobsLabel"; 441 486 this.jobsLabel.Size = new System.Drawing.Size(46, 13); 442 this.jobsLabel.TabIndex = 0;487 this.jobsLabel.TabIndex = 100; 443 488 this.jobsLabel.Text = "Waiting:"; 444 489 // 445 // searchButton446 //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 //456 490 // RefreshableHiveJobView 457 491 // 458 492 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 459 this.Controls.Add(this.UnloadButton);460 493 this.Controls.Add(this.searchButton); 461 494 this.Controls.Add(this.infoGroupBox); 462 495 this.Controls.Add(this.refreshAutomaticallyCheckBox); 463 496 this.Controls.Add(this.refreshButton); 497 this.Controls.Add(this.updateButton); 498 this.Controls.Add(this.UnloadButton); 464 499 this.Controls.Add(this.nameTextBox); 465 500 this.Controls.Add(this.nameLabel); 501 this.Controls.Add(this.descriptionTextBox); 502 this.Controls.Add(this.descriptionLabel); 466 503 this.Controls.Add(this.tabControl); 467 504 this.Controls.Add(this.startButton); 468 505 this.Controls.Add(this.executionTimeTextBox); 469 506 this.Controls.Add(this.executionTimeLabel); 470 this.Controls.Add(this. resourceNamesTextBox);507 this.Controls.Add(this.projectNameTextBox); 471 508 this.Controls.Add(this.pauseButton); 472 this.Controls.Add(this. resourceIdsLabel);509 this.Controls.Add(this.projectLabel); 473 510 this.Controls.Add(this.stopButton); 474 511 this.Name = "RefreshableHiveJobView"; 475 this.Size = new System.Drawing.Size(717, 5 60);512 this.Size = new System.Drawing.Size(717, 588); 476 513 this.tabControl.ResumeLayout(false); 477 514 this.tasksTabPage.ResumeLayout(false); … … 493 530 private System.Windows.Forms.TextBox executionTimeTextBox; 494 531 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; 497 534 private System.Windows.Forms.TabPage logTabPage; 498 535 private Core.Views.LogView logView; … … 501 538 private System.Windows.Forms.Label nameLabel; 502 539 private System.Windows.Forms.TextBox nameTextBox; 540 private System.Windows.Forms.Label descriptionLabel; 541 private System.Windows.Forms.TextBox descriptionTextBox; 503 542 private System.Windows.Forms.ToolTip toolTip; 504 543 private System.Windows.Forms.Button refreshButton; 544 private System.Windows.Forms.Button updateButton; 545 private System.Windows.Forms.Button UnloadButton; 505 546 private System.Windows.Forms.CheckBox refreshAutomaticallyCheckBox; 506 547 private System.Windows.Forms.GroupBox infoGroupBox; … … 520 561 private System.Windows.Forms.Button searchButton; 521 562 private MainForm.WindowsForms.DragOverTabControl tabControl; 522 private System.Windows.Forms.Button UnloadButton;523 524 563 } 525 564 } -
trunk/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
r15583 r16117 23 23 using System.ComponentModel; 24 24 using System.Linq; 25 using System.Text;26 25 using System.Threading; 27 26 using System.Threading.Tasks; … … 34 33 using HeuristicLab.Optimization; 35 34 using HeuristicLab.PluginInfrastructure; 35 using System.Collections.Generic; 36 36 37 37 namespace HeuristicLab.Clients.Hive.JobManager.Views { … … 45 45 private bool SuppressEvents { get; set; } 46 46 private object runCollectionViewLocker = new object(); 47 private Project selectedProject; 48 private Dictionary<Guid, Guid> originalJobProjectAssignment = new Dictionary<Guid, Guid>(); 47 49 48 50 public new RefreshableJob Content { 49 51 get { return (RefreshableJob)base.Content; } 50 set { base.Content = value; } 52 set { 53 base.Content = value; 54 } 51 55 } 52 56 … … 117 121 if (Content == null) { 118 122 nameTextBox.Text = string.Empty; 123 descriptionTextBox.Text = string.Empty; 119 124 executionTimeTextBox.Text = string.Empty; 120 resourceNamesTextBox.Text = string.Empty;125 projectNameTextBox.Text = string.Empty; 121 126 refreshAutomaticallyCheckBox.Checked = false; 122 127 lock (runCollectionViewLocker) { … … 128 133 stateLogViewHost.Content = null; 129 134 } 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 if (Content.Job != null && Content.Job.ProjectId == Guid.Empty) { 142 if (HiveClient.Instance != null && HiveClient.Instance.Projects != null && HiveClient.Instance.Projects.Count == 1) { 143 var p = HiveClient.Instance.Projects.FirstOrDefault(); 144 if (p != null && p.Id != Guid.Empty) { 145 hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId); 146 Content.Job.ProjectId = p.Id; 147 Content.Job.ResourceIds = HiveClient.Instance.GetAvailableResourcesForProject(p.Id).Select(x => x.Id).ToList(); 148 hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; 149 hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; 150 } 151 } 152 } 153 154 130 155 nameTextBox.Text = Content.Job.Name; 156 descriptionTextBox.Text = Content.Job.Description; 131 157 executionTimeTextBox.Text = Content.ExecutionTime.ToString(); 132 resourceNamesTextBox.Text = Content.Job.ResourceNames;133 158 refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically; 159 160 // project look up 161 if(Content.Job.ProjectId != null && Content.Job.ProjectId != Guid.Empty) { 162 if(selectedProject == null || selectedProject.Id != Content.Job.ProjectId) { 163 selectedProject = GetProject(Content.Job.ProjectId); 164 if (selectedProject != null) { 165 projectNameTextBox.Text = selectedProject.Name; 166 } else { 167 projectNameTextBox.Text = string.Empty; 168 } 169 } 170 } else { 171 selectedProject = null; 172 projectNameTextBox.Text = string.Empty; 173 Content.Job.ResourceIds = null; 174 } 175 134 176 logView.Content = Content.Log; 135 177 lock (runCollectionViewLocker) { … … 137 179 } 138 180 } 139 } 140 finally { 181 } finally { 141 182 SuppressEvents = false; 142 183 } … … 158 199 tabControl.Enabled = !Locked; 159 200 nameTextBox.Enabled = !Locked; 160 resourceNamesTextBox.Enabled = !Locked; 201 descriptionTextBox.Enabled = !Locked; 202 projectNameTextBox.Enabled = !Locked; 161 203 searchButton.Enabled = !Locked; 162 204 jobsTreeView.Enabled = !Locked; … … 182 224 tabControl.Enabled = !Content.IsProgressing; 183 225 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;226 this.nameTextBox.ReadOnly = Content.IsProgressing; 227 this.descriptionTextBox.ReadOnly = Content.IsProgressing; 228 this.searchButton.Enabled = !Content.IsProgressing && Content.ExecutionState != ExecutionState.Stopped; 187 229 this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing; 188 230 189 231 this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && (Content.ExecutionState == ExecutionState.Started || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing; 190 232 this.refreshButton.Enabled = Content.IsDownloadable && alreadyUploaded && !Content.IsProgressing; 233 this.updateButton.Enabled = Content.ExecutionState != ExecutionState.Prepared && Content.ExecutionState != ExecutionState.Stopped && !Content.IsProgressing; 191 234 192 235 this.UnloadButton.Enabled = Content.HiveTasks != null && Content.HiveTasks.Count > 0 && alreadyUploaded && !Content.IsProgressing; … … 333 376 #region Control events 334 377 private void searchButton_Click(object sender, EventArgs e) { 335 if (hiveResourceSelectorDialog == null) 336 hiveResourceSelectorDialog = new HiveResourceSelectorDialog(); 378 if (hiveResourceSelectorDialog == null) { 379 hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId); 380 } else if(hiveResourceSelectorDialog.JobId != Content.Job.Id) { 381 hiveResourceSelectorDialog.JobId = Content.Job.Id; 382 hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; 383 hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; 384 385 if (originalJobProjectAssignment.ContainsKey(Content.Job.Id)) { 386 hiveResourceSelectorDialog.ProjectId = originalJobProjectAssignment[Content.Job.Id]; 387 } else { 388 hiveResourceSelectorDialog.ProjectId = Guid.Empty; 389 } 390 } else if(hiveResourceSelectorDialog.JobId == Guid.Empty && Content.Job.Id == Guid.Empty) { 391 hiveResourceSelectorDialog.JobId = Content.Job.Id; 392 hiveResourceSelectorDialog.ProjectId = Guid.Empty; 393 hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; 394 hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; 395 } else { 396 hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; 397 hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; 398 } 399 337 400 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; 401 selectedProject = hiveResourceSelectorDialog.SelectedProject; 402 if(selectedProject != null) { 403 projectNameTextBox.Text = selectedProject.Name; 404 Content.Job.ProjectId = selectedProject.Id; 405 Content.Job.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList(); 406 } else { 407 selectedProject = null; 408 projectNameTextBox.Text = string.Empty; 409 Content.Job.ProjectId = Guid.Empty; 410 Content.Job.ResourceIds = null; 411 } 412 SetEnabledStateOfExecutableButtons(); 346 413 } 347 414 } … … 350 417 if (nameTextBox.Text.Trim() == string.Empty) { 351 418 MessageBox.Show("Please enter a name for the job before uploading it!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); 419 } else if (Content.Job.ProjectId == null || Content.Job.ProjectId == Guid.Empty) { 420 MessageBox.Show("Please select a project before uploading the job!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); 421 } else if (Content.Job.ResourceIds == null || !Content.Job.ResourceIds.Any()) { 422 MessageBox.Show("Please select resources before uploading the job!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); 352 423 } else if (Content.ExecutionState == ExecutionState.Paused) { 353 424 var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobAsync, Content); … … 359 430 } else { 360 431 HiveClient.StartJob((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Start failed.", ex), Content, new CancellationToken()); 432 UpdateSelectorDialog(); 361 433 } 362 434 } … … 403 475 } 404 476 477 private void descriptionTextBox_Validated(object sender, EventArgs e) { 478 if (!SuppressEvents && Content.Job != null && Content.Job.Description != descriptionTextBox.Text) 479 Content.Job.Description = descriptionTextBox.Text; 480 } 481 405 482 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;483 //if (!SuppressEvents && Content.Job != null && Content.Job.ResourceNames != resourceNamesTextBox.Text) 484 // Content.Job.ResourceNames = resourceNamesTextBox.Text; 408 485 } 409 486 … … 417 494 try { 418 495 invoker.EndInvoke(ar); 419 } 420 catch (Exception ex) { 421 ThreadPool.QueueUserWorkItem(delegate(object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex); 496 } catch (Exception ex) { 497 ThreadPool.QueueUserWorkItem(delegate (object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex); 422 498 } 423 499 }, 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 } 500 UpdateSelectorDialog(); 501 } 502 503 private void updateButton_Click2(object sender, EventArgs e) { 504 if (Content.ExecutionState == ExecutionState.Stopped) { 505 MessageBox.Show("Job cannot be updated once it stopped.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); 506 return; 507 } 508 509 HiveClient.UpdateJob( 510 (Exception ex) => ErrorHandling.ShowErrorDialog(this, "Update failed.", ex), 511 Content, 512 new CancellationToken()); 513 UpdateSelectorDialog(); 514 } 515 516 private void updateButton_Click(object sender, EventArgs e) { 517 if (Content.ExecutionState == ExecutionState.Stopped) { 518 MessageBox.Show("Job cannot be updated once it stopped.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); 519 return; 520 } 521 522 var invoker = new Action<RefreshableJob>(HiveClient.UpdateJob); 523 invoker.BeginInvoke(Content, (ar) => { 524 try { 525 invoker.EndInvoke(ar); 526 } catch (Exception ex) { 527 ThreadPool.QueueUserWorkItem(delegate (object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex); 528 } 529 }, null); 530 UpdateSelectorDialog(); 517 531 } 518 532 … … 526 540 SetEnabledStateOfControls(); 527 541 } 542 543 private void refreshPermissionsButton_Click(object sender, EventArgs e) { 544 if (this.Content.Job.Id == Guid.Empty) { 545 MessageBox.Show("You have to upload the Job first before you can share it.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); 546 } else { 547 hiveExperimentPermissionListView.Content = HiveClient.GetJobPermissions(this.Content.Job.Id); 548 } 549 } 550 #endregion 551 552 #region Helpers 553 private void SetEnabledStateOfExecutableButtons() { 554 if (Content == null) { 555 startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = false; 556 } else { 557 startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 558 && Content.Job.ProjectId != null && Content.Job.ProjectId != Guid.Empty && Content.Job.ResourceIds != null && Content.Job.ResourceIds.Any() 559 && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing; 560 pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing; 561 stopButton.Enabled = Content.IsControllable && (Content.ExecutionState == ExecutionState.Started || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing; 562 } 563 } 564 565 private Project GetProject(Guid projectId) { 566 return HiveServiceLocator.Instance.CallHiveService(s => s.GetProject(projectId)); 567 } 568 569 private void UpdateSelectorDialog() { 570 if(hiveResourceSelectorDialog != null) { 571 hiveResourceSelectorDialog = null; 572 //hiveResourceSelectorDialog.JobId = Content.Job.Id; 573 //hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; 574 //hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; 575 } 576 } 577 #endregion 578 579 #region Drag & Drop 580 private void jobsTreeView_DragOver(object sender, DragEventArgs e) { 581 jobsTreeView_DragEnter(sender, e); 582 } 583 584 private void jobsTreeView_DragEnter(object sender, DragEventArgs e) { 585 e.Effect = DragDropEffects.None; 586 var obj = (IDeepCloneable)e.Data.GetData(Constants.DragDropDataFormat); 587 588 Type objType = obj.GetType(); 589 if (ItemTask.IsTypeSupported(objType)) { 590 if (Content.Id != Guid.Empty) e.Effect = DragDropEffects.None; 591 else if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key 592 else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy; 593 } 594 } 595 596 private void jobsTreeView_DragDrop(object sender, DragEventArgs e) { 597 if (e.Effect != DragDropEffects.None) { 598 var obj = (IItem)e.Data.GetData(Constants.DragDropDataFormat); 599 600 IItem newObj = null; 601 if (e.Effect.HasFlag(DragDropEffects.Copy)) { 602 newObj = (IItem)obj.Clone(); 603 } else { 604 newObj = obj; 605 } 606 607 //IOptimizer and IExecutables need some special care 608 if (newObj is IOptimizer) { 609 ((IOptimizer)newObj).Runs.Clear(); 610 } 611 if (newObj is IExecutable) { 612 IExecutable exec = (IExecutable)newObj; 613 if (exec.ExecutionState != ExecutionState.Prepared) { 614 exec.Prepare(); 615 } 616 } 617 618 ItemTask hiveTask = ItemTask.GetItemTaskForItem(newObj); 619 Content.HiveTasks.Add(hiveTask.CreateHiveTask()); 620 } 621 } 622 #endregion 623 624 private void tabControl_SelectedIndexChanged(object sender, EventArgs e) { 625 if (tabControl.SelectedTab == permissionTabPage) { 626 if (!Content.IsSharable) { 627 MessageBox.Show("Unable to load permissions. You have insufficient access privileges.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); 628 tabControl.SelectedTab = tasksTabPage; 629 } 630 } 631 } 632 633 private RunCollection GetAllRunsFromJob(RefreshableJob job) { 634 if (job != null) { 635 RunCollection runs = new RunCollection() { OptimizerName = job.ItemName }; 636 637 foreach (HiveTask subTask in job.HiveTasks) { 638 if (subTask is OptimizerHiveTask) { 639 OptimizerHiveTask ohTask = subTask as OptimizerHiveTask; 640 ohTask.ExecuteReadActionOnItemTask(new Action(delegate () { 641 runs.AddRange(ohTask.ItemTask.Item.Runs); 642 })); 643 } 644 } 645 return runs; 646 } else { 647 return null; 648 } 649 } 650 528 651 } 529 652 }
Note: See TracChangeset
for help on using the changeset viewer.