Free cookie consent management tool by TermsFeed Policy Generator

source: branches/3026_IntegrationIntoSymSpace/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourceView.cs

Last change on this file was 17180, checked in by swagner, 5 years ago

#2875: Removed years in copyrights

File size: 3.3 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 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 && !Locked;
61      idTextBox.ReadOnly = true;
62      nameTextBox.ReadOnly = !enabled;
63      descriptionTextBox.ReadOnly = !enabled;
64      heartbeatIntervalNumericUpDown.ReadOnly = !enabled;
65      publicCheckBox.Enabled = enabled;
66    }
67    #endregion
68
69    #region Event Handlers
70    private void nameTextBox_TextChanged(object sender, EventArgs e) {
71      if (Content != null && Content.Name != nameTextBox.Text)
72        Content.Name = nameTextBox.Text;
73    }
74
75    private void descriptionTextBox_TextChanged(object sender, EventArgs e) {
76      if (Content != null && Content.Description != descriptionTextBox.Text)
77        Content.Description = descriptionTextBox.Text;
78    }
79
80    private void heartbeatIntervalNumericUpDown_ValueChanged(object sender, EventArgs e) {
81      if (Content != null && Content.HbInterval != (int)heartbeatIntervalNumericUpDown.Value)
82        Content.HbInterval = (int)heartbeatIntervalNumericUpDown.Value;
83    }
84
85    private void publicCheckBox_CheckedChanged(object sender, EventArgs e) {
86      var newOwnerUserId = publicCheckBox.Checked ? null : (Guid?)UserInformation.Instance.User.Id;
87      if (Content != null && Content.OwnerUserId != newOwnerUserId)
88        Content.OwnerUserId = newOwnerUserId;
89    }
90    #endregion
91  }
92}
Note: See TracBrowser for help on using the repository browser.