Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
10/18/18 14:07:32 (6 years ago)
Author:
ddorfmei
Message:

#2931: Merged [16168-16232/trunk] into branch

Location:
branches/2931_OR-Tools_LP_MIP
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/2931_OR-Tools_LP_MIP

  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.Clients.Hive.JobManager

  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs

    r16139 r16235  
    2626using System.Windows.Forms;
    2727using HeuristicLab.Collections;
     28using HeuristicLab.Common;
    2829using HeuristicLab.Common.Resources;
    2930using HeuristicLab.Core;
     
    263264      var node = resourcesTreeView.GetNodeAt(new Point(e.X, e.Y));
    264265
    265       if (node == null || node == additionalNode) {
     266      if (node == null && e.Button == MouseButtons.Left) {
    266267        resourcesTreeView.SelectedNode = null;
    267268        ExtractStatistics();
    268       } else {
    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         }
    276269      }
    277270    }
    278271
    279272    private void resourcesTreeView_BeforeSelect(object sender, TreeViewCancelEventArgs e) {
    280       if(e.Node == null || e.Node == additionalNode) {
     273      if(e.Node == null) {
     274        e.Cancel = true;
     275        resourcesTreeView.SelectedNode = null;
     276        ExtractStatistics();
     277      } else if (e.Node == additionalNode) {
    281278        e.Cancel = true;
    282279      } else {
    283280        var r = (Resource)e.Node.Tag;
    284         if(r == null || HiveClient.Instance.DisabledParentResources.Contains(r)) {
     281        if(r != null && !HiveClient.Instance.DisabledParentResources.Contains(r)) {
     282          ExtractStatistics(r);
     283        } else {
    285284          e.Cancel = true;
    286285        }
    287286      }
    288 
    289287    }
    290288
     
    299297          || newIncludedResources.Contains(checkedResource)) {
    300298          e.Cancel = true;
    301 
    302           var selectedNode = resourcesTreeView.SelectedNode;
    303           var selectedResource = (Resource)(selectedNode != null ? selectedNode.Tag : null);
    304 
    305           ExtractStatistics(selectedResource);
    306299        }
    307300      }
     
    317310
    318311      UpdateResourceTreeAfterCheck();
    319       ExtractStatistics();
     312      if(resourcesTreeView.SelectedNode == null)
     313        ExtractStatistics();
    320314      OnAssignedResourcesChanged();
    321315    }
     
    548542      resourcesTreeView.AfterCheck -= resourcesTreeView_AfterCheck;
    549543
    550       var disabledParentResources = HiveClient.Instance.DisabledParentResources;
     544      //var disabledParentResources = HiveClient.Instance.DisabledParentResources;
     545      var disabledParentResources = HiveClient.Instance.GetDisabledResourceAncestors(resources);
    551546      var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>().Where(x => x.ParentResourceId == null));
    552547      //var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>()
     
    643638        additionalNode = new TreeNode(additionalSlavesGroupName) {
    644639          ForeColor = SystemColors.GrayText,
     640          ImageIndex = slaveGroupImageIndex,
    645641          Tag = new SlaveGroup() {
    646642            Name = additionalSlavesGroupName,
     
    651647        foreach (var slave in singleSlaves.OrderBy(x => x.Name)) {
    652648          var slaveNode = new TreeNode(slave.Name) { Tag = slave };
     649
     650          if (newAssignedResources.Select(x => x.Id).Contains(slave.Id)) {
     651            slaveNode.Checked = true;
     652            if (!addedAssignments.Select(x => x.Id).Contains(slave.Id) &&
     653                !removedAssignments.Select(x => x.Id).Contains(slave.Id)) {
     654              slaveNode.Text += SELECTED_TAG;
     655            }
     656          }
     657
     658          if (addedAssignments.Select(x => x.Id).Contains(slave.Id)) {
     659            slaveNode.BackColor = addedAssignmentColor;
     660            slaveNode.ForeColor = controlTextColor;
     661            slaveNode.Text += ADDED_SELECTION_TAG;
     662          } else if (removedAssignments.Select(x => x.Id).Contains(slave.Id)) {
     663            slaveNode.BackColor = removedAssignmentColor;
     664            slaveNode.ForeColor = controlTextColor;
     665            slaveNode.Text += REMOVED_SELECTION_TAG;
     666          }
     667
    653668          additionalNode.Nodes.Add(slaveNode);
    654669        }
     
    667682        Resource r = (Resource)n.Tag;
    668683        if(n.Nodes.Count > 0) {
    669           if(HiveClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any()
    670             || HiveClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<Slave>().Intersect(assignedResources.Union(newAssignedResources)).Any()) {
     684          if(HiveClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any()           
     685            || HiveClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<Slave>().Intersect(assignedResources.Union(newAssignedResources)).Any()
     686            || (n == additionalNode && additionalNode.Nodes.Count > 0 && additionalNode.Nodes.Cast<TreeNode>().Any(x => x.Checked))) {
    671687            n.Expand();
    672688            ExpandResourceNodesOfInterest(n.Nodes);
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.cs

    r16139 r16235  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Linq;
    2425using System.Threading.Tasks;
    2526using System.Windows.Forms;
     
    4647      this.itemsListView.FullRowSelect = true;
    4748
    48       this.itemsListView.ListViewItemSorter = new ListViewItemComparer(new int[] { 2, 0 }, new SortOrder[] { SortOrder.Ascending, SortOrder.Ascending });
     49      this.itemsListView.ListViewItemSorter = new ListViewItemComparer(new int[] { 2, 0 }, new SortOrder[] { SortOrder.Ascending, SortOrder.Ascending });     
    4950
    5051      foreach (ColumnHeader c in this.itemsListView.Columns) {
     
    6364      itemsListView.Sorting = sortOrder;
    6465      itemsListView.Sort();
    65       //AdjustListViewColumnSizes();
     66      AdjustListViewColumnSizes();
    6667    }
    6768
  • branches/2931_OR-Tools_LP_MIP/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r16139 r16235  
    139139          }
    140140
     141          // project look up
    141142          if (Content.Job != null && Content.Job.ProjectId == Guid.Empty) {
     143            projectNameTextBox.Text = string.Empty;
    142144            if (HiveClient.Instance != null && HiveClient.Instance.Projects != null && HiveClient.Instance.Projects.Count == 1) {
    143145              var p = HiveClient.Instance.Projects.FirstOrDefault();
     
    145147                hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId);
    146148                Content.Job.ProjectId = p.Id;
    147                 Content.Job.ResourceIds = HiveClient.Instance.GetAvailableResourcesForProject(p.Id).Select(x => x.Id).ToList();
     149                var resources = HiveClient.Instance.GetAvailableResourcesForProject(p.Id).ToList();
     150                Content.Job.ResourceIds = resources.Select(x => x.Id).ToList();
    148151                hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
    149152                hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     153
     154                var cores = resources.Union(resources.SelectMany(x => HiveClient.Instance.GetAvailableResourceDescendants(x.Id)))
     155                  .OfType<Slave>()
     156                  .Distinct()
     157                  .Sum(x => x.Cores);
     158
     159                projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(Content.Job.ProjectId);
     160                projectNameTextBox.Text += "   (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)";
    150161              }               
    151162            }
    152           }
    153 
    154 
    155           nameTextBox.Text = Content.Job.Name;
    156           descriptionTextBox.Text = Content.Job.Description;
    157           executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    158           refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically;
    159 
    160           // project look up
    161           if(Content.Job.ProjectId != null && Content.Job.ProjectId != Guid.Empty) {
    162             if(selectedProject == null || selectedProject.Id != Content.Job.ProjectId) {
     163          } else if (Content.Job != null && Content.Job.ProjectId != Guid.Empty) {
     164            if (selectedProject == null || selectedProject.Id != Content.Job.ProjectId) {
    163165              selectedProject = GetProject(Content.Job.ProjectId);
    164               if (selectedProject != null) {
    165                 projectNameTextBox.Text = selectedProject.Name;
    166               } else {
    167                 projectNameTextBox.Text = string.Empty;
    168               }
     166              hiveResourceSelectorDialog = null;
    169167            }
     168
     169            if(hiveResourceSelectorDialog == null)
     170              hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId);
     171
     172            if (selectedProject != null) {
     173              projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(selectedProject.Id);
     174            } else {
     175              projectNameTextBox.Text = string.Empty;
     176            }
     177
     178            List<Resource> resources = null;
     179            if (Content.Job.ResourceIds == null)
     180              resources = HiveClient.Instance.GetAssignedResourcesForJob(Content.Job.Id).ToList();
     181            else
     182              resources = HiveClient.Instance.Resources.Where(x => Content.Job.ResourceIds.Contains(x.Id)).ToList();
     183
     184            Content.Job.ResourceIds = resources.Select(x => x.Id).ToList();
     185            hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds;
     186
     187            var cores = resources.Union(resources.SelectMany(x => HiveClient.Instance.GetAvailableResourceDescendants(x.Id)))
     188              .OfType<Slave>()
     189              .Distinct()
     190              .Sum(x => x.Cores);
     191
     192            projectNameTextBox.Text += "   (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)";
     193
    170194          } else {
    171195            selectedProject = null;
     
    173197            Content.Job.ResourceIds = null;
    174198          }
     199
     200
     201          nameTextBox.Text = Content.Job.Name;
     202          descriptionTextBox.Text = Content.Job.Description;
     203          executionTimeTextBox.Text = Content.ExecutionTime.ToString();
     204          refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically;
    175205         
    176206          logView.Content = Content.Log;
     
    182212        SuppressEvents = false;
    183213      }
    184       hiveExperimentPermissionListView.Content = null; // has to be filled by refresh button
     214      hiveExperimentPermissionListView.Content = null; // has to be filled by refresh
    185215      Content_JobStatisticsChanged(this, EventArgs.Empty);
    186216      Content_HiveExperimentChanged(this, EventArgs.Empty);
     
    400430      if (hiveResourceSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    401431        selectedProject = hiveResourceSelectorDialog.SelectedProject;
    402         if(selectedProject != null) {
    403           projectNameTextBox.Text = selectedProject.Name;
     432        if(selectedProject != null) {       
    404433          Content.Job.ProjectId = selectedProject.Id;
    405434          Content.Job.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList();
     435
     436          var cores = hiveResourceSelectorDialog.SelectedResources
     437            .Union(hiveResourceSelectorDialog.SelectedResources
     438              .SelectMany(x => HiveClient.Instance.GetAvailableResourceDescendants(x.Id)))
     439            .OfType<Slave>()
     440            .Distinct()
     441            .Sum(x => x.Cores);
     442
     443          projectNameTextBox.Text = HiveClient.Instance.GetProjectAncestry(selectedProject.Id) + "";
     444          projectNameTextBox.Text += "   (" + (cores.HasValue ? cores.Value.ToString() : "0") + " cores)";
     445
    406446        } else {
    407447          selectedProject = null;
     
    501541    }
    502542
    503     private void updateButton_Click2(object sender, EventArgs e) {
    504       if (Content.ExecutionState == ExecutionState.Stopped) {
    505         MessageBox.Show("Job cannot be updated once it stopped.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
    506         return;
    507       }
    508 
    509       HiveClient.UpdateJob(
    510         (Exception ex) => ErrorHandling.ShowErrorDialog(this, "Update failed.", ex),
    511         Content,
    512         new CancellationToken());
    513       UpdateSelectorDialog();
    514     }
    515 
    516543    private void updateButton_Click(object sender, EventArgs e) {
    517544      if (Content.ExecutionState == ExecutionState.Stopped) {
     
    556583      } else {
    557584        startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0
    558           && Content.Job.ProjectId != null && Content.Job.ProjectId != Guid.Empty && Content.Job.ResourceIds != null  && Content.Job.ResourceIds.Any()
     585          && Content.Job.ProjectId != Guid.Empty && Content.Job.ResourceIds != null  && Content.Job.ResourceIds.Any()
    559586          && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
    560587        pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
Note: See TracChangeset for help on using the changeset viewer.