Changeset 15920 for branches/2839_HiveProjectManagement
- Timestamp:
- 04/25/18 13:12:02 (7 years ago)
- Location:
- branches/2839_HiveProjectManagement
- Files:
-
- 1 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.Designer.cs
r15627 r15920 54 54 this.splitContainer2 = new System.Windows.Forms.SplitContainer(); 55 55 this.projectsTreeView = new System.Windows.Forms.TreeView(); 56 this.resourcesTreeView = new System.Windows.Forms.TreeView();56 this.resourcesTreeView = new HeuristicLab.Clients.Hive.Views.TreeView.NoDoubleClickTreeView(); 57 57 this.summaryGroupBox = new System.Windows.Forms.GroupBox(); 58 58 this.coresLabel = new System.Windows.Forms.Label(); … … 246 246 private System.Windows.Forms.SplitContainer splitContainer2; 247 247 protected System.Windows.Forms.TreeView projectsTreeView; 248 protected System.Windows.Forms.TreeView resourcesTreeView;248 protected HeuristicLab.Clients.Hive.Views.TreeView.NoDoubleClickTreeView resourcesTreeView; 249 249 private System.Windows.Forms.GroupBox summaryGroupBox; 250 250 private System.Windows.Forms.Label coresLabel; -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs
r15914 r15920 62 62 private readonly HashSet<Resource> newIncludedResources = new HashSet<Resource>(); 63 63 64 private IEnumerable<Resource> addedResources;65 private IEnumerable<Resource> removedResources;66 private IEnumerable<Resource> addedIncludes;67 private IEnumerable<Resource> removedIncludes;68 69 64 private readonly Color addedAssignmentColor = Color.FromArgb(255, 87, 191, 193); // #57bfc1 70 65 private readonly Color removedAssignmentColor = Color.FromArgb(255, 236, 159, 72); // #ec9f48 … … 141 136 set { 142 137 if (selectedProject == value) return; 138 139 if ((JobId == Guid.Empty || JobId == null) 140 && (value == null || SelectedProject == null || value.Id != SelectedProject.Id)) selectedResourceIds = null; 143 141 lastSelectedProject = selectedProject; 144 142 selectedProject = value; 145 143 146 if (JobId == Guid.Empty || JobId == null) selectedResourceIds = null;147 144 UpdateResourceTree(); 148 145 ExtractStatistics(); … … 238 235 } 239 236 SelectedProject = node; 240 //ExtractStatistics();241 237 } 242 238 … … 246 242 if (node == null) { 247 243 resourcesTreeView.SelectedNode = null; 248 } 249 250 ExtractStatistics((Resource)node?.Tag); 244 ExtractStatistics(); 245 } else { 246 ExtractStatistics((Resource)node.Tag); 247 } 251 248 } 252 249 253 250 private void resourcesTreeView_BeforeCheck(object sender, TreeViewCancelEventArgs e) { 254 251 var checkedResource = (Resource)e.Node.Tag; 255 if (newIncludedResources.Contains(checkedResource) || checkedResource.Id == Guid.Empty) e.Cancel = true; 252 if (newIncludedResources.Contains(checkedResource) || checkedResource.Id == Guid.Empty) { 253 e.Cancel = true; 254 ExtractStatistics((Resource)resourcesTreeView.SelectedNode?.Tag); 255 } 256 256 } 257 257 … … 264 264 } 265 265 266 Update NewResourceTree();266 UpdateResourceTreeAfterCheck(); 267 267 ExtractStatistics(); 268 //ExtractStatistics((Resource)resourcesTreeView.SelectedNode?.Tag);269 268 OnAssignedResourcesChanged(); 270 269 } … … 384 383 } 385 384 386 private void UpdateNewResourceTree() { 385 private void UpdateResourceTreeAfterCheck() { 386 resourcesTreeView.BeforeCheck -= resourcesTreeView_BeforeCheck; 387 resourcesTreeView.AfterCheck -= resourcesTreeView_AfterCheck; 387 388 UpdateNewAssignedResources(); 388 389 UpdateNewIncludedResources(); 389 BuildResourceTree(availableResources); 390 SetTreeNodes(resourcesTreeView.Nodes); 391 resourcesTreeView.BeforeCheck += resourcesTreeView_BeforeCheck; 392 resourcesTreeView.AfterCheck += resourcesTreeView_AfterCheck; 390 393 } 391 394 … … 497 500 var removedIncludes = includedResources.Except(newIncludedResources); 498 501 499 HashSet<TreeNode> expandedNodes = new HashSet<TreeNode>();500 502 TreeNode currentNode = null; 501 503 Resource currentResource = null; … … 519 521 } else { 520 522 currentNode.Nodes.Add(newNode); 521 }522 523 if(newAssignedResources.Select(x => x.Id).Contains(newResource.Id)524 || assignedResources.Select(x => x.Id).Contains(newResource.Id)525 || newIncludedResources.Select(x => x.Id).Contains(newResource.Id)526 || includedResources.Select(x => x.Id).Contains(newResource.Id)) {527 expandedNodes.Add(newNode);528 523 } 529 524 … … 593 588 } 594 589 595 596 foreach (var node in expandedNodes) { 597 node.Expand(); 598 var parent = node.Parent; 599 while(parent != null) { 600 parent.Expand(); 601 parent = parent.Parent; 602 } 603 } 590 ExpandResourceNodesOfInterest(resourcesTreeView.Nodes); 604 591 605 592 resourcesTreeView.BeforeCheck += resourcesTreeView_BeforeCheck; 606 593 resourcesTreeView.AfterCheck += resourcesTreeView_AfterCheck; 607 //resourcesTreeView.ExpandAll(); 608 } 609 610 private void ExpandSlaveGroupNodes() { 611 foreach (TreeNode n in nodeStore.Where(x => x.Tag is SlaveGroup)) { 612 TreeNode[] children = new TreeNode[n.Nodes.Count]; 613 n.Nodes.CopyTo(children, 0); 614 if (children.Any(x => x.Tag is SlaveGroup)) n.Expand(); 594 } 595 596 private void ExpandResourceNodesOfInterest(TreeNodeCollection nodes) { 597 foreach(TreeNode n in nodes) { 598 Resource r = (Resource)n.Tag; 599 if(n.Nodes.Count > 0) { 600 if(HiveClient.Instance.GetAvailableChildResources(r.Id).OfType<SlaveGroup>().Any() 601 || HiveClient.Instance.GetAvailableChildResources(r.Id).OfType<Slave>().Intersect(assignedResources.Union(newAssignedResources)).Any()) { 602 n.Expand(); 603 ExpandResourceNodesOfInterest(n.Nodes); 604 } else { 605 n.Collapse(); 606 } 607 } else { 608 n.Collapse(); 609 } 610 } 611 } 612 613 private void CollapseSlaveOnlyNodes(TreeNode tn) { 614 if (!(tn.Tag is Resource)) return; 615 616 Resource r = (Resource)tn.Tag; 617 if (HiveClient.Instance.ResourceDescendants.ContainsKey(r.Id)) { 618 if (HiveClient.Instance.GetAvailableChildResources(r.Id).OfType<SlaveGroup>().Any()) { 619 tn.Expand(); 620 foreach (TreeNode n in tn.Nodes) CollapseSlaveOnlyNodes(n); 621 } else { 622 tn.Collapse(); 623 } 615 624 } 616 625 } … … 619 628 HashSet<Slave> newAssignedSlaves = new HashSet<Slave>(newAssignedResources.OfType<Slave>()); 620 629 foreach (var slaveGroup in newAssignedResources.OfType<SlaveGroup>()) { 621 foreach (var slave in HiveClient.Instance.ResourceDescendants[slaveGroup.Id].OfType<Slave>()) {630 foreach (var slave in HiveClient.Instance.GetAvailableChildResources(slaveGroup.Id).OfType<Slave>()) { 622 631 newAssignedSlaves.Add(slave); 623 632 } … … 629 638 var slaveGroup = resource as SlaveGroup; 630 639 if (slaveGroup != null) { 631 selectedSlaves = new HashSet<Slave>(HiveClient.Instance.ResourceDescendants[slaveGroup.Id].OfType<Slave>()); 632 //selectedSlaves.IntersectWith(newAssignedSlaves); 640 selectedSlaves = new HashSet<Slave>(HiveClient.Instance.GetAvailableChildResources(slaveGroup.Id).OfType<Slave>()); 633 641 } else { 634 642 selectedSlaves = new HashSet<Slave>(new[] { resource as Slave }); … … 665 673 } 666 674 675 private void SetTreeNodes(TreeNodeCollection nodes) { 676 var addedAssignments = newAssignedResources.Except(assignedResources); 677 var removedAssignments = assignedResources.Except(newAssignedResources); 678 var addedIncludes = newIncludedResources.Except(includedResources); 679 var removedIncludes = includedResources.Except(newIncludedResources); 680 681 foreach (TreeNode n in nodes) { 682 683 if(n.Tag is Resource) { 684 // reset 685 var resource = (Resource)n.Tag; 686 n.Text = resource.Name; 687 n.BackColor = Color.Transparent; 688 n.ForeColor = Color.Black; 689 n.Checked = false; 690 691 // add additional info 692 if (newAssignedResources.Select(x => x.Id).Contains(resource.Id)) { 693 n.Checked = true; 694 } else if (newIncludedResources.Select(x => x.Id).Contains(resource.Id)) { 695 n.Checked = true; 696 n.ForeColor = grayTextColor; 697 } 698 699 if (includedResources.Select(x => x.Id).Contains(resource.Id) && newIncludedResources.Select(x => x.Id).Contains(resource.Id)) { 700 n.Text += INCLUDED_TAG; 701 } else if (addedIncludes.Select(x => x.Id).Contains(resource.Id)) { 702 n.BackColor = addedIncludeColor; 703 n.ForeColor = grayTextColor; 704 n.Text += ADDED_INCLUDE_TAG; 705 } else if (removedIncludes.Select(x => x.Id).Contains(resource.Id)) { 706 n.BackColor = removedIncludeColor; 707 n.Text += REMOVED_INCLUDE_TAG; 708 } 709 710 if (addedAssignments.Select(x => x.Id).Contains(resource.Id)) { 711 n.BackColor = addedAssignmentColor; 712 n.ForeColor = controlTextColor; 713 n.Text += ADDED_SELECTION_TAG; 714 } else if (removedAssignments.Select(x => x.Id).Contains(resource.Id)) { 715 n.BackColor = removedAssignmentColor; 716 n.ForeColor = controlTextColor; 717 n.Text += REMOVED_SELECTION_TAG; 718 } 719 } 720 721 if(n.Nodes.Count > 0) { 722 SetTreeNodes(n.Nodes); 723 } 724 } 725 } 726 667 727 #endregion 668 728 -
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
r15914 r15920 392 392 Content.Job.ResourceIds = null; 393 393 } 394 SetEnabledStateOfExecutableButtons(); 394 395 } 395 396 } … … 509 510 startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = false; 510 511 } else { 511 startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing; 512 startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 513 && Content.Job.ProjectId != null && Content.Job.ProjectId != Guid.Empty && Content.Job.ResourceIds != null && Content.Job.ResourceIds.Any() 514 && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing; 512 515 pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing; 513 516 stopButton.Enabled = Content.IsControllable && (Content.ExecutionState == ExecutionState.Started || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
Note: See TracChangeset
for help on using the changeset viewer.