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)
Location:
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views
Files:
5 edited

Legend:

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

    r15576 r15922  
    3131      this.splitContainer = new System.Windows.Forms.SplitContainer();
    3232      this.permissionsGroupBox = new System.Windows.Forms.GroupBox();
    33       this.treeView = new System.Windows.Forms.TreeView();
     33      this.treeView = new Hive.Views.TreeView.NoDoubleClickTreeView();
    3434      this.detailsGroupBox = new System.Windows.Forms.GroupBox();
    3535      this.detailsViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     
    184184    private System.Windows.Forms.SplitContainer splitContainer;
    185185    private System.Windows.Forms.GroupBox permissionsGroupBox;
    186     private System.Windows.Forms.TreeView treeView;
     186    private HeuristicLab.Clients.Hive.Views.TreeView.NoDoubleClickTreeView treeView;
    187187    private System.Windows.Forms.GroupBox detailsGroupBox;
    188188    private MainForm.WindowsForms.ViewHost detailsViewHost;
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.Designer.cs

    r15576 r15922  
    3030      this.splitContainer = new System.Windows.Forms.SplitContainer();
    3131      this.resourcesGroupBox = new System.Windows.Forms.GroupBox();
    32       this.treeView = new System.Windows.Forms.TreeView();
     32      this.treeView = new Hive.Views.TreeView.NoDoubleClickTreeView();
    3333      this.imageList = new System.Windows.Forms.ImageList(this.components);
    3434      this.detailsGroupBox = new System.Windows.Forms.GroupBox();
     
    185185    private System.Windows.Forms.GroupBox resourcesGroupBox;
    186186    private System.Windows.Forms.GroupBox detailsGroupBox;
    187     private System.Windows.Forms.TreeView treeView;
     187    private HeuristicLab.Clients.Hive.Views.TreeView.NoDoubleClickTreeView treeView;
    188188    private System.Windows.Forms.ImageList imageList;
    189189    private MainForm.WindowsForms.ViewHost detailsViewHost;
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs

    r15819 r15922  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    5151    private readonly HashSet<Resource> newIncludedResources = new HashSet<Resource>();
    5252
    53     private readonly Dictionary<Guid, HashSet<Project>> projectAncestors = new Dictionary<Guid, HashSet<Project>>();
    54     private readonly Dictionary<Guid, HashSet<Project>> projectDescendants = new Dictionary<Guid, HashSet<Project>>();
    55     private readonly Dictionary<Guid, HashSet<Resource>> resourceAncestors = new Dictionary<Guid, HashSet<Resource>>();
    56     private readonly Dictionary<Guid, HashSet<Resource>> resourceDescendants = new Dictionary<Guid, HashSet<Resource>>();
    57 
    5853    private readonly Color addedAssignmentColor = Color.FromArgb(255, 87, 191, 193); // #57bfc1
    5954    private readonly Color removedAssignmentColor = Color.FromArgb(255, 236, 159, 72); // #ec9f48
     
    8378        newAssignedResources.Clear();
    8479        includedResources.Clear();
    85         resourceAncestors.Clear();
    8680        treeView.Nodes.Clear();
    8781        detailsViewHost.Content = null;
    8882      } else {
    89         UpdateProjectGenealogy();
    9083        UpdateAssignedResources();
    91         UpdateResourceGenealogy();
     84        UpdateIncludedResources();
    9285        var top = BuildResourceTree(HiveAdminClient.Instance.Resources);
    9386        detailsViewHost.Content = top;
     
    111104
    112105    private void refreshButton_Click(object sender, EventArgs e) {
    113       UpdateProjectGenealogy();
     106      HiveAdminClient.Instance.Refresh();
    114107      UpdateAssignedResources();
    115       UpdateResourceGenealogy();
     108      UpdateIncludedResources();
    116109      var top = BuildResourceTree(HiveAdminClient.Instance.Resources);
    117110      detailsViewHost.Content = top;
     
    144137        e.Cancel = true;
    145138      } else if (!HiveRoles.CheckAdminUserPermissions()) {
    146           if (!projectAncestors[Content.Id].Any() || projectExclusiveResources.Contains(checkedResource)) {
     139          if (!HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).Any() || projectExclusiveResources.Contains(checkedResource)) {
    147140            e.Cancel = true;
    148141          }
     
    166159    private void UpdateResourceTree() {
    167160      UpdateAssignedResources();
    168       UpdateResourceGenealogy();
     161      UpdateIncludedResources();
     162
    169163      var top = BuildResourceTree(HiveAdminClient.Instance.Resources);
    170164      detailsViewHost.Content = top;
     
    194188      // look up for assignments of ancestor projects
    195189      var projectIds = new HashSet<Guid>();
    196       if(projectAncestors.ContainsKey(projectId)) {
    197         projectAncestors[projectId].ToList().ForEach(x => projectIds.Add(x.Id));
    198       }
     190      HiveClient.Instance.GetAvailableProjectAncestors(projectId).ToList().ForEach(x => projectIds.Add(x.Id));
     191
    199192      var ancestorProjectResources = resources.Where(x =>
    200193        HiveAdminClient.Instance.ProjectResourceAssignments
     
    206199      HashSet<Resource> availableResources = new HashSet<Resource>(ancestorProjectResources);
    207200      foreach (var r in ancestorProjectResources) {
    208         if(resourceDescendants.ContainsKey(r.Id)) {
    209           foreach(var d in resourceDescendants[r.Id]) {
    210             availableResources.Add(d);
    211           }
     201        foreach(var d in HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id)) {
     202          availableResources.Add(d);
    212203        }
    213204      }
     
    222213      if (projectExclusiveResources.Any()) {
    223214        foreach (var r in projectExclusiveResources.ToArray()) {
    224           if (resourceDescendants.ContainsKey(r.Id)) {
    225             foreach (var d in resourceDescendants[r.Id]) {
    226               projectExclusiveResources.Add(d);
    227             }
    228           }
     215          foreach (var d in HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id)) {
     216            projectExclusiveResources.Add(d);
     217          } 
    229218        }
    230219      }
     
    251240    private void UpdateNewAssignedResources() {
    252241      for(int i = newAssignedResources.Count -1; i >= 0; i--) {
    253         if(newAssignedResources.Intersect(resourceAncestors[newAssignedResources.ElementAt(i).Id]).Any()) {
     242        if(newAssignedResources.Intersect(HiveAdminClient.Instance.GetAvailableResourceAncestors(newAssignedResources.ElementAt(i).Id)).Any()) {
    254243          newAssignedResources.Remove(newAssignedResources.ElementAt(i));
    255244        }
     
    266255    }
    267256
     257    private void UpdateIncludedResources() {
     258      includedResources.Clear();
     259      newIncludedResources.Clear();
     260      foreach (var a in assignedResources) {
     261        foreach (var r in HiveAdminClient.Instance.GetAvailableResourceDescendants(a.Id)) {
     262          includedResources.Add(r);
     263          newIncludedResources.Add(r);
     264        }
     265      }
     266    }
     267
    268268    private void UpdateNewIncludedResources() {
    269269      newIncludedResources.Clear();
    270270      foreach (var a in newAssignedResources) {
    271         if (resourceDescendants.ContainsKey(a.Id)) {
    272           foreach (var r in resourceDescendants[a.Id]) {
    273             newIncludedResources.Add(r);
    274           }
     271        foreach (var r in HiveAdminClient.Instance.GetAvailableResourceDescendants(a.Id)) {
     272          newIncludedResources.Add(r);
    275273        }
    276274      }
     
    325323          newNode.Checked = true;
    326324          if(!HiveRoles.CheckAdminUserPermissions()) {
    327             if(!projectAncestors[Content.Id].Any() || projectExclusiveResources.Contains(newResource)) {
     325            if (!HiveAdminClient.Instance.GetAvailableProjectAncestors(Content.Id).Any()
     326              || projectExclusiveResources.Contains(newResource)) {
    328327              newNode.ForeColor = SystemColors.GrayText;
    329328              newNode.Text += IMMUTABLE_TAG;
     
    401400    }
    402401
    403     private void UpdateProjectGenealogy() {
    404       projectAncestors.Clear();
    405       projectDescendants.Clear();
    406       var projects = HiveAdminClient.Instance.Projects;
    407 
    408       foreach(var p in projects.Where(x => x.Id != Guid.Empty)) {
    409         projectAncestors.Add(p.Id, new HashSet<Project>());
    410         projectDescendants.Add(p.Id, new HashSet<Project>());
    411       }
    412 
    413       foreach (var p in projects.Where(x => x.Id != Guid.Empty)) {
    414         var parentProjectId = p.ParentProjectId;
    415         while (parentProjectId != null) {
    416           var parent = projects.SingleOrDefault(x => x.Id == parentProjectId);
    417           if (parent != null) {
    418             projectAncestors[p.Id].Add(parent);
    419             projectDescendants[parent.Id].Add(p);
    420             parentProjectId = parent.ParentProjectId;
    421           } else {
    422             parentProjectId = null;
    423           }
    424         }
    425       }
    426     }
    427 
    428     private void UpdateResourceGenealogy() {
    429       resourceAncestors.Clear();
    430       resourceDescendants.Clear();
    431       var resources = HiveAdminClient.Instance.Resources;
    432 
    433       foreach (var r in resources.Where(x => x.Id != Guid.Empty)) {
    434         resourceAncestors.Add(r.Id, new HashSet<Resource>());
    435         resourceDescendants.Add(r.Id, new HashSet<Resource>());
    436       }
    437 
    438       foreach (var r in resources.Where(x => x.Id != Guid.Empty)) {
    439         var parentResourceId = r.ParentResourceId;
    440         while (parentResourceId != null) {
    441           var parent = resources.SingleOrDefault(x => x.Id == parentResourceId);
    442           if (parent != null) {
    443             resourceAncestors[r.Id].Add(parent);
    444             resourceDescendants[parent.Id].Add(r);
    445             parentResourceId = parent.ParentResourceId;
    446           } else {
    447             parentResourceId = null;
    448           }
    449         }
    450       }
    451 
    452       includedResources.Clear();
    453       newIncludedResources.Clear();
    454       foreach (var a in assignedResources) {
    455         if (resourceDescendants.ContainsKey(a.Id)) {
    456           foreach (var r in resourceDescendants[a.Id]) {
    457             includedResources.Add(r);
    458             newIncludedResources.Add(r);
    459           }
    460         }
    461       }
    462     }
    463 
    464402    private bool IsAdmin() {
    465403      return HiveRoles.CheckAdminUserPermissions();
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs

    r15813 r15922  
    5454      this.btnRemoveGroup = new System.Windows.Forms.Button();
    5555      this.btnAddGroup = new System.Windows.Forms.Button();
    56       this.treeView = new System.Windows.Forms.TreeView();
     56      this.treeView = new Hive.Views.TreeView.NoDoubleClickTreeView();
    5757      this.tabSlaveGroup = new System.Windows.Forms.TabControl();
    5858      this.tabDetails = new System.Windows.Forms.TabPage();
     
    253253    private System.Windows.Forms.Button btnRemoveGroup;
    254254    private System.Windows.Forms.Button btnAddGroup;
    255     private System.Windows.Forms.TreeView treeView;
     255    private HeuristicLab.Clients.Hive.Views.TreeView.NoDoubleClickTreeView treeView;
    256256    private System.Windows.Forms.TabControl tabSlaveGroup;
    257257    private System.Windows.Forms.TabPage tabDetails;
  • 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.