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