[15422] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[16453] | 3 | * Copyright (C) 2002-2019 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[15422] | 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 |
|
---|
| 22 | using System;
|
---|
| 23 | using HeuristicLab.Clients.Access;
|
---|
| 24 | using HeuristicLab.Core.Views;
|
---|
| 25 | using HeuristicLab.MainForm;
|
---|
| 26 |
|
---|
| 27 | namespace 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();
|
---|
[15567] | 60 | bool enabled = Content != null && !Locked;
|
---|
[15742] | 61 | idTextBox.ReadOnly = true;
|
---|
[15576] | 62 | nameTextBox.ReadOnly = !enabled;
|
---|
| 63 | descriptionTextBox.ReadOnly = !enabled;
|
---|
| 64 | heartbeatIntervalNumericUpDown.ReadOnly = !enabled;
|
---|
[15422] | 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 | }
|
---|