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.Administrator/3.3/Views/ResourcesView.cs

    r15978 r15995  
    5151    private readonly Color calculatingColor = Color.FromArgb(255, 58, 114, 35); // #3a7223
    5252    private readonly Color offlineColor = Color.FromArgb(255, 187, 36, 36); // #bb2424
     53    private readonly Color grayTextColor = SystemColors.GrayText;
    5354
    5455
     
    301302    private void treeSlaveGroup_MouseDown(object sender, MouseEventArgs e) {
    302303      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);
    304307    }
    305308
     
    311314      if(e.Node == ungroupedGroupNode) {
    312315        e.Cancel = true;
     316      } else {
     317        var r = (Resource)e.Node.Tag;
     318        if(HiveAdminClient.Instance.DisabledParentResources.Contains(r)) {
     319          e.Cancel = true;
     320        }
    313321      }
    314322    }
     
    395403      if (!resources.Any()) return;
    396404
     405      var disabledParentResources = HiveAdminClient.Instance.DisabledParentResources;
    397406      var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>()
    398407        .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));
    403414
    404415      var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name));
     
    414425        StyleTreeNode(newNode, newResource, resources);
    415426
    416         if (selectedResource == null) {
     427        if (selectedResource == null && !disabledParentResources.Contains(newResource)) {
    417428          SelectedResource = newResource;
    418429        }
    419         if (newResource.Id == selectedResource.Id && !nodeSelected) {
     430        if (!nodeSelected && selectedResource != null && newResource.Id == selectedResource.Id) {
    420431          newNode.BackColor = selectedBackColor;
    421432          newNode.ForeColor = selectedForeColor;
    422433          newNode.Text += SELECTED_TAG;
    423434          nodeSelected = true;
     435        }
     436
     437        if(disabledParentResources.Contains(newResource)) {
     438          newNode.Checked = false;
     439          newNode.ForeColor = grayTextColor;
    424440        }
    425441
     
    505521        Resource r = (Resource)n.Tag;
    506522        if (n.Nodes.Count > 0) {
    507           if (HiveClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any()) {
     523          if (HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any()) {
    508524            n.Expand();
    509525            ExpandResourceNodesOfInterest(n.Nodes);
     
    570586      n.ForeColor = Color.Black;
    571587
    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)
    574592        n.Text += NOT_STORED_TAG;
    575593      } else if (r.Modified && n != ungroupedGroupNode /*!r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) {
     594        // changed
    576595        n.Text += CHANGES_NOT_STORED_TAG;
    577596      }
     
    682701    private Dictionary<Guid, HashSet<Resource>> GetResourceDescendants() {
    683702      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) {
    687707        var parentResourceId = r.ParentResourceId;
    688708        while(parentResourceId != null) {
    689           var parent = Content.SingleOrDefault(x => x.Id == parentResourceId);
     709          var parent = resources.SingleOrDefault(x => x.Id == parentResourceId);
    690710          if(parent != null) {
    691711            resourceDescendants[parent.Id].Add(r);
Note: See TracChangeset for help on using the changeset viewer.