- Timestamp:
- 10/18/18 16:16:31 (6 years ago)
- Location:
- branches/2915-AbsoluteSymbol
- Files:
-
- 11 edited
- 12 copied
Legend:
- Unmodified
- Added
- Removed
-
branches/2915-AbsoluteSymbol
- Property svn:mergeinfo changed
-
branches/2915-AbsoluteSymbol/HeuristicLab.Clients.Hive.Administrator
- Property svn:mergeinfo changed
-
branches/2915-AbsoluteSymbol/HeuristicLab.Clients.Hive.Administrator/3.3/Views/HiveAdministratorView.Designer.cs
r15583 r16240 29 29 this.components = new System.ComponentModel.Container(); 30 30 this.tabAdmin = new System.Windows.Forms.TabControl(); 31 this.tabSlaves = new System.Windows.Forms.TabPage(); 31 this.tabResources = new System.Windows.Forms.TabPage(); 32 this.resourcesView = new HeuristicLab.Clients.Hive.Administrator.Views.ResourcesView(); 33 this.tabProjects = new System.Windows.Forms.TabPage(); 32 34 this.imageListUsers = new System.Windows.Forms.ImageList(this.components); 33 this. resourcesView = new HeuristicLab.Clients.Hive.Administrator.Views.ResourcesView();35 this.projectsView = new HeuristicLab.Clients.Hive.Administrator.Views.ProjectsView(); 34 36 this.tabAdmin.SuspendLayout(); 35 this.tabSlaves.SuspendLayout(); 37 this.tabResources.SuspendLayout(); 38 this.tabProjects.SuspendLayout(); 36 39 this.SuspendLayout(); 37 40 // 38 41 // tabAdmin 39 42 // 40 this.tabAdmin.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 41 | System.Windows.Forms.AnchorStyles.Left) 42 | System.Windows.Forms.AnchorStyles.Right))); 43 this.tabAdmin.Controls.Add(this.tabSlaves); 43 this.tabAdmin.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 44 | System.Windows.Forms.AnchorStyles.Left) 45 | System.Windows.Forms.AnchorStyles.Right))); 46 this.tabAdmin.Controls.Add(this.tabResources); 47 this.tabAdmin.Controls.Add(this.tabProjects); 44 48 this.tabAdmin.Location = new System.Drawing.Point(3, 0); 45 49 this.tabAdmin.Name = "tabAdmin"; … … 48 52 this.tabAdmin.TabIndex = 0; 49 53 // 50 // tab Slaves54 // tabResources 51 55 // 52 this.tabSlaves.Controls.Add(this.resourcesView); 53 this.tabSlaves.Location = new System.Drawing.Point(4, 22); 54 this.tabSlaves.Name = "tabSlaves"; 55 this.tabSlaves.Padding = new System.Windows.Forms.Padding(3); 56 this.tabSlaves.Size = new System.Drawing.Size(734, 520); 57 this.tabSlaves.TabIndex = 3; 58 this.tabSlaves.Text = "Slaves"; 59 this.tabSlaves.UseVisualStyleBackColor = true; 60 // 61 // imageListUsers 62 // 63 this.imageListUsers.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit; 64 this.imageListUsers.ImageSize = new System.Drawing.Size(16, 16); 65 this.imageListUsers.TransparentColor = System.Drawing.Color.Transparent; 56 this.tabResources.Controls.Add(this.resourcesView); 57 this.tabResources.Location = new System.Drawing.Point(4, 22); 58 this.tabResources.Name = "tabResources"; 59 this.tabResources.Padding = new System.Windows.Forms.Padding(3); 60 this.tabResources.Size = new System.Drawing.Size(734, 520); 61 this.tabResources.TabIndex = 3; 62 this.tabResources.Text = "Resources"; 63 this.tabResources.UseVisualStyleBackColor = true; 66 64 // 67 65 // resourcesView 68 66 // 69 this.resourcesView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 70 | System.Windows.Forms.AnchorStyles.Left)71 67 this.resourcesView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 68 | System.Windows.Forms.AnchorStyles.Left) 69 | System.Windows.Forms.AnchorStyles.Right))); 72 70 this.resourcesView.Caption = "ResourcesView"; 73 71 this.resourcesView.Content = null; … … 78 76 this.resourcesView.TabIndex = 0; 79 77 // 80 // HiveAdministrationView78 // tabProjects 81 79 // 82 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 80 this.tabProjects.Controls.Add(this.projectsView); 81 this.tabProjects.Location = new System.Drawing.Point(4, 22); 82 this.tabProjects.Name = "tabProjects"; 83 this.tabProjects.Size = new System.Drawing.Size(734, 520); 84 this.tabProjects.TabIndex = 4; 85 this.tabProjects.Text = "Projects"; 86 this.tabProjects.UseVisualStyleBackColor = true; 87 // 88 // imageListUsers 89 // 90 this.imageListUsers.ColorDepth = System.Windows.Forms.ColorDepth.Depth32Bit; 91 this.imageListUsers.ImageSize = new System.Drawing.Size(16, 16); 92 this.imageListUsers.TransparentColor = System.Drawing.Color.Transparent; 93 // 94 // projectsView 95 // 96 this.projectsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 97 | System.Windows.Forms.AnchorStyles.Left) 98 | System.Windows.Forms.AnchorStyles.Right))); 99 this.projectsView.Caption = "Resources View"; 100 this.projectsView.Content = null; 101 this.projectsView.Location = new System.Drawing.Point(0, 0); 102 this.projectsView.Name = "projectsView"; 103 this.projectsView.ReadOnly = false; 104 this.projectsView.Size = new System.Drawing.Size(734, 520); 105 this.projectsView.TabIndex = 0; 106 // 107 // HiveAdministratorView 108 // 83 109 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 84 110 this.Controls.Add(this.tabAdmin); 85 this.Name = "HiveAdministrat ionView";111 this.Name = "HiveAdministratorView"; 86 112 this.Size = new System.Drawing.Size(745, 546); 87 113 this.tabAdmin.ResumeLayout(false); 88 this.tabSlaves.ResumeLayout(false); 114 this.tabResources.ResumeLayout(false); 115 this.tabProjects.ResumeLayout(false); 89 116 this.ResumeLayout(false); 90 117 … … 95 122 private System.ComponentModel.IContainer components; 96 123 private System.Windows.Forms.ImageList imageListUsers; 97 private System.Windows.Forms.TabPage tabSlaves; 98 124 private System.Windows.Forms.TabPage tabResources; 125 private System.Windows.Forms.TabPage tabProjects; 126 private ProjectsView projectsView; 99 127 } 100 128 } -
branches/2915-AbsoluteSymbol/HeuristicLab.Clients.Hive.Administrator/3.3/Views/Recurrence.Designer.cs
r15583 r16240 48 48 this.chbade = new System.Windows.Forms.CheckBox(); 49 49 this.dtpEnd = new System.Windows.Forms.DateTimePicker(); 50 this.dtpToTime = new System.Windows.Forms.DateTimePicker();51 50 this.label5 = new System.Windows.Forms.Label(); 52 51 this.dtpStart = new System.Windows.Forms.DateTimePicker(); 53 this.dtpFromTime = new System.Windows.Forms.DateTimePicker();54 52 this.label6 = new System.Windows.Forms.Label(); 55 53 this.btSaveRecurrence = new System.Windows.Forms.Button(); … … 74 72 this.gbAppointment.Controls.Add(this.chbade); 75 73 this.gbAppointment.Controls.Add(this.dtpEnd); 76 this.gbAppointment.Controls.Add(this.dtpToTime);77 74 this.gbAppointment.Controls.Add(this.label5); 78 75 this.gbAppointment.Controls.Add(this.dtpStart); 79 this.gbAppointment.Controls.Add(this.dtpFromTime);80 76 this.gbAppointment.Controls.Add(this.label6); 81 77 this.gbAppointment.Location = new System.Drawing.Point(2, 2); … … 98 94 // dtpEnd 99 95 // 100 this.dtpEnd.Format = System.Windows.Forms.DateTimePickerFormat.Short; 96 this.dtpEnd.Format = System.Windows.Forms.DateTimePickerFormat.Custom; 97 this.dtpEnd.CustomFormat = "ddd, dd.MM.yyyy, HH:mm:ss"; 101 98 this.dtpEnd.Location = new System.Drawing.Point(113, 56); 102 99 this.dtpEnd.Name = "dtpEnd"; 103 this.dtpEnd.Size = new System.Drawing.Size( 91, 20);100 this.dtpEnd.Size = new System.Drawing.Size(175, 20); 104 101 this.dtpEnd.TabIndex = 29; 105 //106 // dtpToTime107 //108 this.dtpToTime.CustomFormat = "HH:mm";109 this.dtpToTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;110 this.dtpToTime.Location = new System.Drawing.Point(226, 56);111 this.dtpToTime.Name = "dtpToTime";112 this.dtpToTime.ShowUpDown = true;113 this.dtpToTime.Size = new System.Drawing.Size(73, 20);114 this.dtpToTime.TabIndex = 38;115 102 // 116 103 // label5 … … 126 113 // 127 114 this.dtpStart.Format = System.Windows.Forms.DateTimePickerFormat.Custom; 115 this.dtpStart.CustomFormat = "ddd, dd.MM.yyyy, HH:mm:ss"; 128 116 this.dtpStart.Location = new System.Drawing.Point(113, 19); 129 117 this.dtpStart.Name = "dtpStart"; 130 this.dtpStart.Size = new System.Drawing.Size( 89, 20);118 this.dtpStart.Size = new System.Drawing.Size(175, 20); 131 119 this.dtpStart.TabIndex = 28; 132 //133 // dtpFromTime134 //135 this.dtpFromTime.CustomFormat = "HH:mm";136 this.dtpFromTime.Format = System.Windows.Forms.DateTimePickerFormat.Custom;137 this.dtpFromTime.Location = new System.Drawing.Point(226, 19);138 this.dtpFromTime.Name = "dtpFromTime";139 this.dtpFromTime.ShowUpDown = true;140 this.dtpFromTime.Size = new System.Drawing.Size(73, 20);141 this.dtpFromTime.TabIndex = 30;142 120 // 143 121 // label6 … … 307 285 private System.Windows.Forms.Button btSaveRecurrence; 308 286 private System.Windows.Forms.Button btCancelRecurrence; 309 private System.Windows.Forms.DateTimePicker dtpFromTime;310 private System.Windows.Forms.DateTimePicker dtpToTime;311 287 private System.Windows.Forms.CheckBox chbade; 312 288 private System.Windows.Forms.GroupBox gbWeekly; -
branches/2915-AbsoluteSymbol/HeuristicLab.Clients.Hive.Administrator/3.3/Views/Recurrence.cs
r15583 r16240 46 46 //check if valid 47 47 if (InputIsValid()) { 48 dateFrom = DateTime.Parse(dtpStart.Text + " " + dtpFromTime.Text);49 dateTo = DateTime.Parse(dtpEnd.Text + " " + dtpToTime.Text);48 dateFrom = DateTime.Parse(dtpStart.Text); 49 dateTo = DateTime.Parse(dtpEnd.Text); 50 50 51 51 RecurrentEvent recurrentEvent = new RecurrentEvent() { … … 89 89 DateTime dateFrom, dateTo; 90 90 91 dateFrom = DateTime.Parse(dtpStart.Text + " " + dtpFromTime.Text);92 dateTo = DateTime.Parse(dtpEnd.Text + " " + dtpToTime.Text);91 dateFrom = DateTime.Parse(dtpStart.Text); 92 dateTo = DateTime.Parse(dtpEnd.Text); 93 93 94 94 if (chbade.Checked && dateFrom < dateTo) { -
branches/2915-AbsoluteSymbol/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs
r15583 r16240 37 37 components.Dispose(); 38 38 } 39 HiveAdminClient.Instance.Refreshing -= new EventHandler(Instance_Refreshing);40 HiveAdminClient.Instance.Refreshed -= new EventHandler(Instance_Refreshed);41 42 Access.AccessClient.Instance.Refreshing -= new EventHandler(AccessClient_Refreshing);43 Access.AccessClient.Instance.Refreshed -= new EventHandler(AccessClient_Refreshed);44 39 base.Dispose(disposing); 45 40 } … … 56 51 this.splitSlaves = new System.Windows.Forms.SplitContainer(); 57 52 this.btnRefresh = new System.Windows.Forms.Button(); 58 this.progressBar = new System.Windows.Forms.ProgressBar();59 53 this.btnSave = new System.Windows.Forms.Button(); 60 54 this.btnRemoveGroup = new System.Windows.Forms.Button(); 61 55 this.btnAddGroup = new System.Windows.Forms.Button(); 62 this.btnPermissionsSave = new System.Windows.Forms.Button(); 63 this.treeSlaveGroup = new System.Windows.Forms.TreeView(); 56 this.treeView = new Hive.Views.TreeView.NoDoubleClickTreeView(); 64 57 this.tabSlaveGroup = new System.Windows.Forms.TabControl(); 65 58 this.tabDetails = new System.Windows.Forms.TabPage(); 66 this. slaveView = new HeuristicLab.Clients.Hive.Administrator.Views.SlaveView();59 this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 67 60 this.tabSchedule = new System.Windows.Forms.TabPage(); 68 61 this.scheduleView = new HeuristicLab.Clients.Hive.Administrator.Views.ScheduleView(); 69 62 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 70 this.tabPermissions = new System.Windows.Forms.TabPage();71 this.permissionView = new HeuristicLab.Clients.Access.Views.RefreshableLightweightUserView();72 63 ((System.ComponentModel.ISupportInitialize)(this.splitSlaves)).BeginInit(); 73 64 this.splitSlaves.Panel1.SuspendLayout(); … … 77 68 this.tabDetails.SuspendLayout(); 78 69 this.tabSchedule.SuspendLayout(); 79 this.tabPermissions.SuspendLayout();80 70 this.SuspendLayout(); 81 71 // … … 88 78 // splitSlaves 89 79 // 90 this.splitSlaves.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 91 | System.Windows.Forms.AnchorStyles.Left) 80 this.splitSlaves.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 81 | System.Windows.Forms.AnchorStyles.Left) 92 82 | System.Windows.Forms.AnchorStyles.Right))); 93 83 this.splitSlaves.Location = new System.Drawing.Point(3, 3); … … 97 87 // 98 88 this.splitSlaves.Panel1.Controls.Add(this.btnRefresh); 99 this.splitSlaves.Panel1.Controls.Add(this.progressBar);100 89 this.splitSlaves.Panel1.Controls.Add(this.btnSave); 101 90 this.splitSlaves.Panel1.Controls.Add(this.btnRemoveGroup); 102 91 this.splitSlaves.Panel1.Controls.Add(this.btnAddGroup); 103 this.splitSlaves.Panel1.Controls.Add(this.tree SlaveGroup);92 this.splitSlaves.Panel1.Controls.Add(this.treeView); 104 93 // 105 94 // splitSlaves.Panel2 … … 117 106 this.btnRefresh.Size = new System.Drawing.Size(24, 24); 118 107 this.btnRefresh.TabIndex = 8; 119 this.toolTip.SetToolTip(this.btnRefresh, "Fetch list from server ");108 this.toolTip.SetToolTip(this.btnRefresh, "Fetch list from server."); 120 109 this.btnRefresh.UseVisualStyleBackColor = true; 121 110 this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click); 122 111 // 123 // progressBar124 //125 this.progressBar.Location = new System.Drawing.Point(123, 4);126 this.progressBar.Name = "progressBar";127 this.progressBar.Size = new System.Drawing.Size(123, 23);128 this.progressBar.Style = System.Windows.Forms.ProgressBarStyle.Continuous;129 this.progressBar.TabIndex = 7;130 //131 112 // btnSave 132 113 // 133 this.btnSave.Image = HeuristicLab.Common.Resources.VSImageLibrary. PublishToWeb;114 this.btnSave.Image = HeuristicLab.Common.Resources.VSImageLibrary.Save; 134 115 this.btnSave.Location = new System.Drawing.Point(93, 3); 135 116 this.btnSave.Name = "btnSave"; 136 117 this.btnSave.Size = new System.Drawing.Size(24, 24); 137 118 this.btnSave.TabIndex = 5; 138 this.toolTip.SetToolTip(this.btnSave, "Store slave and group configuration on the server ");119 this.toolTip.SetToolTip(this.btnSave, "Store slave and group configuration on the server."); 139 120 this.btnSave.UseVisualStyleBackColor = true; 140 121 this.btnSave.Click += new System.EventHandler(this.btnSave_Click); … … 147 128 this.btnRemoveGroup.Size = new System.Drawing.Size(24, 24); 148 129 this.btnRemoveGroup.TabIndex = 2; 149 this.toolTip.SetToolTip(this.btnRemoveGroup, " Delete a slave or a group");130 this.toolTip.SetToolTip(this.btnRemoveGroup, "Remove a slave or a group."); 150 131 this.btnRemoveGroup.UseVisualStyleBackColor = true; 151 132 this.btnRemoveGroup.Click += new System.EventHandler(this.btnRemoveGroup_Click); … … 158 139 this.btnAddGroup.Size = new System.Drawing.Size(24, 24); 159 140 this.btnAddGroup.TabIndex = 1; 160 this.toolTip.SetToolTip(this.btnAddGroup, "Add a new group ");141 this.toolTip.SetToolTip(this.btnAddGroup, "Add a new group."); 161 142 this.btnAddGroup.UseVisualStyleBackColor = true; 162 143 this.btnAddGroup.Click += new System.EventHandler(this.btnAddGroup_Click); 163 144 // 164 // treeSlaveGroup 165 // 166 this.treeSlaveGroup.AllowDrop = true; 167 this.treeSlaveGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 168 | System.Windows.Forms.AnchorStyles.Left) 169 | System.Windows.Forms.AnchorStyles.Right))); 170 this.treeSlaveGroup.ImageIndex = 0; 171 this.treeSlaveGroup.ImageList = this.imageListSlaveGroups; 172 this.treeSlaveGroup.Location = new System.Drawing.Point(3, 33); 173 this.treeSlaveGroup.Name = "treeSlaveGroup"; 174 this.treeSlaveGroup.SelectedImageIndex = 0; 175 this.treeSlaveGroup.Size = new System.Drawing.Size(243, 511); 176 this.treeSlaveGroup.TabIndex = 0; 177 this.treeSlaveGroup.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeSlaveGroup_ItemDrag); 178 this.treeSlaveGroup.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeSlaveGroup_AfterSelect); 179 this.treeSlaveGroup.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragDrop); 180 this.treeSlaveGroup.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragEnter); 181 this.treeSlaveGroup.DragOver += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragOver); 182 this.treeSlaveGroup.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.treeSlaveGroup_QueryContinueDrag); 145 // treeView 146 // 147 this.treeView.AllowDrop = true; 148 this.treeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 149 | System.Windows.Forms.AnchorStyles.Left) 150 | System.Windows.Forms.AnchorStyles.Right))); 151 this.treeView.CheckBoxes = true; 152 this.treeView.ImageIndex = 0; 153 this.treeView.ImageList = this.imageListSlaveGroups; 154 this.treeView.Location = new System.Drawing.Point(3, 33); 155 this.treeView.Name = "treeView"; 156 this.treeView.SelectedImageIndex = 0; 157 this.treeView.Size = new System.Drawing.Size(243, 511); 158 this.treeView.TabIndex = 0; 159 this.treeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeSlaveGroup_ItemDrag); 160 this.treeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeSlaveGroup_MouseDown); 161 this.treeView.BeforeSelect += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeSlaveGroup_BeforeSelect); 162 this.treeView.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragDrop); 163 this.treeView.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragEnterOver); 164 this.treeView.DragOver += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragEnterOver); 165 this.treeView.BeforeCheck += new System.Windows.Forms.TreeViewCancelEventHandler(this.treeSlaveGroup_BeforeCheck); 166 this.treeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.treeSlaveGroup_AfterCheck); 183 167 // 184 168 // tabSlaveGroup 185 169 // 186 this.tabSlaveGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 187 | System.Windows.Forms.AnchorStyles.Left) 170 this.tabSlaveGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 171 | System.Windows.Forms.AnchorStyles.Left) 188 172 | System.Windows.Forms.AnchorStyles.Right))); 189 173 this.tabSlaveGroup.Controls.Add(this.tabDetails); 190 174 this.tabSlaveGroup.Controls.Add(this.tabSchedule); 191 this.tabSlaveGroup.Controls.Add(this.tabPermissions);192 175 this.tabSlaveGroup.Location = new System.Drawing.Point(3, 3); 193 176 this.tabSlaveGroup.Name = "tabSlaveGroup"; … … 195 178 this.tabSlaveGroup.Size = new System.Drawing.Size(585, 541); 196 179 this.tabSlaveGroup.TabIndex = 1; 197 this.tabSlaveGroup.SelectedIndexChanged += new System.EventHandler(this.tabSlaveGroup_SelectedIndexChanged); 180 //this.tabSlaveGroup.TabIndexChanged += TabSlaveGroup_TabIndexChanged; 181 this.tabSlaveGroup.Selected += TabSlaveGroup_Selected; 198 182 // 199 183 // tabDetails 200 184 // 201 this.tabDetails.Controls.Add(this. slaveView);185 this.tabDetails.Controls.Add(this.viewHost); 202 186 this.tabDetails.Location = new System.Drawing.Point(4, 22); 203 187 this.tabDetails.Name = "tabDetails"; … … 208 192 this.tabDetails.UseVisualStyleBackColor = true; 209 193 // 210 // slaveView 211 // 212 this.slaveView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 213 | System.Windows.Forms.AnchorStyles.Left) 214 | System.Windows.Forms.AnchorStyles.Right))); 215 this.slaveView.Caption = "SlaveView"; 216 this.slaveView.Content = null; 217 this.slaveView.Location = new System.Drawing.Point(6, 6); 218 this.slaveView.Name = "slaveView"; 219 this.slaveView.ReadOnly = false; 220 this.slaveView.Size = new System.Drawing.Size(565, 503); 221 this.slaveView.TabIndex = 0; 194 // viewHost 195 // 196 this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 197 | System.Windows.Forms.AnchorStyles.Left) 198 | System.Windows.Forms.AnchorStyles.Right))); 199 this.viewHost.Caption = "View"; 200 this.viewHost.Content = null; 201 this.viewHost.Enabled = true; 202 this.viewHost.Location = new System.Drawing.Point(6, 6); 203 this.viewHost.Name = "viewHost"; 204 this.viewHost.ReadOnly = false; 205 this.viewHost.Size = new System.Drawing.Size(565, 503); 206 this.viewHost.TabIndex = 0; 207 this.viewHost.ViewsLabelVisible = true; 208 this.viewHost.ViewType = null; 222 209 // 223 210 // tabSchedule … … 234 221 // scheduleView 235 222 // 236 this.scheduleView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 237 | System.Windows.Forms.AnchorStyles.Left) 223 this.scheduleView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 224 | System.Windows.Forms.AnchorStyles.Left) 238 225 | System.Windows.Forms.AnchorStyles.Right))); 239 226 this.scheduleView.Caption = "ScheduleView"; … … 244 231 this.scheduleView.Size = new System.Drawing.Size(565, 503); 245 232 this.scheduleView.TabIndex = 0; 246 //247 // tabPermissions248 //249 this.tabPermissions.Controls.Add(this.btnPermissionsSave);250 this.tabPermissions.Controls.Add(this.permissionView);251 this.tabPermissions.Location = new System.Drawing.Point(4, 22);252 this.tabPermissions.Name = "tabPermissions";253 this.tabPermissions.Padding = new System.Windows.Forms.Padding(3);254 this.tabPermissions.Size = new System.Drawing.Size(577, 515);255 this.tabPermissions.TabIndex = 2;256 this.tabPermissions.Text = "Permissions";257 this.tabPermissions.UseVisualStyleBackColor = true;258 //259 // btnPermissionsSave260 //261 this.btnPermissionsSave.Enabled = false;262 this.btnPermissionsSave.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb;263 this.btnPermissionsSave.Location = new System.Drawing.Point(39, 9);264 this.btnPermissionsSave.Name = "btnPermissionsSave";265 this.btnPermissionsSave.Size = new System.Drawing.Size(24, 24);266 this.btnPermissionsSave.TabIndex = 1;267 this.toolTip.SetToolTip(this.btnPermissionsSave, "Store slave and group sharing permissions on the server");268 this.btnPermissionsSave.UseVisualStyleBackColor = true;269 this.btnPermissionsSave.Click += new System.EventHandler(this.btnPermissionsSave_Click);270 //271 // permissionView272 //273 this.permissionView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)274 | System.Windows.Forms.AnchorStyles.Left)275 | System.Windows.Forms.AnchorStyles.Right)));276 this.permissionView.Caption = "RefreshableLightweightUser View";277 this.permissionView.Content = null;278 this.permissionView.FetchSelectedUsers = null;279 this.permissionView.Location = new System.Drawing.Point(6, 6);280 this.permissionView.Name = "permissionView";281 this.permissionView.ReadOnly = false;282 this.permissionView.Size = new System.Drawing.Size(565, 503);283 this.permissionView.TabIndex = 0;284 233 // 285 234 // ResourcesView … … 297 246 this.tabDetails.ResumeLayout(false); 298 247 this.tabSchedule.ResumeLayout(false); 299 this.tabPermissions.ResumeLayout(false);300 248 this.ResumeLayout(false); 301 249 302 250 } 303 304 251 #endregion 305 252 … … 307 254 private System.Windows.Forms.Button btnRemoveGroup; 308 255 private System.Windows.Forms.Button btnAddGroup; 309 private System.Windows.Forms.TreeView treeSlaveGroup;256 private HeuristicLab.Clients.Hive.Views.TreeView.NoDoubleClickTreeView treeView; 310 257 private System.Windows.Forms.TabControl tabSlaveGroup; 311 258 private System.Windows.Forms.TabPage tabDetails; 312 259 private System.Windows.Forms.TabPage tabSchedule; 313 private SlaveView slaveView;314 260 private System.Windows.Forms.ImageList imageListSlaveGroups; 315 261 private ScheduleView scheduleView; 316 262 private System.Windows.Forms.Button btnSave; 317 private System.Windows.Forms.ProgressBar progressBar;318 263 private System.Windows.Forms.Button btnRefresh; 319 264 private System.Windows.Forms.ToolTip toolTip; 320 private System.Windows.Forms.TabPage tabPermissions; 321 private Access.Views.RefreshableLightweightUserView permissionView; 322 private System.Windows.Forms.Button btnPermissionsSave; 265 private MainForm.WindowsForms.ViewHost viewHost; 323 266 } 324 267 } -
branches/2915-AbsoluteSymbol/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs
r15583 r16240 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 8Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.ComponentModel; 24 25 using System.Drawing; 25 26 using System.Linq; 26 using System.ServiceModel.Security;27 using System.Threading;28 using System.Threading.Tasks;29 27 using System.Windows.Forms; 30 28 using HeuristicLab.Clients.Access; 31 29 using HeuristicLab.Clients.Hive.Views; 30 using HeuristicLab.Collections; 31 using HeuristicLab.Common.Resources; 32 32 using HeuristicLab.Core; 33 33 using HeuristicLab.Core.Views; 34 34 using HeuristicLab.MainForm; 35 using TS = System.Threading.Tasks;36 35 37 36 namespace HeuristicLab.Clients.Hive.Administrator.Views { … … 39 38 [Content(typeof(IItemList<Resource>), false)] 40 39 public partial class ResourcesView : ItemView, IDisposable { 40 private const int slaveImageIndex = 0; 41 private const int slaveGroupImageIndex = 1; 42 public const string UNGROUPED_GROUP_NAME = "UNGROUPED"; 43 public const string UNGROUPED_GROUP_DESCRIPTION = "Contains slaves that are not assigned to any group."; 44 private const string SELECTED_TAG = ""; // " [selected]"; 45 private const string NOT_STORED_TAG = "*"; // " [not stored]"; 46 private const string CHANGES_NOT_STORED_TAG = "*"; // " [changes not stored]"; 47 48 private readonly Color changedColor = Color.FromArgb(255, 87, 191, 193); // #57bfc1 49 private readonly Color selectedBackColor = Color.DodgerBlue; 50 private readonly Color selectedForeColor = Color.White; 51 private readonly Color calculatingColor = Color.FromArgb(255, 58, 114, 35); // #3a7223 52 private readonly Color offlineColor = Color.FromArgb(255, 187, 36, 36); // #bb2424 53 private readonly Color grayTextColor = SystemColors.GrayText; 54 55 56 57 private TreeNode ungroupedGroupNode; 58 59 private Resource selectedResource = null; 60 public Resource SelectedResource { 61 get { return selectedResource; } 62 set { if (selectedResource != value) ChangeSelectedResource(value); } 63 } 64 65 private readonly object locker = new object(); 66 41 67 public new IItemList<Resource> Content { 42 68 get { return (IItemList<Resource>)base.Content; } … … 44 70 } 45 71 46 public const string UngroupedGroupName = "UNGROUPED";47 private const int slaveImageIndex = 0;48 private const int slaveGroupImageIndex = 1;49 private readonly Color ownedResourceColor = Color.LightGreen;50 private TS.Task progressTask;51 private bool stopProgressTask;52 private bool currentlyAuthorized;53 54 55 72 public ResourcesView() { 56 73 InitializeComponent(); 57 treeSlaveGroup.ImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.MonitorLarge); 58 treeSlaveGroup.ImageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.NetworkCenterLarge); 59 60 HiveAdminClient.Instance.Refreshing += new EventHandler(Instance_Refreshing); 61 HiveAdminClient.Instance.Refreshed += new EventHandler(Instance_Refreshed); 62 63 Access.AccessClient.Instance.Refreshing += new EventHandler(AccessClient_Refreshing); 64 Access.AccessClient.Instance.Refreshed += new EventHandler(AccessClient_Refreshed); 65 } 66 67 private void UpdateProgress() { 68 while (!stopProgressTask) { 69 int diff = (progressBar.Maximum - progressBar.Minimum) / 10; 70 71 if (progressBar.InvokeRequired) { 72 progressBar.Invoke(new Action(delegate() { progressBar.Value = (progressBar.Value + diff) % progressBar.Maximum; })); 73 } else { 74 progressBar.Value = (progressBar.Value + diff) % progressBar.Maximum; 75 } 76 77 //ok, this is not very clever... 78 Thread.Sleep(500); 79 } 80 if (progressBar.InvokeRequired) { 81 progressBar.Invoke(new Action(delegate() { progressBar.Value = progressBar.Minimum; })); 82 } else { 83 progressBar.Value = progressBar.Minimum; 84 } 85 } 86 87 void Instance_Refreshing(object sender, EventArgs e) { 88 stopProgressTask = false; 89 progressTask = new TS.Task(UpdateProgress); 90 progressTask.Start(); 91 SetEnabledStateOfControls(); 92 } 93 94 void Instance_Refreshed(object sender, EventArgs e) { 95 stopProgressTask = true; 96 SetEnabledStateOfControls(); 97 } 98 99 void AccessClient_Refreshing(object sender, EventArgs e) { 100 stopProgressTask = false; 101 progressTask = new TS.Task(UpdateProgress); 102 progressTask.Start(); 103 SetEnabledStateOfControls(); 104 btnPermissionsSave.Enabled = false; 105 } 106 107 void AccessClient_Refreshed(object sender, EventArgs e) { 108 stopProgressTask = true; 109 SetEnabledStateOfControls(); 110 } 111 112 #region Register Content Events 113 protected override void DeregisterContentEvents() { 114 Content.ItemsAdded -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Resource>>(Content_ItemsAdded); 115 Content.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Resource>>(Content_ItemsRemoved); 116 base.DeregisterContentEvents(); 117 } 74 75 treeView.ImageList.Images.Add(VSImageLibrary.MonitorLarge); 76 treeView.ImageList.Images.Add(VSImageLibrary.NetworkCenterLarge); 77 78 HiveAdminClient.Instance.Refreshing += HiveAdminClient_Instance_Refreshing; 79 HiveAdminClient.Instance.Refreshed += HiveAdminClient_Instance_Refreshed; 80 AccessClient.Instance.Refreshing += AccessClient_Instance_Refreshing; 81 AccessClient.Instance.Refreshed += AccessClient_Instance_Refreshed; 82 } 83 84 #region Overrides 85 protected override void OnClosing(FormClosingEventArgs e) { 86 AccessClient.Instance.Refreshed -= AccessClient_Instance_Refreshed; 87 AccessClient.Instance.Refreshing -= AccessClient_Instance_Refreshing; 88 HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed; 89 HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing; 90 base.OnClosing(e); 91 } 92 118 93 protected override void RegisterContentEvents() { 119 94 base.RegisterContentEvents(); 120 Content.ItemsAdded += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Resource>>(Content_ItemsAdded); 121 Content.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<Collections.IndexedItem<Resource>>(Content_ItemsRemoved); 122 } 123 #endregion 95 Content.ItemsAdded += Content_ItemsAdded; 96 Content.ItemsRemoved += Content_ItemsRemoved; 97 } 98 99 protected override void DeregisterContentEvents() { 100 Content.ItemsRemoved -= Content_ItemsRemoved; 101 Content.ItemsAdded -= Content_ItemsAdded; 102 base.DeregisterContentEvents(); 103 } 124 104 125 105 protected override void OnContentChanged() { 126 106 base.OnContentChanged(); 127 107 if (Content == null) { 128 slaveView.Content = null; 108 treeView.Nodes.Clear(); 109 viewHost.Content = null; 129 110 scheduleView.Content = null; 130 permissionView.Content = null;131 permissionView.FetchSelectedUsers = null;132 treeSlaveGroup.Nodes.Clear();133 111 } else { 134 permissionView.Content = Access.AccessClient.Instance; 135 treeSlaveGroup.Nodes.Clear(); 136 137 //rebuild 138 TreeNode ungrp = new TreeNode(UngroupedGroupName); 139 ungrp.ImageIndex = slaveGroupImageIndex; 140 ungrp.SelectedImageIndex = ungrp.ImageIndex; 141 var newGroup = new SlaveGroup(); 142 newGroup.Name = UngroupedGroupName; 143 newGroup.Id = Guid.NewGuid(); 144 newGroup.Description = "Contains slaves which are in no group"; 145 ungrp.Tag = newGroup; 146 147 foreach (Resource g in Content) { 148 if (g.GetType() == typeof(SlaveGroup)) { 149 //root node 150 if (g.ParentResourceId == null) { 151 TreeNode tn = new TreeNode(); 152 tn.ImageIndex = slaveGroupImageIndex; 153 tn.SelectedImageIndex = tn.ImageIndex; 154 155 tn.Tag = g; 156 tn.Text = g.Name; 157 if (g.OwnerUserId == Access.UserInformation.Instance.User.Id) tn.BackColor = ownedResourceColor; 158 159 BuildSlaveGroupTree(g, tn); 160 treeSlaveGroup.Nodes.Add(tn); 161 } 162 } else if (g.GetType() == typeof(Slave)) { 163 if (g.ParentResourceId == null) { 164 var stn = new TreeNode(g.Name); 165 stn.ImageIndex = slaveImageIndex; 166 stn.SelectedImageIndex = stn.ImageIndex; 167 stn.Tag = g; 168 if (g.OwnerUserId == Access.UserInformation.Instance.User.Id) stn.BackColor = ownedResourceColor; 169 ungrp.Nodes.Add(stn); 170 } 171 } 172 } 173 treeSlaveGroup.Nodes.Add(ungrp); 174 } 175 } 176 177 private void BuildSlaveGroupTree(Resource g, TreeNode tn) { 178 foreach (Resource r in Content.Where(s => s.ParentResourceId != null && s.ParentResourceId == g.Id)) { 179 TreeNode stn = new TreeNode(r.Name); 180 if (r is Slave) { 181 stn.ImageIndex = slaveImageIndex; 182 } else if (r is SlaveGroup) { 183 stn.ImageIndex = slaveGroupImageIndex; 184 } 185 stn.SelectedImageIndex = stn.ImageIndex; 186 stn.Tag = r; 187 if (r.OwnerUserId == Access.UserInformation.Instance.User.Id) stn.BackColor = ownedResourceColor; 188 tn.Nodes.Add(stn); 189 190 BuildSlaveGroupTree(r, stn); 191 } 112 BuildResourceTree(Content); 113 } 114 SetEnabledStateOfControls(); 192 115 } 193 116 194 117 protected override void SetEnabledStateOfControls() { 195 118 base.SetEnabledStateOfControls(); 196 if (Content == null) { 197 btnAddGroup.Enabled = false; 119 120 bool locked = Content == null || Locked || ReadOnly; 121 bool addLocked = locked 122 || !IsAdmin() 123 || (selectedResource is Slave && selectedResource.ParentResourceId != null) 124 || (selectedResource != null && selectedResource.Id == Guid.Empty); 125 126 HashSet<Guid> descendantResources = null; 127 bool selectedRDeleteLocked = selectedResource == null 128 || (selectedResource.Id != Guid.Empty && (!HiveAdminClient.Instance.ResourceDescendants.TryGetValue(selectedResource.Id, out descendantResources) || descendantResources.Any())); 129 130 var nodes = GetCheckedNodes(treeView.Nodes).ToList(); 131 var checkedResources = nodes.Select(x => x.Tag).OfType<Resource>().ToList(); 132 bool checkedRDeleteLocked = false; 133 for (int i = 0; !checkedRDeleteLocked && i < checkedResources.Count; i++) { 134 if (checkedResources[i].Id != Guid.Empty && 135 (!HiveAdminClient.Instance.ResourceDescendants.TryGetValue(checkedResources[i].Id, out descendantResources) || 136 descendantResources.Any())) 137 checkedRDeleteLocked = true; 138 } 139 140 bool deleteLocked = locked 141 || !IsAdmin() 142 || !Content.Any() 143 || checkedResources.Any() && checkedRDeleteLocked 144 || !checkedResources.Any() && selectedRDeleteLocked; 145 146 bool saveLocked = locked 147 || !IsAdmin() 148 || !Content.Any() 149 || selectedResource == null; 150 151 btnAddGroup.Enabled = !addLocked; 152 btnRemoveGroup.Enabled = !deleteLocked; 153 btnSave.Enabled = !saveLocked; 154 viewHost.Locked = locked || !IsAdmin(); 155 scheduleView.Locked = locked || !IsAdmin(); 156 } 157 #endregion 158 159 #region Event Handlers 160 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<Resource>> e) { 161 if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IndexedItem<Resource>>>)Content_ItemsAdded, sender, e); 162 else { 163 OnContentChanged(); 164 } 165 } 166 167 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Resource>> e) { 168 if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IndexedItem<Resource>>>)Content_ItemsRemoved, sender, e); 169 else { 170 OnContentChanged(); 171 } 172 } 173 174 private void SlaveViewContent_PropertyChanged(object sender, PropertyChangedEventArgs e) { 175 if (InvokeRequired) Invoke((Action<object, PropertyChangedEventArgs>)SlaveViewContent_PropertyChanged, sender, e); 176 else { 177 OnContentChanged(); 178 if (e.PropertyName == "HbInterval") { 179 UpdateChildHbIntervall((Resource)viewHost.Content); 180 } 181 } 182 } 183 184 private void HiveAdminClient_Instance_Refreshing(object sender, EventArgs e) { 185 if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshing, sender, e); 186 else { 187 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 188 mainForm.AddOperationProgressToView(this, "Refreshing ..."); 189 SetEnabledStateOfControls(); 190 } 191 } 192 193 private void HiveAdminClient_Instance_Refreshed(object sender, EventArgs e) { 194 if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshed, sender, e); 195 else { 196 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 197 mainForm.RemoveOperationProgressFromView(this); 198 SetEnabledStateOfControls(); 199 } 200 } 201 202 private void AccessClient_Instance_Refreshing(object sender, EventArgs e) { 203 if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshing, sender, e); 204 else { 205 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 206 mainForm.AddOperationProgressToView(this, "Refreshing ..."); 207 SetEnabledStateOfControls(); 208 } 209 } 210 211 private void AccessClient_Instance_Refreshed(object sender, EventArgs e) { 212 if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshed, sender, e); 213 else { 214 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 215 mainForm.RemoveOperationProgressFromView(this); 216 SetEnabledStateOfControls(); 217 } 218 } 219 220 private async void ResourcesView_Load(object sender, EventArgs e) { 221 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 222 action: () => UpdateResources()); 223 } 224 225 private async void btnRefresh_Click(object sender, EventArgs e) { 226 lock (locker) { 227 if (!btnRefresh.Enabled) return; 228 btnRefresh.Enabled = false; 229 } 230 231 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 232 action: () => UpdateResources(), 233 finallyCallback: () => btnRefresh.Enabled = true); 234 } 235 236 private void btnAddGroup_Click(object sender, EventArgs e) { 237 var parentResourceId = selectedResource is SlaveGroup ? selectedResource.Id : (Guid?)null; 238 239 var group = new SlaveGroup { 240 Name = "New Group", 241 OwnerUserId = UserInformation.Instance.User.Id, 242 ParentResourceId = parentResourceId 243 }; 244 245 SelectedResource = group; 246 Content.Add(group); 247 } 248 249 private async void btnRemoveGroup_Click(object sender, EventArgs e) { 250 var nodes = GetCheckedNodes(treeView.Nodes).ToList(); 251 var checkedResources = nodes.Select(x => x.Tag).OfType<Resource>().ToList(); 252 if (selectedResource == null && !checkedResources.Any()) return; 253 254 lock (locker) { 255 if (!btnRemoveGroup.Enabled) return; 198 256 btnRemoveGroup.Enabled = false; 257 } 258 259 if (checkedResources.Count > 0) { 260 var result = MessageBox.Show( 261 "Do you really want to delete all " + checkedResources.Count + " checked resources?", 262 "HeuristicLab Hive Administrator", 263 MessageBoxButtons.YesNo, 264 MessageBoxIcon.Question); 265 if (result == DialogResult.Yes) { 266 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 267 action: () => { 268 RemoveResource(checkedResources); 269 }); 270 } 271 } else { 272 var res = checkedResources.Any() ? checkedResources.First() : selectedResource; 273 var result = MessageBox.Show( 274 "Do you really want to delete the selected resource " + res.Name + "?", 275 "HeuristicLab Hive Administrator", 276 MessageBoxButtons.YesNo, 277 MessageBoxIcon.Question); 278 if (result == DialogResult.Yes) { 279 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 280 action: () => { 281 RemoveResource(res); 282 }); 283 } 284 } 285 286 OnContentChanged(); 287 SetEnabledStateOfControls(); 288 } 289 290 private async void btnSave_Click(object sender, EventArgs e) { 291 lock (locker) { 292 if (!btnSave.Enabled) return; 199 293 btnSave.Enabled = false; 200 btnPermissionsSave.Enabled = false; 201 permissionView.Enabled = false; 202 scheduleView.SetEnabledStateOfSchedule(false); 203 btnPermissionsSave.Enabled = false; 204 permissionView.Enabled = false; 294 } 295 296 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 297 action: () => { 298 var resourcesToSave = Content.Where(x => x.Id == Guid.Empty || x.Modified); 299 foreach (var resource in resourcesToSave) 300 resource.Store(); 301 UpdateResources(); 302 }); 303 304 OnContentChanged(); 305 SetEnabledStateOfControls(); 306 } 307 308 private void treeSlaveGroup_MouseDown(object sender, MouseEventArgs e) { 309 var node = treeView.GetNodeAt(e.Location); 310 if (node == null || node == ungroupedGroupNode) return; 311 var r = (Resource)node.Tag; 312 if (!HiveAdminClient.Instance.DisabledParentResources.Contains(r)) ChangeSelectedResourceNode(node); 313 } 314 315 private void treeSlaveGroup_BeforeSelect(object sender, TreeViewCancelEventArgs e) { 316 e.Cancel = true; 317 } 318 319 private void treeSlaveGroup_BeforeCheck(object sender, TreeViewCancelEventArgs e) { 320 if (!IsAdmin() || e.Node == ungroupedGroupNode) { 321 e.Cancel = true; 205 322 } else { 206 btnAddGroup.Enabled = true; 207 btnRemoveGroup.Enabled = true; 208 btnSave.Enabled = true; 209 scheduleView.SetEnabledStateOfSchedule(IsAuthorized(slaveView.Content)); 210 btnPermissionsSave.Enabled = permissionView.FetchSelectedUsers != null; 211 permissionView.Enabled = permissionView.FetchSelectedUsers != null; 212 } 213 } 214 215 private bool IsAuthorized(Resource resource) { 216 return resource != null 217 && resource.Name != UngroupedGroupName 218 && resource.Id != Guid.Empty 219 && UserInformation.Instance.UserExists 220 && (resource.OwnerUserId == UserInformation.Instance.User.Id || HiveRoles.CheckAdminUserPermissions()); 221 } 222 223 private void treeSlaveGroup_AfterSelect(object sender, TreeViewEventArgs e) { 224 if (e.Action != TreeViewAction.Unknown) { 225 Resource selectedResource = ((Resource)e.Node.Tag); 226 currentlyAuthorized = IsAuthorized(selectedResource); 227 if (currentlyAuthorized) { 228 permissionView.FetchSelectedUsers = new Func<List<Guid>>(() => { 229 return HiveServiceLocator.Instance.CallHiveService<List<ResourcePermission>>(service => { 230 return service.GetResourcePermissions(selectedResource.Id); 231 }).Select(x => x.GrantedUserId).ToList(); 232 }); 233 if (!tabSlaveGroup.TabPages.Contains(tabPermissions)) tabSlaveGroup.TabPages.Add(tabPermissions); 323 var r = (Resource)e.Node.Tag; 324 if (HiveAdminClient.Instance.DisabledParentResources.Contains(r)) { 325 e.Cancel = true; 326 } 327 } 328 } 329 330 private void treeSlaveGroup_AfterCheck(object sender, TreeViewEventArgs e) { 331 SetEnabledStateOfControls(); 332 } 333 334 private void treeSlaveGroup_DragDrop(object sender, DragEventArgs e) { 335 if (e.Effect == DragDropEffects.None) return; 336 337 var targetNode = treeView.GetNodeAt(treeView.PointToClient(new Point(e.X, e.Y))); 338 var targetResource = (targetNode != null) ? (Resource)targetNode.Tag : null; 339 var resources = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as IEnumerable<Resource>; 340 341 foreach (var r in resources) { 342 r.ParentResourceId = targetResource != null ? targetResource.Id : (Guid?)null; 343 } 344 345 // TODO 346 //HiveAdminClient.Instance.UpdateResourceGenealogy(Content); 347 OnContentChanged(); 348 } 349 350 private void treeSlaveGroup_ItemDrag(object sender, ItemDragEventArgs e) { 351 if (!IsAdmin()) return; 352 353 var nodes = GetCheckedNodes(treeView.Nodes).ToList(); 354 TreeNode sourceNode = (TreeNode)e.Item; 355 if (!sourceNode.Checked) nodes.Add(sourceNode); 356 nodes.Remove(ungroupedGroupNode); 357 ungroupedGroupNode.Checked = false; 358 var resources = nodes.Select(x => x.Tag).OfType<Resource>().ToList(); 359 360 if (resources.Count > 0) { 361 DataObject data = new DataObject(); 362 data.SetData(HeuristicLab.Common.Constants.DragDropDataFormat, resources); 363 var action = DoDragDrop(data, DragDropEffects.Copy | DragDropEffects.Link | DragDropEffects.Move); 364 if (action.HasFlag(DragDropEffects.Move)) { 365 foreach (var node in nodes) node.Remove(); 366 StyleTreeNode(ungroupedGroupNode, (Resource)ungroupedGroupNode.Tag, resources); 367 } 368 } 369 } 370 371 private IEnumerable<TreeNode> GetCheckedNodes(TreeNodeCollection nodes) { 372 if (nodes != null) { 373 foreach (var node in nodes.OfType<TreeNode>()) { 374 if (node.Checked && node != ungroupedGroupNode) yield return node; 375 foreach (var child in GetCheckedNodes(node.Nodes)) 376 yield return child; 377 } 378 } 379 } 380 381 private void treeSlaveGroup_DragEnterOver(object sender, DragEventArgs e) { 382 e.Effect = DragDropEffects.Move; 383 var resources = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat) as IEnumerable<Resource>; 384 var targetNode = treeView.GetNodeAt(treeView.PointToClient(new Point(e.X, e.Y))); 385 var targetResource = (targetNode != null ? targetNode.Tag : null) as Resource; 386 387 if (!IsAdmin() 388 || resources == null 389 || !resources.Any() 390 || resources.Any(x => !HiveAdminClient.Instance.CheckParentChange(x, targetResource)) 391 || (targetNode != null && (targetNode == ungroupedGroupNode || targetNode.Parent == ungroupedGroupNode))) { 392 e.Effect = DragDropEffects.None; 393 } 394 } 395 396 private void TabSlaveGroup_TabIndexChanged(object sender, EventArgs e) { 397 throw new NotImplementedException(); 398 } 399 400 private async void TabSlaveGroup_Selected(object sender, System.Windows.Forms.TabControlEventArgs e) { 401 if (e.TabPage == tabSchedule) { 402 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 403 action: () => UpdateSchedule(), 404 finallyCallback: () => scheduleView.Content = HiveAdminClient.Instance.Downtimes); 405 } 406 SetEnabledStateOfControls(); 407 } 408 #endregion 409 410 #region Helpers 411 private void BuildResourceTree(IEnumerable<Resource> resources) { 412 treeView.Nodes.Clear(); 413 if (!resources.Any()) return; 414 415 var disabledParentResources = HiveAdminClient.Instance.DisabledParentResources; 416 var mainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>() 417 .Where(x => x.ParentResourceId == null)); 418 //var parentedMainResources = new HashSet<Resource>(resources.OfType<SlaveGroup>() 419 // .Where(x => x.ParentResourceId.HasValue && !resources.Select(y => y.Id).Contains(x.ParentResourceId.Value))); 420 //mainResources.UnionWith(parentedMainResources); 421 var mainDisabledParentResources = new HashSet<Resource>(disabledParentResources.Where(x => x.ParentResourceId == null || x.ParentResourceId == Guid.Empty)); 422 mainResources.UnionWith(mainDisabledParentResources); 423 var subResources = new HashSet<Resource>(resources.Union(disabledParentResources).Except(mainResources).OrderByDescending(x => x.Name)); 424 425 var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name)); 426 if (selectedResource != null) SelectedResource = resources.Where(x => x.Id == selectedResource.Id).FirstOrDefault(); 427 bool nodeSelected = false; 428 429 TreeNode currentNode = null; 430 Resource currentResource = null; 431 432 while (stack.Any()) { 433 var newResource = stack.Pop(); 434 var newNode = new TreeNode(newResource.Name) { Tag = newResource }; 435 StyleTreeNode(newNode, newResource, resources); 436 437 if (selectedResource == null && !disabledParentResources.Contains(newResource)) { 438 SelectedResource = newResource; 439 } 440 if (!nodeSelected && selectedResource != null && newResource.Id == selectedResource.Id) { 441 newNode.BackColor = selectedBackColor; 442 newNode.ForeColor = selectedForeColor; 443 newNode.Text += SELECTED_TAG; 444 nodeSelected = true; 445 } 446 447 if (disabledParentResources.Contains(newResource)) { 448 newNode.Checked = false; 449 newNode.ForeColor = grayTextColor; 450 } 451 452 // search for parent node of newNode and save in currentNode 453 // necessary since newNodes (stack top items) might be siblings 454 // or grand..grandparents of previous node (currentNode) 455 while (currentNode != null && newResource.ParentResourceId != currentResource.Id) { 456 currentNode = currentNode.Parent; 457 currentResource = currentNode == null ? null : (Resource)currentNode.Tag; 458 } 459 460 if (currentNode == null) { 461 treeView.Nodes.Add(newNode); 234 462 } else { 235 permissionView.FetchSelectedUsers = null; 236 btnPermissionsSave.Enabled = false; 237 if (selectedResource.Id == Guid.Empty) { 238 if (!tabSlaveGroup.TabPages.Contains(tabPermissions)) tabSlaveGroup.TabPages.Add(tabPermissions); 239 } else tabSlaveGroup.TabPages.Remove(tabPermissions); 240 } 241 242 if (slaveView.Content != null && slaveView.Content is SlaveGroup) { 243 slaveView.Content.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(SlaveViewContent_PropertyChanged); 244 } 245 246 slaveView.Content = selectedResource; 247 HiveAdminClient.Instance.DowntimeForResourceId = selectedResource.Id; 248 249 if (selectedResource is SlaveGroup) { 250 slaveView.Content.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(SlaveViewContent_PropertyChanged); 251 } 252 253 if (tabSlaveGroup.SelectedIndex == 1) { 254 UpdateScheduleAsync(); 255 } else if (tabSlaveGroup.SelectedIndex == 2) { 256 UpdatePermissionsAsync(); 257 } 258 } 259 } 260 261 void SlaveViewContent_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { 262 OnContentChanged(); 263 if (e.PropertyName == "HbInterval") { 264 UpdateChildHbIntervall(slaveView.Content); 463 currentNode.Nodes.Add(newNode); 464 } 465 466 if (newResource is SlaveGroup) { 467 var childResources = subResources.Where(x => x.ParentResourceId == newResource.Id); 468 if (childResources.Any()) { 469 foreach (var resource in childResources.OrderByDescending(x => x.Name)) { 470 subResources.Remove(resource); 471 stack.Push(resource); 472 } 473 currentNode = newNode; 474 currentResource = newResource; 475 } 476 } 477 newNode.SelectedImageIndex = newNode.ImageIndex; 478 } 479 480 // collapse slave-only nodes 481 foreach (TreeNode n in treeView.Nodes) { 482 CollapseSlaveOnlyNodes(n); 483 } 484 485 ungroupedGroupNode = new TreeNode(UNGROUPED_GROUP_NAME) { 486 ForeColor = SystemColors.GrayText, 487 ImageIndex = slaveGroupImageIndex, 488 Tag = new SlaveGroup() { 489 Name = UNGROUPED_GROUP_NAME, 490 Description = UNGROUPED_GROUP_DESCRIPTION 491 } 492 }; 493 494 foreach (var slave in subResources.OfType<Slave>().OrderBy(x => x.Name)) { 495 var slaveNode = new TreeNode(slave.Name) { Tag = slave }; 496 StyleTreeNode(slaveNode, slave, resources); 497 ungroupedGroupNode.Nodes.Add(slaveNode); 498 if (selectedResource == null) { 499 SelectedResource = slave; 500 } 501 502 if (slave.Id == selectedResource.Id && !nodeSelected) { 503 slaveNode.BackColor = selectedBackColor; 504 slaveNode.ForeColor = selectedForeColor; 505 slaveNode.Text += SELECTED_TAG; 506 nodeSelected = true; 507 } 508 } 509 510 if (ungroupedGroupNode.Nodes.Count > 0) { 511 ungroupedGroupNode.Text += " [" + ungroupedGroupNode.Nodes.Count.ToString() + "]"; 512 ungroupedGroupNode.Expand(); 513 treeView.Nodes.Add(ungroupedGroupNode); 514 } 515 } 516 517 private void CollapseSlaveOnlyNodes(TreeNode tn) { 518 Resource r = (Resource)tn.Tag; 519 var descendants = GetResourceDescendants(); 520 if (descendants.ContainsKey(r.Id)) { 521 if (descendants[r.Id].OfType<SlaveGroup>().Any()) { 522 tn.Expand(); 523 foreach (TreeNode n in tn.Nodes) CollapseSlaveOnlyNodes(n); 524 } else { 525 tn.Collapse(); 526 } 527 } 528 } 529 530 private void ExpandResourceNodesOfInterest(TreeNodeCollection nodes) { 531 foreach (TreeNode n in nodes) { 532 Resource r = (Resource)n.Tag; 533 if (n.Nodes.Count > 0) { 534 if (HiveAdminClient.Instance.GetAvailableResourceDescendants(r.Id).OfType<SlaveGroup>().Any()) { 535 n.Expand(); 536 ExpandResourceNodesOfInterest(n.Nodes); 537 } else { 538 n.Collapse(); 539 } 540 } else { 541 n.Collapse(); 542 } 265 543 } 266 544 } … … 275 553 } 276 554 277 private void btnAddGroup_Click(object sender, EventArgs e) { 278 SlaveGroup newGroup = new SlaveGroup(); 279 newGroup.Name = "New Group"; 280 newGroup.OwnerUserId = UserInformation.Instance.User.Id; 281 Content.Add(newGroup); 282 } 283 284 void Content_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<Resource>> e) { 285 OnContentChanged(); 286 } 287 288 void Content_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<Resource>> e) { 289 OnContentChanged(); 290 } 291 292 private void btnRemoveGroup_Click(object sender, EventArgs e) { 293 if (treeSlaveGroup.SelectedNode != null && treeSlaveGroup.SelectedNode.Tag != null) { 294 Resource res = (Resource)treeSlaveGroup.SelectedNode.Tag; 295 296 DialogResult diagRes = MessageBox.Show("Do you really want to delete " + res.Name + "?", "HeuristicLab Hive Administrator", MessageBoxButtons.YesNo, MessageBoxIcon.Question); 297 if (diagRes == DialogResult.Yes) { 298 if (res is Slave) { 299 Content.Remove(res); 300 HiveAdminClient.Delete(res); 301 } else if (res is SlaveGroup) { 302 //only delete empty groups 303 if (Content.Where(s => s.ParentResourceId == res.Id).Count() < 1) { 304 Content.Remove(res); 305 HiveAdminClient.Delete(res); 306 } else { 307 MessageBox.Show("Only empty groups can be deleted.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error); 308 } 555 private void UpdateResources() { 556 try { 557 HiveAdminClient.Instance.Refresh(); 558 Content = HiveAdminClient.Instance.Resources; 559 } catch (AnonymousUserException) { 560 ShowHiveInformationDialog(); 561 } 562 } 563 564 private void RemoveResource(Resource resource) { 565 if (resource == null) return; 566 567 try { 568 if (resource.Id != Guid.Empty) { 569 SelectedResource = HiveAdminClient.Instance.GetAvailableResourceAncestors(resource.Id).LastOrDefault(); 570 571 // deal with all new, but not yet saved resources 572 var newResources = Content.Where(x => x.ParentResourceId == resource.Id).ToList(); 573 if (newResources.Any(x => x.Id != Guid.Empty)) return; 574 foreach (var nr in newResources) Content.Remove(nr); 575 576 HiveAdminClient.Delete(resource); 577 UpdateResources(); 578 } else { 579 SelectedResource = Content.FirstOrDefault(x => x.Id == resource.ParentResourceId); 580 Content.Remove(resource); 581 } 582 } catch (AnonymousUserException) { 583 ShowHiveInformationDialog(); 584 } 585 } 586 587 private void RemoveResource(IEnumerable<Resource> resources) { 588 if (resources == null || !resources.Any()) return; 589 590 var ids = resources.Select(x => x.Id).ToList(); 591 try { 592 bool update = false; 593 foreach (var r in resources) { 594 if (r.Id != Guid.Empty) { 595 if(r.Id == SelectedResource.Id) 596 SelectedResource = HiveAdminClient.Instance.GetAvailableResourceAncestors(r.Id).LastOrDefault(); 597 598 // deal with all new, but not yet saved resources 599 var newResources = Content.Where(x => x.ParentResourceId == r.Id).ToList(); 600 if (newResources.Any(x => x.Id != Guid.Empty)) return; 601 foreach (var nr in newResources) Content.Remove(nr); 602 603 HiveAdminClient.Delete(r); 604 update = true; 605 } else { 606 if (r.Id == SelectedResource.Id) 607 SelectedResource = Content.FirstOrDefault(x => x.Id == r.ParentResourceId); 608 Content.Remove(r); 309 609 } 310 610 } 311 } 312 } 313 314 private void btnSave_Click(object sender, EventArgs e) { 315 foreach (Resource res in Content) { 316 if (res is SlaveGroup && res.Id == Guid.Empty) { 317 SlaveGroup slaveGroup = (SlaveGroup)res; 318 slaveGroup.Store(); 319 } else if (res.Id != Guid.Empty && res.Modified) { 320 res.Store(); 321 } 322 } 323 } 324 325 private void treeSlaveGroup_DragDrop(object sender, DragEventArgs e) { 326 if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) { 327 Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); 328 TreeNode destNode = ((TreeView)sender).GetNodeAt(pt); 329 TreeNode newNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); 330 331 if (destNode.TreeView == newNode.TreeView) { 332 if (destNode.Text == UngroupedGroupName || (destNode.Parent != null && destNode.Parent.Text == UngroupedGroupName)) { 333 MessageBox.Show(string.Format("You can't drag items to the group \"{0}\".{1}This group only contains slaves which haven't yet been assigned to a real group.", 334 UngroupedGroupName, Environment.NewLine), "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Information); 335 return; 336 } 337 338 SlaveGroup sgrp = null; 339 TreeNode parentNode = null; 340 if (destNode.Tag != null && destNode.Tag is SlaveGroup) { 341 sgrp = (SlaveGroup)destNode.Tag; 342 parentNode = destNode; 343 } else if (destNode.Parent != null && destNode.Parent.Tag is SlaveGroup) { 344 sgrp = (SlaveGroup)destNode.Parent.Tag; 345 parentNode = destNode.Parent; 346 } 347 348 if (newNode.Tag is SlaveGroup && CheckParentsEqualsMovedNode(parentNode, newNode)) { 349 return; 350 } 351 352 SlaveGroup parent = (SlaveGroup)parentNode.Tag; 353 354 if (parent.OwnerUserId != null && !IsAuthorized(parent)) { 355 MessageBox.Show(string.Format("You don't have the permissions to drag items to the group \"{0}\".", ((Resource)parentNode.Tag).Name), 356 "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error); 357 return; 358 } 359 360 if (sgrp != null && newNode.Tag != null) { 361 //save parent group to get an id 362 if (sgrp.Id == Guid.Empty) { 363 sgrp.Store(); 364 } 365 366 if (newNode.Tag is Slave) { 367 Slave slave = (Slave)newNode.Tag; 368 if (slave.ParentResourceId == null || (slave.ParentResourceId != null && slave.ParentResourceId != sgrp.Id)) { 369 slave.ParentResourceId = sgrp.Id; 370 newNode.Remove(); 371 parentNode.Nodes.Clear(); 372 BuildSlaveGroupTree(sgrp, parentNode); 373 } 374 } else if (newNode.Tag is SlaveGroup) { 375 SlaveGroup slaveGroup = (SlaveGroup)newNode.Tag; 376 if (slaveGroup.ParentResourceId == null || (slaveGroup.ParentResourceId != null && slaveGroup.ParentResourceId != sgrp.Id)) { 377 slaveGroup.ParentResourceId = sgrp.Id; 378 newNode.Remove(); 379 parentNode.Nodes.Clear(); 380 BuildSlaveGroupTree(sgrp, parentNode); 381 } 382 } 383 } 384 } 385 } 386 } 387 388 private bool CheckParentsEqualsMovedNode(TreeNode dest, TreeNode movedNode) { 389 TreeNode tmp = dest; 390 391 while (tmp != null) { 392 if (tmp == movedNode) { 393 return true; 394 } 395 tmp = tmp.Parent; 396 } 397 return false; 398 } 399 400 private void treeSlaveGroup_ItemDrag(object sender, ItemDragEventArgs e) { 401 TreeNode sourceNode = (TreeNode)e.Item; 402 if (IsAuthorized((Resource)sourceNode.Tag)) 403 DoDragDrop(sourceNode, DragDropEffects.All); 404 } 405 406 private void treeSlaveGroup_DragEnter(object sender, DragEventArgs e) { 407 e.Effect = DragDropEffects.Move; 408 } 409 410 private void treeSlaveGroup_DragOver(object sender, DragEventArgs e) { 411 e.Effect = DragDropEffects.Move; 412 } 413 414 private void treeSlaveGroup_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) { 415 e.Action = DragAction.Continue; 416 } 417 418 void ResetView() { 419 if (this.InvokeRequired) { 420 Invoke(new Action(ResetView)); 611 if (update) UpdateResources(); 612 } catch (AnonymousUserException) { 613 ShowHiveInformationDialog(); 614 } 615 } 616 617 private void UpdateSchedule() { 618 try { 619 HiveAdminClient.Instance.RefreshCalendar(); 620 } catch (AnonymousUserException) { 621 ShowHiveInformationDialog(); 622 } 623 } 624 625 private bool IsAdmin() { 626 return HiveRoles.CheckAdminUserPermissions(); 627 } 628 629 private void StyleTreeNode(TreeNode n, Resource r, IEnumerable<Resource> resources) { 630 n.Text = r.Name; 631 n.BackColor = Color.Transparent; 632 n.ForeColor = Color.Black; 633 634 if (HiveAdminClient.Instance.DisabledParentResources.Select(x => x.Id).Contains(r.Id)) { 635 n.ForeColor = grayTextColor; 636 } else if (r.Id == Guid.Empty && n != ungroupedGroupNode /*!r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) { 637 // not stored (i.e. new) 638 n.Text += NOT_STORED_TAG; 639 } else if (r.Modified && n != ungroupedGroupNode /*!r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) { 640 // changed 641 n.Text += CHANGES_NOT_STORED_TAG; 642 } 643 644 // slave count 645 int childSlavesCount = 0; 646 if (r.Id != Guid.Empty && r is SlaveGroup) { 647 var descendants = GetResourceDescendants(); 648 if (descendants.ContainsKey(r.Id)) { 649 childSlavesCount = resources 650 .OfType<Slave>() 651 .Where(x => descendants[r.Id].Select(y => y.Id) 652 .Contains(x.Id)) 653 .Count(); 654 } 655 } else if (n == ungroupedGroupNode /*|| r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) { 656 childSlavesCount = resources 657 .OfType<Slave>() 658 .Where(x => x.ParentResourceId == null 659 || (x.ParentResourceId.HasValue && x.ParentResourceId.Value == Guid.Empty)) 660 .Count(); 661 } 662 if (childSlavesCount > 0) 663 n.Text += " [" + childSlavesCount.ToString() + "]"; 664 665 // slave image index, state, utilization 666 if (r is Slave) { 667 n.ImageIndex = slaveImageIndex; 668 var s = r as Slave; 669 if (s.SlaveState == SlaveState.Calculating) { 670 n.ForeColor = calculatingColor; 671 n.Text += " [" + s.CpuUtilization.ToString("N2") + "%]"; 672 } else if (s.SlaveState == SlaveState.Offline) { 673 n.ForeColor = offlineColor; 674 if (s.LastHeartbeat.HasValue) 675 n.Text += " [" + (s.LastHeartbeat != null ? s.LastHeartbeat.Value.ToString("g") : null) + "]"; 676 } 421 677 } else { 422 treeSlaveGroup.Nodes.Clear(); 423 424 if (slaveView.Content != null && slaveView.Content is SlaveGroup) { 425 slaveView.Content.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(SlaveViewContent_PropertyChanged); 426 } 427 slaveView.Content = null; 678 n.ImageIndex = slaveGroupImageIndex; 679 } 680 681 // ungrouped 682 if (n == ungroupedGroupNode /*r.Name.StartsWith(UNGROUPED_GROUP_NAME)*/) { 683 n.ForeColor = SystemColors.GrayText; 684 } 685 } 686 687 private void ResetTreeNodes(TreeNodeCollection nodes, IEnumerable<Resource> resources) { 688 foreach (TreeNode n in nodes) { 689 StyleTreeNode(n, (Resource)n.Tag, resources); 690 if (n.Nodes.Count > 0) { 691 ResetTreeNodes(n.Nodes, resources); 692 } 693 } 694 } 695 696 private async void ChangeSelectedResource(Resource resource) { 697 selectedResource = resource; 698 viewHost.Content = selectedResource; 699 700 HiveAdminClient.Instance.DowntimeForResourceId = selectedResource != null ? selectedResource.Id : Guid.Empty; 701 if (tabSlaveGroup.SelectedTab == tabSchedule) { 702 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 703 action: () => UpdateSchedule(), 704 finallyCallback: () => scheduleView.Content = HiveAdminClient.Instance.Downtimes); 705 } 706 707 SetEnabledStateOfControls(); 708 } 709 710 private void ChangeSelectedResourceNode(TreeNode resourceNode) { 711 if (resourceNode == null) return; 712 SelectedResource = (Resource)resourceNode.Tag; 713 ResetTreeNodes(treeView.Nodes, Content); 714 resourceNode.BackColor = selectedBackColor; 715 resourceNode.ForeColor = selectedForeColor; 716 resourceNode.Text += SELECTED_TAG; 717 } 718 719 private void ShowHiveInformationDialog() { 720 if (InvokeRequired) Invoke((Action)ShowHiveInformationDialog); 721 else { 722 using (HiveInformationDialog dialog = new HiveInformationDialog()) { 723 dialog.ShowDialog(this); 724 } 725 } 726 } 727 728 private void ResetView() { 729 if (InvokeRequired) Invoke((Action)ResetView); 730 else { 731 treeView.Nodes.Clear(); 732 733 if (viewHost.Content != null && viewHost.Content is SlaveGroup) { 734 ((SlaveGroup)viewHost.Content).PropertyChanged -= SlaveViewContent_PropertyChanged; 735 } 736 737 viewHost.Content = null; 428 738 if (scheduleView.Content != null) { 429 739 scheduleView.Content.Clear(); 430 740 } 741 431 742 HiveAdminClient.Instance.ResetDowntime(); 432 743 } 433 744 } 434 745 435 private void UpdateResources() { 436 ResetView(); 437 438 try { 439 if (!Access.UserInformation.Instance.UserExists) { 440 //do a refresh just in case that the user has changed his usr and pwd in between 441 Access.UserInformation.Instance.Refresh(); 442 } 443 HiveAdminClient.Instance.Refresh(); 444 Content = HiveAdminClient.Instance.Resources; 445 } 446 catch (MessageSecurityException) { 447 ShowMessageSecurityException(); 448 } 449 catch (AnonymousUserException) { 450 ShowHiveInformationDialog(); 451 } 452 } 453 454 private void ShowMessageSecurityException() { 455 if (this.InvokeRequired) { 456 Invoke(new Action(ShowMessageSecurityException)); 457 } else { 458 MessageBox.Show("A Message Security error has occured. This normally means that your user name or password is wrong.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error); 459 } 460 } 461 462 private void ShowHiveInformationDialog() { 463 if (this.InvokeRequired) { 464 Invoke(new Action(ShowHiveInformationDialog)); 465 } else { 466 using (HiveInformationDialog dialog = new HiveInformationDialog()) { 467 dialog.ShowDialog(this); 468 } 469 } 470 } 471 472 private void UpdateResourcesAsync() { 473 TS.Task.Factory.StartNew(UpdateResources).ContinueWith((t) => { 474 DisplayError(t.Exception); 475 }, TaskContinuationOptions.OnlyOnFaulted); 476 } 477 478 private void UpdateSchedule() { 479 HiveAdminClient.Instance.RefreshCalendar(); 480 scheduleView.Invoke(new Action(() => { 481 scheduleView.Content = HiveAdminClient.Instance.Downtimes; 482 SetEnabledStateOfControls(); 483 })); 484 } 485 486 private void UpdateScheduleAsync() { 487 TS.Task.Factory.StartNew(UpdateSchedule).ContinueWith((t) => { 488 DisplayError(t.Exception); 489 }, TaskContinuationOptions.OnlyOnFaulted); 490 } 491 492 private void UpdatePermissions() { 493 if (permissionView.Content != null && permissionView.FetchSelectedUsers != null) 494 permissionView.Invoke(new Action(() => permissionView.ManualRefresh())); 495 } 496 497 private void UpdatePermissionsAsync() { 498 TS.Task.Factory.StartNew(UpdatePermissions).ContinueWith((t) => { 499 DisplayError(t.Exception); 500 }, TaskContinuationOptions.OnlyOnFaulted); 501 } 502 503 504 private void DisplayError(Exception ex) { 505 MessageBox.Show(string.Format("An error occured while updating: {0} {1}", Environment.NewLine, ex.Message), "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error); 506 } 507 508 private void tabSlaveGroup_SelectedIndexChanged(object sender, EventArgs e) { 509 if (tabSlaveGroup.SelectedIndex == 1) { 510 UpdateScheduleAsync(); 511 } else if (tabSlaveGroup.SelectedIndex == 2) { 512 UpdatePermissionsAsync(); 513 } 514 } 515 516 private void btnRefresh_Click(object sender, EventArgs e) { 517 UpdateResourcesAsync(); 518 } 519 520 private void ResourcesView_Load(object sender, EventArgs e) { 521 UpdateResourcesAsync(); 522 } 523 524 private void btnPermissionsSave_Click(object sender, EventArgs e) { 525 SetEnabledStateOfControls(); 526 HiveServiceLocator.Instance.CallHiveService(service => { 527 service.GrantResourcePermissions(((Resource)treeSlaveGroup.SelectedNode.Tag).Id, permissionView.GetAddedUsers().Select(x => x.Id).ToList()); 528 service.RevokeResourcePermissions(((Resource)treeSlaveGroup.SelectedNode.Tag).Id, permissionView.GetDeletedUsers().Select(x => x.Id).ToList()); 529 }); 530 SetEnabledStateOfControls(); 531 } 746 747 private Dictionary<Guid, HashSet<Resource>> GetResourceDescendants() { 748 var resourceDescendants = new Dictionary<Guid, HashSet<Resource>>(); 749 //var resources = Content.Where(x => x.Id != Guid.Empty).Union(HiveAdminClient.Instance.DisabledParentResources).ToList(); 750 var resources = Content.Union(HiveAdminClient.Instance.DisabledParentResources).ToList(); 751 752 foreach (var r in resources) { 753 if(!resourceDescendants.ContainsKey(r.Id)) 754 resourceDescendants.Add(r.Id, new HashSet<Resource>()); 755 } 756 foreach (var r in resources) { 757 var parentResourceId = r.ParentResourceId; 758 while (parentResourceId != null) { 759 var parent = resources.SingleOrDefault(x => x.Id == parentResourceId); 760 if (parent != null) { 761 resourceDescendants[parent.Id].Add(r); 762 parentResourceId = parent.ParentResourceId; 763 } else { 764 parentResourceId = null; 765 } 766 } 767 } 768 return resourceDescendants; 769 } 770 771 #endregion 532 772 } 533 773 } -
branches/2915-AbsoluteSymbol/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.Designer.cs
r15583 r16240 48 48 Calendar.DrawTool drawTool1 = new Calendar.DrawTool(); 49 49 this.dvOnline = new Calendar.DayView(); 50 this.txttimeTo = new System.Windows.Forms.DateTimePicker();51 this.txttimeFrom = new System.Windows.Forms.DateTimePicker();52 50 this.dtpTo = new System.Windows.Forms.DateTimePicker(); 53 51 this.groupBox1 = new System.Windows.Forms.GroupBox(); … … 94 92 this.dvOnline.OnSelectionChanged += new System.EventHandler<System.EventArgs>(this.dvOnline_OnSelectionChanged); 95 93 // 96 // txttimeTo97 //98 this.txttimeTo.CustomFormat = "HH:mm";99 this.txttimeTo.Format = System.Windows.Forms.DateTimePickerFormat.Custom;100 this.txttimeTo.Location = new System.Drawing.Point(164, 45);101 this.txttimeTo.Name = "txttimeTo";102 this.txttimeTo.ShowUpDown = true;103 this.txttimeTo.Size = new System.Drawing.Size(73, 20);104 this.txttimeTo.TabIndex = 40;105 //106 // txttimeFrom107 //108 this.txttimeFrom.CustomFormat = "HH:mm";109 this.txttimeFrom.Format = System.Windows.Forms.DateTimePickerFormat.Custom;110 this.txttimeFrom.Location = new System.Drawing.Point(164, 12);111 this.txttimeFrom.Name = "txttimeFrom";112 this.txttimeFrom.ShowUpDown = true;113 this.txttimeFrom.Size = new System.Drawing.Size(73, 20);114 this.txttimeFrom.TabIndex = 39;115 //116 94 // dtpTo 117 95 // 118 96 this.dtpTo.Format = System.Windows.Forms.DateTimePickerFormat.Custom; 97 this.dtpTo.CustomFormat = "ddd, dd.MM.yyyy, HH:mm:ss"; 119 98 this.dtpTo.Location = new System.Drawing.Point(72, 45); 120 99 this.dtpTo.Name = "dtpTo"; 121 this.dtpTo.Size = new System.Drawing.Size( 89, 20);100 this.dtpTo.Size = new System.Drawing.Size(175, 20); 122 101 this.dtpTo.TabIndex = 33; 123 102 // … … 125 104 // 126 105 this.groupBox1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 127 this.groupBox1.Controls.Add(this.txttimeTo);128 this.groupBox1.Controls.Add(this.txttimeFrom);129 106 this.groupBox1.Controls.Add(this.dtpTo); 130 107 this.groupBox1.Controls.Add(this.dtpFrom); … … 144 121 // 145 122 this.dtpFrom.Format = System.Windows.Forms.DateTimePickerFormat.Custom; 123 this.dtpFrom.CustomFormat = "ddd, dd.MM.yyyy, HH:mm:ss"; 146 124 this.dtpFrom.Location = new System.Drawing.Point(72, 12); 147 125 this.dtpFrom.Name = "dtpFrom"; 148 this.dtpFrom.Size = new System.Drawing.Size( 89, 20);126 this.dtpFrom.Size = new System.Drawing.Size(175, 20); 149 127 this.dtpFrom.TabIndex = 32; 150 128 // … … 157 135 this.chbade.TabIndex = 31; 158 136 this.chbade.Text = "All Day Event"; 137 this.chbade.CheckedChanged += new System.EventHandler(this.chbade_CheckedChanged); 159 138 this.chbade.UseVisualStyleBackColor = true; 160 this.chbade.CheckedChanged += new System.EventHandler(this.chbade_CheckedChanged);161 139 // 162 140 // btnRecurrence … … 220 198 // 221 199 this.btnSaveCal.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 222 this.btnSaveCal.Image = HeuristicLab.Common.Resources.VSImageLibrary. PublishToWeb;200 this.btnSaveCal.Image = HeuristicLab.Common.Resources.VSImageLibrary.Save; 223 201 this.btnSaveCal.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft; 224 202 this.btnSaveCal.Location = new System.Drawing.Point(640, 41); … … 273 251 #endregion 274 252 275 private System.Windows.Forms.DateTimePicker txttimeTo;276 253 private Calendar.DayView dvOnline; 277 private System.Windows.Forms.DateTimePicker txttimeFrom;278 254 private System.Windows.Forms.DateTimePicker dtpTo; 279 255 private System.Windows.Forms.GroupBox groupBox1; -
branches/2915-AbsoluteSymbol/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ScheduleView.cs
r15583 r16240 92 92 93 93 if (!string.IsNullOrEmpty(dtpFrom.Text) && !string.IsNullOrEmpty(dtpTo.Text)) { 94 if ( chbade.Checked) {94 if (DateTime.TryParse(dtpFrom.Text, out from) && DateTime.TryParse(dtpTo.Text, out to) && from <= to) { 95 95 //whole day appointment, only dates are visible 96 if (DateTime.TryParse(dtpFrom.Text, out from) && DateTime.TryParse(dtpTo.Text, out to) && from <= to) 97 offlineTimes.Add(CreateDowntime(from, to.AddDays(1), true, dtType)); 98 else 99 MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 100 } else if (!string.IsNullOrEmpty(txttimeFrom.Text) && !string.IsNullOrEmpty(txttimeTo.Text)) { 101 //Timeframe appointment 102 if (DateTime.TryParse(dtpFrom.Text + " " + txttimeFrom.Text, out from) && DateTime.TryParse(dtpTo.Text + " " + txttimeTo.Text, out to) && from < to) { 96 if (chbade.Checked) { 97 offlineTimes.Add(CreateDowntime(new DateTime(from.Year, from.Month, from.Day), (new DateTime(to.Year, to.Month, to.Day)).AddDays(1), true, dtType)); 98 } else { 99 //Timeframe appointment 103 100 if (from.Date == to.Date) 104 101 offlineTimes.Add(CreateDowntime(from, to, false, dtType)); … … 111 108 offlineTimes.Add(CreateDowntime(from, new DateTime(from.Year, from.Month, from.Day, to.Hour, to.Minute, 0, 0), false, dtType)); 112 109 } 113 } else 114 MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 115 } 110 } 111 112 } else { 113 MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 114 } 115 116 116 117 dvOnline.Invalidate(); 117 118 return true; … … 156 157 157 158 private void ChangeRecurrenceDowntime(Guid recurringId) { 158 int hourfrom = int.Parse(txttimeFrom.Text.Substring(0, txttimeFrom.Text.IndexOf(':'))); 159 int hourTo = int.Parse(txttimeTo.Text.Substring(0, txttimeTo.Text.IndexOf(':'))); 160 List<HiveDowntime> recurringDowntimes = offlineTimes.Where(appointment => ((HiveDowntime)appointment).RecurringId == recurringId).ToList(); 161 recurringDowntimes.ForEach(appointment => appointment.StartDate = new DateTime(appointment.StartDate.Year, appointment.StartDate.Month, appointment.StartDate.Day, hourfrom, 0, 0)); 162 recurringDowntimes.ForEach(appointment => appointment.EndDate = new DateTime(appointment.EndDate.Year, appointment.EndDate.Month, appointment.EndDate.Day, hourTo, 0, 0)); 159 DateTime from, to; 160 if (DateTime.TryParse(dtpFrom.Text, out from) && DateTime.TryParse(dtpTo.Text, out to) && from <= to) { 161 List<HiveDowntime> recurringDowntimes = offlineTimes.Where(appointment => ((HiveDowntime)appointment).RecurringId == recurringId).ToList(); 162 recurringDowntimes.ForEach(appointment => appointment.StartDate = new DateTime(appointment.StartDate.Year, appointment.StartDate.Month, appointment.StartDate.Day, from.Hour, 0, 0)); 163 recurringDowntimes.ForEach(appointment => appointment.EndDate = new DateTime(appointment.EndDate.Year, appointment.EndDate.Month, appointment.EndDate.Day, to.Hour, 0, 0)); 164 } else { 165 MessageBox.Show("Incorrect date format", "Schedule Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 166 } 163 167 } 164 168 … … 222 226 protected override void SetEnabledStateOfControls() { 223 227 base.SetEnabledStateOfControls(); 224 } 225 226 public virtual void SetEnabledStateOfSchedule(bool state) { 227 if (InvokeRequired) { 228 Invoke(new Action(() => SetEnabledStateOfSchedule(state))); 229 } else { 230 if (Content == null) state = false; 231 groupBox1.Enabled = state; 232 btnClearCal.Enabled = state; 233 btnSaveCal.Enabled = state; 234 } 235 } 228 bool enabled = Content != null && !Locked; 229 dtpFrom.Enabled = enabled; 230 dtpTo.Enabled = enabled; 231 chbade.Enabled = enabled; 232 btCreate.Enabled = enabled; 233 btbDelete.Enabled = enabled; 234 btnRecurrence.Enabled = enabled; 235 btnClearCal.Enabled = enabled; 236 btnSaveCal.Enabled = enabled; 237 } 238 239 //public virtual void SetEnabledStateOfSchedule(bool state) { 240 // if (InvokeRequired) { 241 // Invoke(new Action(() => SetEnabledStateOfSchedule(state))); 242 // } else { 243 // if (Content == null || Locked || ReadOnly) state = false; 244 // //groupBox1.Enabled = state; 245 // btnClearCal.Enabled = state; 246 // btnSaveCal.Enabled = state; 247 // } 248 //} 236 249 237 250 private void btnClearCal_Click(object sender, System.EventArgs e) { … … 243 256 244 257 private void chbade_CheckedChanged(object sender, EventArgs e) { 245 txttimeFrom.Visible = !chbade.Checked; 246 txttimeTo.Visible = !chbade.Checked; 258 if(chbade.Checked) { 259 dtpFrom.Value = new DateTime(dtpFrom.Value.Year, dtpFrom.Value.Month, dtpFrom.Value.Day); 260 dtpTo.Value = new DateTime(dtpTo.Value.Year, dtpTo.Value.Month, dtpTo.Value.Day); 261 } 247 262 } 248 263 249 264 private void dvOnline_OnSelectionChanged(object sender, EventArgs e) { 250 265 if (dvOnline.Selection == SelectionType.DateRange) { 251 dtpFrom.Text = dvOnline.SelectionStart.ToShortDateString(); 252 dtpTo.Text = dvOnline.SelectionEnd.Date.ToShortDateString(); 253 txttimeFrom.Text = dvOnline.SelectionStart.ToShortTimeString(); 254 txttimeTo.Text = dvOnline.SelectionEnd.ToShortTimeString(); 266 dtpFrom.Value = dvOnline.SelectionStart; 267 dtpTo.Value = dvOnline.SelectionEnd.Date; 255 268 btCreate.Text = "Create Downtime"; 256 269 } 257 270 258 271 if (dvOnline.Selection == SelectionType.Appointment) { 259 dtpFrom.Text = dvOnline.SelectedAppointment.StartDate.ToShortDateString(); 260 dtpTo.Text = dvOnline.SelectedAppointment.EndDate.ToShortDateString(); 261 txttimeFrom.Text = dvOnline.SelectedAppointment.StartDate.ToShortTimeString(); 262 txttimeTo.Text = dvOnline.SelectedAppointment.EndDate.ToShortTimeString(); 272 dtpFrom.Value = dvOnline.SelectedAppointment.StartDate; 273 dtpTo.Value = dvOnline.SelectedAppointment.EndDate; 263 274 264 275 if (dvOnline.SelectedAppointment.Recurring) -
branches/2915-AbsoluteSymbol/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.Designer.cs
r15583 r16240 45 45 /// </summary> 46 46 private void InitializeComponent() { 47 this.txtSlaveState = new System.Windows.Forms.TextBox(); 48 this.txtOS = new System.Windows.Forms.TextBox(); 49 this.label15 = new System.Windows.Forms.Label(); 50 this.label14 = new System.Windows.Forms.Label(); 51 this.txtDetailsDescription = new System.Windows.Forms.TextBox(); 52 this.label13 = new System.Windows.Forms.Label(); 53 this.txtName = new System.Windows.Forms.TextBox(); 54 this.txtCPU = new System.Windows.Forms.TextBox(); 55 this.txtMemory = new System.Windows.Forms.TextBox(); 56 this.txtLastHeartbeat = new System.Windows.Forms.TextBox(); 57 this.label12 = new System.Windows.Forms.Label(); 58 this.label11 = new System.Windows.Forms.Label(); 59 this.label10 = new System.Windows.Forms.Label(); 60 this.label9 = new System.Windows.Forms.Label(); 61 this.label1 = new System.Windows.Forms.Label(); 62 this.txtFreeMemory = new System.Windows.Forms.TextBox(); 63 this.txtId = new System.Windows.Forms.TextBox(); 64 this.label2 = new System.Windows.Forms.Label(); 65 this.label3 = new System.Windows.Forms.Label(); 66 this.txtHbIntervall = new System.Windows.Forms.TextBox(); 67 this.cbxDisposable = new System.Windows.Forms.CheckBox(); 68 this.label4 = new System.Windows.Forms.Label(); 69 this.cbxPublic = new System.Windows.Forms.CheckBox(); 70 this.label5 = new System.Windows.Forms.Label(); 47 this.cpuLabel = new System.Windows.Forms.Label(); 48 this.cpuTextBox = new System.Windows.Forms.TextBox(); 49 this.memoryLabel = new System.Windows.Forms.Label(); 50 this.memoryTextBox = new System.Windows.Forms.TextBox(); 51 this.operatingSystemLabel = new System.Windows.Forms.Label(); 52 this.operatingSystemTextBox = new System.Windows.Forms.TextBox(); 53 this.stateLabel = new System.Windows.Forms.Label(); 54 this.stateTextBox = new System.Windows.Forms.TextBox(); 55 this.lastHeartbeatLabel = new System.Windows.Forms.Label(); 56 this.lastHeartbeatTextBox = new System.Windows.Forms.TextBox(); 57 this.disposableLabel = new System.Windows.Forms.Label(); 58 this.disposableCheckBox = new System.Windows.Forms.CheckBox(); 59 ((System.ComponentModel.ISupportInitialize)(this.heartbeatIntervalNumericUpDown)).BeginInit(); 71 60 this.SuspendLayout(); 72 61 // 73 // txtSlaveState 74 // 75 this.txtSlaveState.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 76 | System.Windows.Forms.AnchorStyles.Right))); 77 this.txtSlaveState.Enabled = false; 78 this.txtSlaveState.Location = new System.Drawing.Point(146, 242); 79 this.txtSlaveState.Name = "txtSlaveState"; 80 this.txtSlaveState.Size = new System.Drawing.Size(390, 20); 81 this.txtSlaveState.TabIndex = 27; 82 // 83 // txtOS 84 // 85 this.txtOS.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 86 | System.Windows.Forms.AnchorStyles.Right))); 87 this.txtOS.Enabled = false; 88 this.txtOS.Location = new System.Drawing.Point(146, 216); 89 this.txtOS.Name = "txtOS"; 90 this.txtOS.Size = new System.Drawing.Size(390, 20); 91 this.txtOS.TabIndex = 26; 92 // 93 // label15 94 // 95 this.label15.AutoSize = true; 96 this.label15.Location = new System.Drawing.Point(3, 245); 97 this.label15.Name = "label15"; 98 this.label15.Size = new System.Drawing.Size(35, 13); 99 this.label15.TabIndex = 25; 100 this.label15.Text = "State:"; 101 // 102 // label14 103 // 104 this.label14.AutoSize = true; 105 this.label14.Location = new System.Drawing.Point(3, 219); 106 this.label14.Name = "label14"; 107 this.label14.Size = new System.Drawing.Size(93, 13); 108 this.label14.TabIndex = 24; 109 this.label14.Text = "Operating System:"; 110 // 111 // txtDetailsDescription 112 // 113 this.txtDetailsDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 114 | System.Windows.Forms.AnchorStyles.Right))); 115 this.txtDetailsDescription.Enabled = false; 116 this.txtDetailsDescription.Location = new System.Drawing.Point(146, 112); 117 this.txtDetailsDescription.Name = "txtDetailsDescription"; 118 this.txtDetailsDescription.Size = new System.Drawing.Size(390, 20); 119 this.txtDetailsDescription.TabIndex = 23; 120 // 121 // label13 122 // 123 this.label13.AutoSize = true; 124 this.label13.Location = new System.Drawing.Point(3, 115); 125 this.label13.Name = "label13"; 126 this.label13.Size = new System.Drawing.Size(63, 13); 127 this.label13.TabIndex = 22; 128 this.label13.Text = "Description:"; 129 // 130 // txtName 131 // 132 this.txtName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 133 | System.Windows.Forms.AnchorStyles.Right))); 134 this.txtName.Location = new System.Drawing.Point(146, 8); 135 this.txtName.Name = "txtName"; 136 this.txtName.Size = new System.Drawing.Size(390, 20); 137 this.txtName.TabIndex = 21; 138 this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged); 139 // 140 // txtCPU 141 // 142 this.txtCPU.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 143 | System.Windows.Forms.AnchorStyles.Right))); 144 this.txtCPU.Enabled = false; 145 this.txtCPU.Location = new System.Drawing.Point(146, 138); 146 this.txtCPU.Name = "txtCPU"; 147 this.txtCPU.Size = new System.Drawing.Size(390, 20); 148 this.txtCPU.TabIndex = 20; 149 // 150 // txtMemory 151 // 152 this.txtMemory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 153 | System.Windows.Forms.AnchorStyles.Right))); 154 this.txtMemory.Enabled = false; 155 this.txtMemory.Location = new System.Drawing.Point(146, 164); 156 this.txtMemory.Name = "txtMemory"; 157 this.txtMemory.Size = new System.Drawing.Size(390, 20); 158 this.txtMemory.TabIndex = 19; 159 // 160 // txtLastHeartbeat 161 // 162 this.txtLastHeartbeat.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 163 | System.Windows.Forms.AnchorStyles.Right))); 164 this.txtLastHeartbeat.Enabled = false; 165 this.txtLastHeartbeat.Location = new System.Drawing.Point(146, 268); 166 this.txtLastHeartbeat.Name = "txtLastHeartbeat"; 167 this.txtLastHeartbeat.Size = new System.Drawing.Size(390, 20); 168 this.txtLastHeartbeat.TabIndex = 18; 169 // 170 // label12 171 // 172 this.label12.AutoSize = true; 173 this.label12.Location = new System.Drawing.Point(3, 271); 174 this.label12.Name = "label12"; 175 this.label12.Size = new System.Drawing.Size(80, 13); 176 this.label12.TabIndex = 17; 177 this.label12.Text = "Last Heartbeat:"; 178 // 179 // label11 180 // 181 this.label11.AutoSize = true; 182 this.label11.Location = new System.Drawing.Point(3, 167); 183 this.label11.Name = "label11"; 184 this.label11.Size = new System.Drawing.Size(47, 13); 185 this.label11.TabIndex = 16; 186 this.label11.Text = "Memory:"; 187 // 188 // label10 189 // 190 this.label10.AutoSize = true; 191 this.label10.Location = new System.Drawing.Point(3, 141); 192 this.label10.Name = "label10"; 193 this.label10.Size = new System.Drawing.Size(32, 13); 194 this.label10.TabIndex = 15; 195 this.label10.Text = "CPU:"; 196 // 197 // label9 198 // 199 this.label9.AutoSize = true; 200 this.label9.Location = new System.Drawing.Point(3, 11); 201 this.label9.Name = "label9"; 202 this.label9.Size = new System.Drawing.Size(38, 13); 203 this.label9.TabIndex = 14; 204 this.label9.Text = "Name:"; 205 // 206 // label1 207 // 208 this.label1.AutoSize = true; 209 this.label1.Location = new System.Drawing.Point(3, 193); 210 this.label1.Name = "label1"; 211 this.label1.Size = new System.Drawing.Size(70, 13); 212 this.label1.TabIndex = 28; 213 this.label1.Text = "Free memory:"; 214 // 215 // txtFreeMemory 216 // 217 this.txtFreeMemory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 218 | System.Windows.Forms.AnchorStyles.Right))); 219 this.txtFreeMemory.Enabled = false; 220 this.txtFreeMemory.Location = new System.Drawing.Point(146, 190); 221 this.txtFreeMemory.Name = "txtFreeMemory"; 222 this.txtFreeMemory.Size = new System.Drawing.Size(390, 20); 223 this.txtFreeMemory.TabIndex = 29; 224 // 225 // txtId 226 // 227 this.txtId.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 228 | System.Windows.Forms.AnchorStyles.Right))); 229 this.txtId.Enabled = false; 230 this.txtId.Location = new System.Drawing.Point(146, 86); 231 this.txtId.Name = "txtId"; 232 this.txtId.Size = new System.Drawing.Size(390, 20); 233 this.txtId.TabIndex = 30; 234 // 235 // label2 236 // 237 this.label2.AutoSize = true; 238 this.label2.Location = new System.Drawing.Point(3, 89); 239 this.label2.Name = "label2"; 240 this.label2.Size = new System.Drawing.Size(19, 13); 241 this.label2.TabIndex = 31; 242 this.label2.Text = "Id:"; 243 // 244 // label3 245 // 246 this.label3.AutoSize = true; 247 this.label3.Location = new System.Drawing.Point(3, 37); 248 this.label3.Name = "label3"; 249 this.label3.Size = new System.Drawing.Size(137, 13); 250 this.label3.TabIndex = 32; 251 this.label3.Text = "Heartbeat Intervall (in sec) :"; 252 // 253 // txtHbIntervall 254 // 255 this.txtHbIntervall.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 256 | System.Windows.Forms.AnchorStyles.Right))); 257 this.txtHbIntervall.Location = new System.Drawing.Point(146, 34); 258 this.txtHbIntervall.Name = "txtHbIntervall"; 259 this.txtHbIntervall.Size = new System.Drawing.Size(390, 20); 260 this.txtHbIntervall.TabIndex = 33; 261 this.txtHbIntervall.TextChanged += new System.EventHandler(this.txtHbIntervall_TextChanged); 262 // 263 // cbxDisposable 264 // 265 this.cbxDisposable.AutoSize = true; 266 this.cbxDisposable.Enabled = false; 267 this.cbxDisposable.Location = new System.Drawing.Point(146, 297); 268 this.cbxDisposable.Name = "cbxDisposable"; 269 this.cbxDisposable.Size = new System.Drawing.Size(15, 14); 270 this.cbxDisposable.TabIndex = 34; 271 this.cbxDisposable.UseVisualStyleBackColor = true; 272 this.cbxDisposable.CheckedChanged += new System.EventHandler(this.cbxDisposable_CheckedChanged); 273 // 274 // label4 275 // 276 this.label4.AutoSize = true; 277 this.label4.Location = new System.Drawing.Point(3, 297); 278 this.label4.Name = "label4"; 279 this.label4.Size = new System.Drawing.Size(62, 13); 280 this.label4.TabIndex = 35; 281 this.label4.Text = "Disposable:"; 282 // 283 // cbxPublic 284 // 285 this.cbxPublic.AutoSize = true; 286 this.cbxPublic.Enabled = false; 287 this.cbxPublic.Location = new System.Drawing.Point(146, 63); 288 this.cbxPublic.Name = "cbxPublic"; 289 this.cbxPublic.Size = new System.Drawing.Size(15, 14); 290 this.cbxPublic.TabIndex = 36; 291 this.cbxPublic.UseVisualStyleBackColor = true; 292 this.cbxPublic.CheckedChanged += new System.EventHandler(this.cbxPublic_CheckedChanged); 293 // 294 // label5 295 // 296 this.label5.AutoSize = true; 297 this.label5.Location = new System.Drawing.Point(3, 63); 298 this.label5.Name = "label5"; 299 this.label5.Size = new System.Drawing.Size(39, 13); 300 this.label5.TabIndex = 37; 301 this.label5.Text = "Public:"; 62 // nameTextBox 63 // 64 this.nameTextBox.ReadOnly = true; 65 // 66 // cpuLabel 67 // 68 this.cpuLabel.AutoSize = true; 69 this.cpuLabel.Location = new System.Drawing.Point(3, 141); 70 this.cpuLabel.Name = "cpuLabel"; 71 this.cpuLabel.Size = new System.Drawing.Size(32, 13); 72 this.cpuLabel.TabIndex = 16; 73 this.cpuLabel.Text = "CPU:"; 74 // 75 // cpuTextBox 76 // 77 this.cpuTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 78 | System.Windows.Forms.AnchorStyles.Right))); 79 this.cpuTextBox.Location = new System.Drawing.Point(130, 138); 80 this.cpuTextBox.Name = "cpuTextBox"; 81 this.cpuTextBox.ReadOnly = true; 82 this.cpuTextBox.Size = new System.Drawing.Size(397, 20); 83 this.cpuTextBox.TabIndex = 17; 84 // 85 // memoryLabel 86 // 87 this.memoryLabel.AutoSize = true; 88 this.memoryLabel.Location = new System.Drawing.Point(3, 167); 89 this.memoryLabel.Name = "memoryLabel"; 90 this.memoryLabel.Size = new System.Drawing.Size(47, 13); 91 this.memoryLabel.TabIndex = 18; 92 this.memoryLabel.Text = "Memory:"; 93 // 94 // memoryTextBox 95 // 96 this.memoryTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 97 | System.Windows.Forms.AnchorStyles.Right))); 98 this.memoryTextBox.Location = new System.Drawing.Point(130, 164); 99 this.memoryTextBox.Name = "memoryTextBox"; 100 this.memoryTextBox.ReadOnly = true; 101 this.memoryTextBox.Size = new System.Drawing.Size(397, 20); 102 this.memoryTextBox.TabIndex = 19; 103 // 104 // operatingSystemLabel 105 // 106 this.operatingSystemLabel.AutoSize = true; 107 this.operatingSystemLabel.Location = new System.Drawing.Point(3, 193); 108 this.operatingSystemLabel.Name = "operatingSystemLabel"; 109 this.operatingSystemLabel.Size = new System.Drawing.Size(93, 13); 110 this.operatingSystemLabel.TabIndex = 20; 111 this.operatingSystemLabel.Text = "Operating System:"; 112 // 113 // operatingSystemTextBox 114 // 115 this.operatingSystemTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 116 | System.Windows.Forms.AnchorStyles.Right))); 117 this.operatingSystemTextBox.Location = new System.Drawing.Point(130, 190); 118 this.operatingSystemTextBox.Name = "operatingSystemTextBox"; 119 this.operatingSystemTextBox.ReadOnly = true; 120 this.operatingSystemTextBox.Size = new System.Drawing.Size(397, 20); 121 this.operatingSystemTextBox.TabIndex = 21; 122 // 123 // stateLabel 124 // 125 this.stateLabel.AutoSize = true; 126 this.stateLabel.Location = new System.Drawing.Point(3, 219); 127 this.stateLabel.Name = "stateLabel"; 128 this.stateLabel.Size = new System.Drawing.Size(35, 13); 129 this.stateLabel.TabIndex = 22; 130 this.stateLabel.Text = "State:"; 131 // 132 // stateTextBox 133 // 134 this.stateTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 135 | System.Windows.Forms.AnchorStyles.Right))); 136 this.stateTextBox.Location = new System.Drawing.Point(130, 216); 137 this.stateTextBox.Name = "stateTextBox"; 138 this.stateTextBox.ReadOnly = true; 139 this.stateTextBox.Size = new System.Drawing.Size(397, 20); 140 this.stateTextBox.TabIndex = 23; 141 // 142 // lastHeartbeatLabel 143 // 144 this.lastHeartbeatLabel.AutoSize = true; 145 this.lastHeartbeatLabel.Location = new System.Drawing.Point(3, 245); 146 this.lastHeartbeatLabel.Name = "lastHeartbeatLabel"; 147 this.lastHeartbeatLabel.Size = new System.Drawing.Size(80, 13); 148 this.lastHeartbeatLabel.TabIndex = 24; 149 this.lastHeartbeatLabel.Text = "Last Heartbeat:"; 150 // 151 // lastHeartbeatTextBox 152 // 153 this.lastHeartbeatTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 154 | System.Windows.Forms.AnchorStyles.Right))); 155 this.lastHeartbeatTextBox.Location = new System.Drawing.Point(130, 242); 156 this.lastHeartbeatTextBox.Name = "lastHeartbeatTextBox"; 157 this.lastHeartbeatTextBox.ReadOnly = true; 158 this.lastHeartbeatTextBox.Size = new System.Drawing.Size(397, 20); 159 this.lastHeartbeatTextBox.TabIndex = 25; 160 // 161 // disposableLabel 162 // 163 this.disposableLabel.AutoSize = true; 164 this.disposableLabel.Location = new System.Drawing.Point(3, 271); 165 this.disposableLabel.Name = "disposableLabel"; 166 this.disposableLabel.Size = new System.Drawing.Size(62, 13); 167 this.disposableLabel.TabIndex = 28; 168 this.disposableLabel.Text = "Disposable:"; 169 // 170 // disposableCheckBox 171 // 172 this.disposableCheckBox.AutoSize = true; 173 this.disposableCheckBox.Location = new System.Drawing.Point(130, 270); 174 this.disposableCheckBox.Name = "disposableCheckBox"; 175 this.disposableCheckBox.Size = new System.Drawing.Size(15, 14); 176 this.disposableCheckBox.TabIndex = 29; 177 this.disposableCheckBox.UseVisualStyleBackColor = true; 178 this.disposableCheckBox.CheckedChanged += new System.EventHandler(this.disposableCheckBox_CheckedChanged); 302 179 // 303 180 // SlaveView 304 181 // 305 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);306 182 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 307 this.Controls.Add(this.label5); 308 this.Controls.Add(this.cbxPublic); 309 this.Controls.Add(this.label4); 310 this.Controls.Add(this.cbxDisposable); 311 this.Controls.Add(this.txtHbIntervall); 312 this.Controls.Add(this.label3); 313 this.Controls.Add(this.label2); 314 this.Controls.Add(this.txtId); 315 this.Controls.Add(this.txtFreeMemory); 316 this.Controls.Add(this.label1); 317 this.Controls.Add(this.txtSlaveState); 318 this.Controls.Add(this.txtOS); 319 this.Controls.Add(this.label15); 320 this.Controls.Add(this.label14); 321 this.Controls.Add(this.txtDetailsDescription); 322 this.Controls.Add(this.label13); 323 this.Controls.Add(this.txtName); 324 this.Controls.Add(this.txtCPU); 325 this.Controls.Add(this.txtMemory); 326 this.Controls.Add(this.txtLastHeartbeat); 327 this.Controls.Add(this.label12); 328 this.Controls.Add(this.label11); 329 this.Controls.Add(this.label10); 330 this.Controls.Add(this.label9); 183 this.Controls.Add(this.disposableCheckBox); 184 this.Controls.Add(this.disposableLabel); 185 this.Controls.Add(this.lastHeartbeatTextBox); 186 this.Controls.Add(this.lastHeartbeatLabel); 187 this.Controls.Add(this.stateTextBox); 188 this.Controls.Add(this.stateLabel); 189 this.Controls.Add(this.operatingSystemTextBox); 190 this.Controls.Add(this.operatingSystemLabel); 191 this.Controls.Add(this.memoryTextBox); 192 this.Controls.Add(this.memoryLabel); 193 this.Controls.Add(this.cpuTextBox); 194 this.Controls.Add(this.cpuLabel); 331 195 this.Name = "SlaveView"; 332 this.Size = new System.Drawing.Size(539, 407); 196 this.Controls.SetChildIndex(this.idTextBox, 0); 197 this.Controls.SetChildIndex(this.descriptionTextBox, 0); 198 this.Controls.SetChildIndex(this.heartbeatIntervalNumericUpDown, 0); 199 this.Controls.SetChildIndex(this.publicCheckBox, 0); 200 this.Controls.SetChildIndex(this.nameTextBox, 0); 201 this.Controls.SetChildIndex(this.cpuLabel, 0); 202 this.Controls.SetChildIndex(this.cpuTextBox, 0); 203 this.Controls.SetChildIndex(this.memoryLabel, 0); 204 this.Controls.SetChildIndex(this.memoryTextBox, 0); 205 this.Controls.SetChildIndex(this.operatingSystemLabel, 0); 206 this.Controls.SetChildIndex(this.operatingSystemTextBox, 0); 207 this.Controls.SetChildIndex(this.stateLabel, 0); 208 this.Controls.SetChildIndex(this.stateTextBox, 0); 209 this.Controls.SetChildIndex(this.lastHeartbeatLabel, 0); 210 this.Controls.SetChildIndex(this.lastHeartbeatTextBox, 0); 211 this.Controls.SetChildIndex(this.disposableLabel, 0); 212 this.Controls.SetChildIndex(this.disposableCheckBox, 0); 213 ((System.ComponentModel.ISupportInitialize)(this.heartbeatIntervalNumericUpDown)).EndInit(); 333 214 this.ResumeLayout(false); 334 215 this.PerformLayout(); … … 338 219 #endregion 339 220 340 private System.Windows.Forms.TextBox txtSlaveState; 341 private System.Windows.Forms.TextBox txtOS; 342 private System.Windows.Forms.Label label15; 343 private System.Windows.Forms.Label label14; 344 private System.Windows.Forms.TextBox txtDetailsDescription; 345 private System.Windows.Forms.Label label13; 346 private System.Windows.Forms.TextBox txtName; 347 private System.Windows.Forms.TextBox txtCPU; 348 private System.Windows.Forms.TextBox txtMemory; 349 private System.Windows.Forms.TextBox txtLastHeartbeat; 350 private System.Windows.Forms.Label label12; 351 private System.Windows.Forms.Label label11; 352 private System.Windows.Forms.Label label10; 353 private System.Windows.Forms.Label label9; 354 private System.Windows.Forms.Label label1; 355 private System.Windows.Forms.TextBox txtFreeMemory; 356 private System.Windows.Forms.TextBox txtId; 357 private System.Windows.Forms.Label label2; 358 private System.Windows.Forms.Label label3; 359 private System.Windows.Forms.TextBox txtHbIntervall; 360 private System.Windows.Forms.CheckBox cbxDisposable; 361 private System.Windows.Forms.Label label4; 362 private System.Windows.Forms.CheckBox cbxPublic; 363 private System.Windows.Forms.Label label5; 221 private System.Windows.Forms.Label cpuLabel; 222 private System.Windows.Forms.TextBox cpuTextBox; 223 private System.Windows.Forms.Label memoryLabel; 224 private System.Windows.Forms.TextBox memoryTextBox; 225 private System.Windows.Forms.Label operatingSystemLabel; 226 private System.Windows.Forms.TextBox operatingSystemTextBox; 227 private System.Windows.Forms.Label stateLabel; 228 private System.Windows.Forms.TextBox stateTextBox; 229 private System.Windows.Forms.Label lastHeartbeatLabel; 230 private System.Windows.Forms.TextBox lastHeartbeatTextBox; 231 private System.Windows.Forms.Label disposableLabel; 232 private System.Windows.Forms.CheckBox disposableCheckBox; 364 233 } 365 234 } -
branches/2915-AbsoluteSymbol/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.cs
r15583 r16240 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 8Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 22 22 using System; 23 23 using System.Windows.Forms; 24 using HeuristicLab.Clients.Access;25 using HeuristicLab.Core.Views;26 24 using HeuristicLab.MainForm; 27 25 using HeuristicLab.MainForm.WindowsForms; 28 26 29 27 namespace HeuristicLab.Clients.Hive.Administrator.Views { 30 [View("Slave View")]31 [Content(typeof( Resource), IsDefaultView = true)]32 public partial class SlaveView : ItemView {33 public new Resource Content {34 get { return ( Resource)base.Content; }28 [View("Slave View")] 29 [Content(typeof(Slave), IsDefaultView = true)] 30 public sealed partial class SlaveView : ResourceView { 31 public new Slave Content { 32 get { return (Slave)base.Content; } 35 33 set { base.Content = value; } 36 34 } … … 40 38 } 41 39 42 #region Register Content Events 43 protected override void DeregisterContentEvents() { 44 base.DeregisterContentEvents(); 45 } 46 protected override void RegisterContentEvents() { 47 base.RegisterContentEvents(); 48 } 49 #endregion 50 40 #region Overrides 51 41 protected override void OnContentChanged() { 52 42 base.OnContentChanged(); 53 43 if (Content == null) { 54 ShowSlaveUI(true); 55 txtName.Clear(); 56 txtCPU.Clear(); 57 txtDetailsDescription.Clear(); 58 txtMemory.Clear(); 59 txtOS.Clear(); 60 txtSlaveState.Clear(); 61 txtLastHeartbeat.Clear(); 62 txtFreeMemory.Clear(); 63 txtId.Clear(); 64 txtHbIntervall.Clear(); 65 cbxDisposable.Checked = false; 66 cbxPublic.Checked = false; 44 cpuTextBox.Clear(); 45 memoryTextBox.Clear(); 46 operatingSystemTextBox.Clear(); 47 stateTextBox.Clear(); 48 lastHeartbeatTextBox.Clear(); 49 disposableCheckBox.Checked = false; 67 50 } else { 68 if (Content.GetType() == typeof(Slave)) { 69 ShowSlaveUI(true); 70 Slave ct = (Slave)Content; 71 bool authorized = UserInformation.Instance.UserExists && (ct.OwnerUserId == UserInformation.Instance.User.Id || HiveRoles.CheckAdminUserPermissions()); 72 txtName.Text = ct.Name; 73 txtHbIntervall.Text = ct.HbInterval.ToString(); 74 cbxPublic.Enabled = authorized; 75 cbxPublic.CheckedChanged -= new EventHandler(cbxPublic_CheckedChanged); 76 cbxPublic.Checked = ct.OwnerUserId == null; 77 cbxPublic.CheckedChanged += new EventHandler(cbxPublic_CheckedChanged); 78 txtCPU.Text = string.Format("{0} Cores @ {1} Mhz, Arch.: {2}", ct.Cores.ToString(), ct.CpuSpeed.ToString(), ct.CpuArchitecture.ToString()); 79 txtDetailsDescription.Text = ct.Description; 80 txtMemory.Text = ct.Memory.ToString(); 81 txtOS.Text = ct.OperatingSystem; 82 txtSlaveState.Text = ct.SlaveState.ToString(); 83 txtLastHeartbeat.Text = ct.LastHeartbeat.ToString(); 84 txtFreeMemory.Text = ct.FreeMemory.ToString(); 85 txtId.Text = ct.Id.ToString(); 86 cbxDisposable.Enabled = authorized; 87 cbxDisposable.Checked = ct.IsDisposable.GetValueOrDefault(); 88 } else if (Content.GetType() == typeof(SlaveGroup)) { 89 SlaveGroup ct = (SlaveGroup)Content; 90 txtName.Text = ct.Name; 91 txtHbIntervall.Text = ct.HbInterval.ToString(); 92 cbxPublic.Enabled = ct.Name != "UNGROUPED" && HiveRoles.CheckAdminUserPermissions(); 93 cbxPublic.CheckedChanged -= new EventHandler(cbxPublic_CheckedChanged); 94 cbxPublic.Checked = ct.OwnerUserId == null; 95 cbxPublic.CheckedChanged += new EventHandler(cbxPublic_CheckedChanged); 96 ShowSlaveUI(false); 97 } else { 98 throw new Exception("Unknown Resource in SlaveView"); 99 } 51 cpuTextBox.Text = string.Format("{0} Cores @ {1} MHz, Arch.: {2}", Content.Cores, Content.CpuSpeed, Content.CpuArchitecture); 52 memoryTextBox.Text = string.Format("{0} ({1} Free)", Content.Memory, Content.FreeMemory); 53 operatingSystemTextBox.Text = Content.OperatingSystem; 54 stateTextBox.Text = Content.SlaveState.ToString(); 55 lastHeartbeatTextBox.Text = Content.LastHeartbeat.ToString(); 56 disposableCheckBox.Checked = Content.IsDisposable.GetValueOrDefault(); 100 57 } 101 }102 103 private void ShowSlaveUI(bool show) {104 label1.Visible = show;105 label2.Visible = show;106 label4.Visible = show;107 label10.Visible = show;108 label11.Visible = show;109 label12.Visible = show;110 label13.Visible = show;111 label14.Visible = show;112 label15.Visible = show;113 txtCPU.Visible = show;114 txtDetailsDescription.Visible = show;115 txtMemory.Visible = show;116 txtOS.Visible = show;117 txtSlaveState.Visible = show;118 txtLastHeartbeat.Visible = show;119 txtFreeMemory.Visible = show;120 txtId.Visible = show;121 txtName.Enabled = !show;122 cbxDisposable.Visible = show;123 58 } 124 59 125 60 protected override void SetEnabledStateOfControls() { 126 61 base.SetEnabledStateOfControls(); 62 bool enabled = Content != null && !Locked; 63 disposableCheckBox.Enabled = enabled; 127 64 } 65 #endregion 128 66 129 private void txtName_TextChanged(object sender, EventArgs e) {130 if (Content != null && Content is SlaveGroup) {131 Content.Name = txtName.Text;132 }67 #region Event Handlers 68 private void disposableCheckBox_CheckedChanged(object sender, EventArgs e) { 69 if (Content != null) 70 Content.IsDisposable = disposableCheckBox.Checked; 133 71 } 134 135 private void txtHbIntervall_TextChanged(object sender, EventArgs e) { 136 if (Content != null) { 137 if (txtHbIntervall.Text.Length > 0) { 138 try { 139 int interval = int.Parse(txtHbIntervall.Text); 140 Content.HbInterval = interval; 141 } 142 catch (Exception) { 143 MessageBox.Show("Please enter a numeric value for the Heartbeat Interval.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error); 144 txtHbIntervall.Text = "10"; 145 } 146 } 147 } 148 } 149 150 private void cbxDisposable_CheckedChanged(object sender, EventArgs e) { 151 if (Content != null) { 152 ((Slave)Content).IsDisposable = cbxDisposable.Checked; 153 } 154 } 155 156 private void cbxPublic_CheckedChanged(object sender, EventArgs e) { 157 if (Content != null) { 158 Content.OwnerUserId = cbxPublic.Checked ? null : new Guid?(UserInformation.Instance.User.Id); 159 } 160 } 72 #endregion 161 73 } 162 74 }
Note: See TracChangeset
for help on using the changeset viewer.