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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r15412 r15627  
    3333using HeuristicLab.Optimization;
    3434using HeuristicLab.PluginInfrastructure;
     35using System.Collections.Generic;
    3536
    3637namespace HeuristicLab.Clients.Hive.JobManager.Views {
     
    4445    private bool SuppressEvents { get; set; }
    4546    private object runCollectionViewLocker = new object();
     47    private Project selectedProject;
    4648
    4749    public new RefreshableJob Content {
     
    129131          nameTextBox.Text = Content.Job.Name;
    130132          executionTimeTextBox.Text = Content.ExecutionTime.ToString();
    131           //resourceNamesTextBox.Text = Content.Job.ResourceNames;
    132133          refreshAutomaticallyCheckBox.Checked = Content.RefreshAutomatically;
     134
     135          // project look up
     136          if(Content.Job.ProjectId != null && Content.Job.ProjectId != Guid.Empty) {
     137            selectedProject = GetProject(Content.Job.ProjectId);
     138            if(selectedProject != null) {
     139              projectNameTextBox.Text = selectedProject.Name;
     140            } else {
     141              projectNameTextBox.Text = string.Empty;
     142            }
     143          } else {
     144            selectedProject = null;
     145            projectNameTextBox.Text = string.Empty;
     146          }
     147         
    133148          logView.Content = Content.Log;
    134149          lock (runCollectionViewLocker) {
     
    330345    #region Control events
    331346    private void searchButton_Click(object sender, EventArgs e) {
    332       if (hiveResourceSelectorDialog == null)
    333         hiveResourceSelectorDialog = new HiveResourceSelectorDialog();
     347      if (hiveResourceSelectorDialog == null) {
     348        hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Content.Job.Id, Content.Job.ProjectId);
     349      } else if(selectedProject != null) {
     350        hiveResourceSelectorDialog.SelectedProjectId = Content.Job.ProjectId;
     351      } else {
     352        hiveResourceSelectorDialog.SelectedProjectId = null;
     353      }
    334354
    335355      if (hiveResourceSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    336         var selectedProject = hiveResourceSelectorDialog.SelectedProject;
    337         projectNameTextBox.Text = selectedProject.Name;
    338         Content.Job.ProjectId = selectedProject.Id;
    339         Content.Job.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList();
     356        selectedProject = hiveResourceSelectorDialog.SelectedProject;
     357        if(selectedProject != null) {
     358          projectNameTextBox.Text = selectedProject.Name;
     359          Content.Job.ProjectId = selectedProject.Id;
     360          Content.Job.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList();
     361        } else {
     362          projectNameTextBox.Text = string.Empty;
     363          Content.Job.ProjectId = Guid.Empty;
     364          Content.Job.ResourceIds = null;
     365        }
    340366      }
    341367    }
     
    344370      if (nameTextBox.Text.Trim() == string.Empty) {
    345371        MessageBox.Show("Please enter a name for the job before uploading it!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     372      } else if (Content.Job.ProjectId == null || Content.Job.ProjectId == Guid.Empty) {
     373        MessageBox.Show("Please select a project before uploading the job!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     374      } else if (Content.Job.ResourceIds == null || !Content.Job.ResourceIds.Any()) {
     375        MessageBox.Show("Please select resources before uploading the job!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
    346376      } else if (Content.ExecutionState == ExecutionState.Paused) {
    347377        var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobAsync, Content);
     
    436466      }
    437467    }
     468   
     469    private Project GetProject(Guid projectId) {
     470      return HiveServiceLocator.Instance.CallHiveService(s => s.GetProject(projectId));
     471    }
    438472    #endregion
    439473
Note: See TracChangeset for help on using the changeset viewer.