Changeset 15995 for branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views
- Timestamp:
- 07/19/18 13:37:32 (6 years ago)
- Location:
- branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views
- Files:
-
- 4 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);
Note: See TracChangeset
for help on using the changeset viewer.