Changeset 15922 for branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views
- Timestamp:
- 04/26/18 16:33:53 (7 years ago)
- Location:
- branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectPermissionsView.Designer.cs
r15576 r15922 31 31 this.splitContainer = new System.Windows.Forms.SplitContainer(); 32 32 this.permissionsGroupBox = new System.Windows.Forms.GroupBox(); 33 this.treeView = new System.Windows.Forms.TreeView();33 this.treeView = new Hive.Views.TreeView.NoDoubleClickTreeView(); 34 34 this.detailsGroupBox = new System.Windows.Forms.GroupBox(); 35 35 this.detailsViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); … … 184 184 private System.Windows.Forms.SplitContainer splitContainer; 185 185 private System.Windows.Forms.GroupBox permissionsGroupBox; 186 private System.Windows.Forms.TreeView treeView;186 private HeuristicLab.Clients.Hive.Views.TreeView.NoDoubleClickTreeView treeView; 187 187 private System.Windows.Forms.GroupBox detailsGroupBox; 188 188 private MainForm.WindowsForms.ViewHost detailsViewHost; -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.Designer.cs
r15576 r15922 30 30 this.splitContainer = new System.Windows.Forms.SplitContainer(); 31 31 this.resourcesGroupBox = new System.Windows.Forms.GroupBox(); 32 this.treeView = new System.Windows.Forms.TreeView();32 this.treeView = new Hive.Views.TreeView.NoDoubleClickTreeView(); 33 33 this.imageList = new System.Windows.Forms.ImageList(this.components); 34 34 this.detailsGroupBox = new System.Windows.Forms.GroupBox(); … … 185 185 private System.Windows.Forms.GroupBox resourcesGroupBox; 186 186 private System.Windows.Forms.GroupBox detailsGroupBox; 187 private System.Windows.Forms.TreeView treeView;187 private HeuristicLab.Clients.Hive.Views.TreeView.NoDoubleClickTreeView treeView; 188 188 private System.Windows.Forms.ImageList imageList; 189 189 private MainForm.WindowsForms.ViewHost detailsViewHost; -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs
r15819 r15922 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 7Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 51 51 private readonly HashSet<Resource> newIncludedResources = new HashSet<Resource>(); 52 52 53 private readonly Dictionary<Guid, HashSet<Project>> projectAncestors = new Dictionary<Guid, HashSet<Project>>();54 private readonly Dictionary<Guid, HashSet<Project>> projectDescendants = new Dictionary<Guid, HashSet<Project>>();55 private readonly Dictionary<Guid, HashSet<Resource>> resourceAncestors = new Dictionary<Guid, HashSet<Resource>>();56 private readonly Dictionary<Guid, HashSet<Resource>> resourceDescendants = new Dictionary<Guid, HashSet<Resource>>();57 58 53 private readonly Color addedAssignmentColor = Color.FromArgb(255, 87, 191, 193); // #57bfc1 59 54 private readonly Color removedAssignmentColor = Color.FromArgb(255, 236, 159, 72); // #ec9f48 … … 83 78 newAssignedResources.Clear(); 84 79 includedResources.Clear(); 85 resourceAncestors.Clear();86 80 treeView.Nodes.Clear(); 87 81 detailsViewHost.Content = null; 88 82 } else { 89 UpdateProjectGenealogy();90 83 UpdateAssignedResources(); 91 Update ResourceGenealogy();84 UpdateIncludedResources(); 92 85 var top = BuildResourceTree(HiveAdminClient.Instance.Resources); 93 86 detailsViewHost.Content = top; … … 111 104 112 105 private void refreshButton_Click(object sender, EventArgs e) { 113 UpdateProjectGenealogy();106 HiveAdminClient.Instance.Refresh(); 114 107 UpdateAssignedResources(); 115 Update ResourceGenealogy();108 UpdateIncludedResources(); 116 109 var top = BuildResourceTree(HiveAdminClient.Instance.Resources); 117 110 detailsViewHost.Content = top; … … 144 137 e.Cancel = true; 145 138 } else if (!HiveRoles.CheckAdminUserPermissions()) { 146 if (! projectAncestors[Content.Id].Any() || projectExclusiveResources.Contains(checkedResource)) {139 if (!HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).Any() || projectExclusiveResources.Contains(checkedResource)) { 147 140 e.Cancel = true; 148 141 } … … 166 159 private void UpdateResourceTree() { 167 160 UpdateAssignedResources(); 168 UpdateResourceGenealogy(); 161 UpdateIncludedResources(); 162 169 163 var top = BuildResourceTree(HiveAdminClient.Instance.Resources); 170 164 detailsViewHost.Content = top; … … 194 188 // look up for assignments of ancestor projects 195 189 var projectIds = new HashSet<Guid>(); 196 if(projectAncestors.ContainsKey(projectId)) { 197 projectAncestors[projectId].ToList().ForEach(x => projectIds.Add(x.Id)); 198 } 190 HiveClient.Instance.GetAvailableProjectAncestors(projectId).ToList().ForEach(x => projectIds.Add(x.Id)); 191 199 192 var ancestorProjectResources = resources.Where(x => 200 193 HiveAdminClient.Instance.ProjectResourceAssignments … … 206 199 HashSet<Resource> availableResources = new HashSet<Resource>(ancestorProjectResources); 207 200 foreach (var r in ancestorProjectResources) { 208 if(resourceDescendants.ContainsKey(r.Id)) { 209 foreach(var d in resourceDescendants[r.Id]) { 210 availableResources.Add(d); 211 } 201 foreach(var d in HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id)) { 202 availableResources.Add(d); 212 203 } 213 204 } … … 222 213 if (projectExclusiveResources.Any()) { 223 214 foreach (var r in projectExclusiveResources.ToArray()) { 224 if (resourceDescendants.ContainsKey(r.Id)) { 225 foreach (var d in resourceDescendants[r.Id]) { 226 projectExclusiveResources.Add(d); 227 } 228 } 215 foreach (var d in HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id)) { 216 projectExclusiveResources.Add(d); 217 } 229 218 } 230 219 } … … 251 240 private void UpdateNewAssignedResources() { 252 241 for(int i = newAssignedResources.Count -1; i >= 0; i--) { 253 if(newAssignedResources.Intersect( resourceAncestors[newAssignedResources.ElementAt(i).Id]).Any()) {242 if(newAssignedResources.Intersect(HiveAdminClient.Instance.GetAvailableResourceAncestors(newAssignedResources.ElementAt(i).Id)).Any()) { 254 243 newAssignedResources.Remove(newAssignedResources.ElementAt(i)); 255 244 } … … 266 255 } 267 256 257 private void UpdateIncludedResources() { 258 includedResources.Clear(); 259 newIncludedResources.Clear(); 260 foreach (var a in assignedResources) { 261 foreach (var r in HiveAdminClient.Instance.GetAvailableResourceDescendants(a.Id)) { 262 includedResources.Add(r); 263 newIncludedResources.Add(r); 264 } 265 } 266 } 267 268 268 private void UpdateNewIncludedResources() { 269 269 newIncludedResources.Clear(); 270 270 foreach (var a in newAssignedResources) { 271 if (resourceDescendants.ContainsKey(a.Id)) { 272 foreach (var r in resourceDescendants[a.Id]) { 273 newIncludedResources.Add(r); 274 } 271 foreach (var r in HiveAdminClient.Instance.GetAvailableResourceDescendants(a.Id)) { 272 newIncludedResources.Add(r); 275 273 } 276 274 } … … 325 323 newNode.Checked = true; 326 324 if(!HiveRoles.CheckAdminUserPermissions()) { 327 if(!projectAncestors[Content.Id].Any() || projectExclusiveResources.Contains(newResource)) { 325 if (!HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).Any() 326 || projectExclusiveResources.Contains(newResource)) { 328 327 newNode.ForeColor = SystemColors.GrayText; 329 328 newNode.Text += IMMUTABLE_TAG; … … 401 400 } 402 401 403 private void UpdateProjectGenealogy() {404 projectAncestors.Clear();405 projectDescendants.Clear();406 var projects = HiveAdminClient.Instance.Projects;407 408 foreach(var p in projects.Where(x => x.Id != Guid.Empty)) {409 projectAncestors.Add(p.Id, new HashSet<Project>());410 projectDescendants.Add(p.Id, new HashSet<Project>());411 }412 413 foreach (var p in projects.Where(x => x.Id != Guid.Empty)) {414 var parentProjectId = p.ParentProjectId;415 while (parentProjectId != null) {416 var parent = projects.SingleOrDefault(x => x.Id == parentProjectId);417 if (parent != null) {418 projectAncestors[p.Id].Add(parent);419 projectDescendants[parent.Id].Add(p);420 parentProjectId = parent.ParentProjectId;421 } else {422 parentProjectId = null;423 }424 }425 }426 }427 428 private void UpdateResourceGenealogy() {429 resourceAncestors.Clear();430 resourceDescendants.Clear();431 var resources = HiveAdminClient.Instance.Resources;432 433 foreach (var r in resources.Where(x => x.Id != Guid.Empty)) {434 resourceAncestors.Add(r.Id, new HashSet<Resource>());435 resourceDescendants.Add(r.Id, new HashSet<Resource>());436 }437 438 foreach (var r in resources.Where(x => x.Id != Guid.Empty)) {439 var parentResourceId = r.ParentResourceId;440 while (parentResourceId != null) {441 var parent = resources.SingleOrDefault(x => x.Id == parentResourceId);442 if (parent != null) {443 resourceAncestors[r.Id].Add(parent);444 resourceDescendants[parent.Id].Add(r);445 parentResourceId = parent.ParentResourceId;446 } else {447 parentResourceId = null;448 }449 }450 }451 452 includedResources.Clear();453 newIncludedResources.Clear();454 foreach (var a in assignedResources) {455 if (resourceDescendants.ContainsKey(a.Id)) {456 foreach (var r in resourceDescendants[a.Id]) {457 includedResources.Add(r);458 newIncludedResources.Add(r);459 }460 }461 }462 }463 464 402 private bool IsAdmin() { 465 403 return HiveRoles.CheckAdminUserPermissions(); -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs
r15813 r15922 54 54 this.btnRemoveGroup = new System.Windows.Forms.Button(); 55 55 this.btnAddGroup = new System.Windows.Forms.Button(); 56 this.treeView = new System.Windows.Forms.TreeView();56 this.treeView = new Hive.Views.TreeView.NoDoubleClickTreeView(); 57 57 this.tabSlaveGroup = new System.Windows.Forms.TabControl(); 58 58 this.tabDetails = new System.Windows.Forms.TabPage(); … … 253 253 private System.Windows.Forms.Button btnRemoveGroup; 254 254 private System.Windows.Forms.Button btnAddGroup; 255 private System.Windows.Forms.TreeView treeView;255 private HeuristicLab.Clients.Hive.Views.TreeView.NoDoubleClickTreeView treeView; 256 256 private System.Windows.Forms.TabControl tabSlaveGroup; 257 257 private System.Windows.Forms.TabPage tabDetails; -
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.