Changeset 15995 for branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views
- Timestamp:
- 07/19/18 13:37:32 (6 years ago)
- Location:
- branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.Designer.cs
r15978 r15995 165 165 this.resourcesTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.resourcesTreeView_AfterCheck); 166 166 this.resourcesTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.resourcesTreeView_MouseDown); 167 this.resourcesTreeView.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.resourcesTreeView_BeforeSelect); 167 168 // 168 169 // summaryGroupBox -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs
r15992 r15995 53 53 private const string REMOVED_INCLUDE_TAG = " [removed include]"; 54 54 55 private TreeNode additionalNode; 56 55 57 private readonly HashSet<TreeNode> mainTreeNodes = new HashSet<TreeNode>(); 56 58 private readonly HashSet<TreeNode> filteredTreeNodes = new HashSet<TreeNode>(); 57 private readonly HashSet<TreeNode> nodeStore = new HashSet<TreeNode>();58 59 59 60 private readonly HashSet<Resource> availableResources = new HashSet<Resource>(); … … 262 263 var node = resourcesTreeView.GetNodeAt(new Point(e.X, e.Y)); 263 264 264 if (node == null ) {265 if (node == null || node == additionalNode) { 265 266 resourcesTreeView.SelectedNode = null; 266 267 ExtractStatistics(); 267 268 } else { 268 ExtractStatistics((Resource)node.Tag); 269 } 269 var r = (Resource)node.Tag; 270 if (!HiveClient.Instance.DisabledParentResources.Contains(r)) { 271 ExtractStatistics((Resource)node.Tag); 272 } else { 273 resourcesTreeView.SelectedNode = null; 274 ExtractStatistics(); 275 } 276 } 277 } 278 279 private void resourcesTreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e) { 280 if(e.Node == null || e.Node == additionalNode) { 281 e.Cancel = true; 282 } else { 283 var r = (Resource)e.Node.Tag; 284 if(r == null || HiveClient.Instance.DisabledParentResources.Contains(r)) { 285 e.Cancel = true; 286 } 287 } 288 270 289 } 271 290 272 291 private void resourcesTreeView_BeforeCheck(object sender, TreeViewCancelEventArgs e) { 273 var checkedResource = (Resource)e.Node.Tag; 274 if (newIncludedResources.Contains(checkedResource) || checkedResource.Id == Guid.Empty) { 292 if(e.Node == null || e.Node == additionalNode) { 275 293 e.Cancel = true; 276 ExtractStatistics((Resource)resourcesTreeView.SelectedNode?.Tag); 294 } else { 295 var checkedResource = (Resource)e.Node.Tag; 296 if (checkedResource == null 297 || checkedResource.Id == Guid.Empty 298 || HiveClient.Instance.DisabledParentResources.Contains(checkedResource) 299 || newIncludedResources.Contains(checkedResource)) { 300 e.Cancel = true; 301 ExtractStatistics((Resource)resourcesTreeView.SelectedNode?.Tag); 302 } 277 303 } 278 304 } … … 330 356 // && !projects.SelectMany(y => HiveClient.Instance.ProjectAncestors[y.Id]).Contains(x.ParentProjectId.Value))); 331 357 //mainProjects.UnionWith(parentedMainProjects); 332 var mainDisabledParentProjects = new HashSet<Project>(disabledParentProjects.Where(x => x.ParentProjectId == null ));358 var mainDisabledParentProjects = new HashSet<Project>(disabledParentProjects.Where(x => x.ParentProjectId == null || x.ParentProjectId == Guid.Empty)); 333 359 mainProjects.UnionWith(mainDisabledParentProjects); 334 360 var subProbjects = new HashSet<Project>(projects.Union(disabledParentProjects).Except(mainProjects)); … … 518 544 resourcesTreeView.AfterCheck -= resourcesTreeView_AfterCheck; 519 545 546 var disabledParentResources = HiveClient.Instance.DisabledParentResources; 520 547 var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>().Where(x => x.ParentResourceId == null)); 521 var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>() 522 .Where(x => x.ParentResourceId.HasValue && !resources.Select(y => y.Id).Contains(x.ParentResourceId.Value))); 523 mainResources.UnionWith(parentedMainResources); 524 var subResources = new HashSet<Resource>(resources.Except(mainResources)); 548 //var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>() 549 // .Where(x => x.ParentResourceId.HasValue && !resources.Select(y => y.Id).Contains(x.ParentResourceId.Value))); 550 //mainResources.UnionWith(parentedMainResources); 551 //var subResources = new HashSet<Resource>(resources.Except(mainResources)); 552 var mainDisabledParentResources = new HashSet<Resource>(disabledParentResources.Where(x => x.ParentResourceId == null || x.ParentResourceId == Guid.Empty)); 553 mainResources.UnionWith(mainDisabledParentResources); 554 var subResources = new HashSet<Resource>(resources.Union(disabledParentResources).Except(mainResources).OrderByDescending(x => x.Name)); 525 555 526 556 var addedAssignments = newAssignedResources.Except(assignedResources); … … 552 582 } 553 583 554 if (newAssignedResources.Select(x => x.Id).Contains(newResource.Id)) { 584 if (disabledParentResources.Contains(newResource)) { 585 newNode.Checked = false; 586 newNode.ForeColor = grayTextColor; 587 } else if (newAssignedResources.Select(x => x.Id).Contains(newResource.Id)) { 555 588 newNode.Checked = true; 556 589 if(!addedAssignments.Select(x => x.Id).Contains(newResource.Id) && !removedAssignments.Select(x => x.Id).Contains(newResource.Id)) { … … 604 637 if (singleSlaves.Any()) { 605 638 606 varadditionalNode = new TreeNode(additionalSlavesGroupName) {639 additionalNode = new TreeNode(additionalSlavesGroupName) { 607 640 ForeColor = SystemColors.GrayText, 608 641 Tag = new SlaveGroup() { … … 693 726 var p = (Project)n.Tag; 694 727 if(HiveClient.Instance.DisabledParentProjects.Select(x => x.Id).Contains(p.Id)) { 728 n.Checked = false; 729 n.ForeColor = grayTextColor; 730 } 731 } else if(n.Tag is Resource) { 732 var r = (Resource)n.Tag; 733 if(HiveClient.Instance.DisabledParentResources.Select(x => x.Id).Contains(r.Id) || n == additionalNode) { 734 n.Checked = false; 695 735 n.ForeColor = grayTextColor; 696 736 } … … 725 765 n.ForeColor = Color.Black; 726 766 n.Checked = false; 767 768 if (HiveClient.Instance.DisabledParentResources.Select(x => x.Id).Contains(resource.Id) || n == additionalNode) { 769 n.ForeColor = grayTextColor; 770 } 727 771 728 772 // add additional info
Note: See TracChangeset
for help on using the changeset viewer.