Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/26/18 16:33:53 (6 years ago)
Author:
jzenisek
Message:

#2839:

  • replaced use of TreeView with NoDoubleClickTreeView everywhere allegedly reasonable for Hive
  • updated genealogy computation for HiveAdminClient and corresponding views (ResourcesView & ProjectResourcesView)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs

    r15819 r15922  
    231231      };
    232232
    233       HiveAdminClient.Instance.UpdateResourceGenealogy(Content);
     233      //HiveAdminClient.Instance.UpdateResourceGenealogy(Content);
    234234      SelectedResource = group;
    235235      Content.Add(group);
     
    322322      }
    323323
    324       HiveAdminClient.Instance.UpdateResourceGenealogy(Content);
     324      // TODO
     325      //HiveAdminClient.Instance.UpdateResourceGenealogy(Content);
    325326      OnContentChanged();
    326327    }
     
    486487    private void CollapseSlaveOnlyNodes(TreeNode tn) {
    487488      Resource r = (Resource)tn.Tag;
    488       var descendants = HiveAdminClient.Instance.ResourceDescendants;
     489      var descendants = GetResourceDescendants();
    489490      if(descendants.ContainsKey(r.Id)) {
    490491        if(descendants[r.Id].OfType<SlaveGroup>().Any()) {
     
    493494        } else {
    494495          tn.Collapse();
     496        }
     497      }
     498    }
     499
     500    private void ExpandResourceNodesOfInterest(TreeNodeCollection nodes) {
     501      foreach (TreeNode n in nodes) {
     502        Resource r = (Resource)n.Tag;
     503        if (n.Nodes.Count > 0) {
     504          if (HiveClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any()) {
     505            n.Expand();
     506            ExpandResourceNodesOfInterest(n.Nodes);
     507          } else {
     508            n.Collapse();
     509          }
     510        } else {
     511          n.Collapse();
    495512        }
    496513      }
     
    560577      int childSlavesCount = 0;
    561578      if (r.Id != Guid.Empty && r is SlaveGroup) {
    562         var descendants = HiveAdminClient.Instance.ResourceDescendants;
     579        var descendants = GetResourceDescendants();
    563580        if (descendants.ContainsKey(r.Id)) {
    564581          childSlavesCount = resources
    565582            .OfType<Slave>()
    566583            .Where(x => descendants[r.Id].Select(y => y.Id)
    567             .Contains(x.Id))
     584              .Contains(x.Id))
    568585            .Count();
    569586        }
     
    659676    }
    660677
     678
     679    private Dictionary<Guid, HashSet<Resource>> GetResourceDescendants() {
     680      var resourceDescendants = new Dictionary<Guid, HashSet<Resource>>();
     681
     682      foreach (var r in Content) resourceDescendants.Add(r.Id, new HashSet<Resource>());
     683      foreach(var r in Content) {
     684        var parentResourceId = r.ParentResourceId;
     685        while(parentResourceId != null) {
     686          var parent = Content.SingleOrDefault(x => x.Id == parentResourceId);
     687          if(parent != null) {
     688            resourceDescendants[parent.Id].Add(r);
     689            parentResourceId = parent.ParentResourceId;
     690          } else {
     691            parentResourceId = null;
     692          }
     693        }
     694      }
     695      return resourceDescendants;
     696    }
     697   
    661698    #endregion
    662699  }
Note: See TracChangeset for help on using the changeset viewer.