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 | using HeuristicLab.Services.Hive.Common.DataTransfer;
|
---|
28 |
|
---|
29 | namespace 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_NodeMouseClick(object sender, TreeNodeMouseClickEventArgs e) {
|
---|
126 | if (e.Node != null) {
|
---|
127 | if (e.Node.Tag.GetType() == typeof(Slave)) {
|
---|
128 | Slave s = e.Node.Tag as Slave;
|
---|
129 | txtName.Text = s.Name;
|
---|
130 | txtDetailsDescription.Text = s.Description;
|
---|
131 | txtCPU.Text = s.CpuArchitecture + ", " + s.Cores + " Cores @ " + s.CpuSpeed.ToString();
|
---|
132 | txtMemory.Text = s.Memory.ToString();
|
---|
133 | txtDetailsCalculatedJobs.Clear();
|
---|
134 | txtOS.Text = s.OperatingSystem;
|
---|
135 | txtSlaveState.Text = s.SlaveState.ToString();
|
---|
136 | } else if (e.Node.Tag.GetType() == typeof(SlaveGroup)) {
|
---|
137 | SlaveGroup s = e.Node.Tag as SlaveGroup;
|
---|
138 | txtName.Text = s.Name;
|
---|
139 | txtDetailsDescription.Text = s.Description;
|
---|
140 | txtCPU.Clear();
|
---|
141 | txtMemory.Clear();
|
---|
142 | txtDetailsCalculatedJobs.Clear();
|
---|
143 | txtOS.Clear();
|
---|
144 | txtSlaveState.Clear();
|
---|
145 | }
|
---|
146 | }
|
---|
147 | }
|
---|
148 |
|
---|
149 |
|
---|
150 | #region Event Handlers
|
---|
151 | // TODO: Put event handlers here
|
---|
152 | #endregion
|
---|
153 | }
|
---|
154 | }
|
---|