Free cookie consent management tool by TermsFeed Policy Generator

source: branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectJobsView.cs @ 15966

Last change on this file since 15966 was 15966, checked in by jzenisek, 6 years ago

#2839: Fixed several bugs and added project duration handling

  • fixed project duration handling (client- & service-side)
  • fixed tagging in HiveJobAdmin
  • added ProjectJobs view (under construction)
  • added necessary service methods
File size: 4.0 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2018 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 System.Collections.Generic;
24using System.Drawing;
25using System.Linq;
26using System.Windows.Forms;
27using HeuristicLab.MainForm;
28using HeuristicLab.MainForm.WindowsForms;
29using HeuristicLab.Core.Views;
30using HeuristicLab.Data.Views;
31using HeuristicLab.Data;
32
33namespace HeuristicLab.Clients.Hive.Administrator.Views {
34  [View("ProjectView")]
35  [Content(typeof(Project), IsDefaultView = false)]
36  public partial class ProjectJobsView : ItemView {
37    private const string JOB_ID = "Id";
38    private const string JOB_NAME = "Name";
39    private const string JOB_OWNER = "Owner";
40    private const string JOB_DATECREATED = "Date Created";
41    private const string JOB_STATE = "State";
42    private const string JOB_DESCRIPTION = "Description";
43
44    public new Project Content {
45      get { return (Project)base.Content; }
46      set { base.Content = value; }
47    }
48
49    public ProjectJobsView() /*: base()*/ {
50      InitializeComponent();
51    }
52
53    #region Overrides
54    protected override void OnContentChanged() {
55      base.OnContentChanged();
56      UpdateJobs();
57    }
58    protected override void SetEnabledStateOfControls() {
59      base.SetEnabledStateOfControls();
60      bool enabled = Content != null && !Locked && !ReadOnly;
61
62      refreshButton.Enabled = enabled;
63      removeButton.Enabled = enabled;
64      matrixView.Enabled = enabled;
65    }
66    #endregion Overrides
67
68    #region Event Handlers
69    private void ProjectJobsView_Load(object sender, EventArgs e) {
70     
71    }
72
73    private void refreshButton_Click(object sender, EventArgs e) {
74      HiveAdminClient.Instance.Refresh();
75      // Update list/matrix
76    }
77
78    private async void removeButton_Click(object sender, EventArgs e) {
79      // remove selected job(s)
80    }
81
82    #endregion Event Handlers
83
84    #region Helpers
85    private StringMatrix CreateValueMatrix() {
86      var jobs = HiveAdminClient.Instance.Jobs[Content.Id];
87      string[,] values = new string[jobs.Count, 7];
88
89      for(int i = 0; i < jobs.Count; i++) {
90        var job = jobs.ElementAt(i);
91        values[i, 0] = job.Id.ToString();
92        values[i, 1] = job.Name;
93        values[i, 2] = job.OwnerUserId.ToString();
94        values[i, 3] = job.OwnerUsername;
95        values[i, 4] = job.DateCreated.ToString();
96        values[i, 5] = job.State.ToString();
97        values[i, 6] = job.Description;
98      }
99
100      var matrix = new StringMatrix(values);
101      matrix.ColumnNames = new string[] { JOB_ID, JOB_NAME, JOB_OWNER, JOB_OWNER, JOB_DATECREATED, JOB_STATE, JOB_DESCRIPTION };
102      matrix.SortableView = true;
103      return matrix;
104    }
105
106    private void UpdateJobs() {
107      if (InvokeRequired) Invoke((Action)UpdateJobs);
108      else {
109        StringMatrix matrix = null;
110        if(Content != null) {
111          matrix = CreateValueMatrix();
112        } else {
113          refreshButton.Enabled = false;
114          removeButton.Enabled = false;
115        }
116        matrixView.Content = matrix;
117        matrixView.DataGridView.AutoResizeColumns();
118        //foreach(DataGridViewColumn col in matrixView.DataGridView.Columns) {
119        //  col.Width = -2;
120        //}
121      }
122    }
123    #endregion Helpers
124  }
125}
Note: See TracBrowser for help on using the repository browser.