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

Location:
branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views
Files:
4 edited

Legend:

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

    r15953 r15995  
    123123      this.treeView.BeforeCheck += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeView_BeforeCheck);
    124124      this.treeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterCheck);
     125      this.treeView.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeView_BeforeSelect);
    125126      this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeView_AfterSelect);
    126127      //
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs

    r15978 r15995  
    5555    private readonly Color addedIncludeColor = Color.FromArgb(25, 169, 221, 221); // #a9dddd
    5656    private readonly Color removedIncludeColor = Color.FromArgb(25, 249, 210, 145); // #f9d291
     57    private readonly Color selectedBackColor = Color.DodgerBlue;
     58    private readonly Color selectedForeColor = Color.White;
     59    private readonly Color grayTextColor = SystemColors.GrayText;
    5760
    5861    private HashSet<Resource> projectExclusiveResources = new HashSet<Resource>();
     
    8386        UpdateAssignedResources();
    8487        UpdateIncludedResources();
    85         var top = BuildResourceTree(HiveAdminClient.Instance.Resources);
     88        var top = BuildResourceTree();
    8689        detailsViewHost.Content = top;
    8790        detailsViewHost.Locked = true;
     
    108111      UpdateAssignedResources();
    109112      UpdateIncludedResources();
    110       var top = BuildResourceTree(HiveAdminClient.Instance.Resources);
     113      var top = BuildResourceTree();
    111114      detailsViewHost.Content = top;
    112115    }
     
    130133    }
    131134
     135    private void treeView_BeforeSelect(object sender, TreeViewCancelEventArgs e) {
     136      if (e.Node == null || e.Node == ungroupedGroupNode)
     137        e.Cancel = true;
     138
     139      var selectedResource = (Resource)e.Node.Tag;
     140      if(HiveAdminClient.Instance.DisabledParentResources.Contains(selectedResource))
     141        e.Cancel = true;
     142    }
     143
    132144    private void treeView_AfterSelect(object sender, TreeViewEventArgs e) {
    133145      var selectedResource = (Resource)e.Node.Tag;
     
    136148
    137149    private void treeView_BeforeCheck(object sender, TreeViewCancelEventArgs e) {
     150      if (e.Node == null || e.Node == ungroupedGroupNode) {
     151        e.Cancel = true;
     152        return;
     153      }
     154       
    138155      var checkedResource = (Resource)e.Node.Tag;
    139       if (newIncludedResources.Contains(checkedResource) || checkedResource.Id == Guid.Empty || e.Node == ungroupedGroupNode) {
     156      if (checkedResource == null
     157        || checkedResource.Id == Guid.Empty
     158        || HiveAdminClient.Instance.DisabledParentResources.Contains(checkedResource)
     159        || newIncludedResources.Contains(checkedResource)) {
    140160        e.Cancel = true;
    141161      } else if (!HiveRoles.CheckAdminUserPermissions()) {
     
    164184      UpdateIncludedResources();
    165185
    166       var top = BuildResourceTree(HiveAdminClient.Instance.Resources);
     186      var top = BuildResourceTree();
    167187      detailsViewHost.Content = top;
    168188    }
     
    171191      UpdateNewAssignedResources();
    172192      UpdateNewIncludedResources();
    173       var top = BuildResourceTree(HiveAdminClient.Instance.Resources);
     193      var top = BuildResourceTree();
    174194      detailsViewHost.Content = top;
    175195    }
     
    191211      // look up for assignments of ancestor projects
    192212      var projectIds = new HashSet<Guid>();
    193       HiveClient.Instance.GetAvailableProjectAncestors(projectId).ToList().ForEach(x => projectIds.Add(x.Id));
     213      HiveAdminClient.Instance.GetAvailableProjectAncestors(projectId).ToList().ForEach(x => projectIds.Add(x.Id));
    194214
    195215      var ancestorProjectResources = resources.Where(x =>
     
    278298    }
    279299
    280     private Resource BuildResourceTree(IEnumerable<Resource> resources) {
     300    private Resource BuildResourceTree() {
    281301      treeView.Nodes.Clear();
    282       if (!resources.Any()) return null;
    283302
    284303      treeView.BeforeCheck -= treeView_BeforeCheck;
    285304      treeView.AfterCheck -= treeView_AfterCheck;
    286305
    287       resources = GetAvailableResourcesForProjectAdministration(Content.Id);
    288 
     306      var resources = GetAvailableResourcesForProjectAdministration(Content.Id);
     307
     308      var disabledParentResources = HiveAdminClient.Instance.DisabledParentResources;
    289309      var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>().Where(x => x.ParentResourceId == null));
    290       var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>()
    291         .Where(x => x.ParentResourceId.HasValue && !resources.Select(y => y.Id).Contains(x.ParentResourceId.Value)));
    292       mainResources.UnionWith(parentedMainResources);
    293       var subResources = new HashSet<Resource>(resources.Except(mainResources));
     310      //var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>()
     311      //  .Where(x => x.ParentResourceId.HasValue && !resources.Select(y => y.Id).Contains(x.ParentResourceId.Value)));
     312      //mainResources.UnionWith(parentedMainResources);
     313      var mainDisabledParentResources = new HashSet<Resource>(disabledParentResources.Where(x => x.ParentResourceId == null || x.ParentResourceId == Guid.Empty));
     314      mainResources.UnionWith(mainDisabledParentResources);
     315      var subResources = new HashSet<Resource>(resources.Union(disabledParentResources).Except(mainResources).OrderByDescending(x => x.Name));
    294316
    295317      var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name));
     318     
    296319      Resource top = null;
     320      //bool nodeSelected = false;
     321      if (detailsViewHost != null && detailsViewHost.Content != null && detailsViewHost.Content is Resource) {
     322        var resourceId = ((Resource)detailsViewHost.Content).Id;
     323        top = resources.Where(x => x.Id == resourceId).FirstOrDefault();
     324      }
     325     
    297326
    298327      TreeNode currentNode = null;
     
    305334
    306335      while (stack.Any()) {
    307         if(top == null)  top = stack.Peek();
    308336        var newResource = stack.Pop();
    309337        var newNode = new TreeNode(newResource.Name) { Tag = newResource };
     338
     339        if(top == null && !disabledParentResources.Contains(newResource)) {
     340          top = newResource;
     341        }
     342
     343        //if(!nodeSelected && top != null && newResource.Id == top.Id) {
     344        //  newNode.BackColor = selectedBackColor;
     345        //  newNode.ForeColor = selectedForeColor;
     346        //  nodeSelected = true;
     347        //}
    310348
    311349        // search for parent node of newNode and save in currentNode
     
    323361        }
    324362
    325         if (newAssignedResources.Contains(newResource)) {
     363        if (disabledParentResources.Contains(newResource)) {
     364          newNode.Checked = false;
     365          newNode.ForeColor = grayTextColor;
     366        } else if (newAssignedResources.Contains(newResource)) {
    326367          newNode.Checked = true;
    327368          if(!HiveRoles.CheckAdminUserPermissions()) {
     
    398439      treeView.BeforeCheck += treeView_BeforeCheck;
    399440      treeView.AfterCheck += treeView_AfterCheck;
    400       treeView.ExpandAll();
     441     
     442      ExpandResourceNodesOfInterest(treeView.Nodes);
    401443
    402444      return top;
     445    }
     446
     447    private void ExpandResourceNodesOfInterest(TreeNodeCollection nodes) {
     448      foreach (TreeNode n in nodes) {
     449        Resource r = (Resource)n.Tag;
     450        if (n.Nodes.Count > 0) {
     451          if (HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any()) {
     452            n.Expand();
     453            ExpandResourceNodesOfInterest(n.Nodes);
     454          } else {
     455            n.Collapse();
     456          }
     457        } else {
     458          n.Collapse();
     459        }
     460      }
    403461    }
    404462
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs

    r15992 r15995  
    4646    private readonly Color selectedBackColor = Color.DodgerBlue;
    4747    private readonly Color selectedForeColor = Color.White;
     48    private readonly Color grayTextColor = SystemColors.GrayText;
    4849
    4950    private Project selectedProject = null;
     
    293294    private void projectsTreeView_MouseDown(object sender, MouseEventArgs e) {
    294295      var node = projectsTreeView.GetNodeAt(e.Location);
    295       if(node != null) ChangeSelectedProjectNode(node);
     296      if (node == null) return;
     297      var p = (Project)node.Tag;
     298      if(!HiveAdminClient.Instance.DisabledParentProjects.Contains(p)) ChangeSelectedProjectNode(node);
    296299    }
    297300
     
    378381      if (!projects.Any()) return;
    379382
     383      var disabledParentProjects = HiveAdminClient.Instance.DisabledParentProjects;
    380384      var mainProjects = new HashSet<Project>(projects.Where(x => x.ParentProjectId == null));
    381       var parentedMainProjects = new HashSet<Project>(projects
    382         .Where(x => x.ParentProjectId.HasValue
    383         && !projects.Select(y => y.Id).Contains(x.ParentProjectId.Value)));
    384       mainProjects.UnionWith(parentedMainProjects);
    385       var subProbjects = new HashSet<Project>(projects.Except(mainProjects));
     385      //var parentedMainProjects = new HashSet<Project>(projects
     386      //  .Where(x => x.ParentProjectId.HasValue
     387      //  && !projects.Select(y => y.Id).Contains(x.ParentProjectId.Value)));
     388      //mainProjects.UnionWith(parentedMainProjects);
     389      var mainDisabledParentProjects = new HashSet<Project>(disabledParentProjects.Where(x => x.ParentProjectId == null || x.ParentProjectId == Guid.Empty));
     390      mainProjects.UnionWith(mainDisabledParentProjects);
     391      var subProbjects = new HashSet<Project>(projects.Union(disabledParentProjects).Except(mainProjects));
    386392
    387393      var stack = new Stack<Project>(mainProjects.OrderByDescending(x => x.Name));
     
    397403        StyleTreeNode(newNode, newProject);
    398404     
    399         if (selectedProject == null) {
     405        if (selectedProject == null && !disabledParentProjects.Contains(newProject)) {
    400406          SelectedProject = newProject;
    401407        }
    402         if (newProject.Id == selectedProject.Id && !nodeSelected) {
     408        if (!nodeSelected && selectedProject != null && selectedProject.Id == newProject.Id) {
    403409          newNode.BackColor = selectedBackColor;
    404410          newNode.ForeColor = selectedForeColor;
     
    424430
    425431        newNode.SelectedImageIndex = newNode.ImageIndex;
     432
     433        if (disabledParentProjects.Contains(newProject)) {
     434          newNode.Checked = false;
     435          newNode.ForeColor = grayTextColor;
     436        }
    426437
    427438        var childProjects = subProbjects.Where(x => x.ParentProjectId == newProject.Id);
     
    444455      n.ForeColor = Color.Black;
    445456
    446       if (p.Id == Guid.Empty) {
     457      if (HiveAdminClient.Instance.DisabledParentProjects.Select(x => x.Id).Contains(p.Id)) {
     458        n.ForeColor = grayTextColor;
     459      } else if (p.Id == Guid.Empty) {
    447460        n.Text += NOT_STORED_TAG;
    448461      } else if (p.Modified) {
  • 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.