Changeset 15422
- Timestamp:
- 10/17/17 13:44:16 (7 years ago)
- Location:
- branches/HiveProjectManagement
- Files:
-
- 6 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveProjectManagement/HeuristicLab.Clients.Access.Administration/3.3/Views/UserGroupView.cs
r14185 r15422 40 40 protected override void RegisterContentEvents() { 41 41 base.RegisterContentEvents(); 42 Access .AccessClient.Instance.Refreshing += new EventHandler(Content_Refreshing);42 AccessClient.Instance.Refreshing += new EventHandler(Content_Refreshing); 43 43 refreshableLightweightUserView.StorableStateChanged += new EventHandler(refreshableLightweightUserView_StorableStateChanged); 44 44 } 45 45 46 46 protected override void DeregisterContentEvents() { 47 Access .AccessClient.Instance.Refreshing -= new EventHandler(Content_Refreshing);47 AccessClient.Instance.Refreshing -= new EventHandler(Content_Refreshing); 48 48 refreshableLightweightUserView.StorableStateChanged -= new EventHandler(refreshableLightweightUserView_StorableStateChanged); 49 49 base.DeregisterContentEvents(); … … 63 63 idTextBox.Text = Content.Id.ToString(); 64 64 65 refreshableLightweightUserView.Content = Content.Id != Guid.Empty ? Access .AccessClient.Instance : null;66 refreshableLightweightUserView.FetchSelectedUsers = Content.Id != Guid.Empty ? new Func<List<Guid>>(delegate { return AccessAdministrationClient.CallAccessService <List<Guid>>(s => s.GetUserGroupIdsOfGroup(Content.Id)); }) : null;65 refreshableLightweightUserView.Content = Content.Id != Guid.Empty ? AccessClient.Instance : null; 66 refreshableLightweightUserView.FetchSelectedUsers = Content.Id != Guid.Empty ? new Func<List<Guid>>(delegate { return AccessAdministrationClient.CallAccessService(s => s.GetUserGroupIdsOfGroup(Content.Id)); }) : null; 67 67 } 68 68 } 69 69 70 private void groupNameTextBox_TextChanged(object sender, System.EventArgs e) {71 if (Content .Name != this.groupNameTextBox.Text)72 Content.Name = this.groupNameTextBox.Text;70 private void groupNameTextBox_TextChanged(object sender, EventArgs e) { 71 if (Content != null && Content.Name != groupNameTextBox.Text) 72 Content.Name = groupNameTextBox.Text; 73 73 } 74 74 -
branches/HiveProjectManagement/HeuristicLab.Clients.Access/3.3/ServiceClients/User.cs
r14185 r15422 51 51 52 52 public override string ToString() { 53 return UserName + " (" + FullName + ")";53 return UserName + " (" + FullName + ")"; 54 54 } 55 55 } -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/HeuristicLab.Clients.Hive.Administrator-3.3.csproj
r15401 r15422 132 132 </Compile> 133 133 <Compile Include="MenuItems\AdministratorMenuItem.cs" /> 134 <Compile Include="Views\ProjectPermissionsView.cs"> 135 <SubType>UserControl</SubType> 136 </Compile> 137 <Compile Include="Views\ProjectPermissionsView.Designer.cs"> 138 <DependentUpon>ProjectPermissionsView.cs</DependentUpon> 139 </Compile> 140 <Compile Include="Views\ProjectResourcesView.cs"> 141 <SubType>UserControl</SubType> 142 </Compile> 143 <Compile Include="Views\ProjectResourcesView.Designer.cs"> 144 <DependentUpon>ProjectResourcesView.cs</DependentUpon> 145 </Compile> 134 146 <Compile Include="Views\ProjectsView.cs"> 135 147 <SubType>UserControl</SubType> … … 162 174 <Compile Include="Views\ScheduleView.Designer.cs"> 163 175 <DependentUpon>ScheduleView.cs</DependentUpon> 176 </Compile> 177 <Compile Include="Views\ResourceView.cs"> 178 <SubType>UserControl</SubType> 179 </Compile> 180 <Compile Include="Views\ResourceView.Designer.cs"> 181 <DependentUpon>ResourceView.cs</DependentUpon> 164 182 </Compile> 165 183 <Compile Include="Views\SlaveView.cs"> … … 178 196 </ItemGroup> 179 197 <ItemGroup> 198 <ProjectReference Include="..\..\HeuristicLab.Clients.Access.Administration\3.3\HeuristicLab.Clients.Access.Administration-3.3.csproj"> 199 <Project>{C9CF6AE8-4637-4A75-9141-042F479B5D50}</Project> 200 <Name>HeuristicLab.Clients.Access.Administration-3.3</Name> 201 </ProjectReference> 180 202 <ProjectReference Include="..\..\HeuristicLab.Clients.Access.Views\3.3\HeuristicLab.Clients.Access.Views-3.3.csproj"> 181 203 <Project>{FE856595-64CD-46DA-9CD2-FFF3E6B0D4F2}</Project> -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.Designer.cs
r15412 r15422 57 57 this.nameTextBox.Size = new System.Drawing.Size(464, 20); 58 58 this.nameTextBox.TabIndex = 1; 59 this.nameTextBox.TextChanged += new System.EventHandler(this.nameTextBox_TextChanged); 59 60 this.nameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.nameTextBox_Validating); 60 61 // … … 77 78 this.descriptionTextBox.Size = new System.Drawing.Size(464, 98); 78 79 this.descriptionTextBox.TabIndex = 3; 79 this.descriptionTextBox. Validating += new System.ComponentModel.CancelEventHandler(this.descriptionTextBox_Validating);80 this.descriptionTextBox.TextChanged += new System.EventHandler(this.descriptionTextBox_TextChanged); 80 81 // 81 82 // ownerComboBox … … 118 119 this.startDateTimePicker.Size = new System.Drawing.Size(200, 20); 119 120 this.startDateTimePicker.TabIndex = 9; 120 this.startDateTimePicker.Val idating += new System.ComponentModel.CancelEventHandler(this.startDateTimePicker_Validating);121 this.startDateTimePicker.ValueChanged += new System.EventHandler(this.startDateTimePicker_ValueChanged); 121 122 // 122 123 // startLabel … … 138 139 this.endDateTimePicker.Size = new System.Drawing.Size(200, 20); 139 140 this.endDateTimePicker.TabIndex = 11; 140 this.endDateTimePicker.Val idating += new System.ComponentModel.CancelEventHandler(this.endDateTimePicker_Validating);141 this.endDateTimePicker.ValueChanged += new System.EventHandler(this.endDateTimePicker_ValueChanged); 141 142 // 142 143 // endLabel -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs
r15412 r15422 34 34 public partial class ProjectView : ItemView { 35 35 private readonly object locker = new object(); 36 private bool updatingUsers = false;37 36 38 37 public new Project Content { … … 91 90 protected override void SetEnabledStateOfControls() { 92 91 base.SetEnabledStateOfControls(); 93 bool enabled = Content != null ;92 bool enabled = Content != null && !ReadOnly; 94 93 nameTextBox.Enabled = enabled; 95 94 descriptionTextBox.Enabled = enabled; … … 138 137 private async void refreshButton_Click(object sender, EventArgs e) { 139 138 lock (locker) { 140 if ( updatingUsers) return;141 updatingUsers = true;139 if (!refreshButton.Enabled) return; 140 refreshButton.Enabled = false; 142 141 } 143 142 … … 149 148 ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == Content.OwnerUserId); 150 149 ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged; 151 updatingUsers = false;150 refreshButton.Enabled = true; 152 151 }); 153 152 } … … 161 160 MessageBoxIcon.Error); 162 161 e.Cancel = true; 163 } else Content.Name = nameTextBox.Text; 164 } 165 166 private void descriptionTextBox_Validating(object sender, CancelEventArgs e) { 167 Content.Description = descriptionTextBox.Text; 162 } 163 } 164 165 private void nameTextBox_TextChanged(object sender, EventArgs e) { 166 if (Content != null && Content.Name != nameTextBox.Text) 167 Content.Name = nameTextBox.Text; 168 } 169 170 private void descriptionTextBox_TextChanged(object sender, EventArgs e) { 171 if (Content != null && Content.Description != descriptionTextBox.Text) 172 Content.Description = descriptionTextBox.Text; 168 173 } 169 174 170 175 private void ownerComboBox_SelectedIndexChanged(object sender, EventArgs e) { 171 176 var selectedItem = (LightweightUser)ownerComboBox.SelectedItem; 172 Content.OwnerUserId = selectedItem != null ? selectedItem.Id : Guid.Empty; 173 } 174 175 private void startDateTimePicker_Validating(object sender, CancelEventArgs e) { 177 var selectedOwnerUserId = selectedItem != null ? selectedItem.Id : Guid.Empty; 178 if (Content != null && Content.OwnerUserId != selectedOwnerUserId) 179 Content.OwnerUserId = selectedOwnerUserId; 180 } 181 182 private void startDateTimePicker_ValueChanged(object sender, EventArgs e) { 183 if (Content == null) return; 176 184 if (!Content.EndDate.HasValue || startDateTimePicker.Value > Content.EndDate) 177 185 endDateTimePicker.Value = startDateTimePicker.Value; 178 Content.StartDate = startDateTimePicker.Value; 179 } 180 181 private void endDateTimePicker_Validating(object sender, CancelEventArgs e) { 186 if (Content.StartDate != startDateTimePicker.Value) 187 Content.StartDate = startDateTimePicker.Value; 188 } 189 190 private void endDateTimePicker_ValueChanged(object sender, EventArgs e) { 191 if (Content == null) return; 182 192 if (endDateTimePicker.Value < startDateTimePicker.Value) 183 193 endDateTimePicker.Value = startDateTimePicker.Value; 184 Content.EndDate = endDateTimePicker.Value; 194 if (Content.EndDate != endDateTimePicker.Value) 195 Content.EndDate = endDateTimePicker.Value; 185 196 } 186 197 187 198 private void indefiniteCheckBox_CheckedChanged(object sender, EventArgs e) { 188 Content.EndDate = indefiniteCheckBox.Checked ? (DateTime?)null : Content.StartDate; 199 if (Content == null) return; 200 var newEndDate = indefiniteCheckBox.Checked ? (DateTime?)null : Content.StartDate; 201 if (Content.EndDate != newEndDate) 202 Content.EndDate = newEndDate; 189 203 } 190 204 #endregion -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.Designer.cs
r15401 r15422 36 36 this.projectView = new HeuristicLab.Clients.Hive.Administrator.Views.ProjectView(); 37 37 this.permissionsTabPage = new System.Windows.Forms.TabPage(); 38 this.savePermissionsButton = new System.Windows.Forms.Button(); 39 this.permissionsView = new HeuristicLab.Clients.Access.Views.RefreshableLightweightUserView(); 38 this.projectPermissionsView = new HeuristicLab.Clients.Hive.Administrator.Views.ProjectPermissionsView(); 39 this.resourcesTabPage = new System.Windows.Forms.TabPage(); 40 this.projectResourcesView = new HeuristicLab.Clients.Hive.Administrator.Views.ProjectResourcesView(); 40 41 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); 41 42 this.splitContainer.Panel1.SuspendLayout(); … … 45 46 this.detailsTabPage.SuspendLayout(); 46 47 this.permissionsTabPage.SuspendLayout(); 48 this.resourcesTabPage.SuspendLayout(); 47 49 this.SuspendLayout(); 48 50 // … … 82 84 // saveProjectButton 83 85 // 84 this.saveProjectButton.Image = HeuristicLab.Common.Resources.VSImageLibrary. PublishToWeb;86 this.saveProjectButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Save; 85 87 this.saveProjectButton.Location = new System.Drawing.Point(93, 3); 86 88 this.saveProjectButton.Name = "saveProjectButton"; … … 143 145 this.tabControl.Controls.Add(this.detailsTabPage); 144 146 this.tabControl.Controls.Add(this.permissionsTabPage); 147 this.tabControl.Controls.Add(this.resourcesTabPage); 145 148 this.tabControl.Location = new System.Drawing.Point(3, 3); 146 149 this.tabControl.Name = "tabControl"; … … 148 151 this.tabControl.Size = new System.Drawing.Size(585, 541); 149 152 this.tabControl.TabIndex = 0; 150 this.tabControl.SelectedIndexChanged += new System.EventHandler(this.tabControl_SelectedIndexChanged);151 153 // 152 154 // detailsTabPage … … 176 178 // permissionsTabPage 177 179 // 178 this.permissionsTabPage.Controls.Add(this.savePermissionsButton); 179 this.permissionsTabPage.Controls.Add(this.permissionsView); 180 this.permissionsTabPage.Controls.Add(this.projectPermissionsView); 180 181 this.permissionsTabPage.Location = new System.Drawing.Point(4, 22); 181 182 this.permissionsTabPage.Name = "permissionsTabPage"; … … 186 187 this.permissionsTabPage.UseVisualStyleBackColor = true; 187 188 // 188 // savePermissionsButton 189 // 190 this.savePermissionsButton.Enabled = false; 191 this.savePermissionsButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb; 192 this.savePermissionsButton.Location = new System.Drawing.Point(39, 9); 193 this.savePermissionsButton.Name = "savePermissionsButton"; 194 this.savePermissionsButton.Size = new System.Drawing.Size(24, 24); 195 this.savePermissionsButton.TabIndex = 2; 196 this.savePermissionsButton.UseVisualStyleBackColor = true; 197 this.savePermissionsButton.Click += new System.EventHandler(this.savePermissionsButton_Click); 198 // 199 // permissionsView 200 // 201 this.permissionsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 202 | System.Windows.Forms.AnchorStyles.Left) 203 | System.Windows.Forms.AnchorStyles.Right))); 204 this.permissionsView.Caption = "RefreshableLightweightUser View"; 205 this.permissionsView.Content = null; 206 this.permissionsView.FetchSelectedUsers = null; 207 this.permissionsView.Location = new System.Drawing.Point(6, 6); 208 this.permissionsView.Name = "permissionsView"; 209 this.permissionsView.ReadOnly = false; 210 this.permissionsView.Size = new System.Drawing.Size(565, 503); 211 this.permissionsView.TabIndex = 0; 189 // projectPermissionsView 190 // 191 this.projectPermissionsView.Caption = "ProjectView"; 192 this.projectPermissionsView.Content = null; 193 this.projectPermissionsView.Dock = System.Windows.Forms.DockStyle.Fill; 194 this.projectPermissionsView.Location = new System.Drawing.Point(3, 3); 195 this.projectPermissionsView.Name = "projectPermissionsView"; 196 this.projectPermissionsView.ReadOnly = false; 197 this.projectPermissionsView.Size = new System.Drawing.Size(571, 509); 198 this.projectPermissionsView.TabIndex = 0; 199 // 200 // resourcesTabPage 201 // 202 this.resourcesTabPage.Controls.Add(this.projectResourcesView); 203 this.resourcesTabPage.Location = new System.Drawing.Point(4, 22); 204 this.resourcesTabPage.Name = "resourcesTabPage"; 205 this.resourcesTabPage.Padding = new System.Windows.Forms.Padding(3); 206 this.resourcesTabPage.Size = new System.Drawing.Size(577, 515); 207 this.resourcesTabPage.TabIndex = 2; 208 this.resourcesTabPage.Text = "Resources"; 209 this.resourcesTabPage.UseVisualStyleBackColor = true; 210 // 211 // projectResourcesView 212 // 213 this.projectResourcesView.Caption = "ProjectView"; 214 this.projectResourcesView.Content = null; 215 this.projectResourcesView.Dock = System.Windows.Forms.DockStyle.Fill; 216 this.projectResourcesView.Location = new System.Drawing.Point(3, 3); 217 this.projectResourcesView.Name = "projectResourcesView"; 218 this.projectResourcesView.ReadOnly = false; 219 this.projectResourcesView.Size = new System.Drawing.Size(571, 509); 220 this.projectResourcesView.TabIndex = 0; 212 221 // 213 222 // ProjectsView … … 226 235 this.detailsTabPage.ResumeLayout(false); 227 236 this.permissionsTabPage.ResumeLayout(false); 237 this.resourcesTabPage.ResumeLayout(false); 228 238 this.ResumeLayout(false); 229 239 … … 243 253 private ProjectView projectView; 244 254 private System.Windows.Forms.ImageList imageList; 245 private Access.Views.RefreshableLightweightUserView permissionsView; 246 private System.Windows.Forms.Button savePermissionsButton; 255 private System.Windows.Forms.TabPage resourcesTabPage; 256 private ProjectResourcesView projectResourcesView; 257 private ProjectPermissionsView projectPermissionsView; 247 258 } 248 259 } -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs
r15412 r15422 42 42 43 43 private readonly object locker = new object(); 44 private bool updatingProjects = false;45 private bool removingProjects = false;46 private bool savingProjects = false;47 44 48 45 public new IItemList<Project> Content { … … 89 86 projectsTreeView.Nodes.Clear(); 90 87 projectView.Content = null; 91 p ermissionsView.Content = null;92 p ermissionsView.FetchSelectedUsers= null;88 projectPermissionsView.Content = null; 89 projectResourcesView.Content = null; 93 90 } else { 94 91 var top = BuildProjectTree(Content); 95 92 projectView.Content = top; 96 permissionsView.Content = AccessClient.Instance; 93 projectPermissionsView.Content = top; 94 projectResourcesView.Content = top; 97 95 } 98 96 } … … 100 98 protected override void SetEnabledStateOfControls() { 101 99 base.SetEnabledStateOfControls(); 102 bool enabled = Content != null; 100 bool enabled = Content != null && !ReadOnly; 101 refreshButton.Enabled = enabled; 103 102 addButton.Enabled = enabled; 104 103 removeButton.Enabled = enabled; 105 104 saveProjectButton.Enabled = enabled; 106 savePermissionsButton.Enabled = enabled && permissionsView.Content != null && permissionsView.FetchSelectedUsers != null; 107 permissionsView.Enabled = enabled && permissionsView.Content != null && permissionsView.FetchSelectedUsers != null; 105 projectView.Enabled = enabled; 106 projectPermissionsView.Enabled = enabled; 107 projectResourcesView.Enabled = enabled; 108 108 } 109 109 #endregion … … 175 175 private async void refreshButton_Click(object sender, EventArgs e) { 176 176 lock (locker) { 177 if ( updatingProjects) return;178 updatingProjects = true;177 if (!refreshButton.Enabled) return; 178 refreshButton.Enabled = false; 179 179 } 180 180 … … 183 183 finallyCallback: () => { 184 184 Content = HiveAdminClient.Instance.Projects; 185 updatingProjects = false;185 refreshButton.Enabled = true; 186 186 }); 187 187 } … … 197 197 private async void removeButton_Click(object sender, EventArgs e) { 198 198 lock (locker) { 199 if ( removingProjects) return;200 remov ingProjects = true;199 if (!removeButton.Enabled) return; 200 removeButton.Enabled = false; 201 201 } 202 202 … … 223 223 finallyCallback: () => { 224 224 Content.Remove(project); 225 remov ingProjects = false;225 removeButton.Enabled = true; 226 226 }); 227 227 } … … 231 231 private async void saveProjectButton_Click(object sender, EventArgs e) { 232 232 lock (locker) { 233 if ( savingProjects) return;234 sav ingProjects = true;233 if (!saveProjectButton.Enabled) return; 234 saveProjectButton.Enabled = false; 235 235 } 236 236 … … 241 241 project.Store(); 242 242 }, 243 finallyCallback: () => sav ingProjects = false);244 } 245 246 private asyncvoid projectsTreeView_AfterSelect(object sender, TreeViewEventArgs e) {243 finallyCallback: () => saveProjectButton.Enabled = true); 244 } 245 246 private void projectsTreeView_AfterSelect(object sender, TreeViewEventArgs e) { 247 247 var selectedProject = (Project)e.Node.Tag; 248 248 … … 251 251 252 252 projectView.Content = selectedProject; 253 projectPermissionsView.Content = selectedProject; 254 projectResourcesView.Content = selectedProject; 253 255 254 256 if (selectedProject != null) … … 258 260 if (!tabControl.TabPages.Contains(permissionsTabPage)) 259 261 tabControl.TabPages.Add(permissionsTabPage); 260 261 permissionsView.FetchSelectedUsers = () => 262 HiveServiceLocator.Instance.CallHiveService(s => s.GetProjectPermissions(selectedProject.Id)) 263 .Select(x => x.GrantedUserId) 264 .ToList(); 265 266 if (tabControl.SelectedIndex == 1 && permissionsView.Content != null && permissionsView.FetchSelectedUsers != null) 267 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 268 action: () => UpdatePermissions()); 262 if (!tabControl.TabPages.Contains(resourcesTabPage)) 263 tabControl.TabPages.Add(resourcesTabPage); 269 264 } else { 270 265 if (tabControl.TabPages.Contains(permissionsTabPage)) 271 266 tabControl.TabPages.Remove(permissionsTabPage); 272 permissionsView.FetchSelectedUsers = null; 267 if (tabControl.TabPages.Contains(resourcesTabPage)) 268 tabControl.TabPages.Remove(resourcesTabPage); 273 269 } 274 270 } … … 317 313 private void projectsTreeView_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) { 318 314 e.Action = DragAction.Continue; 319 }320 321 private async void tabControl_SelectedIndexChanged(object sender, EventArgs e) {322 if (tabControl.SelectedIndex == 1 && permissionsView.Content != null && permissionsView.FetchSelectedUsers != null)323 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(324 action: () => UpdatePermissions());325 }326 327 private async void savePermissionsButton_Click(object sender, EventArgs e) {328 var project = (Project)projectsTreeView.SelectedNode.Tag;329 330 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(331 action: () => HiveServiceLocator.Instance.CallHiveService(s => {332 s.GrantProjectPermissions(project.Id, permissionsView.GetAddedUsers().Select(x => x.Id).ToList());333 s.RevokeProjectPermissions(project.Id, permissionsView.GetDeletedUsers().Select(x => x.Id).ToList());334 }));335 315 } 336 316 #endregion … … 401 381 } 402 382 403 private void UpdatePermissions() {404 try {405 permissionsView.ManualRefresh();406 } catch (AnonymousUserException) {407 ShowHiveInformationDialog();408 }409 }410 411 383 private bool IsAuthorized(Project project) { 412 384 return project != null -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs
r15412 r15422 37 37 components.Dispose(); 38 38 } 39 HiveAdminClient.Instance.Refreshing -= new EventHandler(HiveAdminClient_Instance_Refreshing);40 HiveAdminClient.Instance.Refreshed -= new EventHandler(HiveAdminClient_Instance_Refreshed);41 42 Access.AccessClient.Instance.Refreshing -= new EventHandler(AccessClient_Instance_Refreshing);43 Access.AccessClient.Instance.Refreshed -= new EventHandler(AccessClient_Instance_Refreshed);44 39 base.Dispose(disposing); 45 40 } … … 59 54 this.btnRemoveGroup = new System.Windows.Forms.Button(); 60 55 this.btnAddGroup = new System.Windows.Forms.Button(); 61 this.tree SlaveGroup= new System.Windows.Forms.TreeView();56 this.treeView = new System.Windows.Forms.TreeView(); 62 57 this.tabSlaveGroup = new System.Windows.Forms.TabControl(); 63 58 this.tabDetails = new System.Windows.Forms.TabPage(); 59 this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 64 60 this.tabSchedule = new System.Windows.Forms.TabPage(); 61 this.scheduleView = new HeuristicLab.Clients.Hive.Administrator.Views.ScheduleView(); 65 62 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 66 this.slaveView = new HeuristicLab.Clients.Hive.Administrator.Views.SlaveView();67 this.scheduleView = new HeuristicLab.Clients.Hive.Administrator.Views.ScheduleView();68 63 ((System.ComponentModel.ISupportInitialize)(this.splitSlaves)).BeginInit(); 69 64 this.splitSlaves.Panel1.SuspendLayout(); … … 95 90 this.splitSlaves.Panel1.Controls.Add(this.btnRemoveGroup); 96 91 this.splitSlaves.Panel1.Controls.Add(this.btnAddGroup); 97 this.splitSlaves.Panel1.Controls.Add(this.tree SlaveGroup);92 this.splitSlaves.Panel1.Controls.Add(this.treeView); 98 93 // 99 94 // splitSlaves.Panel2 … … 117 112 // btnSave 118 113 // 119 this.btnSave.Image = HeuristicLab.Common.Resources.VSImageLibrary. PublishToWeb;114 this.btnSave.Image = HeuristicLab.Common.Resources.VSImageLibrary.Save; 120 115 this.btnSave.Location = new System.Drawing.Point(93, 3); 121 116 this.btnSave.Name = "btnSave"; … … 148 143 this.btnAddGroup.Click += new System.EventHandler(this.btnAddGroup_Click); 149 144 // 150 // tree SlaveGroup151 // 152 this.tree SlaveGroup.AllowDrop = true;153 this.tree SlaveGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)154 | System.Windows.Forms.AnchorStyles.Left) 155 | System.Windows.Forms.AnchorStyles.Right))); 156 this.tree SlaveGroup.ImageIndex = 0;157 this.tree SlaveGroup.ImageList = this.imageListSlaveGroups;158 this.tree SlaveGroup.Location = new System.Drawing.Point(3, 33);159 this.tree SlaveGroup.Name = "treeSlaveGroup";160 this.tree SlaveGroup.SelectedImageIndex = 0;161 this.tree SlaveGroup.Size = new System.Drawing.Size(243, 511);162 this.tree SlaveGroup.TabIndex = 0;163 this.tree SlaveGroup.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeSlaveGroup_ItemDrag);164 this.tree SlaveGroup.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeSlaveGroup_AfterSelect);165 this.tree SlaveGroup.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragDrop);166 this.tree SlaveGroup.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragEnter);167 this.tree SlaveGroup.DragOver += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragOver);168 this.tree SlaveGroup.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.ImageIndex = 0; 152 this.treeView.ImageList = this.imageListSlaveGroups; 153 this.treeView.Location = new System.Drawing.Point(3, 33); 154 this.treeView.Name = "treeView"; 155 this.treeView.SelectedImageIndex = 0; 156 this.treeView.Size = new System.Drawing.Size(243, 511); 157 this.treeView.TabIndex = 0; 158 this.treeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeSlaveGroup_ItemDrag); 159 this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeSlaveGroup_AfterSelect); 160 this.treeView.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragDrop); 161 this.treeView.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragEnter); 162 this.treeView.DragOver += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragOver); 163 this.treeView.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.treeSlaveGroup_QueryContinueDrag); 169 164 // 170 165 // tabSlaveGroup … … 180 175 this.tabSlaveGroup.Size = new System.Drawing.Size(585, 541); 181 176 this.tabSlaveGroup.TabIndex = 1; 182 this.tabSlaveGroup.SelectedIndexChanged += new System.EventHandler(this.tabSlaveGroup_SelectedIndexChanged);183 177 // 184 178 // tabDetails 185 179 // 186 this.tabDetails.Controls.Add(this. slaveView);180 this.tabDetails.Controls.Add(this.viewHost); 187 181 this.tabDetails.Location = new System.Drawing.Point(4, 22); 188 182 this.tabDetails.Name = "tabDetails"; … … 192 186 this.tabDetails.Text = "Details"; 193 187 this.tabDetails.UseVisualStyleBackColor = true; 188 // 189 // viewHost 190 // 191 this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 192 | System.Windows.Forms.AnchorStyles.Left) 193 | System.Windows.Forms.AnchorStyles.Right))); 194 this.viewHost.Caption = "View"; 195 this.viewHost.Content = null; 196 this.viewHost.Enabled = false; 197 this.viewHost.Location = new System.Drawing.Point(6, 6); 198 this.viewHost.Name = "viewHost"; 199 this.viewHost.ReadOnly = false; 200 this.viewHost.Size = new System.Drawing.Size(565, 503); 201 this.viewHost.TabIndex = 0; 202 this.viewHost.ViewsLabelVisible = true; 203 this.viewHost.ViewType = null; 194 204 // 195 205 // tabSchedule … … 203 213 this.tabSchedule.Text = "Schedule"; 204 214 this.tabSchedule.UseVisualStyleBackColor = true; 205 //206 // slaveView207 //208 this.slaveView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)209 | System.Windows.Forms.AnchorStyles.Left)210 | System.Windows.Forms.AnchorStyles.Right)));211 this.slaveView.Caption = "SlaveView";212 this.slaveView.Content = null;213 this.slaveView.Location = new System.Drawing.Point(6, 6);214 this.slaveView.Name = "slaveView";215 this.slaveView.ReadOnly = false;216 this.slaveView.Size = new System.Drawing.Size(565, 503);217 this.slaveView.TabIndex = 0;218 215 // 219 216 // scheduleView … … 253 250 private System.Windows.Forms.Button btnRemoveGroup; 254 251 private System.Windows.Forms.Button btnAddGroup; 255 private System.Windows.Forms.TreeView tree SlaveGroup;252 private System.Windows.Forms.TreeView treeView; 256 253 private System.Windows.Forms.TabControl tabSlaveGroup; 257 254 private System.Windows.Forms.TabPage tabDetails; 258 255 private System.Windows.Forms.TabPage tabSchedule; 259 private SlaveView slaveView;260 256 private System.Windows.Forms.ImageList imageListSlaveGroups; 261 257 private ScheduleView scheduleView; … … 263 259 private System.Windows.Forms.Button btnRefresh; 264 260 private System.Windows.Forms.ToolTip toolTip; 261 private MainForm.WindowsForms.ViewHost viewHost; 265 262 } 266 263 } -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs
r15412 r15422 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.ComponentModel; 24 25 using System.Drawing; … … 37 38 [Content(typeof(IItemList<Resource>), false)] 38 39 public partial class ResourcesView : ItemView, IDisposable { 39 private const string UngroupedGroupName = "UNGROUPED";40 40 private const int slaveImageIndex = 0; 41 41 private const int slaveGroupImageIndex = 1; 42 public const string ungroupedGroupName = "UNGROUPED"; 43 public const string ungroupedGroupDescription = "Contains slaves that are not assigned to any group."; 42 44 43 45 private readonly Color ownedResourceColor = Color.LightGreen; 44 46 private readonly object locker = new object(); 45 private bool updatingResources = false;46 private bool removingResources = false;47 private bool savingResources = false;48 47 49 48 public new IItemList<Resource> Content { … … 55 54 InitializeComponent(); 56 55 57 tree SlaveGroup.ImageList.Images.Add(VSImageLibrary.MonitorLarge);58 tree SlaveGroup.ImageList.Images.Add(VSImageLibrary.NetworkCenterLarge);56 treeView.ImageList.Images.Add(VSImageLibrary.MonitorLarge); 57 treeView.ImageList.Images.Add(VSImageLibrary.NetworkCenterLarge); 59 58 60 59 HiveAdminClient.Instance.Refreshing += HiveAdminClient_Instance_Refreshing; … … 88 87 base.OnContentChanged(); 89 88 if (Content == null) { 90 slaveView.Content = null; 89 treeView.Nodes.Clear(); 90 viewHost.Content = null; 91 91 scheduleView.Content = null; 92 treeSlaveGroup.Nodes.Clear();93 92 } else { 94 treeSlaveGroup.Nodes.Clear(); 95 96 //rebuild 97 TreeNode ungrp = new TreeNode(UngroupedGroupName); 98 ungrp.ImageIndex = slaveGroupImageIndex; 99 ungrp.SelectedImageIndex = ungrp.ImageIndex; 100 var newGroup = new SlaveGroup(); 101 newGroup.Name = UngroupedGroupName; 102 newGroup.Id = Guid.NewGuid(); 103 newGroup.Description = "Contains slaves which are in no group"; 104 ungrp.Tag = newGroup; 105 106 foreach (Resource g in Content.OrderBy(x => x.Name)) { 107 if (g.GetType() == typeof(SlaveGroup)) { 108 //root node 109 if (g.ParentResourceId == null) { 110 TreeNode tn = new TreeNode(); 111 tn.ImageIndex = slaveGroupImageIndex; 112 tn.SelectedImageIndex = tn.ImageIndex; 113 114 tn.Tag = g; 115 tn.Text = g.Name; 116 if (g.OwnerUserId == Access.UserInformation.Instance.User.Id) tn.BackColor = ownedResourceColor; 117 118 BuildSlaveGroupTree(g, tn); 119 treeSlaveGroup.Nodes.Add(tn); 120 } 121 } else if (g.GetType() == typeof(Slave)) { 122 if (g.ParentResourceId == null) { 123 var stn = new TreeNode(g.Name); 124 stn.ImageIndex = slaveImageIndex; 125 stn.SelectedImageIndex = stn.ImageIndex; 126 stn.Tag = g; 127 if (g.OwnerUserId == Access.UserInformation.Instance.User.Id) stn.BackColor = ownedResourceColor; 128 ungrp.Nodes.Add(stn); 129 } 130 } 131 } 132 treeSlaveGroup.Nodes.Add(ungrp); 93 var top = BuildResourceTree(Content); 94 viewHost.Content = top; 133 95 } 134 96 } … … 140 102 btnRemoveGroup.Enabled = enabled; 141 103 btnSave.Enabled = enabled; 142 scheduleView.SetEnabledStateOfSchedule(enabled && IsAuthorized( slaveView.Content));104 scheduleView.SetEnabledStateOfSchedule(enabled && IsAuthorized((Resource)viewHost.Content)); 143 105 } 144 106 #endregion … … 164 126 OnContentChanged(); 165 127 if (e.PropertyName == "HbInterval") { 166 UpdateChildHbIntervall( slaveView.Content);128 UpdateChildHbIntervall((Resource)viewHost.Content); 167 129 } 168 130 } … … 212 174 private async void btnRefresh_Click(object sender, EventArgs e) { 213 175 lock (locker) { 214 if ( updatingResources) return;215 updatingResources = true;176 if (!btnRefresh.Enabled) return; 177 btnRefresh.Enabled = false; 216 178 } 217 179 218 180 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 219 181 action: () => UpdateResources(), 220 finallyCallback: () => updatingResources = false);182 finallyCallback: () => btnRefresh.Enabled = true); 221 183 } 222 184 … … 231 193 private async void btnRemoveGroup_Click(object sender, EventArgs e) { 232 194 lock (locker) { 233 if ( removingResources) return;234 removingResources = true;195 if (!btnRemoveGroup.Enabled) return; 196 btnRemoveGroup.Enabled = false; 235 197 } 236 198 237 199 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 238 200 action: () => RemoveResource(), 239 finallyCallback: () => removingResources = false);201 finallyCallback: () => btnRemoveGroup.Enabled = true); 240 202 } 241 203 242 204 private async void btnSave_Click(object sender, EventArgs e) { 243 205 lock (locker) { 244 if ( savingResources) return;245 savingResources = true;206 if (!btnSave.Enabled) return; 207 btnSave.Enabled = false; 246 208 } 247 209 … … 252 214 resource.Store(); 253 215 }, 254 finallyCallback: () => savingResources = false);216 finallyCallback: () => btnSave.Enabled = true); 255 217 } 256 218 … … 258 220 var selectedResource = (Resource)e.Node.Tag; 259 221 260 if (slaveView.Content != null && slaveView.Content is SlaveGroup) 261 slaveView.Content.PropertyChanged -= SlaveViewContent_PropertyChanged; 262 263 slaveView.Content = selectedResource; 222 if (viewHost.Content != null && viewHost.Content is SlaveGroup) 223 ((SlaveGroup)viewHost.Content).PropertyChanged -= SlaveViewContent_PropertyChanged; 224 225 viewHost.Content = selectedResource; 226 HiveAdminClient.Instance.DowntimeForResourceId = selectedResource != null ? selectedResource.Id : Guid.Empty; 227 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 228 action: () => UpdateSchedule(), 229 finallyCallback: () => scheduleView.Content = HiveAdminClient.Instance.Downtimes); 264 230 265 231 if (selectedResource != null && selectedResource is SlaveGroup) … … 269 235 if (!tabSlaveGroup.TabPages.Contains(tabSchedule)) 270 236 tabSlaveGroup.TabPages.Add(tabSchedule); 271 272 HiveAdminClient.Instance.DowntimeForResourceId = selectedResource.Id;273 274 if (tabSlaveGroup.SelectedIndex == 1) {275 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(276 action: () => UpdateSchedule(),277 finallyCallback: () => scheduleView.Content = HiveAdminClient.Instance.Downtimes);278 }279 237 } else { 280 238 if (tabSlaveGroup.TabPages.Contains(tabSchedule)) 281 239 tabSlaveGroup.TabPages.Remove(tabSchedule); 282 HiveAdminClient.Instance.DowntimeForResourceId = Guid.Empty;283 240 } 284 241 } 285 242 286 243 private void treeSlaveGroup_DragDrop(object sender, DragEventArgs e) { 287 if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) { 288 Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y)); 289 TreeNode destNode = ((TreeView)sender).GetNodeAt(pt); 290 TreeNode newNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode"); 291 292 if (destNode.TreeView == newNode.TreeView) { 293 if (destNode.Text == UngroupedGroupName || (destNode.Parent != null && destNode.Parent.Text == UngroupedGroupName)) { 294 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.", 295 UngroupedGroupName, Environment.NewLine), "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Information); 296 return; 297 } 298 299 SlaveGroup sgrp = null; 300 TreeNode parentNode = null; 301 if (destNode.Tag != null && destNode.Tag is SlaveGroup) { 302 sgrp = (SlaveGroup)destNode.Tag; 303 parentNode = destNode; 304 } else if (destNode.Parent != null && destNode.Parent.Tag is SlaveGroup) { 305 sgrp = (SlaveGroup)destNode.Parent.Tag; 306 parentNode = destNode.Parent; 307 } 308 309 if (newNode.Tag is SlaveGroup && CheckParentsEqualsMovedNode(parentNode, newNode)) { 310 return; 311 } 312 313 SlaveGroup parent = (SlaveGroup)parentNode.Tag; 314 315 if (parent.OwnerUserId != null && !IsAuthorized(parent)) { 316 MessageBox.Show(string.Format("You don't have the permissions to drag items to the group \"{0}\".", ((Resource)parentNode.Tag).Name), 317 "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error); 318 return; 319 } 320 321 if (sgrp != null && newNode.Tag != null) { 322 //save parent group to get an id 323 if (sgrp.Id == Guid.Empty) { 324 sgrp.Store(); 325 } 326 327 if (newNode.Tag is Slave) { 328 Slave slave = (Slave)newNode.Tag; 329 if (slave.ParentResourceId == null || (slave.ParentResourceId != null && slave.ParentResourceId != sgrp.Id)) { 330 slave.ParentResourceId = sgrp.Id; 331 newNode.Remove(); 332 parentNode.Nodes.Clear(); 333 BuildSlaveGroupTree(sgrp, parentNode); 334 } 335 } else if (newNode.Tag is SlaveGroup) { 336 SlaveGroup slaveGroup = (SlaveGroup)newNode.Tag; 337 if (slaveGroup.ParentResourceId == null || (slaveGroup.ParentResourceId != null && slaveGroup.ParentResourceId != sgrp.Id)) { 338 slaveGroup.ParentResourceId = sgrp.Id; 339 newNode.Remove(); 340 parentNode.Nodes.Clear(); 341 BuildSlaveGroupTree(sgrp, parentNode); 342 } 343 } 344 } 345 } 244 var sourceNode = (TreeNode)e.Data.GetData(typeof(TreeNode)); 245 if (sourceNode == null) return; 246 247 var treeView = (TreeView)sender; 248 if (sourceNode.TreeView != treeView) return; 249 250 var targetPoint = treeView.PointToClient(new Point(e.X, e.Y)); 251 var targetNode = treeView.GetNodeAt(targetPoint); 252 253 if (sourceNode == targetNode) return; 254 255 if (targetNode.Text == ungroupedGroupName || targetNode.Parent != null && targetNode.Parent.Text == ungroupedGroupName) { 256 MessageBox.Show( 257 string.Format(@"You cannot drag resources to group ""{0}"". This group only contains slaves which have not been assigned to a real group yet.", ungroupedGroupName), 258 "HeuristicLab Hive Administrator", 259 MessageBoxButtons.OK, 260 MessageBoxIcon.Information); 261 return; 262 } 263 264 if (sourceNode.Parent == null) 265 treeView.Nodes.Remove(sourceNode); 266 else { 267 sourceNode.Parent.Nodes.Remove(sourceNode); 268 ((Resource)sourceNode.Tag).ParentResourceId = null; 269 } 270 271 if (targetNode == null) { 272 treeView.Nodes.Add(sourceNode); 273 } else { 274 targetNode.Nodes.Add(sourceNode); 275 ((Resource)sourceNode.Tag).ParentResourceId = ((Project)targetNode.Tag).Id; 346 276 } 347 277 } … … 364 294 e.Action = DragAction.Continue; 365 295 } 366 367 private void tabSlaveGroup_SelectedIndexChanged(object sender, EventArgs e) {368 if (tabSlaveGroup.SelectedIndex == 1) {369 UpdateSchedule();370 }371 }372 296 #endregion 373 297 374 298 #region Helpers 375 private void BuildSlaveGroupTree(Resource g, TreeNode tn) { 376 foreach (Resource r in Content.Where(s => s.ParentResourceId != null && s.ParentResourceId == g.Id).OrderBy(x => x.Name)) { 377 TreeNode stn = new TreeNode(r.Name); 378 if (r is Slave) { 379 stn.ImageIndex = slaveImageIndex; 380 } else if (r is SlaveGroup) { 381 stn.ImageIndex = slaveGroupImageIndex; 382 } 383 stn.SelectedImageIndex = stn.ImageIndex; 384 stn.Tag = r; 385 if (r.OwnerUserId == Access.UserInformation.Instance.User.Id) stn.BackColor = ownedResourceColor; 386 tn.Nodes.Add(stn); 387 388 BuildSlaveGroupTree(r, stn); 389 } 299 private Resource BuildResourceTree(IEnumerable<Resource> resources) { 300 treeView.Nodes.Clear(); 301 if (!resources.Any()) return null; 302 303 var slaveGroups = new HashSet<SlaveGroup>(resources.OfType<SlaveGroup>()); 304 var slaves = new HashSet<Slave>(resources.OfType<Slave>()); 305 306 var stack = new Stack<Resource>(slaveGroups.OrderByDescending(x => x.Name)); 307 var top = stack.Peek(); 308 309 TreeNode currentNode = null; 310 Resource currentResource = null; 311 312 while (stack.Any()) { 313 var newResource = stack.Pop(); 314 var newNode = new TreeNode(newResource.Name) { Tag = newResource }; 315 316 while (currentNode != null && newResource.ParentResourceId != currentResource.Id) { 317 currentNode = currentNode.Parent; 318 currentResource = currentNode == null ? null : (Resource)currentNode.Tag; 319 } 320 321 if (currentNode == null) { 322 treeView.Nodes.Add(newNode); 323 } else { 324 currentNode.Nodes.Add(newNode); 325 } 326 327 if (newResource is Slave) { 328 newNode.ImageIndex = slaveImageIndex; 329 } else { 330 newNode.ImageIndex = slaveGroupImageIndex; 331 332 var childSlaves = slaves.Where(x => x.ParentResourceId == newResource.Id); 333 foreach (var slave in childSlaves.OrderBy(x => x.Name)) { 334 slaves.Remove(slave); 335 var slaveNode = new TreeNode(slave.Name) { Tag = slave }; 336 337 slaveNode.SelectedImageIndex = slaveNode.ImageIndex = slaveImageIndex; 338 if (slave.OwnerUserId == UserInformation.Instance.User.Id) 339 slaveNode.BackColor = ownedResourceColor; 340 341 newNode.Nodes.Add(slaveNode); 342 } 343 344 var childSlaveGroups = slaveGroups.Where(x => x.ParentResourceId == newResource.Id); 345 if (childSlaveGroups.Any()) { 346 foreach (var slaveGroup in childSlaveGroups.OrderByDescending(x => x.Name)) { 347 slaveGroups.Remove(slaveGroup); 348 stack.Push(slaveGroup); 349 } 350 currentNode = newNode; 351 currentResource = newResource; 352 } 353 } 354 355 newNode.SelectedImageIndex = newNode.ImageIndex; 356 if (newResource.OwnerUserId == UserInformation.Instance.User.Id) 357 newNode.BackColor = ownedResourceColor; 358 } 359 360 var ungroupedNode = new TreeNode(ungroupedGroupName) { 361 ForeColor = SystemColors.GrayText, 362 Tag = new SlaveGroup() { 363 Name = ungroupedGroupName, 364 Description = ungroupedGroupDescription 365 } 366 }; 367 368 foreach (var slave in slaves.OrderBy(x => x.Name)) { 369 var slaveNode = new TreeNode(slave.Name) { Tag = slave }; 370 ungroupedNode.Nodes.Add(slaveNode); 371 } 372 373 treeView.Nodes.Add(ungroupedNode); 374 treeView.ExpandAll(); 375 376 return top; 390 377 } 391 378 … … 414 401 if (InvokeRequired) Invoke((Action)ResetView); 415 402 else { 416 tree SlaveGroup.Nodes.Clear();417 418 if ( slaveView.Content != null && slaveView.Content is SlaveGroup) {419 slaveView.Content.PropertyChanged -= SlaveViewContent_PropertyChanged;420 } 421 422 slaveView.Content = null;403 treeView.Nodes.Clear(); 404 405 if (viewHost.Content != null && viewHost.Content is SlaveGroup) { 406 ((SlaveGroup)viewHost.Content).PropertyChanged -= SlaveViewContent_PropertyChanged; 407 } 408 409 viewHost.Content = null; 423 410 if (scheduleView.Content != null) { 424 411 scheduleView.Content.Clear(); … … 435 422 436 423 private void RemoveResource() { 437 var selectedNode = tree SlaveGroup.SelectedNode;424 var selectedNode = treeView.SelectedNode; 438 425 if (selectedNode == null || selectedNode.Tag == null) return; 439 426 … … 474 461 private bool IsAuthorized(Resource resource) { 475 462 return resource != null 476 && resource.Name != UngroupedGroupName463 && resource.Name != ungroupedGroupName 477 464 && resource.Id != Guid.Empty 478 465 && UserInformation.Instance.UserExists -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.Designer.cs
r14185 r15422 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/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.cs
r15412 r15422 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-201 6Heuristic 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(); 127 bool enabled = Content != null; 128 txtName.Enabled = enabled; 129 txtHbIntervall.Enabled = enabled; 130 cbxPublic.Enabled = enabled; 62 disposableCheckBox.Enabled = Content != null; 131 63 } 64 #endregion 132 65 133 private void txtName_TextChanged(object sender, EventArgs e) {134 if (Content != null && Content is SlaveGroup) {135 Content.Name = txtName.Text;136 }66 #region Event Handlers 67 private void disposableCheckBox_CheckedChanged(object sender, EventArgs e) { 68 if (Content != null) 69 Content.IsDisposable = disposableCheckBox.Checked; 137 70 } 138 139 private void txtHbIntervall_TextChanged(object sender, EventArgs e) { 140 if (Content != null) { 141 if (txtHbIntervall.Text.Length > 0) { 142 try { 143 int interval = int.Parse(txtHbIntervall.Text); 144 Content.HbInterval = interval; 145 } catch (Exception) { 146 MessageBox.Show("Please enter a numeric value for the Heartbeat Interval.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error); 147 txtHbIntervall.Text = "10"; 148 } 149 } 150 } 151 } 152 153 private void cbxDisposable_CheckedChanged(object sender, EventArgs e) { 154 if (Content != null) { 155 ((Slave)Content).IsDisposable = cbxDisposable.Checked; 156 } 157 } 158 159 private void cbxPublic_CheckedChanged(object sender, EventArgs e) { 160 if (Content != null) { 161 Content.OwnerUserId = cbxPublic.Checked ? null : new Guid?(UserInformation.Instance.User.Id); 162 } 163 } 71 #endregion 164 72 } 165 73 }
Note: See TracChangeset
for help on using the changeset viewer.