Changeset 15922 for branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs
- Timestamp:
- 04/26/18 16:33:53 (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs
r15819 r15922 231 231 }; 232 232 233 HiveAdminClient.Instance.UpdateResourceGenealogy(Content);233 //HiveAdminClient.Instance.UpdateResourceGenealogy(Content); 234 234 SelectedResource = group; 235 235 Content.Add(group); … … 322 322 } 323 323 324 HiveAdminClient.Instance.UpdateResourceGenealogy(Content); 324 // TODO 325 //HiveAdminClient.Instance.UpdateResourceGenealogy(Content); 325 326 OnContentChanged(); 326 327 } … … 486 487 private void CollapseSlaveOnlyNodes(TreeNode tn) { 487 488 Resource r = (Resource)tn.Tag; 488 var descendants = HiveAdminClient.Instance.ResourceDescendants;489 var descendants = GetResourceDescendants(); 489 490 if(descendants.ContainsKey(r.Id)) { 490 491 if(descendants[r.Id].OfType<SlaveGroup>().Any()) { … … 493 494 } else { 494 495 tn.Collapse(); 496 } 497 } 498 } 499 500 private void ExpandResourceNodesOfInterest(TreeNodeCollection nodes) { 501 foreach (TreeNode n in nodes) { 502 Resource r = (Resource)n.Tag; 503 if (n.Nodes.Count > 0) { 504 if (HiveClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any()) { 505 n.Expand(); 506 ExpandResourceNodesOfInterest(n.Nodes); 507 } else { 508 n.Collapse(); 509 } 510 } else { 511 n.Collapse(); 495 512 } 496 513 } … … 560 577 int childSlavesCount = 0; 561 578 if (r.Id != Guid.Empty && r is SlaveGroup) { 562 var descendants = HiveAdminClient.Instance.ResourceDescendants;579 var descendants = GetResourceDescendants(); 563 580 if (descendants.ContainsKey(r.Id)) { 564 581 childSlavesCount = resources 565 582 .OfType<Slave>() 566 583 .Where(x => descendants[r.Id].Select(y => y.Id) 567 .Contains(x.Id))584 .Contains(x.Id)) 568 585 .Count(); 569 586 } … … 659 676 } 660 677 678 679 private Dictionary<Guid, HashSet<Resource>> GetResourceDescendants() { 680 var resourceDescendants = new Dictionary<Guid, HashSet<Resource>>(); 681 682 foreach (var r in Content) resourceDescendants.Add(r.Id, new HashSet<Resource>()); 683 foreach(var r in Content) { 684 var parentResourceId = r.ParentResourceId; 685 while(parentResourceId != null) { 686 var parent = Content.SingleOrDefault(x => x.Id == parentResourceId); 687 if(parent != null) { 688 resourceDescendants[parent.Id].Add(r); 689 parentResourceId = parent.ParentResourceId; 690 } else { 691 parentResourceId = null; 692 } 693 } 694 } 695 return resourceDescendants; 696 } 697 661 698 #endregion 662 699 }
Note: See TracChangeset
for help on using the changeset viewer.