Changeset 15995


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

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

Location:
branches/2839_HiveProjectManagement
Files:
11 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);
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.Designer.cs

    r15978 r15995  
    165165      this.resourcesTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.resourcesTreeView_AfterCheck);
    166166      this.resourcesTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.resourcesTreeView_MouseDown);
     167      this.resourcesTreeView.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.resourcesTreeView_BeforeSelect);
    167168      //
    168169      // summaryGroupBox
  • 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
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveAdminClient.cs

    r15969 r15995  
    9898      get { return resourceDescendants; }
    9999    }
     100
     101    private Dictionary<Guid, string> projectNames;
     102    public Dictionary<Guid, string> ProjectNames {
     103      get { return projectNames; }
     104    }
     105
     106    private HashSet<Project> disabledParentProjects;
     107    public HashSet<Project> DisabledParentProjects {
     108      get { return disabledParentProjects; }
     109    }
     110
     111    private Dictionary<Guid, string> resourceNames;
     112    public Dictionary<Guid, string> ResourceNames {
     113      get { return resourceNames; }
     114    }
     115
     116    private HashSet<Resource> disabledParentResources;
     117    public HashSet<Resource> DisabledParentResources {
     118      get { return disabledParentResources; }
     119    }
    100120    #endregion
    101121
     
    124144        projectResourceAssignments = new ItemList<AssignedProjectResource>();
    125145        jobs = new Dictionary<Guid, HiveItemCollection<Job>>();
     146        projectNames = new Dictionary<Guid, string>();
     147        resourceNames = new Dictionary<Guid, string>();
    126148
    127149        projectAncestors = new Dictionary<Guid, HashSet<Guid>>();
     
    145167            unsortedJobs.Where(j => j.State == JobState.StatisticsPending).ToList().ForEach(j => jobs[j.ProjectId].Add(j));
    146168            unsortedJobs.Where(j => j.State == JobState.Online).ToList().ForEach(j => jobs[j.ProjectId].Add(j));
     169
     170            projectNames = service.GetProjectNames();
     171            resourceNames = service.GetResourceNames();
    147172          }
    148173        });
     
    150175        UpdateResourceGenealogy();
    151176        UpdateProjectGenealogy();
     177        RefreshDisabledParentProjects();
     178        RefreshDisabledParentResources();
    152179      }
    153180      catch {
     
    244271          projectDescendants[ancestor].Add(pa.Key);
    245272        }
     273      }
     274    }
     275
     276    private void RefreshDisabledParentProjects() {
     277      disabledParentProjects = new HashSet<Project>();
     278
     279      foreach (var pid in projects
     280        .Where(x => x.ParentProjectId.HasValue)
     281        .SelectMany(x => projectAncestors[x.Id]).Distinct()
     282        .Where(x => !projects.Select(y => y.Id).Contains(x))) {
     283        var p = new Project();
     284        p.Id = pid;
     285        p.ParentProjectId = projectAncestors[pid].FirstOrDefault();
     286        p.Name = projectNames[pid];
     287        disabledParentProjects.Add(p);
     288      }
     289    }
     290
     291    private void RefreshDisabledParentResources() {
     292      disabledParentResources = new HashSet<Resource>();
     293
     294      foreach (var rid in resources
     295        .Where(x => x.ParentResourceId.HasValue)
     296        .SelectMany(x => resourceAncestors[x.Id]).Distinct()
     297        .Where(x => !resources.Select(y => y.Id).Contains(x))) {
     298        var r = new SlaveGroup();
     299        r.Id = rid;
     300        r.ParentResourceId = resourceAncestors[rid].FirstOrDefault();
     301        r.Name = resourceNames[rid];
     302        disabledParentResources.Add(r);
    246303      }
    247304    }
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r15992 r15995  
    9797    }
    9898
     99    private Dictionary<Guid, string> resourceNames;
     100    public Dictionary<Guid, string> ResourceNames {
     101      get { return resourceNames; }
     102    }
     103
     104    private HashSet<Resource> disabledParentResources;
     105    public HashSet<Resource> DisabledParentResources {
     106      get { return disabledParentResources; }
     107    }
     108
    99109    private List<Plugin> onlinePlugins;
    100110    public List<Plugin> OnlinePlugins {
     
    137147        jobs = new HiveItemCollection<RefreshableJob>();
    138148        projectNames = new Dictionary<Guid, string>();
     149        resourceNames = new Dictionary<Guid, string>();
    139150
    140151        projectAncestors = new Dictionary<Guid, HashSet<Guid>>();
     
    149160          service.GetJobs().ForEach(p => jobs.Add(new RefreshableJob(p)));
    150161          projectNames = service.GetProjectNames();
     162          resourceNames = service.GetResourceNames();
    151163        });
    152164
     
    154166        RefreshProjectGenealogy();
    155167        RefreshDisabledParentProjects();
     168        RefreshDisabledParentResources();
    156169      }
    157170      catch {
     
    173186        projectNames = new Dictionary<Guid, string>();
    174187        resources = new ItemList<Resource>();
     188        resourceNames = new Dictionary<Guid, string>();
    175189
    176190        projectAncestors = new Dictionary<Guid, HashSet<Guid>>();
     
    184198          service.GetSlaves().ForEach(s => resources.Add(s));
    185199          projectNames = service.GetProjectNames();
     200          resourceNames = service.GetResourceNames();
    186201        });
    187202
     
    189204        RefreshProjectGenealogy();
    190205        RefreshDisabledParentProjects();
     206        RefreshDisabledParentResources();
    191207      } catch {
    192208        projects = null;
     
    266282        p.Name = projectNames[pid];
    267283        disabledParentProjects.Add(p);
     284      }
     285    }
     286
     287    private void RefreshDisabledParentResources() {
     288      disabledParentResources = new HashSet<Resource>();
     289
     290      foreach (var rid in resources
     291        .Where(x => x.ParentResourceId.HasValue)
     292        .SelectMany(x => resourceAncestors[x.Id]).Distinct()
     293        .Where(x => !resources.Select(y => y.Id).Contains(x))) {
     294        var r = new SlaveGroup();
     295        r.Id = rid;
     296        r.ParentResourceId = resourceAncestors[rid].FirstOrDefault();
     297        r.Name = resourceNames[rid];
     298        disabledParentResources.Add(r);
    268299      }
    269300    }
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/ServiceClients/HiveServiceClient.cs

    r15978 r15995  
    25072507        System.Collections.Generic.Dictionary<System.Guid, System.Collections.Generic.List<System.Guid>> GetResourceGenealogy();
    25082508       
     2509        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetResourceNames", ReplyAction="http://tempuri.org/IHiveService/GetResourceNamesResponse")]
     2510        System.Collections.Generic.Dictionary<System.Guid, string> GetResourceNames();
     2511       
    25092512        [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/UpdateSlave", ReplyAction="http://tempuri.org/IHiveService/UpdateSlaveResponse")]
    25102513        void UpdateSlave(HeuristicLab.Clients.Hive.Slave slave);
     
    28662869        }
    28672870       
     2871        public System.Collections.Generic.Dictionary<System.Guid, string> GetResourceNames()
     2872        {
     2873            return base.Channel.GetResourceNames();
     2874        }
     2875       
    28682876        public void UpdateSlave(HeuristicLab.Clients.Hive.Slave slave)
    28692877        {
  • branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/HiveService.cs

    r15992 r15995  
    15371537    }
    15381538
     1539    public IDictionary<Guid, string> GetResourceNames() {
     1540      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
     1541      var pm = PersistenceManager;
     1542      using (new PerformanceLogger("GetResourceNames")) {
     1543        var resourceDao = pm.ResourceDao;
     1544        var resourceNames = new Dictionary<Guid, string>();
     1545        return pm.UseTransaction(() => {
     1546          resourceDao
     1547            .GetAll().ToList()
     1548            .ForEach(p => resourceNames.Add(p.ResourceId, p.Name));
     1549          return resourceNames;
     1550        });
     1551      }
     1552    }
     1553
    15391554    public void UpdateSlave(DT.Slave slaveDto) {
    15401555      RoleVerifier.AuthenticateForAnyRole(HiveRoles.Administrator, HiveRoles.Client);
  • branches/2839_HiveProjectManagement/HeuristicLab.Services.Hive/3.3/ServiceContracts/IHiveService.cs

    r15978 r15995  
    231231
    232232    [OperationContract]
     233    IDictionary<Guid, string> GetResourceNames();
     234
     235    [OperationContract]
    233236    void UpdateSlave(Slave slave);
    234237
Note: See TracChangeset for help on using the changeset viewer.