Changeset 15412
- Timestamp:
- 10/07/17 10:32:07 (7 years ago)
- Location:
- branches/HiveProjectManagement
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.Designer.cs
r15401 r15412 85 85 this.ownerComboBox.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList; 86 86 this.ownerComboBox.FormattingEnabled = true; 87 this.ownerComboBox.Location = new System.Drawing.Point( 72, 138);87 this.ownerComboBox.Location = new System.Drawing.Point(102, 138); 88 88 this.ownerComboBox.Name = "ownerComboBox"; 89 89 this.ownerComboBox.Size = new System.Drawing.Size(434, 21); … … 170 170 // refreshButton 171 171 // 172 this.refreshButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));173 172 this.refreshButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh; 174 this.refreshButton.Location = new System.Drawing.Point( 512, 136);173 this.refreshButton.Location = new System.Drawing.Point(72, 136); 175 174 this.refreshButton.Name = "refreshButton"; 176 175 this.refreshButton.Size = new System.Drawing.Size(24, 24); -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs
r15401 r15412 25 25 using System.Windows.Forms; 26 26 using HeuristicLab.Clients.Access; 27 using HeuristicLab.Clients.Hive.Views; 27 28 using HeuristicLab.Core.Views; 28 29 using HeuristicLab.MainForm; 29 using Tasks = System.Threading.Tasks;30 30 31 31 namespace HeuristicLab.Clients.Hive.Administrator.Views { … … 48 48 } 49 49 50 #region Overrides 50 51 protected override void OnClosing(FormClosingEventArgs e) { 51 52 AccessClient.Instance.Refreshed -= AccessClient_Instance_Refreshed; … … 62 63 Content.PropertyChanged -= Content_PropertyChanged; 63 64 base.DeregisterContentEvents(); 64 }65 66 private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) {67 OnContentChanged();68 65 } 69 66 … … 73 70 nameTextBox.Clear(); 74 71 descriptionTextBox.Clear(); 75 ownerComboBox.DataSource = null;76 72 ownerComboBox.SelectedItem = null; 77 73 createdTextBox.Clear(); … … 82 78 nameTextBox.Text = Content.Name; 83 79 descriptionTextBox.Text = Content.Description; 84 ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList();85 80 ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == Content.OwnerUserId); 86 81 createdTextBox.Text = Content.DateCreated.ToString("ddd, dd.MM.yyyy, HH:mm:ss"); … … 99 94 nameTextBox.Enabled = enabled; 100 95 descriptionTextBox.Enabled = enabled; 96 refreshButton.Enabled = enabled; 101 97 ownerComboBox.Enabled = enabled; 102 98 createdTextBox.Enabled = enabled; … … 104 100 endDateTimePicker.Enabled = enabled && Content.EndDate.HasValue; 105 101 indefiniteCheckBox.Enabled = enabled; 102 } 103 #endregion 104 105 #region Event Handlers 106 private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) { 107 OnContentChanged(); 106 108 } 107 109 … … 125 127 126 128 private async void ProjectView_Load(object sender, EventArgs e) { 127 lock (locker) { 128 if (updatingUsers) return; 129 updatingUsers = true; 130 } 131 try { 132 await Tasks.Task.Run(() => UpdateUsers()); 133 } finally { 134 updatingUsers = false; 135 } 129 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 130 action: () => UpdateUsers(), 131 finallyCallback: () => { 132 ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged; 133 ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList(); 134 ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged; 135 }); 136 136 } 137 137 … … 141 141 updatingUsers = true; 142 142 } 143 try { 144 await Tasks.Task.Run(() => UpdateUsers()); 145 } finally { 146 updatingUsers = false; 147 } 148 } 149 150 private void UpdateUsers() { 151 ownerComboBox.DataSource = null; 152 AccessClient.Instance.Refresh(); 153 if (Content != null) { 154 ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList(); 155 ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == Content.OwnerUserId); 156 } 143 144 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 145 action: () => UpdateUsers(), 146 finallyCallback: () => { 147 ownerComboBox.SelectedIndexChanged -= ownerComboBox_SelectedIndexChanged; 148 ownerComboBox.DataSource = AccessClient.Instance.UsersAndGroups.OfType<LightweightUser>().ToList(); 149 ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == Content.OwnerUserId); 150 ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged; 151 updatingUsers = false; 152 }); 157 153 } 158 154 … … 192 188 Content.EndDate = indefiniteCheckBox.Checked ? (DateTime?)null : Content.StartDate; 193 189 } 190 #endregion 191 192 #region Helpers 193 private void UpdateUsers() { 194 try { 195 AccessClient.Instance.Refresh(); 196 } catch (AnonymousUserException) { 197 ShowHiveInformationDialog(); 198 } 199 } 200 201 private void ShowHiveInformationDialog() { 202 if (InvokeRequired) Invoke((Action)ShowHiveInformationDialog); 203 else { 204 using (HiveInformationDialog dialog = new HiveInformationDialog()) { 205 dialog.ShowDialog(this); 206 } 207 } 208 } 209 #endregion 194 210 } 195 211 } -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs
r15401 r15412 104 104 removeButton.Enabled = enabled; 105 105 saveProjectButton.Enabled = enabled; 106 savePermissionsButton.Enabled = enabled && permissionsView. FetchSelectedUsers != null;107 permissionsView.Enabled = enabled && permissionsView. FetchSelectedUsers != null;106 savePermissionsButton.Enabled = enabled && permissionsView.Content != null && permissionsView.FetchSelectedUsers != null; 107 permissionsView.Enabled = enabled && permissionsView.Content != null && permissionsView.FetchSelectedUsers != null; 108 108 } 109 109 #endregion … … 111 111 #region Event Handlers 112 112 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<Project>> e) { 113 OnContentChanged(); 113 if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IndexedItem<Project>>>)Content_ItemsAdded, sender, e); 114 else { 115 OnContentChanged(); 116 } 114 117 } 115 118 116 119 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Project>> e) { 117 OnContentChanged(); 120 if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IndexedItem<Project>>>)Content_ItemsRemoved, sender, e); 121 else { 122 OnContentChanged(); 123 } 118 124 } 119 125 120 126 private void ProjectViewContent_PropertyChanged(object sender, PropertyChangedEventArgs e) { 121 OnContentChanged(); 127 if (InvokeRequired) Invoke((Action<object, PropertyChangedEventArgs>)ProjectViewContent_PropertyChanged, sender, e); 128 else { 129 OnContentChanged(); 130 } 122 131 } 123 132 … … 159 168 160 169 private async void ProjectsView_Load(object sender, EventArgs e) { 161 lock (locker) {162 if (updatingProjects) return;163 updatingProjects = true;164 }165 166 170 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 167 171 action: () => UpdateProjects(), 168 finallyCallback: () => updatingProjects = false);172 finallyCallback: () => Content = HiveAdminClient.Instance.Projects); 169 173 } 170 174 … … 177 181 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 178 182 action: () => UpdateProjects(), 179 finallyCallback: () => updatingProjects = false); 183 finallyCallback: () => { 184 Content = HiveAdminClient.Instance.Projects; 185 updatingProjects = false; 186 }); 180 187 } 181 188 … … 194 201 } 195 202 196 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 197 action: () => RemoveProject(), 198 finallyCallback: () => removingProjects = false); 203 var selectedNode = projectsTreeView.SelectedNode; 204 if (selectedNode == null || selectedNode.Tag == null) return; 205 206 var project = (Project)selectedNode.Tag; 207 var result = MessageBox.Show( 208 "Do you really want to delete " + project.Name + "?", 209 "HeuristicLab Hive Administrator", 210 MessageBoxButtons.YesNo, 211 MessageBoxIcon.Question); 212 213 if (result == DialogResult.Yes) { 214 if (Content.Any(x => x.ParentProjectId == project.Id)) { 215 MessageBox.Show( 216 "Only empty projects can be deleted.", 217 "HeuristicLab Hive Administrator", 218 MessageBoxButtons.OK, 219 MessageBoxIcon.Error); 220 } else { 221 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 222 action: () => RemoveProject(project), 223 finallyCallback: () => { 224 Content.Remove(project); 225 removingProjects = false; 226 }); 227 } 228 } 199 229 } 200 230 … … 222 252 projectView.Content = selectedProject; 223 253 224 selectedProject.PropertyChanged += ProjectViewContent_PropertyChanged; 225 226 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 227 action: () => UpdatePermissions()); 254 if (selectedProject != null) 255 selectedProject.PropertyChanged += ProjectViewContent_PropertyChanged; 256 257 if (IsAuthorized(selectedProject)) { 258 if (!tabControl.TabPages.Contains(permissionsTabPage)) 259 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()); 269 } else { 270 if (tabControl.TabPages.Contains(permissionsTabPage)) 271 tabControl.TabPages.Remove(permissionsTabPage); 272 permissionsView.FetchSelectedUsers = null; 273 } 228 274 } 229 275 … … 273 319 } 274 320 275 private void tabControl_SelectedIndexChanged(object sender, EventArgs e) {276 if (tabControl.SelectedIndex == 1 ) {277 UpdatePermissions();278 }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()); 279 325 } 280 326 … … 341 387 private void UpdateProjects() { 342 388 try { 343 389 HiveAdminClient.Instance.Refresh(); 344 390 } catch (AnonymousUserException) { 345 391 ShowHiveInformationDialog(); 346 392 } 347 HiveAdminClient.Instance.Refresh(); 348 Content = HiveAdminClient.Instance.Projects; 349 } 350 351 private void RemoveProject() { 352 var selectedNode = projectsTreeView.SelectedNode; 353 if (selectedNode == null || selectedNode.Tag == null) return; 354 355 var project = (Project)selectedNode.Tag; 356 var result = MessageBox.Show( 357 "Do you really want to delete " + project.Name + "?", 358 "HeuristicLab Hive Administrator", 359 MessageBoxButtons.YesNo, 360 MessageBoxIcon.Question); 361 362 if (result == DialogResult.Yes) { 363 if (Content.Any(x => x.ParentProjectId == project.Id)) { 364 MessageBox.Show( 365 "Only empty projects can be deleted.", 366 "HeuristicLab Hive Administrator", 367 MessageBoxButtons.OK, 368 MessageBoxIcon.Error); 369 } else { 370 Content.Remove(project); 371 HiveAdminClient.Delete(project); 372 } 393 } 394 395 private void RemoveProject(Project project) { 396 try { 397 HiveAdminClient.Delete(project); 398 } catch (AnonymousUserException) { 399 ShowHiveInformationDialog(); 373 400 } 374 401 } 375 402 376 403 private void UpdatePermissions() { 377 var selectedNode = projectsTreeView.SelectedNode; 378 var project = (Project)selectedNode?.Tag; 379 380 if (IsAuthorized(project)) { 381 permissionsView.FetchSelectedUsers = () => 382 HiveServiceLocator.Instance.CallHiveService(s => s.GetProjectPermissions(project.Id)) 383 .Select(x => x.GrantedUserId) 384 .ToList(); 385 386 savePermissionsButton.Enabled = true; 387 388 if (!tabControl.TabPages.Contains(permissionsTabPage)) 389 tabControl.TabPages.Add(permissionsTabPage); 390 391 if (tabControl.SelectedIndex == 1 && permissionsView.Content != null && permissionsView.FetchSelectedUsers != null) 392 permissionsView.ManualRefresh(); 393 } else { 394 permissionsView.FetchSelectedUsers = null; 395 savePermissionsButton.Enabled = false; 396 397 if (tabControl.TabPages.Contains(permissionsTabPage)) 398 tabControl.TabPages.Remove(permissionsTabPage); 404 try { 405 permissionsView.ManualRefresh(); 406 } catch (AnonymousUserException) { 407 ShowHiveInformationDialog(); 399 408 } 400 409 } -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs
r15401 r15412 53 53 private void InitializeComponent() { 54 54 this.components = new System.ComponentModel.Container(); 55 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ResourcesView));56 55 this.imageListSlaveGroups = new System.Windows.Forms.ImageList(this.components); 57 56 this.splitSlaves = new System.Windows.Forms.SplitContainer(); … … 63 62 this.tabSlaveGroup = new System.Windows.Forms.TabControl(); 64 63 this.tabDetails = new System.Windows.Forms.TabPage(); 64 this.tabSchedule = new System.Windows.Forms.TabPage(); 65 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 65 66 this.slaveView = new HeuristicLab.Clients.Hive.Administrator.Views.SlaveView(); 66 this.tabSchedule = new System.Windows.Forms.TabPage();67 67 this.scheduleView = new HeuristicLab.Clients.Hive.Administrator.Views.ScheduleView(); 68 this.toolTip = new System.Windows.Forms.ToolTip(this.components);69 68 ((System.ComponentModel.ISupportInitialize)(this.splitSlaves)).BeginInit(); 70 69 this.splitSlaves.Panel1.SuspendLayout(); … … 194 193 this.tabDetails.UseVisualStyleBackColor = true; 195 194 // 196 // slaveView197 //198 this.slaveView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)199 | System.Windows.Forms.AnchorStyles.Left)200 | System.Windows.Forms.AnchorStyles.Right)));201 this.slaveView.Caption = "SlaveView";202 this.slaveView.Content = null;203 this.slaveView.Location = new System.Drawing.Point(6, 6);204 this.slaveView.Name = "slaveView";205 this.slaveView.ReadOnly = false;206 this.slaveView.Size = new System.Drawing.Size(565, 503);207 this.slaveView.TabIndex = 0;208 //209 195 // tabSchedule 210 196 // … … 217 203 this.tabSchedule.Text = "Schedule"; 218 204 this.tabSchedule.UseVisualStyleBackColor = true; 205 // 206 // slaveView 207 // 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; 219 218 // 220 219 // scheduleView -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs
r15401 r15412 27 27 using HeuristicLab.Clients.Access; 28 28 using HeuristicLab.Clients.Hive.Views; 29 using HeuristicLab.Collections; 29 30 using HeuristicLab.Common.Resources; 30 31 using HeuristicLab.Core; … … 144 145 145 146 #region Event Handlers 146 private void Content_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<Resource>> e) { 147 OnContentChanged(); 148 } 149 150 private void Content_ItemsRemoved(object sender, Collections.CollectionItemsChangedEventArgs<Collections.IndexedItem<Resource>> e) { 151 OnContentChanged(); 147 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IndexedItem<Resource>> e) { 148 if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IndexedItem<Resource>>>)Content_ItemsAdded, sender, e); 149 else { 150 OnContentChanged(); 151 } 152 } 153 154 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IndexedItem<Resource>> e) { 155 if (InvokeRequired) Invoke((Action<object, CollectionItemsChangedEventArgs<IndexedItem<Resource>>>)Content_ItemsRemoved, sender, e); 156 else { 157 OnContentChanged(); 158 } 152 159 } 153 160 154 161 private void SlaveViewContent_PropertyChanged(object sender, PropertyChangedEventArgs e) { 155 OnContentChanged(); 156 if (e.PropertyName == "HbInterval") { 157 UpdateChildHbIntervall(slaveView.Content); 162 if (InvokeRequired) Invoke((Action<object, PropertyChangedEventArgs>)SlaveViewContent_PropertyChanged, sender, e); 163 else { 164 OnContentChanged(); 165 if (e.PropertyName == "HbInterval") { 166 UpdateChildHbIntervall(slaveView.Content); 167 } 158 168 } 159 169 } … … 196 206 197 207 private async void ResourcesView_Load(object sender, EventArgs e) { 198 lock (locker) {199 if (updatingResources) return;200 updatingResources = true;201 }202 203 208 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 204 action: () => UpdateResources(), 205 finallyCallback: () => updatingResources = false); 209 action: () => UpdateResources()); 206 210 } 207 211 … … 259 263 slaveView.Content = selectedResource; 260 264 261 if (selectedResource is SlaveGroup) 262 slaveView.Content.PropertyChanged += SlaveViewContent_PropertyChanged; 263 264 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 265 action: () => UpdateSchedule()); 265 if (selectedResource != null && selectedResource is SlaveGroup) 266 selectedResource.PropertyChanged += SlaveViewContent_PropertyChanged; 267 268 if (IsAuthorized(selectedResource)) { 269 if (!tabSlaveGroup.TabPages.Contains(tabSchedule)) 270 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 } else { 280 if (tabSlaveGroup.TabPages.Contains(tabSchedule)) 281 tabSlaveGroup.TabPages.Remove(tabSchedule); 282 HiveAdminClient.Instance.DowntimeForResourceId = Guid.Empty; 283 } 266 284 } 267 285 … … 412 430 413 431 private void UpdateResources() { 414 try { 415 ResetView(); 416 HiveAdminClient.Instance.Refresh(); 417 Content = HiveAdminClient.Instance.Resources; 418 } catch (AnonymousUserException) { 419 ShowHiveInformationDialog(); 420 } 432 HiveAdminClient.Instance.Refresh(); 433 Content = HiveAdminClient.Instance.Resources; 421 434 } 422 435 … … 452 465 453 466 private void UpdateSchedule() { 454 var selectedNode = treeSlaveGroup.SelectedNode; 455 var resource = (Resource)selectedNode?.Tag; 456 457 if (IsAuthorized(resource)) { 458 if (!tabSlaveGroup.TabPages.Contains(tabSchedule)) 459 tabSlaveGroup.TabPages.Add(tabSchedule); 460 461 if (tabSlaveGroup.SelectedIndex == 1) { 462 HiveAdminClient.Instance.DowntimeForResourceId = resource.Id; 463 HiveAdminClient.Instance.RefreshCalendar(); 464 scheduleView.Invoke((Action)(() => { 465 scheduleView.Content = HiveAdminClient.Instance.Downtimes; 466 SetEnabledStateOfControls(); 467 })); 468 } 469 } else { 470 if (tabSlaveGroup.TabPages.Contains(tabSchedule)) 471 tabSlaveGroup.TabPages.Remove(tabSchedule); 467 try { 468 HiveAdminClient.Instance.RefreshCalendar(); 469 } catch (AnonymousUserException) { 470 ShowHiveInformationDialog(); 472 471 } 473 472 } -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.cs
r14185 r15412 125 125 protected override void SetEnabledStateOfControls() { 126 126 base.SetEnabledStateOfControls(); 127 bool enabled = Content != null; 128 txtName.Enabled = enabled; 129 txtHbIntervall.Enabled = enabled; 130 cbxPublic.Enabled = enabled; 127 131 } 128 132 … … 139 143 int interval = int.Parse(txtHbIntervall.Text); 140 144 Content.HbInterval = interval; 141 } 142 catch (Exception) { 145 } catch (Exception) { 143 146 MessageBox.Show("Please enter a numeric value for the Heartbeat Interval.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error); 144 147 txtHbIntervall.Text = "10"; -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/HeuristicLab.Clients.Hive.JobManager-3.3.csproj
r15401 r15412 164 164 <Private>False</Private> 165 165 </ProjectReference> 166 <ProjectReference Include="..\..\HeuristicLab.Clients.Common\3.3\HeuristicLab.Clients.Common-3.3.csproj"> 167 <Project>{730a9104-d4d1-4360-966b-e49b7571dda3}</Project> 168 <Name>HeuristicLab.Clients.Common-3.3</Name> 169 <Private>False</Private> 170 </ProjectReference> 166 171 <ProjectReference Include="..\..\HeuristicLab.Clients.Hive.Views\3.3\HeuristicLab.Clients.Hive.Views-3.3.csproj"> 167 172 <Project>{E1D6C801-892A-406A-B606-F158E36DD3C3}</Project> -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.Designer.cs
r15401 r15412 46 46 private void InitializeComponent() { 47 47 this.components = new System.ComponentModel.Container(); 48 this.resourcesGroupBox = new System.Windows.Forms.GroupBox(); 49 this.splitContainer = new System.Windows.Forms.SplitContainer(); 50 this.resourcesTreeView = new System.Windows.Forms.TreeView(); 51 this.imageList = new System.Windows.Forms.ImageList(this.components); 48 this.projectsGroupBox = new System.Windows.Forms.GroupBox(); 49 this.projectsImageList = new System.Windows.Forms.ImageList(this.components); 50 this.resourcesImageList = new System.Windows.Forms.ImageList(this.components); 52 51 this.searchLabel = new System.Windows.Forms.Label(); 53 52 this.searchTextBox = new System.Windows.Forms.TextBox(); 54 this.descriptionTextBox = new System.Windows.Forms.TextBox();55 53 this.toolTip = new System.Windows.Forms.ToolTip(this.components); 56 this.resourcesGroupBox.SuspendLayout(); 57 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); 58 this.splitContainer.Panel1.SuspendLayout(); 59 this.splitContainer.Panel2.SuspendLayout(); 60 this.splitContainer.SuspendLayout(); 54 this.splitContainer2 = new System.Windows.Forms.SplitContainer(); 55 this.projectsTreeView = new System.Windows.Forms.TreeView(); 56 this.resourcesTreeView = new System.Windows.Forms.TreeView(); 57 this.summaryGroupBox = new System.Windows.Forms.GroupBox(); 58 this.coresLabel = new System.Windows.Forms.Label(); 59 this.coresSummaryLabel = new System.Windows.Forms.Label(); 60 this.memoryLabel = new System.Windows.Forms.Label(); 61 this.memorySummaryLabel = new System.Windows.Forms.Label(); 62 this.projectsGroupBox.SuspendLayout(); 63 ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).BeginInit(); 64 this.splitContainer2.Panel1.SuspendLayout(); 65 this.splitContainer2.Panel2.SuspendLayout(); 66 this.splitContainer2.SuspendLayout(); 67 this.summaryGroupBox.SuspendLayout(); 61 68 this.SuspendLayout(); 62 69 // 63 // resourcesGroupBox 64 // 65 this.resourcesGroupBox.Controls.Add(this.splitContainer); 66 this.resourcesGroupBox.Dock = System.Windows.Forms.DockStyle.Fill; 67 this.resourcesGroupBox.Location = new System.Drawing.Point(0, 0); 68 this.resourcesGroupBox.Name = "resourcesGroupBox"; 69 this.resourcesGroupBox.Size = new System.Drawing.Size(308, 365); 70 this.resourcesGroupBox.TabIndex = 0; 71 this.resourcesGroupBox.TabStop = false; 72 this.resourcesGroupBox.Text = "Available Projects"; 73 // 74 // splitContainer 75 // 76 this.splitContainer.Dock = System.Windows.Forms.DockStyle.Fill; 77 this.splitContainer.Location = new System.Drawing.Point(3, 16); 78 this.splitContainer.Name = "splitContainer"; 79 this.splitContainer.Orientation = System.Windows.Forms.Orientation.Horizontal; 80 // 81 // splitContainer.Panel1 82 // 83 this.splitContainer.Panel1.Controls.Add(this.resourcesTreeView); 84 this.splitContainer.Panel1.Controls.Add(this.searchLabel); 85 this.splitContainer.Panel1.Controls.Add(this.searchTextBox); 86 // 87 // splitContainer.Panel2 88 // 89 this.splitContainer.Panel2.Controls.Add(this.descriptionTextBox); 90 this.splitContainer.Size = new System.Drawing.Size(302, 346); 91 this.splitContainer.SplitterDistance = 219; 92 this.splitContainer.TabIndex = 0; 93 // 94 // resourcesTreeView 95 // 96 this.resourcesTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 70 // projectsGroupBox 71 // 72 this.projectsGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 97 73 | System.Windows.Forms.AnchorStyles.Left) 98 74 | System.Windows.Forms.AnchorStyles.Right))); 99 this.resourcesTreeView.CheckBoxes = true; 100 this.resourcesTreeView.HideSelection = false; 101 this.resourcesTreeView.ImageIndex = 0; 102 this.resourcesTreeView.ImageList = this.imageList; 103 this.resourcesTreeView.Location = new System.Drawing.Point(3, 29); 104 this.resourcesTreeView.Name = "resourcesTreeView"; 105 this.resourcesTreeView.SelectedImageIndex = 0; 106 this.resourcesTreeView.ShowNodeToolTips = true; 107 this.resourcesTreeView.Size = new System.Drawing.Size(296, 196); 108 this.resourcesTreeView.TabIndex = 2; 109 this.resourcesTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.resourcesTreeView_AfterCheck); 110 this.resourcesTreeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.resourcesTreeView_AfterSelect); 111 // 112 // imageList 113 // 114 this.imageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; 115 this.imageList.ImageSize = new System.Drawing.Size(16, 16); 116 this.imageList.TransparentColor = System.Drawing.Color.Transparent; 75 this.projectsGroupBox.Controls.Add(this.searchLabel); 76 this.projectsGroupBox.Controls.Add(this.splitContainer2); 77 this.projectsGroupBox.Controls.Add(this.searchTextBox); 78 this.projectsGroupBox.Location = new System.Drawing.Point(3, 3); 79 this.projectsGroupBox.Name = "projectsGroupBox"; 80 this.projectsGroupBox.Size = new System.Drawing.Size(426, 461); 81 this.projectsGroupBox.TabIndex = 0; 82 this.projectsGroupBox.TabStop = false; 83 this.projectsGroupBox.Text = "Available Projects"; 84 // 85 // projectsImageList 86 // 87 this.projectsImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; 88 this.projectsImageList.ImageSize = new System.Drawing.Size(16, 16); 89 this.projectsImageList.TransparentColor = System.Drawing.Color.Transparent; 90 // 91 // resourcesImageList 92 // 93 this.resourcesImageList.ColorDepth = System.Windows.Forms.ColorDepth.Depth8Bit; 94 this.resourcesImageList.ImageSize = new System.Drawing.Size(16, 16); 95 this.resourcesImageList.TransparentColor = System.Drawing.Color.Transparent; 117 96 // 118 97 // searchLabel 119 98 // 120 99 this.searchLabel.Image = HeuristicLab.Common.Resources.VSImageLibrary.Zoom; 121 this.searchLabel.Location = new System.Drawing.Point( 3, 3);100 this.searchLabel.Location = new System.Drawing.Point(6, 19); 122 101 this.searchLabel.Name = "searchLabel"; 123 102 this.searchLabel.Size = new System.Drawing.Size(20, 20); … … 129 108 this.searchTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 130 109 | System.Windows.Forms.AnchorStyles.Right))); 131 this.searchTextBox.Location = new System.Drawing.Point( 29, 3);110 this.searchTextBox.Location = new System.Drawing.Point(32, 19); 132 111 this.searchTextBox.Name = "searchTextBox"; 133 this.searchTextBox.Size = new System.Drawing.Size( 270, 20);112 this.searchTextBox.Size = new System.Drawing.Size(388, 20); 134 113 this.searchTextBox.TabIndex = 1; 135 114 this.toolTip.SetToolTip(this.searchTextBox, "Enter string to search for resources"); 136 115 this.searchTextBox.TextChanged += new System.EventHandler(this.searchTextBox_TextChanged); 137 116 // 138 // descriptionTextBox139 // 140 this. descriptionTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)117 // splitContainer2 118 // 119 this.splitContainer2.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 141 120 | System.Windows.Forms.AnchorStyles.Left) 142 121 | System.Windows.Forms.AnchorStyles.Right))); 143 this.descriptionTextBox.Font = new System.Drawing.Font("Courier New", 8.25F); 144 this.descriptionTextBox.Location = new System.Drawing.Point(3, 3); 145 this.descriptionTextBox.Multiline = true; 146 this.descriptionTextBox.Name = "descriptionTextBox"; 147 this.descriptionTextBox.ReadOnly = true; 148 this.descriptionTextBox.ScrollBars = System.Windows.Forms.ScrollBars.Both; 149 this.descriptionTextBox.Size = new System.Drawing.Size(296, 108); 150 this.descriptionTextBox.TabIndex = 0; 151 this.descriptionTextBox.WordWrap = false; 152 // 153 // HiveResourceSelector 122 this.splitContainer2.Location = new System.Drawing.Point(6, 45); 123 this.splitContainer2.Name = "splitContainer2"; 124 // 125 // splitContainer2.Panel1 126 // 127 this.splitContainer2.Panel1.Controls.Add(this.projectsTreeView); 128 // 129 // splitContainer2.Panel2 130 // 131 this.splitContainer2.Panel2.Controls.Add(this.resourcesTreeView); 132 this.splitContainer2.Size = new System.Drawing.Size(414, 410); 133 this.splitContainer2.SplitterDistance = 204; 134 this.splitContainer2.TabIndex = 4; 135 // 136 // projectsTreeView 137 // 138 this.projectsTreeView.Dock = System.Windows.Forms.DockStyle.Fill; 139 this.projectsTreeView.HideSelection = false; 140 this.projectsTreeView.ImageIndex = 0; 141 this.projectsTreeView.ImageList = this.projectsImageList; 142 this.projectsTreeView.Location = new System.Drawing.Point(0, 0); 143 this.projectsTreeView.Name = "projectsTreeView"; 144 this.projectsTreeView.SelectedImageIndex = 0; 145 this.projectsTreeView.ShowNodeToolTips = true; 146 this.projectsTreeView.Size = new System.Drawing.Size(204, 410); 147 this.projectsTreeView.TabIndex = 3; 148 this.projectsTreeView.MouseDoubleClick += new System.Windows.Forms.MouseEventHandler(this.projectsTreeView_MouseDoubleClick); 149 this.projectsTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.projectsTreeView_MouseDown); 150 // 151 // resourcesTreeView 152 // 153 this.resourcesTreeView.CheckBoxes = true; 154 this.resourcesTreeView.Dock = System.Windows.Forms.DockStyle.Fill; 155 this.resourcesTreeView.ImageIndex = 0; 156 this.resourcesTreeView.ImageList = this.resourcesImageList; 157 this.resourcesTreeView.Location = new System.Drawing.Point(0, 0); 158 this.resourcesTreeView.Name = "resourcesTreeView"; 159 this.resourcesTreeView.SelectedImageIndex = 0; 160 this.resourcesTreeView.Size = new System.Drawing.Size(206, 410); 161 this.resourcesTreeView.TabIndex = 0; 162 this.resourcesTreeView.AfterCheck += new System.Windows.Forms.TreeViewEventHandler(this.resourcesTreeView_AfterCheck); 163 this.resourcesTreeView.MouseDown += new System.Windows.Forms.MouseEventHandler(this.resourcesTreeView_MouseDown); 164 // 165 // summaryGroupBox 166 // 167 this.summaryGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left) 168 | System.Windows.Forms.AnchorStyles.Right))); 169 this.summaryGroupBox.Controls.Add(this.memorySummaryLabel); 170 this.summaryGroupBox.Controls.Add(this.memoryLabel); 171 this.summaryGroupBox.Controls.Add(this.coresSummaryLabel); 172 this.summaryGroupBox.Controls.Add(this.coresLabel); 173 this.summaryGroupBox.Location = new System.Drawing.Point(3, 470); 174 this.summaryGroupBox.Name = "summaryGroupBox"; 175 this.summaryGroupBox.Size = new System.Drawing.Size(426, 71); 176 this.summaryGroupBox.TabIndex = 1; 177 this.summaryGroupBox.TabStop = false; 178 this.summaryGroupBox.Text = "Computing Resources"; 179 // 180 // coresLabel 181 // 182 this.coresLabel.AutoSize = true; 183 this.coresLabel.Location = new System.Drawing.Point(6, 22); 184 this.coresLabel.Name = "coresLabel"; 185 this.coresLabel.Size = new System.Drawing.Size(37, 13); 186 this.coresLabel.TabIndex = 1; 187 this.coresLabel.Text = "Cores:"; 188 // 189 // coresSummaryLabel 190 // 191 this.coresSummaryLabel.AutoSize = true; 192 this.coresSummaryLabel.Location = new System.Drawing.Point(59, 22); 193 this.coresSummaryLabel.Name = "coresSummaryLabel"; 194 this.coresSummaryLabel.Size = new System.Drawing.Size(124, 13); 195 this.coresSummaryLabel.TabIndex = 5; 196 this.coresSummaryLabel.Text = "0 Total (0 Free / 0 Used)"; 197 // 198 // memoryLabel 199 // 200 this.memoryLabel.AutoSize = true; 201 this.memoryLabel.Location = new System.Drawing.Point(6, 48); 202 this.memoryLabel.Name = "memoryLabel"; 203 this.memoryLabel.Size = new System.Drawing.Size(47, 13); 204 this.memoryLabel.TabIndex = 7; 205 this.memoryLabel.Text = "Memory:"; 206 // 207 // memorySummaryLabel 208 // 209 this.memorySummaryLabel.AutoSize = true; 210 this.memorySummaryLabel.Location = new System.Drawing.Point(59, 48); 211 this.memorySummaryLabel.Name = "memorySummaryLabel"; 212 this.memorySummaryLabel.Size = new System.Drawing.Size(223, 13); 213 this.memorySummaryLabel.TabIndex = 8; 214 this.memorySummaryLabel.Text = "0.00 GB Total (0.00 GB Free / 0.00 GB Used)"; 215 // 216 // HiveProjectSelector 154 217 // 155 218 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit; 156 this.Controls.Add(this.resourcesGroupBox); 157 this.Name = "HiveResourceSelector"; 158 this.Size = new System.Drawing.Size(308, 365); 159 this.resourcesGroupBox.ResumeLayout(false); 160 this.splitContainer.Panel1.ResumeLayout(false); 161 this.splitContainer.Panel1.PerformLayout(); 162 this.splitContainer.Panel2.ResumeLayout(false); 163 this.splitContainer.Panel2.PerformLayout(); 164 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).EndInit(); 165 this.splitContainer.ResumeLayout(false); 219 this.Controls.Add(this.summaryGroupBox); 220 this.Controls.Add(this.projectsGroupBox); 221 this.Name = "HiveProjectSelector"; 222 this.Size = new System.Drawing.Size(432, 544); 223 this.Load += new System.EventHandler(this.HiveProjectSelector_Load); 224 this.projectsGroupBox.ResumeLayout(false); 225 this.projectsGroupBox.PerformLayout(); 226 this.splitContainer2.Panel1.ResumeLayout(false); 227 this.splitContainer2.Panel2.ResumeLayout(false); 228 ((System.ComponentModel.ISupportInitialize)(this.splitContainer2)).EndInit(); 229 this.splitContainer2.ResumeLayout(false); 230 this.summaryGroupBox.ResumeLayout(false); 231 this.summaryGroupBox.PerformLayout(); 166 232 this.ResumeLayout(false); 167 233 … … 170 236 #endregion 171 237 172 protected System.Windows.Forms.GroupBox resourcesGroupBox; 173 protected System.Windows.Forms.SplitContainer splitContainer; 238 protected System.Windows.Forms.GroupBox projectsGroupBox; 174 239 protected System.Windows.Forms.Label searchLabel; 175 240 protected System.Windows.Forms.TextBox searchTextBox; 241 protected System.Windows.Forms.ImageList projectsImageList; 242 protected System.Windows.Forms.ToolTip toolTip; 243 private System.Windows.Forms.ImageList resourcesImageList; 244 private System.Windows.Forms.SplitContainer splitContainer2; 245 protected System.Windows.Forms.TreeView projectsTreeView; 176 246 protected System.Windows.Forms.TreeView resourcesTreeView; 177 protected System.Windows.Forms.TextBox descriptionTextBox; 178 protected System.Windows.Forms.ImageList imageList; 179 protected System.Windows.Forms.ToolTip toolTip; 180 247 private System.Windows.Forms.GroupBox summaryGroupBox; 248 private System.Windows.Forms.Label coresLabel; 249 private System.Windows.Forms.Label memorySummaryLabel; 250 private System.Windows.Forms.Label memoryLabel; 251 private System.Windows.Forms.Label coresSummaryLabel; 181 252 } 182 253 } -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs
r15401 r15412 25 25 using System.Linq; 26 26 using System.Windows.Forms; 27 using HeuristicLab.Collections; 28 using HeuristicLab.Common.Resources; 27 29 using HeuristicLab.Core; 28 30 using HeuristicLab.Core.Views; … … 36 38 private const int greenFlagImageIndex = 0; 37 39 private const int redFlagImageIndex = 1; 40 private const int slaveImageIndex = 0; 41 private const int slaveGroupImageIndex = 1; 42 43 private readonly ISet<TreeNode> mainTreeNodes = new HashSet<TreeNode>(); 44 private readonly ISet<TreeNode> filteredTreeNodes = new HashSet<TreeNode>(); 45 private readonly ISet<TreeNode> nodeStore = new HashSet<TreeNode>(); 46 private readonly ISet<Resource> resources = new HashSet<Resource>(); 47 38 48 private string currentSearchString; 39 private ISet<TreeNode> mainTreeNodes; 40 private ISet<TreeNode> filteredTreeNodes; 41 private ISet<TreeNode> nodeStore; 42 43 private ISet<Project> selectedResources; 44 public ISet<Project> SelectedResources { 45 get { return selectedResources; } 46 set { selectedResources = value; } 47 } 48 49 50 private Project selectedProject; 49 51 public Project SelectedProject { 50 get { return (Project)resourcesTreeView.SelectedNode.Tag; } 51 } 52 get { return selectedProject; } 53 set { 54 if (selectedProject == value) return; 55 selectedProject = value; 56 UpdateResources(); 57 OnSelectedProjectChanged(); 58 } 59 } 60 61 private readonly IObservableSet<Resource> selectedResources = new ObservableSet<Resource>(); 62 public IEnumerable<Resource> SelectedResources { get { return selectedResources; } } 52 63 53 64 public new IItemList<Project> Content { … … 58 69 public HiveProjectSelector() { 59 70 InitializeComponent(); 60 mainTreeNodes = new HashSet<TreeNode>(); 61 filteredTreeNodes = new HashSet<TreeNode>(); 62 nodeStore = new HashSet<TreeNode>(); 63 selectedResources = new HashSet<Project>(); 64 imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.FlagGreen); 65 imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.FlagRed); 66 } 67 68 public void StartProgressView() { 69 if (InvokeRequired) { 70 Invoke(new Action(StartProgressView)); 71 } else { 72 var message = "Downloading projects. Please be patient."; 73 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, message); 74 } 75 } 76 77 public void FinishProgressView() { 78 if (InvokeRequired) { 79 Invoke(new Action(FinishProgressView)); 80 } else { 81 MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this); 82 } 83 } 84 71 72 projectsImageList.Images.Add(VSImageLibrary.FlagGreen); 73 projectsImageList.Images.Add(VSImageLibrary.FlagRed); 74 resourcesImageList.Images.Add(VSImageLibrary.MonitorLarge); 75 resourcesImageList.Images.Add(VSImageLibrary.NetworkCenterLarge); 76 } 77 78 #region Overrides 85 79 protected override void OnContentChanged() { 86 80 base.OnContentChanged(); 87 81 88 82 if (Content != null) { 89 selectedResources = new HashSet<Project>(Content.Where(x => selectedResources.Any(y => x.Id == y.Id)));90 83 UpdateMainTree(); 91 84 ExtractStatistics(); … … 94 87 UpdateFilteredTree(); 95 88 } 96 } 97 98 #region MainTree Methods 89 90 SelectedProject = null; 91 } 92 #endregion 93 94 #region Event Handlers 95 private void HiveProjectSelector_Load(object sender, EventArgs e) { 96 projectsTreeView.Nodes.Clear(); 97 resourcesTreeView.Nodes.Clear(); 98 SelectedProject = null; 99 } 100 101 private void searchTextBox_TextChanged(object sender, EventArgs e) { 102 currentSearchString = searchTextBox.Text.ToLower(); 103 UpdateFilteredTree(); 104 } 105 106 private void projectsTreeView_MouseDoubleClick(object sender, MouseEventArgs e) { 107 OnProjectsTreeViewDoubleClicked(); 108 } 109 110 private void projectsTreeView_MouseDown(object sender, MouseEventArgs e) { 111 var node = projectsTreeView.GetNodeAt(new Point(e.X, e.Y)); 112 113 SelectedProject = (Project)node?.Tag; 114 115 if (node == null) { 116 projectsTreeView.SelectedNode = null; 117 } 118 119 ExtractStatistics(); 120 } 121 122 private void resourcesTreeView_MouseDown(object sender, MouseEventArgs e) { 123 var node = resourcesTreeView.GetNodeAt(new Point(e.X, e.Y)); 124 125 if (node == null) { 126 resourcesTreeView.SelectedNode = null; 127 } 128 129 ExtractStatistics((Resource)node?.Tag); 130 } 131 132 private void resourcesTreeView_AfterCheck(object sender, TreeViewEventArgs e) { 133 var resource = (Resource)e.Node.Tag; 134 135 if (e.Node.Checked) 136 selectedResources.Add(resource); 137 else 138 selectedResources.Remove(resource); 139 140 ExtractStatistics((Resource)resourcesTreeView.SelectedNode?.Tag); 141 OnSelectedResourcesChanged(); 142 } 143 #endregion 144 145 #region Helpers 99 146 private void UpdateMainTree() { 100 147 mainTreeNodes.Clear(); 101 148 102 149 foreach (Project g in Content.OrderBy(x => x.Name)) { 103 //root node104 150 if (g.ParentProjectId == null) { 105 151 TreeNode tn = new TreeNode(); … … 131 177 } 132 178 } 133 #endregion 134 135 #region FilteredTree Methods 179 136 180 private void UpdateFilteredTree() { 137 181 filteredTreeNodes.Clear(); … … 144 188 } 145 189 } 146 UpdateResourceTree(); 147 } 148 149 private void TraverseParentNodes(TreeNode node) { 150 if (node != null) { 151 for (TreeNode parent = node.Parent; parent != null; parent = parent.Parent) 152 filteredTreeNodes.Add(parent); 153 } 154 } 155 #endregion 156 157 #region ResourceTree Methods 158 private void UpdateResourceTree() { 159 resourcesTreeView.Nodes.Clear(); 190 UpdateProjectsTree(); 191 } 192 193 private void UpdateProjectsTree() { 194 projectsTreeView.Nodes.Clear(); 160 195 nodeStore.Clear(); 161 196 … … 178 213 } 179 214 } 180 resourcesTreeView.Nodes.AddRange(nodeStore.Where(x => ((Project)x.Tag).ParentProjectId == null).ToArray());215 projectsTreeView.Nodes.AddRange(nodeStore.Where(x => ((Project)x.Tag).ParentProjectId == null).ToArray()); 181 216 if (string.IsNullOrEmpty(currentSearchString)) ExpandSlaveGroupNodes(); 182 else resourcesTreeView.ExpandAll(); 183 } 184 #endregion 185 186 #region Events 187 private void resourcesTreeView_AfterCheck(object sender, TreeViewEventArgs e) { 188 //if (e.Action != TreeViewAction.Unknown) { 189 // if (e.Node.Checked) { 190 // IncludeChildNodes(mainTreeNodes.SingleOrDefault(x => ((Project)x.Tag).Id == ((Project)e.Node.Tag).Id)); 191 // IncludeParentNodes(mainTreeNodes.SingleOrDefault(x => ((Project)x.Tag).Id == ((Project)e.Node.Tag).Id)); 192 // } else { 193 // ExcludeChildNodes(mainTreeNodes.SingleOrDefault(x => ((Project)x.Tag).Id == ((Project)e.Node.Tag).Id)); 194 // ExcludeParentNodes(mainTreeNodes.SingleOrDefault(x => ((Project)x.Tag).Id == ((Project)e.Node.Tag).Id)); 195 // } 196 // ExtractStatistics(); 197 //} 198 } 199 200 private void resourcesTreeView_AfterSelect(object sender, TreeViewEventArgs e) { 201 if (e.Action != TreeViewAction.Unknown) { 202 ExtractStatistics(e.Node); 203 } 204 } 205 206 private void searchTextBox_TextChanged(object sender, System.EventArgs e) { 207 currentSearchString = searchTextBox.Text.ToLower(); 208 UpdateFilteredTree(); 209 } 210 #endregion 211 212 #region Helpers 217 else projectsTreeView.ExpandAll(); 218 } 219 220 private void TraverseParentNodes(TreeNode node) { 221 if (node != null) { 222 for (TreeNode parent = node.Parent; parent != null; parent = parent.Parent) 223 filteredTreeNodes.Add(parent); 224 } 225 } 226 227 private void UpdateResources() { 228 selectedResources.Clear(); 229 230 if (selectedProject != null) { 231 var assignedResources = HiveServiceLocator.Instance.CallHiveService(s => s.GetAssignedResourcesForProject(selectedProject.Id)); 232 var assignedResourceIds = new HashSet<Guid>(assignedResources.Select(x => x.ResourceId)); 233 234 foreach (var resource in HiveAdminClient.Instance.Resources) { 235 if (assignedResourceIds.Contains(resource.Id)) { 236 resources.Add(resource); 237 selectedResources.Add(resource); 238 } 239 } 240 } 241 242 BuildResourceTree(selectedResources); 243 ExtractStatistics(); 244 OnSelectedResourcesChanged(); 245 } 246 247 private Resource BuildResourceTree(IEnumerable<Resource> resources) { 248 resourcesTreeView.Nodes.Clear(); 249 if (!resources.Any()) return null; 250 251 var mainResources = new HashSet<Resource>(resources.Where(x => x.ParentResourceId == null)); 252 var subResources = new HashSet<Resource>(resources.Except(mainResources)); 253 254 var stack = new Stack<Resource>(mainResources.OrderByDescending(x => x.Name)); 255 var top = stack.Peek(); 256 257 TreeNode currentNode = null; 258 Resource currentResource = null; 259 260 while (stack.Any()) { 261 var newResource = stack.Pop(); 262 var newNode = new TreeNode(newResource.Name) { 263 Checked = true, 264 ImageIndex = newResource is Slave ? slaveImageIndex : slaveGroupImageIndex, 265 Tag = newResource 266 }; 267 268 while (currentNode != null && newResource.ParentResourceId != currentResource.Id) { 269 currentNode = currentNode.Parent; 270 currentResource = currentNode == null ? null : (Resource)currentNode.Tag; 271 } 272 273 if (currentNode == null) { 274 resourcesTreeView.Nodes.Add(newNode); 275 } else { 276 currentNode.Nodes.Add(newNode); 277 } 278 279 newNode.SelectedImageIndex = newNode.ImageIndex; 280 281 var childResources = subResources.Where(x => x.ParentResourceId == newResource.Id); 282 if (childResources.Any()) { 283 foreach (var resource in childResources.OrderByDescending(x => x.Name)) { 284 subResources.Remove(resource); 285 stack.Push(resource); 286 } 287 currentNode = newNode; 288 currentResource = newResource; 289 } 290 } 291 292 resourcesTreeView.ExpandAll(); 293 294 return top; 295 } 296 213 297 private void ExpandSlaveGroupNodes() { 214 298 foreach (TreeNode n in nodeStore.Where(x => x.Tag is SlaveGroup)) { … … 219 303 } 220 304 221 private void ExtractStatistics(TreeNode treeNode = null) { 222 //StringBuilder sb = new StringBuilder(); 223 //Resource resource = treeNode == null ? null : treeNode.Tag as Resource; 224 //ISet<Resource> resources = treeNode == null ? selectedResources : new HashSet<Resource>(treeNode.DescendantNodes().Select(x => x.Tag as Resource)); ; 225 //IEnumerable<SlaveGroup> slaveGroups = resources.OfType<SlaveGroup>(); 226 //IEnumerable<Slave> slaves = resources.OfType<Slave>(); 227 //int cpuSpeed = 0, cores = 0, freeCores = 0, memory = 0, freeMemory = 0; 228 //string contextString = treeNode == null ? "Selected" : "Included"; 229 230 //if (resources.Any() || resource != null) { 231 // foreach (Slave s in slaves) { 232 // cpuSpeed += s.CpuSpeed.GetValueOrDefault(); 233 // cores += s.Cores.GetValueOrDefault(); 234 // freeCores += s.FreeCores.GetValueOrDefault(); 235 // memory += s.Memory.GetValueOrDefault(); 236 // freeMemory += s.FreeMemory.GetValueOrDefault(); 237 // } 238 // if (resource != null) { 239 // if (resource is SlaveGroup) sb.Append("Slave group: "); 240 // else if (resource is Slave) { 241 // sb.Append("Slave: "); 242 // if (!resources.Any()) { 243 // Slave s = resource as Slave; 244 // cpuSpeed = s.CpuSpeed.GetValueOrDefault(); 245 // cores = s.Cores.GetValueOrDefault(); 246 // freeCores = s.FreeCores.GetValueOrDefault(); 247 // memory = s.Memory.GetValueOrDefault(); 248 // freeMemory = s.FreeMemory.GetValueOrDefault(); 249 // } 250 // } 251 // sb.AppendLine(string.Format("{0}", resource.Name)); 252 // } 253 // if (resource == null || resource is SlaveGroup) { 254 // if (resources.Any()) { 255 // sb.AppendFormat("{0} slave groups ({1}): ", contextString, slaveGroups.Count()); 256 // foreach (SlaveGroup sg in slaveGroups) sb.AppendFormat("{0}; ", sg.Name); 257 // sb.AppendLine(); 258 // sb.AppendFormat("{0} slaves ({1}): ", contextString, slaves.Count()); 259 // foreach (Slave s in slaves) sb.AppendFormat("{0}; ", s.Name); 260 // sb.AppendLine(); 261 // } else { 262 // sb.Append("The selection does not inlcude any further resources."); 263 // } 264 // } 265 // sb.AppendLine(); 266 // sb.AppendLine(string.Format("CPU speed: {0} MHz", cpuSpeed)); 267 // if (resources.Any()) sb.AppendLine(string.Format("Avg. CPU speed: {0:0.00} MHz", (double)cpuSpeed / resources.Count())); 268 // sb.AppendLine(string.Format("Cores: {0}", cores)); 269 // sb.AppendLine(string.Format("Free cores: {0}", freeCores)); 270 // if (resources.Any()) sb.AppendLine(string.Format("Avg. free cores: {0:0.00}", (double)freeCores / resources.Count())); 271 // sb.AppendLine(string.Format("Memory: {0} MB", memory)); 272 // sb.AppendFormat("Free memory: {0} MB", freeMemory); 273 // if (resources.Any()) sb.Append(string.Format("{0}Avg. free memory: {1:0.00} MB", Environment.NewLine, (double)freeMemory / resources.Count())); 274 //} else { 275 // sb.Append("No resources selected."); 276 //} 277 278 //descriptionTextBox.Text = sb.ToString(); 305 private void ExtractStatistics(Resource resource = null) { 306 ISet<Slave> selectedSlaves = null; 307 308 if (resource != null) { 309 var slaveGroup = resource as SlaveGroup; 310 if (slaveGroup != null) { 311 var children = new HashSet<Resource>(resources.Where(x => x.ParentResourceId == slaveGroup.Id)); 312 int nrOfChildren = children.Count; 313 do { 314 var newChildren = resources.Where(x => children.Any(y => y.Id == x.ParentResourceId)); 315 foreach (var newChild in newChildren) 316 children.Add(newChild); 317 } while (children.Count > nrOfChildren); 318 selectedSlaves = new HashSet<Slave>(children.OfType<Slave>()); 319 selectedSlaves.IntersectWith(selectedResources.OfType<Slave>()); 320 } else { 321 selectedSlaves = new HashSet<Slave>(new[] { resource as Slave }); 322 } 323 } else { 324 selectedSlaves = new HashSet<Slave>(selectedResources.OfType<Slave>()); 325 } 326 327 int sumCores = selectedSlaves.OfType<Slave>().Sum(x => x.Cores.GetValueOrDefault()); 328 int sumFreeCores = selectedSlaves.OfType<Slave>().Sum(x => x.FreeCores.GetValueOrDefault()); 329 double sumMemory = selectedSlaves.OfType<Slave>().Sum(x => x.Memory.GetValueOrDefault()) / 1024.0; 330 double sumFreeMemory = selectedSlaves.OfType<Slave>().Sum(x => x.FreeMemory.GetValueOrDefault()) / 1024.0; 331 332 coresSummaryLabel.Text = $"{sumCores} Total ({sumFreeCores} Free / {sumCores - sumFreeCores} Used)"; 333 memorySummaryLabel.Text = $"{sumMemory:0.00} GB Total ({sumFreeMemory:0.00} GB Free / {(sumMemory - sumFreeMemory):0.00} GB Used)"; 334 } 335 #endregion 336 337 #region Events 338 public event EventHandler SelectedProjectChanged; 339 private void OnSelectedProjectChanged() { 340 SelectedProjectChanged?.Invoke(this, EventArgs.Empty); 341 } 342 343 public event EventHandler SelectedResourcesChanged; 344 private void OnSelectedResourcesChanged() { 345 SelectedResourcesChanged?.Invoke(this, EventArgs.Empty); 346 } 347 348 public event EventHandler ProjectsTreeViewDoubleClicked; 349 private void OnProjectsTreeViewDoubleClicked() { 350 ProjectsTreeViewDoubleClicked?.Invoke(this, EventArgs.Empty); 279 351 } 280 352 #endregion -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelectorDialog.Designer.cs
r15401 r15412 94 94 this.hiveResourceSelector.Name = "hiveResourceSelector"; 95 95 this.hiveResourceSelector.ReadOnly = false; 96 this.hiveResourceSelector.SelectedProject = null; 96 97 this.hiveResourceSelector.Size = new System.Drawing.Size(549, 591); 97 98 this.hiveResourceSelector.TabIndex = 0; 99 this.hiveResourceSelector.SelectedProjectChanged += new System.EventHandler(this.hiveResourceSelector_SelectedProjectChanged); 100 this.hiveResourceSelector.SelectedResourcesChanged += new System.EventHandler(this.hiveResourceSelector_SelectedResourcesChanged); 101 this.hiveResourceSelector.ProjectsTreeViewDoubleClicked += new System.EventHandler(this.hiveResourceSelector_ProjectsTreeViewDoubleClicked); 98 102 // 99 103 // HiveResourceSelectorDialog … … 114 118 this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent; 115 119 this.Text = "Select Project"; 116 this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.HiveResourceSelectorDialog_FormClosing);117 120 this.Load += new System.EventHandler(this.HiveResourceSelectorDialog_Load); 118 121 this.ResumeLayout(false); … … 124 127 protected System.Windows.Forms.Button okButton; 125 128 protected System.Windows.Forms.Button cancelButton; 129 protected System.Windows.Forms.Button refreshButton; 126 130 protected HiveProjectSelector hiveResourceSelector; 127 protected System.Windows.Forms.Button refreshButton;128 131 } 129 132 } -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelectorDialog.cs
r15401 r15412 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 using System.Threading.Tasks; 24 using System.ComponentModel; 25 using System.Linq; 24 26 using System.Windows.Forms; 25 using HeuristicLab.PluginInfrastructure; 27 using HeuristicLab.Clients.Hive.Views; 28 using HeuristicLab.MainForm; 26 29 27 30 namespace HeuristicLab.Clients.Hive.JobManager.Views { 28 31 public partial class HiveResourceSelectorDialog : Form { 32 private readonly object locker = new object(); 33 private bool updatingProjects = false; 34 35 public Project SelectedProject { 36 get { return hiveResourceSelector.SelectedProject; } 37 } 38 39 public IEnumerable<Resource> SelectedResources { 40 get { return hiveResourceSelector.SelectedResources; } 41 } 42 29 43 public HiveResourceSelectorDialog() { 30 44 InitializeComponent(); 31 45 } 32 46 33 public ISet<Project> GetSelectedResources() { return hiveResourceSelector.SelectedResources; } 34 public Project SelectedProject { get { return hiveResourceSelector.SelectedProject; } } 35 36 private void HiveResourceSelectorDialog_Load(object sender, System.EventArgs e) { 37 HiveAdminClient.Instance.Refreshed += new System.EventHandler(Instance_Refreshed); 38 DownloadResources(); 47 #region Overrides 48 protected override void OnLoad(EventArgs e) { 49 HiveAdminClient.Instance.Refreshing += HiveAdminClient_Instance_Refreshing; 50 HiveAdminClient.Instance.Refreshed += HiveAdminClient_Instance_Refreshed; 51 base.OnLoad(e); 39 52 } 40 53 41 private void HiveResourceSelectorDialog_FormClosing(object sender, FormClosingEventArgs e) { 42 HiveAdminClient.Instance.Refreshed -= new System.EventHandler(Instance_Refreshed); 54 protected override void OnClosing(CancelEventArgs e) { 55 HiveAdminClient.Instance.Refreshed -= HiveAdminClient_Instance_Refreshed; 56 HiveAdminClient.Instance.Refreshing -= HiveAdminClient_Instance_Refreshing; 57 base.OnClosing(e); 58 } 59 #endregion 60 61 #region Event Handlers 62 private void HiveAdminClient_Instance_Refreshing(object sender, EventArgs e) { 63 if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshing, sender, e); 64 else { 65 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 66 mainForm.AddOperationProgressToView(this, "Refreshing ..."); 67 refreshButton.Enabled = false; 68 } 43 69 } 44 70 45 void Instance_Refreshed(object sender, System.EventArgs e) { 71 private void HiveAdminClient_Instance_Refreshed(object sender, EventArgs e) { 72 if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshed, sender, e); 73 else { 74 var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>(); 75 mainForm.RemoveOperationProgressFromView(this); 76 refreshButton.Enabled = true; 77 } 78 } 79 80 private async void HiveResourceSelectorDialog_Load(object sender, EventArgs e) { 81 lock (locker) { 82 if (updatingProjects) return; 83 updatingProjects = true; 84 } 85 86 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 87 action: () => UpdateProjects(), 88 finallyCallback: () => updatingProjects = false); 89 } 90 91 private async void refreshButton_Click(object sender, EventArgs e) { 92 lock (locker) { 93 if (updatingProjects) return; 94 updatingProjects = true; 95 } 96 97 await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions( 98 action: () => UpdateProjects(), 99 finallyCallback: () => updatingProjects = false); 100 } 101 102 private void hiveResourceSelector_SelectedProjectChanged(object sender, EventArgs e) { 103 okButton.Enabled = hiveResourceSelector.SelectedProject != null; 104 } 105 106 private void hiveResourceSelector_SelectedResourcesChanged(object sender, EventArgs e) { 107 okButton.Enabled = hiveResourceSelector.SelectedResources.Any(); 108 } 109 110 private void hiveResourceSelector_ProjectsTreeViewDoubleClicked(object sender, EventArgs e) { 111 if (hiveResourceSelector.SelectedProject == null) return; 112 113 DialogResult = DialogResult.OK; 114 Close(); 115 } 116 #endregion 117 118 #region Helpers 119 private void UpdateProjects() { 120 HiveAdminClient.Instance.Refresh(); 46 121 hiveResourceSelector.Content = HiveAdminClient.Instance.Projects; 47 122 } 48 123 49 private void refreshButton_Click(object sender, System.EventArgs e) { 50 DownloadResources(); 124 private void ShowHiveInformationDialog() { 125 if (InvokeRequired) Invoke((Action)ShowHiveInformationDialog); 126 else { 127 using (HiveInformationDialog dialog = new HiveInformationDialog()) { 128 dialog.ShowDialog(this); 129 } 130 } 51 131 } 52 53 private void DownloadResources() { 54 var task = System.Threading.Tasks.Task.Factory.StartNew(DownloadResourcesAsync); 55 task.ContinueWith(t => { 56 hiveResourceSelector.FinishProgressView(); 57 ErrorHandling.ShowErrorDialog(this, "An error occurred while downloading the tasks.", t.Exception); 58 }, TaskContinuationOptions.OnlyOnFaulted); 59 } 60 61 private void DownloadResourcesAsync() { 62 hiveResourceSelector.StartProgressView(); 63 HiveAdminClient.Instance.Refresh(); 64 hiveResourceSelector.FinishProgressView(); 65 } 132 #endregion 66 133 } 67 134 } -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.Designer.cs
r14901 r15412 51 51 this.permissionTabPage = new System.Windows.Forms.TabPage(); 52 52 this.refreshPermissionsButton = new System.Windows.Forms.Button(); 53 this.hiveExperimentPermissionListView = new HeuristicLab.Clients.Hive.JobManager.Views.HiveJobPermissionListView();54 53 this.runsTabPage = new System.Windows.Forms.TabPage(); 55 54 this.runCollectionViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); … … 63 62 this.executionTimeTextBox = new System.Windows.Forms.TextBox(); 64 63 this.pauseButton = new System.Windows.Forms.Button(); 65 this. resourceIdsLabel = new System.Windows.Forms.Label();66 this. resourceNamesTextBox = new System.Windows.Forms.TextBox();64 this.projectLabel = new System.Windows.Forms.Label(); 65 this.projectNameTextBox = new System.Windows.Forms.TextBox(); 67 66 this.nameLabel = new System.Windows.Forms.Label(); 68 67 this.nameTextBox = new System.Windows.Forms.TextBox(); … … 79 78 this.jobsLabel = new System.Windows.Forms.Label(); 80 79 this.searchButton = new System.Windows.Forms.Button(); 80 this.hiveExperimentPermissionListView = new HeuristicLab.Clients.Hive.JobManager.Views.HiveJobPermissionListView(); 81 81 this.tabControl.SuspendLayout(); 82 82 this.tasksTabPage.SuspendLayout(); … … 91 91 // 92 92 this.tabControl.AllowDrop = true; 93 this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 94 | System.Windows.Forms.AnchorStyles.Left) 93 this.tabControl.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 94 | System.Windows.Forms.AnchorStyles.Left) 95 95 | System.Windows.Forms.AnchorStyles.Right))); 96 96 this.tabControl.Controls.Add(this.tasksTabPage); … … 119 119 // 120 120 this.jobsTreeView.AllowDrop = true; 121 this.jobsTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 122 | System.Windows.Forms.AnchorStyles.Left) 121 this.jobsTreeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 122 | System.Windows.Forms.AnchorStyles.Left) 123 123 | System.Windows.Forms.AnchorStyles.Right))); 124 124 this.jobsTreeView.Caption = "ItemTree View"; … … 155 155 this.refreshPermissionsButton.Click += new System.EventHandler(this.refreshPermissionsButton_Click); 156 156 // 157 // hiveExperimentPermissionListView158 //159 this.hiveExperimentPermissionListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)160 | System.Windows.Forms.AnchorStyles.Left)161 | System.Windows.Forms.AnchorStyles.Right)));162 this.hiveExperimentPermissionListView.Caption = "HiveExperimentPermissionList View";163 this.hiveExperimentPermissionListView.Content = null;164 this.hiveExperimentPermissionListView.HiveExperimentId = new System.Guid("00000000-0000-0000-0000-000000000000");165 this.hiveExperimentPermissionListView.Location = new System.Drawing.Point(3, 33);166 this.hiveExperimentPermissionListView.Name = "hiveExperimentPermissionListView";167 this.hiveExperimentPermissionListView.ReadOnly = false;168 this.hiveExperimentPermissionListView.ShowDetails = true;169 this.hiveExperimentPermissionListView.Size = new System.Drawing.Size(703, 390);170 this.hiveExperimentPermissionListView.TabIndex = 0;171 //172 157 // runsTabPage 173 158 // … … 183 168 // runCollectionViewHost 184 169 // 185 this.runCollectionViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 186 | System.Windows.Forms.AnchorStyles.Left) 170 this.runCollectionViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 171 | System.Windows.Forms.AnchorStyles.Left) 187 172 | System.Windows.Forms.AnchorStyles.Right))); 188 173 this.runCollectionViewHost.Caption = "View"; … … 209 194 // stateLogViewHost 210 195 // 211 this.stateLogViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 212 | System.Windows.Forms.AnchorStyles.Left) 196 this.stateLogViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 197 | System.Windows.Forms.AnchorStyles.Left) 213 198 | System.Windows.Forms.AnchorStyles.Right))); 214 199 this.stateLogViewHost.Caption = "StateLog View"; … … 235 220 // logView 236 221 // 237 this.logView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 238 | System.Windows.Forms.AnchorStyles.Left) 222 this.logView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 223 | System.Windows.Forms.AnchorStyles.Left) 239 224 | System.Windows.Forms.AnchorStyles.Right))); 240 225 this.logView.Caption = "Log View"; … … 302 287 this.pauseButton.Click += new System.EventHandler(this.pauseButton_Click); 303 288 // 304 // resourceIdsLabel 305 // 306 this.resourceIdsLabel.AutoSize = true; 307 this.resourceIdsLabel.Location = new System.Drawing.Point(3, 56); 308 this.resourceIdsLabel.Name = "resourceIdsLabel"; 309 this.resourceIdsLabel.Size = new System.Drawing.Size(61, 13); 310 this.resourceIdsLabel.TabIndex = 12; 311 this.resourceIdsLabel.Text = "Resources:"; 312 // 313 // resourceNamesTextBox 314 // 315 this.resourceNamesTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 316 | System.Windows.Forms.AnchorStyles.Right))); 317 this.resourceNamesTextBox.Location = new System.Drawing.Point(70, 52); 318 this.resourceNamesTextBox.Name = "resourceNamesTextBox"; 319 this.resourceNamesTextBox.Size = new System.Drawing.Size(471, 20); 320 this.resourceNamesTextBox.TabIndex = 2; 321 this.resourceNamesTextBox.Validated += new System.EventHandler(this.resourceNamesTextBox_Validated); 289 // projectLabel 290 // 291 this.projectLabel.AutoSize = true; 292 this.projectLabel.Location = new System.Drawing.Point(3, 56); 293 this.projectLabel.Name = "projectLabel"; 294 this.projectLabel.Size = new System.Drawing.Size(43, 13); 295 this.projectLabel.TabIndex = 12; 296 this.projectLabel.Text = "Project:"; 297 // 298 // projectNameTextBox 299 // 300 this.projectNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 301 | System.Windows.Forms.AnchorStyles.Right))); 302 this.projectNameTextBox.Location = new System.Drawing.Point(82, 52); 303 this.projectNameTextBox.Name = "projectNameTextBox"; 304 this.projectNameTextBox.ReadOnly = true; 305 this.projectNameTextBox.Size = new System.Drawing.Size(489, 20); 306 this.projectNameTextBox.TabIndex = 2; 307 this.projectNameTextBox.Validated += new System.EventHandler(this.resourceNamesTextBox_Validated); 322 308 // 323 309 // nameLabel … … 332 318 // nameTextBox 333 319 // 334 this.nameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 335 | System.Windows.Forms.AnchorStyles.Right))); 336 this.nameTextBox.Location = new System.Drawing.Point( 70, 27);320 this.nameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 321 | System.Windows.Forms.AnchorStyles.Right))); 322 this.nameTextBox.Location = new System.Drawing.Point(52, 27); 337 323 this.nameTextBox.Name = "nameTextBox"; 338 this.nameTextBox.Size = new System.Drawing.Size(5 01, 20);324 this.nameTextBox.Size = new System.Drawing.Size(519, 20); 339 325 this.nameTextBox.TabIndex = 1; 340 326 this.nameTextBox.Validated += new System.EventHandler(this.nameTextBox_Validated); … … 391 377 // finishedTextBox 392 378 // 393 this.finishedTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 379 this.finishedTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 394 380 | System.Windows.Forms.AnchorStyles.Right))); 395 381 this.finishedTextBox.Location = new System.Drawing.Point(74, 64); … … 400 386 // calculatingTextBox 401 387 // 402 this.calculatingTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 388 this.calculatingTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 403 389 | System.Windows.Forms.AnchorStyles.Right))); 404 390 this.calculatingTextBox.Location = new System.Drawing.Point(74, 40); … … 409 395 // jobsTextBox 410 396 // 411 this.jobsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 397 this.jobsTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 412 398 | System.Windows.Forms.AnchorStyles.Right))); 413 399 this.jobsTextBox.Location = new System.Drawing.Point(74, 16); … … 445 431 // searchButton 446 432 // 447 this.searchButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));448 433 this.searchButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Zoom; 449 this.searchButton.Location = new System.Drawing.Point(5 47, 50);434 this.searchButton.Location = new System.Drawing.Point(52, 50); 450 435 this.searchButton.Name = "searchButton"; 451 436 this.searchButton.Size = new System.Drawing.Size(24, 24); … … 453 438 this.searchButton.UseVisualStyleBackColor = true; 454 439 this.searchButton.Click += new System.EventHandler(this.searchButton_Click); 440 // 441 // hiveExperimentPermissionListView 442 // 443 this.hiveExperimentPermissionListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 444 | System.Windows.Forms.AnchorStyles.Left) 445 | System.Windows.Forms.AnchorStyles.Right))); 446 this.hiveExperimentPermissionListView.Caption = "HiveExperimentPermissionList View"; 447 this.hiveExperimentPermissionListView.Content = null; 448 this.hiveExperimentPermissionListView.HiveExperimentId = new System.Guid("00000000-0000-0000-0000-000000000000"); 449 this.hiveExperimentPermissionListView.Location = new System.Drawing.Point(3, 33); 450 this.hiveExperimentPermissionListView.Name = "hiveExperimentPermissionListView"; 451 this.hiveExperimentPermissionListView.ReadOnly = false; 452 this.hiveExperimentPermissionListView.ShowDetails = true; 453 this.hiveExperimentPermissionListView.Size = new System.Drawing.Size(703, 390); 454 this.hiveExperimentPermissionListView.TabIndex = 0; 455 455 // 456 456 // RefreshableHiveJobView … … 468 468 this.Controls.Add(this.executionTimeTextBox); 469 469 this.Controls.Add(this.executionTimeLabel); 470 this.Controls.Add(this. resourceNamesTextBox);470 this.Controls.Add(this.projectNameTextBox); 471 471 this.Controls.Add(this.pauseButton); 472 this.Controls.Add(this. resourceIdsLabel);472 this.Controls.Add(this.projectLabel); 473 473 this.Controls.Add(this.stopButton); 474 474 this.Name = "RefreshableHiveJobView"; … … 493 493 private System.Windows.Forms.TextBox executionTimeTextBox; 494 494 private System.Windows.Forms.Button pauseButton; 495 private System.Windows.Forms.Label resourceIdsLabel;496 private System.Windows.Forms.TextBox resourceNamesTextBox;495 private System.Windows.Forms.Label projectLabel; 496 private System.Windows.Forms.TextBox projectNameTextBox; 497 497 private System.Windows.Forms.TabPage logTabPage; 498 498 private Core.Views.LogView logView; -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
r15401 r15412 23 23 using System.ComponentModel; 24 24 using System.Linq; 25 using System.Text;26 25 using System.Threading; 27 26 using System.Threading.Tasks; … … 118 117 nameTextBox.Text = string.Empty; 119 118 executionTimeTextBox.Text = string.Empty; 120 resourceNamesTextBox.Text = string.Empty;119 projectNameTextBox.Text = string.Empty; 121 120 refreshAutomaticallyCheckBox.Checked = false; 122 121 lock (runCollectionViewLocker) { … … 137 136 } 138 137 } 139 } 140 finally { 138 } finally { 141 139 SuppressEvents = false; 142 140 } … … 158 156 tabControl.Enabled = !Locked; 159 157 nameTextBox.Enabled = !Locked; 160 resourceNamesTextBox.Enabled = !Locked;158 projectNameTextBox.Enabled = !Locked; 161 159 searchButton.Enabled = !Locked; 162 160 jobsTreeView.Enabled = !Locked; … … 183 181 184 182 this.nameTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing; 185 this.resourceNamesTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;186 183 this.searchButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Prepared && !alreadyUploaded && !Content.IsProgressing; 187 184 this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing; … … 335 332 if (hiveResourceSelectorDialog == null) 336 333 hiveResourceSelectorDialog = new HiveResourceSelectorDialog(); 334 337 335 if (hiveResourceSelectorDialog.ShowDialog(this) == DialogResult.OK) { 338 StringBuilder sb = new StringBuilder();339 //foreach (Project resource in hiveResourceSelectorDialog.GetSelectedResources()) {340 // sb.Append(resource.Name);341 // sb.Append(";");342 //}343 //resourceNamesTextBox.Text = sb.ToString();344 //if (Content.Job.ResourceNames != resourceNamesTextBox.Text)345 // Content.Job.ResourceNames = resourceNamesTextBox.Text;346 336 var selectedProject = hiveResourceSelectorDialog.SelectedProject; 347 resourceNamesTextBox.Text = selectedProject.Name;348 if (Content.Job.ProjectId != selectedProject.Id)349 Content.Job.ProjectId = selectedProject.Id;337 projectNameTextBox.Text = selectedProject.Name; 338 Content.Job.ProjectId = selectedProject.Id; 339 Content.Job.ResourceIds = hiveResourceSelectorDialog.SelectedResources.Select(x => x.Id).ToList(); 350 340 } 351 341 } … … 421 411 try { 422 412 invoker.EndInvoke(ar); 423 } 424 catch (Exception ex) { 425 ThreadPool.QueueUserWorkItem(delegate(object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex); 413 } catch (Exception ex) { 414 ThreadPool.QueueUserWorkItem(delegate (object exception) { ErrorHandling.ShowErrorDialog(this, (Exception)exception); }, ex); 426 415 } 427 416 }, null); … … 510 499 if (subTask is OptimizerHiveTask) { 511 500 OptimizerHiveTask ohTask = subTask as OptimizerHiveTask; 512 ohTask.ExecuteReadActionOnItemTask(new Action(delegate () {501 ohTask.ExecuteReadActionOnItemTask(new Action(delegate () { 513 502 runs.AddRange(ohTask.ItemTask.Item.Runs); 514 503 })); -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveClient.cs
r15401 r15412 255 255 refreshableJob.IsProgressing = true; 256 256 refreshableJob.Progress.Start("Connecting to server..."); 257 IEnumerable<string> resourceNames = ToResourceNameList("");258 var resourceIds = new List<Guid>();259 foreach (var resourceName in resourceNames) {260 Guid resourceId = HiveServiceLocator.Instance.CallHiveService((s) => s.GetResourceId(resourceName));261 if (resourceId == Guid.Empty) {262 throw new ResourceNotFoundException(string.Format("Could not find the resource '{0}'", resourceName));263 }264 resourceIds.Add(resourceId);265 }266 257 267 258 foreach (OptimizerHiveTask hiveJob in refreshableJob.HiveTasks.OfType<OptimizerHiveTask>()) { … … 293 284 foreach (HiveTask hiveTask in refreshableJob.HiveTasks) { 294 285 var task = TS.Task.Factory.StartNew((hj) => { 295 UploadTaskWithChildren(refreshableJob.Progress, (HiveTask)hj, null, re sourceIds, jobCount, totalJobCount, configFilePlugin.Id, refreshableJob.Job.Id, refreshableJob.Log, cancellationToken);286 UploadTaskWithChildren(refreshableJob.Progress, (HiveTask)hj, null, refreshableJob.Job.ResourceIds, jobCount, totalJobCount, configFilePlugin.Id, refreshableJob.Job.Id, refreshableJob.Log, cancellationToken); 296 287 }, hiveTask); 297 288 task.ContinueWith((x) => refreshableJob.Log.LogException(x.Exception), TaskContinuationOptions.OnlyOnFaulted); … … 377 368 hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddChildTask(parentHiveTask.Task.Id, hiveTask.Task, taskData)); 378 369 } else { 379 hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddTask(hiveTask.Task, taskData ));370 hiveTask.Task.Id = HiveServiceLocator.Instance.CallHiveService((s) => s.AddTask(hiveTask.Task, taskData, groups.ToList())); 380 371 } 381 372 } -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/ServiceClients/HiveServiceClient.cs
r15401 r15412 30 30 [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.PluginData))] 31 31 [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.ProjectPermission))] 32 [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.AssignedProjectResource))] 32 33 [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.Downtime))] 33 34 [System.Runtime.Serialization.KnownTypeAttribute(typeof(HeuristicLab.Clients.Hive.UserPriority))] … … 1166 1167 this.ProjectIdField = value; 1167 1168 this.RaisePropertyChanged("ProjectId"); 1169 } 1170 } 1171 } 1172 } 1173 1174 [System.Diagnostics.DebuggerStepThroughAttribute()] 1175 [System.CodeDom.Compiler.GeneratedCodeAttribute("System.Runtime.Serialization", "4.0.0.0")] 1176 [System.Runtime.Serialization.DataContractAttribute(Name="AssignedProjectResource", Namespace="http://schemas.datacontract.org/2004/07/HeuristicLab.Services.Hive.DataTransfer")] 1177 [System.SerializableAttribute()] 1178 public partial class AssignedProjectResource : HeuristicLab.Clients.Hive.HiveItem 1179 { 1180 1181 [System.Runtime.Serialization.OptionalFieldAttribute()] 1182 private System.Guid ProjectIdField; 1183 1184 [System.Runtime.Serialization.OptionalFieldAttribute()] 1185 private System.Guid ResourceIdField; 1186 1187 [System.Runtime.Serialization.DataMemberAttribute()] 1188 public System.Guid ProjectId 1189 { 1190 get 1191 { 1192 return this.ProjectIdField; 1193 } 1194 set 1195 { 1196 if ((this.ProjectIdField.Equals(value) != true)) 1197 { 1198 this.ProjectIdField = value; 1199 this.RaisePropertyChanged("ProjectId"); 1200 } 1201 } 1202 } 1203 1204 [System.Runtime.Serialization.DataMemberAttribute()] 1205 public System.Guid ResourceId 1206 { 1207 get 1208 { 1209 return this.ResourceIdField; 1210 } 1211 set 1212 { 1213 if ((this.ResourceIdField.Equals(value) != true)) 1214 { 1215 this.ResourceIdField = value; 1216 this.RaisePropertyChanged("ResourceId"); 1168 1217 } 1169 1218 } … … 2210 2259 2211 2260 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddTask", ReplyAction="http://tempuri.org/IHiveService/AddTaskResponse")] 2212 System.Guid AddTask(HeuristicLab.Clients.Hive.Task task, HeuristicLab.Clients.Hive.TaskData taskData );2261 System.Guid AddTask(HeuristicLab.Clients.Hive.Task task, HeuristicLab.Clients.Hive.TaskData taskData, System.Collections.Generic.List<System.Guid> resourceIds); 2213 2262 2214 2263 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddChildTask", ReplyAction="http://tempuri.org/IHiveService/AddChildTaskResponse")] … … 2318 2367 System.Collections.Generic.List<HeuristicLab.Clients.Hive.ProjectPermission> GetProjectPermissions(System.Guid projectId); 2319 2368 2369 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AssignProjectResources", ReplyAction="http://tempuri.org/IHiveService/AssignProjectResourcesResponse")] 2370 void AssignProjectResources(System.Guid projectId, System.Collections.Generic.List<System.Guid> resourceIds); 2371 2372 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/UnassignProjectResources", ReplyAction="http://tempuri.org/IHiveService/UnassignProjectResourcesResponse")] 2373 void UnassignProjectResources(System.Guid projectId, System.Collections.Generic.List<System.Guid> resourceIds); 2374 2375 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/GetAssignedResourcesForProject", ReplyAction="http://tempuri.org/IHiveService/GetAssignedResourcesForProjectResponse")] 2376 System.Collections.Generic.List<HeuristicLab.Clients.Hive.AssignedProjectResource> GetAssignedResourcesForProject(System.Guid projectId); 2377 2320 2378 [System.ServiceModel.OperationContractAttribute(Action="http://tempuri.org/IHiveService/AddSlave", ReplyAction="http://tempuri.org/IHiveService/AddSlaveResponse")] 2321 2379 System.Guid AddSlave(HeuristicLab.Clients.Hive.Slave slave); … … 2416 2474 } 2417 2475 2418 public System.Guid AddTask(HeuristicLab.Clients.Hive.Task task, HeuristicLab.Clients.Hive.TaskData taskData )2419 { 2420 return base.Channel.AddTask(task, taskData );2476 public System.Guid AddTask(HeuristicLab.Clients.Hive.Task task, HeuristicLab.Clients.Hive.TaskData taskData, System.Collections.Generic.List<System.Guid> resourceIds) 2477 { 2478 return base.Channel.AddTask(task, taskData, resourceIds); 2421 2479 } 2422 2480 … … 2596 2654 } 2597 2655 2656 public void AssignProjectResources(System.Guid projectId, System.Collections.Generic.List<System.Guid> resourceIds) 2657 { 2658 base.Channel.AssignProjectResources(projectId, resourceIds); 2659 } 2660 2661 public void UnassignProjectResources(System.Guid projectId, System.Collections.Generic.List<System.Guid> resourceIds) 2662 { 2663 base.Channel.UnassignProjectResources(projectId, resourceIds); 2664 } 2665 2666 public System.Collections.Generic.List<HeuristicLab.Clients.Hive.AssignedProjectResource> GetAssignedResourcesForProject(System.Guid projectId) 2667 { 2668 return base.Channel.GetAssignedResourcesForProject(projectId); 2669 } 2670 2598 2671 public System.Guid AddSlave(HeuristicLab.Clients.Hive.Slave slave) 2599 2672 { -
branches/HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/ServiceClients/Job.cs
r15401 r15412 21 21 22 22 using System; 23 using System.Collections.Generic; 23 24 using System.ComponentModel; 24 25 using HeuristicLab.Common; … … 26 27 namespace HeuristicLab.Clients.Hive { 27 28 public partial class Job : IDeepCloneable, IContent { 29 public List<Guid> ResourceIds { get; set; } 28 30 29 31 #region Constructors and Cloning … … 43 45 this.Id = original.Id; 44 46 this.Permission = original.Permission; 47 this.ResourceIds = original.ResourceIds; 45 48 } 46 49 public override IDeepCloneable Clone(Cloner cloner) {
Note: See TracChangeset
for help on using the changeset viewer.