Changeset 15995 for branches/2839_HiveProjectManagement
- Timestamp:
- 07/19/18 13:37:32 (6 years ago)
- Location:
- branches/2839_HiveProjectManagement
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.Designer.cs
r15953 r15995 123 123 this.treeView.BeforeCheck += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeView_BeforeCheck); 124 124 this.treeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterCheck); 125 this.treeView.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeView_BeforeSelect); 125 126 this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect); 126 127 // -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs
r15978 r15995 55 55 private readonly Color addedIncludeColor = Color.FromArgb(25, 169, 221, 221); // #a9dddd 56 56 private readonly Color removedIncludeColor = Color.FromArgb(25, 249, 210, 145); // #f9d291 57 private readonly Color selectedBackColor = Color.DodgerBlue; 58 private readonly Color selectedForeColor = Color.White; 59 private readonly Color grayTextColor = SystemColors.GrayText; 57 60 58 61 private HashSet<Resource> projectExclusiveResources = new HashSet<Resource>(); … … 83 86 UpdateAssignedResources(); 84 87 UpdateIncludedResources(); 85 var top = BuildResourceTree( HiveAdminClient.Instance.Resources);88 var top = BuildResourceTree(); 86 89 detailsViewHost.Content = top; 87 90 detailsViewHost.Locked = true; … … 108 111 UpdateAssignedResources(); 109 112 UpdateIncludedResources(); 110 var top = BuildResourceTree( HiveAdminClient.Instance.Resources);113 var top = BuildResourceTree(); 111 114 detailsViewHost.Content = top; 112 115 } … … 130 133 } 131 134 135 private void treeView_BeforeSelect(object sender, TreeViewCancelEventArgs e) { 136 if (e.Node == null || e.Node == ungroupedGroupNode) 137 e.Cancel = true; 138 139 var selectedResource = (Resource)e.Node.Tag; 140 if(HiveAdminClient.Instance.DisabledParentResources.Contains(selectedResource)) 141 e.Cancel = true; 142 } 143 132 144 private void treeView_AfterSelect(object sender, TreeViewEventArgs e) { 133 145 var selectedResource = (Resource)e.Node.Tag; … … 136 148 137 149 private void treeView_BeforeCheck(object sender, TreeViewCancelEventArgs e) { 150 if (e.Node == null || e.Node == ungroupedGroupNode) { 151 e.Cancel = true; 152 return; 153 } 154 138 155 var checkedResource = (Resource)e.Node.Tag; 139 if (newIncludedResources.Contains(checkedResource) || checkedResource.Id == Guid.Empty || e.Node == ungroupedGroupNode) { 156 if (checkedResource == null 157 || checkedResource.Id == Guid.Empty 158 || HiveAdminClient.Instance.DisabledParentResources.Contains(checkedResource) 159 || newIncludedResources.Contains(checkedResource)) { 140 160 e.Cancel = true; 141 161 } else if (!HiveRoles.CheckAdminUserPermissions()) { … … 164 184 UpdateIncludedResources(); 165 185 166 var top = BuildResourceTree( HiveAdminClient.Instance.Resources);186 var top = BuildResourceTree(); 167 187 detailsViewHost.Content = top; 168 188 } … … 171 191 UpdateNewAssignedResources(); 172 192 UpdateNewIncludedResources(); 173 var top = BuildResourceTree( HiveAdminClient.Instance.Resources);193 var top = BuildResourceTree(); 174 194 detailsViewHost.Content = top; 175 195 } … … 191 211 // look up for assignments of ancestor projects 192 212 var projectIds = new HashSet<Guid>(); 193 Hive Client.Instance.GetAvailableProjectAncestors(projectId).ToList().ForEach(x => projectIds.Add(x.Id));213 HiveAdminClient.Instance.GetAvailableProjectAncestors(projectId).ToList().ForEach(x => projectIds.Add(x.Id)); 194 214 195 215 var ancestorProjectResources = resources.Where(x => … … 278 298 } 279 299 280 private Resource BuildResourceTree( IEnumerable<Resource> resources) {300 private Resource BuildResourceTree() { 281 301 treeView.Nodes.Clear(); 282 if (!resources.Any()) return null;283 302 284 303 treeView.BeforeCheck -= treeView_BeforeCheck; 285 304 treeView.AfterCheck -= treeView_AfterCheck; 286 305 287 resources = GetAvailableResourcesForProjectAdministration(Content.Id); 288 306 var resources = GetAvailableResourcesForProjectAdministration(Content.Id); 307 308 var disabledParentResources = HiveAdminClient.Instance.DisabledParentResources; 289 309 var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>().Where(x => x.ParentResourceId == null)); 290 var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>() 291 .Where(x => x.ParentResourceId.HasValue && !resources.Select(y => y.Id).Contains(x.ParentResourceId.Value))); 292 mainResources.UnionWith(parentedMainResources); 293 var subResources = new HashSet<Resource>(resources.Except(mainResources)); 310 //var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>() 311 // .Where(x => x.ParentResourceId.HasValue && !resources.Select(y => y.Id).Contains(x.ParentResourceId.Value))); 312 //mainResources.UnionWith(parentedMainResources); 313 var mainDisabledParentResources = new HashSet<Resource>(disabledParentResources.Where(x => x.ParentResourceId == null || x.ParentResourceId == Guid.Empty)); 314 mainResources.UnionWith(mainDisabledParentResources); 315 var subResources = new HashSet<Resource>(resources.Union(disabledParentResources).Except(mainResources).OrderByDescending(x => x.Name)); 294 316 295 317 var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name)); 318 296 319 Resource top = null; 320 //bool nodeSelected = false; 321 if (detailsViewHost != null && detailsViewHost.Content != null && detailsViewHost.Content is Resource) { 322 var resourceId = ((Resource)detailsViewHost.Content).Id; 323 top = resources.Where(x => x.Id == resourceId).FirstOrDefault(); 324 } 325 297 326 298 327 TreeNode currentNode = null; … … 305 334 306 335 while (stack.Any()) { 307 if(top == null) top = stack.Peek();308 336 var newResource = stack.Pop(); 309 337 var newNode = new TreeNode(newResource.Name) { Tag = newResource }; 338 339 if(top == null && !disabledParentResources.Contains(newResource)) { 340 top = newResource; 341 } 342 343 //if(!nodeSelected && top != null && newResource.Id == top.Id) { 344 // newNode.BackColor = selectedBackColor; 345 // newNode.ForeColor = selectedForeColor; 346 // nodeSelected = true; 347 //} 310 348 311 349 // search for parent node of newNode and save in currentNode … … 323 361 } 324 362 325 if (newAssignedResources.Contains(newResource)) { 363 if (disabledParentResources.Contains(newResource)) { 364 newNode.Checked = false; 365 newNode.ForeColor = grayTextColor; 366 } else if (newAssignedResources.Contains(newResource)) { 326 367 newNode.Checked = true; 327 368 if(!HiveRoles.CheckAdminUserPermissions()) { … … 398 439 treeView.BeforeCheck += treeView_BeforeCheck; 399 440 treeView.AfterCheck += treeView_AfterCheck; 400 treeView.ExpandAll(); 441 442 ExpandResourceNodesOfInterest(treeView.Nodes); 401 443 402 444 return top; 445 } 446 447 private void ExpandResourceNodesOfInterest(TreeNodeCollection nodes) { 448 foreach (TreeNode n in nodes) { 449 Resource r = (Resource)n.Tag; 450 if (n.Nodes.Count > 0) { 451 if (HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any()) { 452 n.Expand(); 453 ExpandResourceNodesOfInterest(n.Nodes); 454 } else { 455 n.Collapse(); 456 } 457 } else { 458 n.Collapse(); 459 } 460 } 403 461 } 404 462 -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs
r15992 r15995 46 46 private readonly Color selectedBackColor = Color.DodgerBlue; 47 47 private readonly Color selectedForeColor = Color.White; 48 private readonly Color grayTextColor = SystemColors.GrayText; 48 49 49 50 private Project selectedProject = null; … … 293 294 private void projectsTreeView_MouseDown(object sender, MouseEventArgs e) { 294 295 var node = projectsTreeView.GetNodeAt(e.Location); 295 if(node != null) ChangeSelectedProjectNode(node); 296 if (node == null) return; 297 var p = (Project)node.Tag; 298 if(!HiveAdminClient.Instance.DisabledParentProjects.Contains(p)) ChangeSelectedProjectNode(node); 296 299 } 297 300 … … 378 381 if (!projects.Any()) return; 379 382 383 var disabledParentProjects = HiveAdminClient.Instance.DisabledParentProjects; 380 384 var mainProjects = new HashSet<Project>(projects.Where(x => x.ParentProjectId == null)); 381 var parentedMainProjects = new HashSet<Project>(projects 382 .Where(x => x.ParentProjectId.HasValue 383 && !projects.Select(y => y.Id).Contains(x.ParentProjectId.Value))); 384 mainProjects.UnionWith(parentedMainProjects); 385 var subProbjects = new HashSet<Project>(projects.Except(mainProjects)); 385 //var parentedMainProjects = new HashSet<Project>(projects 386 // .Where(x => x.ParentProjectId.HasValue 387 // && !projects.Select(y => y.Id).Contains(x.ParentProjectId.Value))); 388 //mainProjects.UnionWith(parentedMainProjects); 389 var mainDisabledParentProjects = new HashSet<Project>(disabledParentProjects.Where(x => x.ParentProjectId == null || x.ParentProjectId == Guid.Empty)); 390 mainProjects.UnionWith(mainDisabledParentProjects); 391 var subProbjects = new HashSet<Project>(projects.Union(disabledParentProjects).Except(mainProjects)); 386 392 387 393 var stack = new Stack<Project>(mainProjects.OrderByDescending(x => x.Name)); … … 397 403 StyleTreeNode(newNode, newProject); 398 404 399 if (selectedProject == null ) {405 if (selectedProject == null && !disabledParentProjects.Contains(newProject)) { 400 406 SelectedProject = newProject; 401 407 } 402 if ( newProject.Id == selectedProject.Id && !nodeSelected) {408 if (!nodeSelected && selectedProject != null && selectedProject.Id == newProject.Id) { 403 409 newNode.BackColor = selectedBackColor; 404 410 newNode.ForeColor = selectedForeColor; … … 424 430 425 431 newNode.SelectedImageIndex = newNode.ImageIndex; 432 433 if (disabledParentProjects.Contains(newProject)) { 434 newNode.Checked = false; 435 newNode.ForeColor = grayTextColor; 436 } 426 437 427 438 var childProjects = subProbjects.Where(x => x.ParentProjectId == newProject.Id); … … 444 455 n.ForeColor = Color.Black; 445 456 446 if (p.Id == Guid.Empty) { 457 if (HiveAdminClient.Instance.DisabledParentProjects.Select(x => x.Id).Contains(p.Id)) { 458 n.ForeColor = grayTextColor; 459 } else if (p.Id == Guid.Empty) { 447 460 n.Text += NOT_STORED_TAG; 448 461 } else if (p.Modified) { -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs
r15978 r15995 51 51 private readonly Color calculatingColor = Color.FromArgb(255, 58, 114, 35); // #3a7223 52 52 private readonly Color offlineColor = Color.FromArgb(255, 187, 36, 36); // #bb2424 53 private readonly Color grayTextColor = SystemColors.GrayText; 53 54 54 55 … … 301 302 private void treeSlaveGroup_MouseDown(object sender, MouseEventArgs e) { 302 303 var node = treeView.GetNodeAt(e.Location); 303 if(node != null && node != ungroupedGroupNode) ChangeSelectedResourceNode(node); 304 if (node == null || node == ungroupedGroupNode) return; 305 var r = (Resource)node.Tag; 306 if(!HiveAdminClient.Instance.DisabledParentResources.Contains(r)) ChangeSelectedResourceNode(node); 304 307 } 305 308 … … 311 314 if(e.Node == ungroupedGroupNode) { 312 315 e.Cancel = true; 316 } else { 317 var r = (Resource)e.Node.Tag; 318 if(HiveAdminClient.Instance.DisabledParentResources.Contains(r)) { 319 e.Cancel = true; 320 } 313 321 } 314 322 } … … 395 403 if (!resources.Any()) return; 396 404 405 var disabledParentResources = HiveAdminClient.Instance.DisabledParentResources; 397 406 var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>() 398 407 .Where(x => x.ParentResourceId == null)); 399 var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>() 400 .Where(x => x.ParentResourceId.HasValue && !resources.Select(y => y.Id).Contains(x.ParentResourceId.Value))); 401 mainResources.UnionWith(parentedMainResources); 402 var subResources = new HashSet<Resource>(resources.Except(mainResources).OrderByDescending(x => x.Name)); 408 //var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>() 409 // .Where(x => x.ParentResourceId.HasValue && !resources.Select(y => y.Id).Contains(x.ParentResourceId.Value))); 410 //mainResources.UnionWith(parentedMainResources); 411 var mainDisabledParentResources = new HashSet<Resource>(disabledParentResources.Where(x => x.ParentResourceId == null || x.ParentResourceId == Guid.Empty)); 412 mainResources.UnionWith(mainDisabledParentResources); 413 var subResources = new HashSet<Resource>(resources.Union(disabledParentResources).Except(mainResources).OrderByDescending(x => x.Name)); 403 414 404 415 var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name)); … … 414 425 StyleTreeNode(newNode, newResource, resources); 415 426 416 if (selectedResource == null ) {427 if (selectedResource == null && !disabledParentResources.Contains(newResource)) { 417 428 SelectedResource = newResource; 418 429 } 419 if ( newResource.Id == selectedResource.Id && !nodeSelected) {430 if (!nodeSelected && selectedResource != null && newResource.Id == selectedResource.Id) { 420 431 newNode.BackColor = selectedBackColor; 421 432 newNode.ForeColor = selectedForeColor; 422 433 newNode.Text += SELECTED_TAG; 423 434 nodeSelected = true; 435 } 436 437 if(disabledParentResources.Contains(newResource)) { 438 newNode.Checked = false; 439 newNode.ForeColor = grayTextColor; 424 440 } 425 441 … … 505 521 Resource r = (Resource)n.Tag; 506 522 if (n.Nodes.Count > 0) { 507 if (Hive Client.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any()) {523 if (HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any()) { 508 524 n.Expand(); 509 525 ExpandResourceNodesOfInterest(n.Nodes); … … 570 586 n.ForeColor = Color.Black; 571 587 572 // not stored (i.e. new), changed 573 if (r.Id == Guid.Empty && n != ungroupedGroupNode /*!r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) { 588 if(HiveAdminClient.Instance.DisabledParentResources.Select(x => x.Id).Contains(r.Id)) { 589 n.ForeColor = grayTextColor; 590 } else if (r.Id == Guid.Empty && n != ungroupedGroupNode /*!r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) { 591 // not stored (i.e. new) 574 592 n.Text += NOT_STORED_TAG; 575 593 } else if (r.Modified && n != ungroupedGroupNode /*!r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) { 594 // changed 576 595 n.Text += CHANGES_NOT_STORED_TAG; 577 596 } … … 682 701 private Dictionary<Guid, HashSet<Resource>> GetResourceDescendants() { 683 702 var resourceDescendants = new Dictionary<Guid, HashSet<Resource>>(); 684 685 foreach (var r in Content) resourceDescendants.Add(r.Id, new HashSet<Resource>()); 686 foreach(var r in Content) { 703 var resources = Content.Union(HiveAdminClient.Instance.DisabledParentResources).ToList(); 704 705 foreach (var r in resources) resourceDescendants.Add(r.Id, new HashSet<Resource>()); 706 foreach(var r in resources) { 687 707 var parentResourceId = r.ParentResourceId; 688 708 while(parentResourceId != null) { 689 var parent = Content.SingleOrDefault(x => x.Id == parentResourceId);709 var parent = resources.SingleOrDefault(x => x.Id == parentResourceId); 690 710 if(parent != null) { 691 711 resourceDescendants[parent.Id].Add(r); -
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 -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveAdminClient.cs
r15969 r15995 98 98 get { return resourceDescendants; } 99 99 } 100 101 private Dictionary<Guid, string> projectNames; 102 public Dictionary<Guid, string> ProjectNames { 103 get { return projectNames; } 104 } 105 106 private HashSet<Project> disabledParentProjects; 107 public HashSet<Project> DisabledParentProjects { 108 get { return disabledParentProjects; } 109 } 110 111 private Dictionary<Guid, string> resourceNames; 112 public Dictionary<Guid, string> ResourceNames { 113 get { return resourceNames; } 114 } 115 116 private HashSet<Resource> disabledParentResources; 117 public HashSet<Resource> DisabledParentResources { 118 get { return disabledParentResources; } 119 } 100 120 #endregion 101 121 … … 124 144 projectResourceAssignments = new ItemList<AssignedProjectResource>(); 125 145 jobs = new Dictionary<Guid, HiveItemCollection<Job>>(); 146 projectNames = new Dictionary<Guid, string>(); 147 resourceNames = new Dictionary<Guid, string>(); 126 148 127 149 projectAncestors = new Dictionary<Guid, HashSet<Guid>>(); … … 145 167 unsortedJobs.Where(j => j.State == JobState.StatisticsPending).ToList().ForEach(j => jobs[j.ProjectId].Add(j)); 146 168 unsortedJobs.Where(j => j.State == JobState.Online).ToList().ForEach(j => jobs[j.ProjectId].Add(j)); 169 170 projectNames = service.GetProjectNames(); 171 resourceNames = service.GetResourceNames(); 147 172 } 148 173 }); … … 150 175 UpdateResourceGenealogy(); 151 176 UpdateProjectGenealogy(); 177 RefreshDisabledParentProjects(); 178 RefreshDisabledParentResources(); 152 179 } 153 180 catch { … … 244 271 projectDescendants[ancestor].Add(pa.Key); 245 272 } 273 } 274 } 275 276 private void RefreshDisabledParentProjects() { 277 disabledParentProjects = new HashSet<Project>(); 278 279 foreach (var pid in projects 280 .Where(x => x.ParentProjectId.HasValue) 281 .SelectMany(x => projectAncestors[x.Id]).Distinct() 282 .Where(x => !projects.Select(y => y.Id).Contains(x))) { 283 var p = new Project(); 284 p.Id = pid; 285 p.ParentProjectId = projectAncestors[pid].FirstOrDefault(); 286 p.Name = projectNames[pid]; 287 disabledParentProjects.Add(p); 288 } 289 } 290 291 private void RefreshDisabledParentResources() { 292 disabledParentResources = new HashSet<Resource>(); 293 294 foreach (var rid in resources 295 .Where(x => x.ParentResourceId.HasValue) 296 .SelectMany(x => resourceAncestors[x.Id]).Distinct() 297 .Where(x => !resources.Select(y => y.Id).Contains(x))) { 298 var r = new SlaveGroup(); 299 r.Id = rid; 300 r.ParentResourceId = resourceAncestors[rid].FirstOrDefault(); 301 r.Name = resourceNames[rid]; 302 disabledParentResources.Add(r); 246 303 } 247 304 } -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r15992 r15995 97 97 } 98 98 99 private Dictionary<Guid, string> resourceNames; 100 public Dictionary<Guid, string> ResourceNames { 101 get { return resourceNames; } 102 } 103 104 private HashSet<Resource> disabledParentResources; 105 public HashSet<Resource> DisabledParentResources { 106 get { return disabledParentResources; } 107 } 108 99 109 private List<Plugin> onlinePlugins; 100 110 public List<Plugin> OnlinePlugins { … … 137 147 jobs = new HiveItemCollection<RefreshableJob>(); 138 148 projectNames = new Dictionary<Guid, string>(); 149 resourceNames = new Dictionary<Guid, string>(); 139 150 140 151 projectAncestors = new Dictionary<Guid, HashSet<Guid>>(); … … 149 160 service.GetJobs().ForEach(p => jobs.Add(new RefreshableJob(p))); 150 161 projectNames = service.GetProjectNames(); 162 resourceNames = service.GetResourceNames(); 151 163 }); 152 164 … … 154 166 RefreshProjectGenealogy(); 155 167 RefreshDisabledParentProjects(); 168 RefreshDisabledParentResources(); 156 169 } 157 170 catch { … … 173 186 projectNames = new Dictionary<Guid, string>(); 174 187 resources = new ItemList<Resource>(); 188 resourceNames = new Dictionary<Guid, string>(); 175 189 176 190 projectAncestors = new Dictionary<Guid, HashSet<Guid>>(); … … 184 198 service.GetSlaves().ForEach(s => resources.Add(s)); 185 199 projectNames = service.GetProjectNames(); 200 resourceNames = service.GetResourceNames(); 186 201 }); 187 202 … … 189 204 RefreshProjectGenealogy(); 190 205 RefreshDisabledParentProjects(); 206 RefreshDisabledParentResources(); 191 207 } catch { 192 208 projects = null; … … 266 282 p.Name = projectNames[pid]; 267 283 disabledParentProjects.Add(p); 284 } 285 } 286 287 private void RefreshDisabledParentResources() { 288 disabledParentResources = new HashSet<Resource>(); 289 290 foreach (var rid in resources 291 .Where(x => x.ParentResourceId.HasValue) 292 .SelectMany(x => resourceAncestors[x.Id]).Distinct() 293 .Where(x => !resources.Select(y => y.Id).Contains(x))) { 294 var r = new SlaveGroup(); 295 r.Id = rid; 296 r.ParentResourceId = resourceAncestors[rid].FirstOrDefault(); 297 r.Name = resourceNames[rid]; 298 disabledParentResources.Add(r); 268 299 } 269 300 } -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/ServiceClients/HiveServiceClient.cs
r15978 r15995 2507 2507 System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<System.Guid>> GetResourceGenealogy(); 2508 2508 2509 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetResourceNames", ReplyAction="http://tempuri.org/IHiveService/GetResourceNamesResponse")] 2510 System.Collections.Generic.Dictionary<System.Guid, string> GetResourceNames(); 2511 2509 2512 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/UpdateSlave", ReplyAction="http://tempuri.org/IHiveService/UpdateSlaveResponse")] 2510 2513 void UpdateSlave(HeuristicLab.Clients.Hive.Slave slave); … … 2866 2869 } 2867 2870 2871 public System.Collections.Generic.Dictionary<System.Guid, string> GetResourceNames() 2872 { 2873 return base.Channel.GetResourceNames(); 2874 } 2875 2868 2876 public void UpdateSlave(HeuristicLab.Clients.Hive.Slave slave) 2869 2877 { -
branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs
r15992 r15995 1537 1537 } 1538 1538 1539 public IDictionary<Guid, string> GetResourceNames() { 1540 RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); 1541 var pm = PersistenceManager; 1542 using (new PerformanceLogger("GetResourceNames")) { 1543 var resourceDao = pm.ResourceDao; 1544 var resourceNames = new Dictionary<Guid, string>(); 1545 return pm.UseTransaction(() => { 1546 resourceDao 1547 .GetAll().ToList() 1548 .ForEach(p => resourceNames.Add(p.ResourceId, p.Name)); 1549 return resourceNames; 1550 }); 1551 } 1552 } 1553 1539 1554 public void UpdateSlave(DT.Slave slaveDto) { 1540 1555 RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client); -
branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs
r15978 r15995 231 231 232 232 [OperationContract] 233 IDictionary<Guid, string> GetResourceNames(); 234 235 [OperationContract] 233 236 void UpdateSlave(Slave slave); 234 237
Note: See TracChangeset
for help on using the changeset viewer.