Changeset 16311 for branches/2845_EnhancedProgress/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
- Timestamp:
- 11/20/18 15:26:57 (5 years ago)
- Location:
- branches/2845_EnhancedProgress
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2845_EnhancedProgress
- Property svn:mergeinfo changed
-
branches/2845_EnhancedProgress/HeuristicLab.Clients.Hive.JobManager
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
/branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager merged eligible /stable/HeuristicLab.Clients.Hive.JobManager merged eligible /trunk/HeuristicLab.Clients.Hive.JobManager merged eligible /branches/1721-RandomForestPersistence/HeuristicLab.Clients.Hive.JobManager 10321-10322 /branches/Algorithms.GradientDescent/HeuristicLab.Clients.Hive.JobManager 5516-5520 /branches/Async/HeuristicLab.Clients.Hive.JobManager 13329-15286 /branches/Benchmarking/sources/HeuristicLab.Clients.Hive.JobManager 6917-7005 /branches/CloningRefactoring/HeuristicLab.Clients.Hive.JobManager 4656-4721 /branches/CodeEditor/HeuristicLab.Clients.Hive.JobManager 11700-11806 /branches/DataAnalysis Refactoring/HeuristicLab.Clients.Hive.JobManager 5471-5808 /branches/DataAnalysis SolutionEnsembles/HeuristicLab.Clients.Hive.JobManager 5815-6180 /branches/DataAnalysis/HeuristicLab.Clients.Hive.JobManager 4458-4459,4462,4464 /branches/DataPreprocessing/HeuristicLab.Clients.Hive.JobManager 10085-11101 /branches/GP.Grammar.Editor/HeuristicLab.Clients.Hive.JobManager 6284-6795 /branches/GP.Symbols (TimeLag, Diff, Integral)/HeuristicLab.Clients.Hive.JobManager 5060 /branches/HLScript/HeuristicLab.Clients.Hive.JobManager 10331-10358 /branches/HeuristicLab.DatasetRefactor/sources/HeuristicLab.Clients.Hive.JobManager 11570-12508 /branches/HeuristicLab.Problems.DataAnalysis.Trading/HeuristicLab.Clients.Hive.JobManager 6123-9799 /branches/HeuristicLab.Problems.Orienteering/HeuristicLab.Clients.Hive.JobManager 11130-12721 /branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager 15377-15760 /branches/HiveStatistics/sources/HeuristicLab.Clients.Hive.JobManager 12440-12877 /branches/LogResidualEvaluator/HeuristicLab.Clients.Hive.JobManager 10202-10483 /branches/NET40/sources/HeuristicLab.Clients.Hive.JobManager 5138-5162 /branches/NSGA-II Changes/HeuristicLab.Clients.Hive.JobManager 12033-12122 /branches/ParallelEngine/HeuristicLab.Clients.Hive.JobManager 5175-5192 /branches/ProblemInstancesRegressionAndClassification/HeuristicLab.Clients.Hive.JobManager 7568-7810 /branches/QAPAlgorithms/HeuristicLab.Clients.Hive.JobManager 6350-6627 /branches/Restructure trunk solution/HeuristicLab.Clients.Hive.JobManager 6828 /branches/RuntimeOptimizer/HeuristicLab.Clients.Hive.JobManager 8943-9078 /branches/ScatterSearch (trunk integration)/HeuristicLab.Clients.Hive.JobManager 7787-8333 /branches/SlaveShutdown/HeuristicLab.Clients.Hive.JobManager 8944-8956 /branches/SpectralKernelForGaussianProcesses/HeuristicLab.Clients.Hive.JobManager 10204-10479 /branches/SuccessProgressAnalysis/HeuristicLab.Clients.Hive.JobManager 5370-5682 /branches/Trunk/HeuristicLab.Clients.Hive.JobManager 6829-6865 /branches/UnloadJobs/HeuristicLab.Clients.Hive.JobManager 9168-9215 /branches/VNS/HeuristicLab.Clients.Hive.JobManager 5594-5752 /branches/crossvalidation-2434/HeuristicLab.Clients.Hive.JobManager 12948-12950 /branches/histogram/HeuristicLab.Clients.Hive.JobManager 5959-6341 /branches/symbreg-factors-2650/HeuristicLab.Clients.Hive.JobManager 14232-14825
-
Property
svn:mergeinfo
set to
(toggle deleted branches)
-
branches/2845_EnhancedProgress/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
r16308 r16311 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 6Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 23 23 using System.ComponentModel; 24 24 using System.Linq; 25 using System.Text;26 25 using System.Threading; 27 26 using System.Threading.Tasks; … … 34 33 using HeuristicLab.Optimization; 35 34 using HeuristicLab.PluginInfrastructure; 35 using System.Collections.Generic; 36 36 37 37 namespace HeuristicLab.Clients.Hive.JobManager.Views { … … 45 45 private bool SuppressEvents { get; set; } 46 46 private object runCollectionViewLocker = new object(); 47 private Project selectedProject; 48 private Dictionary<Guid, Guid> originalJobProjectAssignment = new Dictionary<Guid, Guid>(); 47 49 48 50 public new RefreshableJob Content { 49 51 get { return (RefreshableJob)base.Content; } 50 set { base.Content = value; } 52 set { 53 base.Content = value; 54 } 51 55 } 52 56 … … 117 121 if (Content == null) { 118 122 nameTextBox.Text = string.Empty; 123 descriptionTextBox.Text = string.Empty; 119 124 executionTimeTextBox.Text = string.Empty; 120 resourceNamesTextBox.Text = string.Empty;125 projectNameTextBox.Text = string.Empty; 121 126 refreshAutomaticallyCheckBox.Checked = false; 122 127 lock (runCollectionViewLocker) { … … 128 133 stateLogViewHost.Content = null; 129 134 } else { 135 if(Content.Job != null 136 && Content.Job.Id != Guid.Empty 137 && !originalJobProjectAssignment.ContainsKey(Content.Job.Id)) { 138 originalJobProjectAssignment.Add(Content.Job.Id, Content.Job.ProjectId); 139 } 140 141 // project look up 142 if (Content.Job != null && Content.Job.ProjectId == Guid.Empty) { 143 projectNameTextBox.Text = string.Empty; 144 if (HiveClient.Instance != null && HiveClient.Instance.Projects != null && HiveClient.Instance.Projects.Count == 1) { 145 var p = HiveClient.Instance.Projects.FirstOrDefault(); 146 if (p != null && p.Id != Guid.Empty) { 147 hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId); 148 Content.Job.ProjectId = p.Id; 149 var resources = HiveClient.Instance.GetAvailableResourcesForProject(p.Id).ToList(); 150 Content.Job.ResourceIds = resources.Select(x => x.Id).ToList(); 151 hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; 152 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)"; 161 } 162 } 163 } else if (Content.Job != null && Content.Job.ProjectId != Guid.Empty) { 164 if (selectedProject == null || selectedProject.Id != Content.Job.ProjectId) { 165 selectedProject = GetProject(Content.Job.ProjectId); 166 hiveResourceSelectorDialog = null; 167 } 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 194 } else { 195 selectedProject = null; 196 projectNameTextBox.Text = string.Empty; 197 Content.Job.ResourceIds = null; 198 } 199 200 130 201 nameTextBox.Text = Content.Job.Name; 202 descriptionTextBox.Text = Content.Job.Description; 131 203 executionTimeTextBox.Text = Content.ExecutionTime.ToString(); 132 resourceNamesTextBox.Text = Content.Job.ResourceNames;133 204 refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically; 205 134 206 logView.Content = Content.Log; 135 207 lock (runCollectionViewLocker) { … … 140 212 SuppressEvents = false; 141 213 } 142 hiveExperimentPermissionListView.Content = null; // has to be filled by refresh button214 hiveExperimentPermissionListView.Content = null; // has to be filled by refresh 143 215 Content_JobStatisticsChanged(this, EventArgs.Empty); 144 216 Content_HiveExperimentChanged(this, EventArgs.Empty); … … 157 229 tabControl.Enabled = !Locked; 158 230 nameTextBox.Enabled = !Locked; 159 resourceNamesTextBox.Enabled = !Locked; 231 descriptionTextBox.Enabled = !Locked; 232 projectNameTextBox.Enabled = !Locked; 160 233 searchButton.Enabled = !Locked; 161 234 jobsTreeView.Enabled = !Locked; … … 181 254 tabControl.Enabled = !Content.IsProgressing; 182 255 183 this.nameTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded ||Content.IsProgressing;184 this. resourceNamesTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded ||Content.IsProgressing;185 this.searchButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Prepared && !alreadyUploaded && !Content.IsProgressing;256 this.nameTextBox.ReadOnly = Content.IsProgressing; 257 this.descriptionTextBox.ReadOnly = Content.IsProgressing; 258 this.searchButton.Enabled = !Content.IsProgressing && Content.ExecutionState != ExecutionState.Stopped; 186 259 this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing; 187 260 188 261 this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && (Content.ExecutionState == ExecutionState.Started || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing; 189 262 this.refreshButton.Enabled = Content.IsDownloadable && alreadyUploaded && !Content.IsProgressing; 263 this.updateButton.Enabled = Content.ExecutionState != ExecutionState.Prepared && Content.ExecutionState != ExecutionState.Stopped && !Content.IsProgressing; 190 264 191 265 this.UnloadButton.Enabled = Content.HiveTasks != null && Content.HiveTasks.Count > 0 && alreadyUploaded && !Content.IsProgressing; … … 332 406 #region Control events 333 407 private void searchButton_Click(object sender, EventArgs e) { 334 if (hiveResourceSelectorDialog == null) 335 hiveResourceSelectorDialog = new HiveResourceSelectorDialog(); 408 if (hiveResourceSelectorDialog == null) { 409 hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId); 410 } else if(hiveResourceSelectorDialog.JobId != Content.Job.Id) { 411 hiveResourceSelectorDialog.JobId = Content.Job.Id; 412 hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; 413 hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; 414 415 if (originalJobProjectAssignment.ContainsKey(Content.Job.Id)) { 416 hiveResourceSelectorDialog.ProjectId = originalJobProjectAssignment[Content.Job.Id]; 417 } else { 418 hiveResourceSelectorDialog.ProjectId = Guid.Empty; 419 } 420 } else if(hiveResourceSelectorDialog.JobId == Guid.Empty && Content.Job.Id == Guid.Empty) { 421 hiveResourceSelectorDialog.JobId = Content.Job.Id; 422 hiveResourceSelectorDialog.ProjectId = Guid.Empty; 423 hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; 424 hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; 425 } else { 426 hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; 427 hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; 428 } 429 336 430 if (hiveResourceSelectorDialog.ShowDialog(this) == DialogResult.OK) { 337 StringBuilder sb = new StringBuilder(); 338 foreach (Resource resource in hiveResourceSelectorDialog.GetSelectedResources()) { 339 sb.Append(resource.Name); 340 sb.Append(";"); 341 } 342 resourceNamesTextBox.Text = sb.ToString(); 343 if (Content.Job.ResourceNames != resourceNamesTextBox.Text) 344 Content.Job.ResourceNames = resourceNamesTextBox.Text; 431 selectedProject = hiveResourceSelectorDialog.SelectedProject; 432 if(selectedProject != null) { 433 Content.Job.ProjectId = selectedProject.Id; 434 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 446 } else { 447 selectedProject = null; 448 projectNameTextBox.Text = string.Empty; 449 Content.Job.ProjectId = Guid.Empty; 450 Content.Job.ResourceIds = null; 451 } 452 SetEnabledStateOfExecutableButtons(); 345 453 } 346 454 } … … 349 457 if (nameTextBox.Text.Trim() == string.Empty) { 350 458 MessageBox.Show("Please enter a name for the job before uploading it!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); 459 } else if (Content.Job.ProjectId == null || Content.Job.ProjectId == Guid.Empty) { 460 MessageBox.Show("Please select a project before uploading the job!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); 461 } else if (Content.Job.ResourceIds == null || !Content.Job.ResourceIds.Any()) { 462 MessageBox.Show("Please select resources before uploading the job!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); 351 463 } else if (Content.ExecutionState == ExecutionState.Paused) { 352 464 var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobAsync, Content); … … 358 470 } else { 359 471 HiveClient.StartJob((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Start failed.", ex), Content, new CancellationToken()); 472 UpdateSelectorDialog(); 360 473 } 361 474 } … … 402 515 } 403 516 517 private void descriptionTextBox_Validated(object sender, EventArgs e) { 518 if (!SuppressEvents && Content.Job != null && Content.Job.Description != descriptionTextBox.Text) 519 Content.Job.Description = descriptionTextBox.Text; 520 } 521 404 522 private void resourceNamesTextBox_Validated(object sender, EventArgs e) { 405 if (!SuppressEvents && Content.Job != null && Content.Job.ResourceNames != resourceNamesTextBox.Text)406 Content.Job.ResourceNames = resourceNamesTextBox.Text;523 //if (!SuppressEvents && Content.Job != null && Content.Job.ResourceNames != resourceNamesTextBox.Text) 524 // Content.Job.ResourceNames = resourceNamesTextBox.Text; 407 525 } 408 526 … … 420 538 } 421 539 }, null); 540 UpdateSelectorDialog(); 541 } 542 543 private void updateButton_Click(object sender, EventArgs e) { 544 if (Content.ExecutionState == ExecutionState.Stopped) { 545 MessageBox.Show("Job cannot be updated once it stopped.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information); 546 return; 547 } 548 549 var invoker = new Action<RefreshableJob>(HiveClient.UpdateJob); 550 invoker.BeginInvoke(Content, (ar) => { 551 try { 552 invoker.EndInvoke(ar); 553 } catch (Exception ex) { 554 ThreadPool.QueueUserWorkItem(delegate (object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex); 555 } 556 }, null); 557 UpdateSelectorDialog(); 558 } 559 560 private void UnloadButton_Click(object sender, EventArgs e) { 561 Content.Unload(); 562 runCollectionViewHost.Content = null; 563 stateLogViewHost.Content = null; 564 hiveExperimentPermissionListView.Content = null; 565 jobsTreeView.Content = null; 566 567 SetEnabledStateOfControls(); 422 568 } 423 569 … … 436 582 startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = false; 437 583 } else { 438 startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing; 584 startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 585 && Content.Job.ProjectId != Guid.Empty && Content.Job.ResourceIds != null && Content.Job.ResourceIds.Any() 586 && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing; 439 587 pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing; 440 588 stopButton.Enabled = Content.IsControllable && (Content.ExecutionState == ExecutionState.Started || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing; 589 } 590 } 591 592 private Project GetProject(Guid projectId) { 593 return HiveServiceLocator.Instance.CallHiveService(s => s.GetProject(projectId)); 594 } 595 596 private void UpdateSelectorDialog() { 597 if(hiveResourceSelectorDialog != null) { 598 hiveResourceSelectorDialog = null; 599 //hiveResourceSelectorDialog.JobId = Content.Job.Id; 600 //hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId; 601 //hiveResourceSelectorDialog.SelectedResourceIds = Content.Job.ResourceIds; 441 602 } 442 603 } … … 515 676 } 516 677 517 private void UnloadButton_Click(object sender, EventArgs e) {518 Content.Unload();519 runCollectionViewHost.Content = null;520 stateLogViewHost.Content = null;521 hiveExperimentPermissionListView.Content = null;522 jobsTreeView.Content = null;523 524 SetEnabledStateOfControls();525 }526 678 } 527 679 }
Note: See TracChangeset
for help on using the changeset viewer.