source: branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourceView.cs @ 15559

Last change on this file since 15559 was 15422, checked in by jkarder, 4 years ago

#2839: worked on resources and projects views

File size: 3.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using HeuristicLab.Clients.Access;
24using HeuristicLab.Core.Views;
25using HeuristicLab.MainForm;
26
27namespace HeuristicLab.Clients.Hive.Administrator.Views {
28  [View("Resource View")]
29  [Content(typeof(Resource), IsDefaultView = true)]
30  public partial class ResourceView : ItemView {
31    public new Resource Content {
32      get { return (Resource)base.Content; }
33      set { base.Content = value; }
34    }
35
36    public ResourceView() {
37      InitializeComponent();
38    }
39
40    #region Overrides
41    protected override void OnContentChanged() {
42      base.OnContentChanged();
43      if (Content == null) {
44        idTextBox.Clear();
45        nameTextBox.Clear();
46        descriptionTextBox.Clear();
47        heartbeatIntervalNumericUpDown.Value = 0;
48        publicCheckBox.Checked = false;
49      } else {
50        idTextBox.Text = Content.Id.ToString();
51        nameTextBox.Text = Content.Name;
52        descriptionTextBox.Text = Content.Description;
53        heartbeatIntervalNumericUpDown.Value = Content.HbInterval;
54        publicCheckBox.Checked = Content.OwnerUserId == null;
55      }
56    }
57
58    protected override void SetEnabledStateOfControls() {
59      base.SetEnabledStateOfControls();
60      bool enabled = Content != null;
61      nameTextBox.Enabled = enabled;
62      descriptionTextBox.Enabled = enabled;
63      heartbeatIntervalNumericUpDown.Enabled = enabled;
64      publicCheckBox.Enabled = enabled;
65    }
66    #endregion
67
68    #region Event Handlers
69    private void nameTextBox_TextChanged(object sender, EventArgs e) {
70      if (Content != null && Content.Name != nameTextBox.Text)
71        Content.Name = nameTextBox.Text;
72    }
73
74    private void descriptionTextBox_TextChanged(object sender, EventArgs e) {
75      if (Content != null && Content.Description != descriptionTextBox.Text)
76        Content.Description = descriptionTextBox.Text;
77    }
78
79    private void heartbeatIntervalNumericUpDown_ValueChanged(object sender, EventArgs e) {
80      if (Content != null && Content.HbInterval != (int)heartbeatIntervalNumericUpDown.Value)
81        Content.HbInterval = (int)heartbeatIntervalNumericUpDown.Value;
82    }
83
84    private void publicCheckBox_CheckedChanged(object sender, EventArgs e) {
85      var newOwnerUserId = publicCheckBox.Checked ? null : (Guid?)UserInformation.Instance.User.Id;
86      if (Content != null && Content.OwnerUserId != newOwnerUserId)
87        Content.OwnerUserId = newOwnerUserId;
88    }
89    #endregion
90  }
91}
Note: See TracBrowser for help on using the repository browser.