Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/Administration/HiveAdministrationView.cs @ 5525

Last change on this file since 5525 was 5525, checked in by ascheibe, 14 years ago

#1233 worked on administration gui

File size: 5.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2011 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.Windows.Forms;
24using HeuristicLab.Clients.Hive.Administration;
25using HeuristicLab.Core.Views;
26using HeuristicLab.MainForm;
27using HeuristicLab.Services.Hive.Common.DataTransfer;
28
29namespace HeuristicLab.Clients.Hive.Views.Administration {
30  [View("HiveAdministrationView")]
31  [Content(typeof(HiveAdministrationClient), IsDefaultView = true)]
32  public partial class HiveAdministrationView : ItemView {
33    public new HiveAdministrationClient Content {
34      get { return (HiveAdministrationClient)base.Content; }
35      set { base.Content = value; }
36    }
37
38    public HiveAdministrationView() {
39      InitializeComponent();
40    }
41
42    #region Register Content Events
43    protected override void DeregisterContentEvents() {
44      // TODO: Deregister your event handlers on the Content here
45      base.DeregisterContentEvents();
46    }
47    protected override void RegisterContentEvents() {
48      base.RegisterContentEvents();
49      // TODO: Register your event handlers on the Content here
50    }
51    #endregion
52
53
54    protected override void OnContentChanged() {
55      base.OnContentChanged();
56      if (Content == null) {
57        // TODO: Put code here when content is null
58      } else {
59        updateSlaveGroups.UpdateAction = new Action(Content.UpdateSlaveGroups);
60        treeSlaveGroup.ImageList.Images.Add(HiveImageLibrary.Slave);
61        treeSlaveGroup.ImageList.Images.Add(HiveImageLibrary.SlaveGroup);
62
63        foreach (SlaveGroup g in Content.SlaveGroups) {
64          TreeNode tn = new TreeNode();
65          tn.ImageIndex = treeSlaveGroup.ImageList.Images.Count - 1;
66          tn.SelectedImageIndex = tn.ImageIndex;
67
68          tn.Tag = g;
69          tn.Text = g.Name;
70          foreach (Slave s in Content.Slaves.FindAll(s => s.ParentResourceId != null && s.ParentResourceId == g.Id)) {
71            var stn = new TreeNode(s.Name);
72            stn.ImageIndex = 0;
73            stn.SelectedImageIndex = stn.ImageIndex;
74            stn.Tag = s;
75            tn.Nodes.Add(stn);
76          }
77          treeSlaveGroup.Nodes.Add(tn);
78        }
79
80        TreeNode ungrp = new TreeNode("UNGROUPED");
81        ungrp.ImageIndex = treeSlaveGroup.ImageList.Images.Count - 1;
82        ungrp.SelectedImageIndex = ungrp.ImageIndex;
83        var newGroup = new SlaveGroup();
84        newGroup.Name = "UNGROUPED";
85        newGroup.Id = Guid.NewGuid();
86        newGroup.Description = "Contains slaves which are in no group";
87        ungrp.Tag = newGroup;
88
89        foreach (Slave s in Content.Slaves.FindAll(s => s.ParentResourceId == null)) {
90          var stn = new TreeNode(s.Name);
91          stn.ImageIndex = 0;
92          stn.SelectedImageIndex = stn.ImageIndex;
93          stn.Tag = s;
94          ungrp.Nodes.Add(stn);
95        }
96        treeSlaveGroup.Nodes.Add(ungrp);
97
98        ShowUsers();
99      }
100    }
101
102    private void ShowUsers() {
103      lstUsers.SmallImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.User);
104
105      foreach (string user in Content.Users) {
106        ListViewItem lvi = new ListViewItem();
107        lvi.Tag = user;
108        lvi.Text = user;
109        lvi.ImageIndex = 0;
110        lstUsers.Items.Add(lvi);
111      }
112    }
113
114    protected override void SetEnabledStateOfControls() {
115      base.SetEnabledStateOfControls();
116      // TODO: Put code here to enable or disable controls based on whether the Content is/not null or the view is ReadOnly
117    }
118
119    private void HiveAdministrationView_Load(object sender, System.EventArgs e) {
120      if (Content != null) {
121
122      }
123    }
124
125    private void treeSlaveGroup_Click(object sender, System.EventArgs e) {
126
127    }
128
129    private void treeSlaveGroup_MouseClick(object sender, MouseEventArgs e) {
130      if (treeSlaveGroup.SelectedNode != null &&
131      treeSlaveGroup.SelectedNode.Tag != null) {
132        if (treeSlaveGroup.SelectedNode.Tag.GetType() == typeof(Slave)) {
133          Slave s = treeSlaveGroup.SelectedNode.Tag as Slave;
134          txtName.Text = s.Name;
135          txtDetailsDescription.Text = s.Description;
136          txtCPU.Text = s.CpuArchitecture + ", " + s.Cores + " Cores @ " + s.CpuSpeed.ToString();
137          txtMemory.Text = s.Memory.ToString();
138          txtDetailsCalculatedJobs.Clear();
139          txtOS.Text = s.OperatingSystem;
140          txtSlaveState.Text = s.SlaveState.ToString();
141        } else if (treeSlaveGroup.SelectedNode.Tag.GetType() == typeof(SlaveGroup)) {
142          SlaveGroup s = treeSlaveGroup.SelectedNode.Tag as SlaveGroup;
143          txtName.Text = s.Name;
144          txtDetailsDescription.Text = s.Description;
145          txtCPU.Clear();
146          txtMemory.Clear();
147          txtDetailsCalculatedJobs.Clear();
148          txtOS.Clear();
149          txtSlaveState.Clear();
150        }
151      }
152    }
153
154
155
156    #region Event Handlers
157    // TODO: Put event handlers here
158    #endregion
159  }
160}
Note: See TracBrowser for help on using the repository browser.