Changeset 15557 for branches/HiveProjectManagement
- Timestamp:
- 12/21/17 10:09:40 (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs
r15422 r15557 301 301 if (!resources.Any()) return null; 302 302 303 var slaveGroups = new HashSet<SlaveGroup>(resources.OfType<SlaveGroup>());304 var s laves = new HashSet<Slave>(resources.OfType<Slave>());305 306 var stack = new Stack<Resource>( slaveGroups.OrderByDescending(x => x.Name));303 var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>().Where(x => x.ParentResourceId == null)); 304 var subResources = new HashSet<Resource>(resources.Except(mainResources)); 305 306 var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name)); 307 307 var top = stack.Peek(); 308 308 … … 310 310 Resource currentResource = null; 311 311 312 while 312 while(stack.Any()) { 313 313 var newResource = stack.Pop(); 314 314 var newNode = new TreeNode(newResource.Name) { Tag = newResource }; 315 315 316 while (currentNode != null && newResource.ParentResourceId != currentResource.Id) { 316 // search for parent node of newNode and save in currentNode 317 // necessary since newNodes (stack top items) might be siblings 318 // or grand..grandparents of previous node (currentNode) 319 while(currentNode != null && newResource.ParentResourceId != currentResource.Id) { 317 320 currentNode = currentNode.Parent; 318 321 currentResource = currentNode == null ? null : (Resource)currentNode.Tag; 319 322 } 320 323 321 if 324 if(currentNode == null) { 322 325 treeView.Nodes.Add(newNode); 323 326 } else { … … 325 328 } 326 329 327 if 330 if(newResource is Slave) { 328 331 newNode.ImageIndex = slaveImageIndex; 329 332 } else { 330 333 newNode.ImageIndex = slaveGroupImageIndex; 331 334 332 var childSlaves = slaves.Where(x => x.ParentResourceId == newResource.Id); 333 foreach (var slave in childSlaves.OrderBy(x => x.Name)) { 334 slaves.Remove(slave); 335 var slaveNode = new TreeNode(slave.Name) { Tag = slave }; 336 337 slaveNode.SelectedImageIndex = slaveNode.ImageIndex = slaveImageIndex; 338 if (slave.OwnerUserId == UserInformation.Instance.User.Id) 339 slaveNode.BackColor = ownedResourceColor; 340 341 newNode.Nodes.Add(slaveNode); 342 } 343 344 var childSlaveGroups = slaveGroups.Where(x => x.ParentResourceId == newResource.Id); 345 if (childSlaveGroups.Any()) { 346 foreach (var slaveGroup in childSlaveGroups.OrderByDescending(x => x.Name)) { 347 slaveGroups.Remove(slaveGroup); 348 stack.Push(slaveGroup); 335 var childResources = subResources.Where(x => x.ParentResourceId == newResource.Id); 336 if(childResources.Any()) { 337 foreach(var resource in childResources.OrderByDescending(x => x.Name)) { 338 subResources.Remove(resource); 339 stack.Push(resource); 349 340 } 350 341 currentNode = newNode; … … 352 343 } 353 344 } 354 355 345 newNode.SelectedImageIndex = newNode.ImageIndex; 356 346 if (newResource.OwnerUserId == UserInformation.Instance.User.Id) … … 366 356 }; 367 357 368 foreach (var slave in s laves.OrderBy(x => x.Name)) {358 foreach (var slave in subResources.OfType<Slave>().OrderBy(x => x.Name)) { 369 359 var slaveNode = new TreeNode(slave.Name) { Tag = slave }; 370 360 ungroupedNode.Nodes.Add(slaveNode);
Note: See TracChangeset
for help on using the changeset viewer.