Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/17/18 15:20:29 (7 years ago)
Author:
jzenisek
Message:

#2839 worked on Hive Job Manager: improved project/resource selector to show existent assignments and preserve selections

Location:
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectResourcesView.cs

    r15576 r15627  
    152152
    153153    private static IEnumerable<Resource> GetAssignedResourcesForProject(Guid projectId) {
    154       var assignedProjectResources = HiveServiceLocator.Instance.CallHiveService(s => s.GetAssignedResourcesForProject(projectId));
     154      var assignedProjectResources = HiveServiceLocator.Instance.CallHiveService(s => s.GetAssignedResourcesForProjectAdministration(projectId));
    155155      return HiveAdminClient.Instance.Resources.Where(x => assignedProjectResources.Select(y => y.ResourceId).Contains(x.Id));
    156156    }
     
    242242
    243243      var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>().Where(x => x.ParentResourceId == null));
     244      var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>()
     245        .Where(x => x.ParentResourceId.HasValue && !resources.Select(y => y.Id).Contains(x.ParentResourceId.Value)));
     246      mainResources.UnionWith(parentedMainResources);
    244247      var subResources = new HashSet<Resource>(resources.Except(mainResources));
    245248
    246249      var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name));
    247       var top = stack.Peek();
     250      Resource top = null;
    248251
    249252      TreeNode currentNode = null;
     
    262265
    263266      while (stack.Any()) {
     267        if(top == null)  top = stack.Peek();
    264268        var newResource = stack.Pop();
    265269        var newNode = new TreeNode(newResource.Name) { Tag = newResource };
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs

    r15567 r15627  
    4545    private readonly object locker = new object();
    4646
     47    private Project selectedProject = null;
     48
    4749    public new IItemList<Project> Content {
    4850      get { return (IItemList<Project>)base.Content; }
     
    190192
    191193    private void addButton_Click(object sender, EventArgs e) {
     194      Guid? parentProjectId = null;
     195      if (selectedProject != null) parentProjectId = selectedProject.Id;
    192196      var project = new Project {
    193197        Name = "New Project",
    194         OwnerUserId = UserInformation.Instance.User.Id
     198        OwnerUserId = UserInformation.Instance.User.Id,
     199        ParentProjectId = parentProjectId
    195200      };
    196201      Content.Add(project);
     
    244249        },
    245250        finallyCallback: () => saveProjectButton.Enabled = true);
     251
     252      OnContentChanged();
    246253    }
    247254
    248255    private void projectsTreeView_AfterSelect(object sender, TreeViewEventArgs e) {
    249       var selectedProject = (Project)e.Node.Tag;
    250       ReColorTreeNodes(projectsTreeView.Nodes, selectedColor, Color.Transparent);
     256      selectedProject = (Project)e.Node.Tag;
     257      ReColorTreeNodes(projectsTreeView.Nodes, selectedColor, Color.Transparent, true);
    251258      e.Node.BackColor = selectedColor;
     259      e.Node.Text += " [selected]";
    252260     
    253261
    254       if (projectView.Content != null)
    255         projectView.Content.PropertyChanged -= ProjectViewContent_PropertyChanged;
     262      //if (projectView.Content != null)
     263      //  projectView.Content.PropertyChanged -= ProjectViewContent_PropertyChanged;
    256264
    257265      projectView.Content = selectedProject;
     
    259267      projectResourcesView.Content = selectedProject;
    260268
    261       if (selectedProject != null)
    262         selectedProject.PropertyChanged += ProjectViewContent_PropertyChanged;
     269      //if (selectedProject != null)
     270      //  selectedProject.PropertyChanged += ProjectViewContent_PropertyChanged;
    263271
    264272      if (IsAuthorized(selectedProject)) {
     
    322330
    323331    #region Helpers
    324     private void ReColorTreeNodes(TreeNodeCollection nodes, Color c1, Color c2) {
     332    private void ReColorTreeNodes(TreeNodeCollection nodes, Color c1, Color c2, bool resetText) {
    325333      foreach(TreeNode n in nodes) {
    326334        if(n.BackColor.Equals(c1)) {
    327335          n.BackColor = c2;
     336          if (resetText) n.Text = ((Project)n.Tag).Name;
    328337        }
    329338        if (n.Nodes.Count > 0) {
    330           ReColorTreeNodes(n.Nodes, c1, c2);
     339          ReColorTreeNodes(n.Nodes, c1, c2, resetText);
    331340        }
    332341      }
     
    338347
    339348      var mainProjects = new HashSet<Project>(projects.Where(x => x.ParentProjectId == null));
     349      var parentedMainProjects = new HashSet<Project>(projects
     350        .Where(x => x.ParentProjectId.HasValue
     351        && !projects.Select(y => y.Id).Contains(x.ParentProjectId.Value)));
     352            mainProjects.UnionWith(parentedMainProjects);
    340353      var subProbjects = new HashSet<Project>(projects.Except(mainProjects));
    341354
    342355      var stack = new Stack<Project>(mainProjects.OrderByDescending(x => x.Name));
    343       var top = stack.Peek();
    344       bool first = true;
     356      Project top = null;
    345357
    346358      TreeNode currentNode = null;
     
    350362        var newProject = stack.Pop();
    351363        var newNode = new TreeNode(newProject.Name) { Tag = newProject };
    352         if (first) {
     364        if (top == null) {
     365          top = newProject;
    353366          newNode.BackColor = selectedColor;
    354           first = false;
     367          newNode.Text += " [selected]";
    355368        }
    356369
Note: See TracChangeset for help on using the changeset viewer.