Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/19/18 13:37:32 (6 years ago)
Author:
jzenisek
Message:

#2839: adapted illustration of project and resource ancestry in HiveAdministrator and HiveJobAdministrator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs

    r15992 r15995  
    5353    private const string REMOVED_INCLUDE_TAG = " [removed include]";
    5454
     55    private TreeNode additionalNode;
     56
    5557    private readonly HashSet<TreeNode> mainTreeNodes = new HashSet<TreeNode>();
    5658    private readonly HashSet<TreeNode> filteredTreeNodes = new HashSet<TreeNode>();
    57     private readonly HashSet<TreeNode> nodeStore = new HashSet<TreeNode>();
    5859
    5960    private readonly HashSet<Resource> availableResources = new HashSet<Resource>();
     
    262263      var node = resourcesTreeView.GetNodeAt(new Point(e.X, e.Y));
    263264
    264       if (node == null) {
     265      if (node == null || node == additionalNode) {
    265266        resourcesTreeView.SelectedNode = null;
    266267        ExtractStatistics();
    267268      } 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
    270289    }
    271290
    272291    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) {
    275293        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        }
    277303      }
    278304    }
     
    330356      //  && !projects.SelectMany(y => HiveClient.Instance.ProjectAncestors[y.Id]).Contains(x.ParentProjectId.Value)));
    331357      //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));
    333359      mainProjects.UnionWith(mainDisabledParentProjects);
    334360      var subProbjects = new HashSet<Project>(projects.Union(disabledParentProjects).Except(mainProjects));
     
    518544      resourcesTreeView.AfterCheck -= resourcesTreeView_AfterCheck;
    519545
     546      var disabledParentResources = HiveClient.Instance.DisabledParentResources;
    520547      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));
    525555
    526556      var addedAssignments = newAssignedResources.Except(assignedResources);
     
    552582        }
    553583
    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)) {
    555588          newNode.Checked = true;
    556589          if(!addedAssignments.Select(x => x.Id).Contains(newResource.Id) && !removedAssignments.Select(x => x.Id).Contains(newResource.Id)) {
     
    604637      if (singleSlaves.Any()) {
    605638
    606         var additionalNode = new TreeNode(additionalSlavesGroupName) {
     639        additionalNode = new TreeNode(additionalSlavesGroupName) {
    607640          ForeColor = SystemColors.GrayText,
    608641          Tag = new SlaveGroup() {
     
    693726        var p = (Project)n.Tag;
    694727        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;
    695735          n.ForeColor = grayTextColor;
    696736        }
     
    725765          n.ForeColor = Color.Black;
    726766          n.Checked = false;
     767
     768          if (HiveClient.Instance.DisabledParentResources.Select(x => x.Id).Contains(resource.Id) || n == additionalNode) {
     769            n.ForeColor = grayTextColor;
     770          }
    727771
    728772          // add additional info
Note: See TracChangeset for help on using the changeset viewer.