- Timestamp:
- 10/08/18 15:32:53 (6 years ago)
- Location:
- trunk/HeuristicLab.Clients.Hive.JobManager/3.3/Views
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs
r16205 r16219 26 26 using System.Windows.Forms; 27 27 using HeuristicLab.Collections; 28 using HeuristicLab.Common; 28 29 using HeuristicLab.Common.Resources; 29 30 using HeuristicLab.Core; … … 637 638 additionalNode = new TreeNode(additionalSlavesGroupName) { 638 639 ForeColor = SystemColors.GrayText, 640 ImageIndex = slaveGroupImageIndex, 639 641 Tag = new SlaveGroup() { 640 642 Name = additionalSlavesGroupName, … … 645 647 foreach (var slave in singleSlaves.OrderBy(x => x.Name)) { 646 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 647 668 additionalNode.Nodes.Add(slaveNode); 648 669 } … … 661 682 Resource r = (Resource)n.Tag; 662 683 if(n.Nodes.Count > 0) { 663 if(HiveClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any() 664 || HiveClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<Slave>().Intersect(assignedResources.Union(newAssignedResources)).Any()) { 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))) { 665 687 n.Expand(); 666 688 ExpandResourceNodesOfInterest(n.Nodes); -
trunk/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
r16209 r16219 141 141 // project look up 142 142 if (Content.Job != null && Content.Job.ProjectId == Guid.Empty) { 143 projectNameTextBox.Text = string.Empty; 143 144 if (HiveClient.Instance != null && HiveClient.Instance.Projects != null && HiveClient.Instance.Projects.Count == 1) { 144 145 var p = HiveClient.Instance.Projects.FirstOrDefault(); … … 146 147 hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId); 147 148 Content.Job.ProjectId = p.Id; 148 Content.Job.ResourceIds = HiveClient.Instance.GetAvailableResourcesForProject(p.Id).Select(x => x.Id).ToList(); 149 var resources = HiveClient.Instance.GetAvailableResourcesForProject(p.Id).ToList(); 150 Content.Job.ResourceIds = resources.Select(x => x.Id).ToList(); 149 151 hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; 150 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)"; 151 161 } 152 162 } … … 155 165 selectedProject = GetProject(Content.Job.ProjectId); 156 166 hiveResourceSelectorDialog = null; 157 if (selectedProject != null) {158 projectNameTextBox.Text = selectedProject.Name;159 } else {160 projectNameTextBox.Text = string.Empty;161 }162 167 } 163 168 … … 165 170 hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId); 166 171 167 if (Content.Job.ResourceIds == null) { 168 Content.Job.ResourceIds = HiveClient.Instance.GetAssignedResourcesForJob(Content.Job.Id) 169 .Select(x => x.Id) 170 .ToList(); 171 hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; 172 if (selectedProject != null) { 173 projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(selectedProject.Id); 174 } else { 175 projectNameTextBox.Text = string.Empty; 172 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)"; 173 193 174 194 } else { … … 192 212 SuppressEvents = false; 193 213 } 194 hiveExperimentPermissionListView.Content = null; // has to be filled by refresh button214 hiveExperimentPermissionListView.Content = null; // has to be filled by refresh 195 215 Content_JobStatisticsChanged(this, EventArgs.Empty); 196 216 Content_HiveExperimentChanged(this, EventArgs.Empty); … … 410 430 if (hiveResourceSelectorDialog.ShowDialog(this) == DialogResult.OK) { 411 431 selectedProject = hiveResourceSelectorDialog.SelectedProject; 412 if(selectedProject != null) { 413 projectNameTextBox.Text = selectedProject.Name; 432 if(selectedProject != null) { 414 433 Content.Job.ProjectId = selectedProject.Id; 415 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 416 446 } else { 417 447 selectedProject = null;
Note: See TracChangeset
for help on using the changeset viewer.