Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
09/21/18 16:00:50 (6 years ago)
Author:
jkarder
Message:

#2839:

  • fixed compilation errors in HiveEngine
  • minor changes
File:
1 edited

Legend:

Unmodified
Added
Removed
  • addons/HeuristicLab.MetaOptimization/HeuristicLab.HiveEngine.Views/3.3/HiveEngineView.cs

    r12930 r16173  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Linq;
     25using System.Windows.Forms;
     26using HeuristicLab.Clients.Hive;
     27using HeuristicLab.Clients.Hive.JobManager.Views;
    2328using HeuristicLab.Core.Views;
    2429using HeuristicLab.MainForm;
     
    2833  [Content(typeof(HiveEngine), IsDefaultView = true)]
    2934  public sealed partial class HiveEngineView : ItemView {
     35    private readonly HiveResourceSelectorDialog hiveResourceSelectorDialog = new HiveResourceSelectorDialog(Guid.Empty, Guid.Empty);
     36
    3037    public new HiveEngine Content {
    3138      get { return (HiveEngine)base.Content; }
     
    7077      base.OnContentChanged();
    7178      if (Content == null) {
    72         resourceIdsTextBox.Text = string.Empty;
    73         priorityTextBox.Text = string.Empty;
     79        projectNameTextBox.Text = string.Empty;
     80        priorityComboBox.SelectedIndex = 1;
    7481        executionTimeOnHiveTextBox.Text = string.Empty;
    7582        hiveExperimentListView.Content = null;
    7683        logView.Content = null;
    7784      } else {
    78         resourceIdsTextBox.Text = Content.ResourceNames;
    79         priorityTextBox.Text = Content.Priority.ToString();
     85        if (Content.ProjectId != null && Content.ProjectId != Guid.Empty) {
     86          var project = HiveServiceLocator.Instance.CallHiveService(s => s.GetProject(Content.ProjectId));
     87          if (project != null) projectNameTextBox.Text = project.Name;
     88        } else {
     89          projectNameTextBox.Text = string.Empty;
     90        }
     91
     92        if (Content.Priority >= 0 && Content.Priority < priorityComboBox.Items.Count) {
     93          priorityComboBox.SelectedIndex = Content.Priority;
     94        } else {
     95          priorityComboBox.SelectedIndex = 1;
     96        }
     97
    8098        executionTimeOnHiveTextBox.Text = Content.ExecutionTimeOnHive.ToString();
    8199        hiveExperimentListView.Content = Content.Jobs;
     
    86104    protected override void SetEnabledStateOfControls() {
    87105      base.SetEnabledStateOfControls();
    88       // Enable or disable controls based on whether the content is null or the view is set readonly
    89       if (Content != null) {
    90         resourceIdsTextBox.ReadOnly = this.ReadOnly;
    91         priorityTextBox.ReadOnly = this.ReadOnly;
    92       } else {
    93         resourceIdsTextBox.ReadOnly = false;
    94         priorityTextBox.ReadOnly = false;
     106
     107      searchButton.Enabled = Content != null && !ReadOnly && !Locked;
     108      projectNameTextBox.Enabled = Content != null && !ReadOnly && !Locked;
     109      priorityComboBox.Enabled = Content != null && !ReadOnly && !Locked;
     110    }
     111
     112    private void searchButton_Click(object sender, EventArgs e) {
     113      hiveResourceSelectorDialog.SelectedProjectId = Content != null ? Content.ProjectId : Guid.Empty;
     114      hiveResourceSelectorDialog.SelectedResourceIds = Content != null ? Content.ResourceIds : new List<Guid>();
     115
     116      var result = hiveResourceSelectorDialog.ShowDialog(this);
     117      if (result == DialogResult.OK) {
     118        var selectedProject = hiveResourceSelectorDialog.SelectedProject;
     119        if (selectedProject != null) {
     120          projectNameTextBox.Text = selectedProject.Name;
     121          Content.ProjectId = selectedProject.Id;
     122          Content.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList();
     123        } else {
     124          projectNameTextBox.Text = string.Empty;
     125          Content.ProjectId = Guid.Empty;
     126          Content.ResourceIds = new List<Guid>();
     127        }
    95128      }
    96129    }
    97130
    98     #region Event Handlers (child controls)
    99     private void resourceIdsTextBox_Validated(object sender, EventArgs e) {
    100       Content.ResourceNames = resourceIdsTextBox.Text;
     131    private void priorityComboBox_SelectedIndexChanged(object sender, EventArgs e) {
     132      if (Content != null && Content.Priority != priorityComboBox.SelectedIndex) {
     133        Content.Priority = priorityComboBox.SelectedIndex;
     134      }
    101135    }
    102 
    103     private void priorityTextBox_Validated(object sender, EventArgs e) {
    104       Content.Priority = int.Parse(priorityTextBox.Text);
    105     }
    106     #endregion
    107136  }
    108137}
Note: See TracChangeset for help on using the changeset viewer.