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