Changeset 9223
- Timestamp:
- 02/18/13 15:08:46 (12 years ago)
- Location:
- trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobManagerView.cs
r9222 r9223 25 25 using System.Windows.Forms; 26 26 using HeuristicLab.Clients.Hive.Views; 27 using HeuristicLab.Collections;28 27 using HeuristicLab.MainForm; 29 28 using HeuristicLab.MainForm.WindowsForms; … … 54 53 Content.Refreshing += new EventHandler(Content_Refreshing); 55 54 Content.Refreshed += new EventHandler(Content_Refreshed); 56 Content.HiveJobsChanged += new EventHandler(Content_HiveJobsChanged);57 55 } 58 56 … … 60 58 Content.Refreshing -= new EventHandler(Content_Refreshing); 61 59 Content.Refreshed -= new EventHandler(Content_Refreshed); 62 Content.HiveJobsChanged -= new EventHandler(Content_HiveJobsChanged);63 60 base.DeregisterContentEvents(); 64 61 } … … 130 127 } else { 131 128 base.OnClosing(e); 132 if (Content != null && Content.Jobs != null) { 133 Content.Jobs.ItemsRemoved -= new CollectionItemsChangedEventHandler<RefreshableJob>(HiveExperiments_ItemsRemoved); 129 if (Content != null) { 134 130 Content.ClearHiveClient(); 135 131 Content = null; … … 137 133 } 138 134 } 139 140 private void HiveExperiments_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<RefreshableJob> e) {141 foreach (var item in e.Items) {142 HiveClient.Delete(item);143 }144 }145 146 private void Content_HiveJobsChanged(object sender, EventArgs e) {147 if (Content.Jobs != null) {148 Content.Jobs.ItemsRemoved += new CollectionItemsChangedEventHandler<RefreshableJob>(HiveExperiments_ItemsRemoved);149 }150 }151 135 } 152 136 } -
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.Designer.cs
r8924 r9223 27 27 private System.ComponentModel.IContainer components = null; 28 28 29 /// <summary>30 /// Clean up any resources being used.31 /// </summary>32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>33 protected override void Dispose(bool disposing) {34 if (disposing) {35 if (components != null) components.Dispose();36 }37 base.Dispose(disposing);38 }39 29 40 30 #region Component Designer generated code -
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.cs
r9107 r9223 21 21 22 22 using System; 23 using System.Collections.Generic; 24 using System.Threading.Tasks; 23 25 using System.Windows.Forms; 24 26 using HeuristicLab.Collections; 25 27 using HeuristicLab.Core; 26 28 using HeuristicLab.MainForm; 29 using HeuristicLab.MainForm.WindowsForms; 27 30 28 31 namespace HeuristicLab.Clients.Hive.JobManager.Views { … … 30 33 [Content(typeof(ItemCollection<RefreshableJob>), false)] 31 34 public partial class RefreshableHiveJobListView : HeuristicLab.Core.Views.ItemCollectionView<RefreshableJob> { 35 private Progress progress; 36 private ProgressView progressView; 32 37 33 38 public RefreshableHiveJobListView() { 34 39 InitializeComponent(); 35 40 itemsGroupBox.Text = "Jobs"; 36 this.itemsListView.View = View.Details;41 this.itemsListView.View = System.Windows.Forms.View.Details; 37 42 this.itemsListView.Columns.Clear(); 38 43 this.itemsListView.Columns.Add(new ColumnHeader("Date") { Text = "Date" }); … … 47 52 this.itemsListView.Sorting = SortOrder.Ascending; 48 53 this.itemsListView.Sort(); 54 55 progress = new Progress() { 56 CanBeCanceled = false, 57 ProgressState = ProgressState.Finished 58 }; 59 progressView = new ProgressView(this, progress); 49 60 } 50 61 … … 53 64 refreshableJob.Job.Name = "New Hive Job"; 54 65 return refreshableJob; 66 } 67 68 protected override void OnLockedChanged() { 69 base.OnLockedChanged(); 70 71 itemsListView.Enabled = !Locked; 72 addButton.Enabled = !Locked; 73 sortAscendingButton.Enabled = !Locked; 74 sortDescendingButton.Enabled = !Locked; 75 removeButton.Enabled = !Locked; 76 } 77 78 protected override void SetEnabledStateOfControls() { 79 // if the view is locked, a job is currently beeing deleted and everything should be disabled 80 if (!Locked) 81 base.SetEnabledStateOfControls(); 55 82 } 56 83 … … 72 99 return; 73 100 } else { 74 base.removeButton_Click(sender, e); 75 } 76 } 101 DeleteHiveJobs(e); 102 } 103 } 104 } 105 106 private void DeleteHiveJobs(EventArgs e) { 107 if (itemsListView.SelectedItems.Count > 0) { 108 List<RefreshableJob> items = new List<RefreshableJob>(); 109 foreach (ListViewItem item in itemsListView.SelectedItems) 110 items.Add((RefreshableJob)item.Tag); 111 112 var task = System.Threading.Tasks.Task.Factory.StartNew(DeleteHiveJobsAsync, items); 113 114 task.ContinueWith((t) => { 115 progress.Finish(); 116 MessageBox.Show("An error occured while deleting the job: " + Environment.NewLine + t.Exception, "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error); 117 }, TaskContinuationOptions.OnlyOnFaulted); 118 119 task.ContinueWith((t) => { 120 itemsListView.SelectedItems.Clear(); 121 }, TaskContinuationOptions.OnlyOnRanToCompletion); 122 } 123 } 124 125 private void DeleteHiveJobsAsync(object items) { 126 progress.Status = "Deleting job..."; 127 progress.ProgressState = ProgressState.Started; 128 progress.ProgressValue = 0.0; 129 foreach (RefreshableJob item in (List<RefreshableJob>)items) { 130 Content.Remove(item); 131 } 132 progress.Finish(); 77 133 } 78 134 … … 158 214 return newGroup; 159 215 } 216 217 /// <summary> 218 /// Clean up any resources being used. 219 /// </summary> 220 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> 221 protected override void Dispose(bool disposing) { 222 if (disposing) { 223 if (components != null) components.Dispose(); 224 progressView.Content = null; 225 progressView.Dispose(); 226 } 227 base.Dispose(disposing); 228 } 160 229 } 161 230 } -
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
r9219 r9223 166 166 } 167 167 168 protected override void OnLockedChanged() { 169 base.OnLockedChanged(); 170 executionTimeTextBox.Enabled = !Locked; 171 jobsTextBox.Enabled = !Locked; 172 calculatingTextBox.Enabled = !Locked; 173 finishedTextBox.Enabled = !Locked; 174 tabControl.Enabled = !Locked; 175 nameTextBox.Enabled = !Locked; 176 resourceNamesTextBox.Enabled = !Locked; 177 searchButton.Enabled = !Locked; 178 jobsTreeView.Enabled = !Locked; 179 isPrivilegedCheckBox.Enabled = !Locked; 180 refreshAutomaticallyCheckBox.Enabled = !Locked; 181 refreshButton.Enabled = !Locked; 182 UnloadButton.Enabled = !Locked; 183 startButton.Enabled = !Locked; 184 pauseButton.Enabled = !Locked; 185 stopButton.Enabled = !Locked; 186 resetButton.Enabled = !Locked; 187 } 188 168 189 protected override void SetEnabledStateOfControls() { 169 190 base.SetEnabledStateOfControls(); 170 executionTimeTextBox.Enabled = Content != null; 171 jobsTextBox.ReadOnly = true; 172 calculatingTextBox.ReadOnly = true; 173 finishedTextBox.ReadOnly = true; 174 175 if (Content != null) { 176 bool alreadyUploaded = Content.Id != Guid.Empty; 177 bool jobsLoaded = Content.HiveTasks != null && Content.HiveTasks.All(x => x.Task.Id != Guid.Empty); 178 tabControl.Enabled = !Content.IsProgressing; 179 180 this.nameTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing; 181 this.resourceNamesTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing; 182 this.searchButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Prepared && !alreadyUploaded && !Content.IsProgressing; 183 this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing; 184 185 this.isPrivilegedCheckBox.Enabled = HiveClient.Instance.IsAllowedPrivileged && Content.IsControllable && !(Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded) && !Content.IsProgressing; 186 this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing; 187 this.refreshButton.Enabled = Content.IsDownloadable && alreadyUploaded && !Content.IsProgressing; 188 this.Locked = !Content.IsControllable || Content.ExecutionState == ExecutionState.Started || Content.IsProgressing; 189 190 this.UnloadButton.Enabled = Content.HiveTasks != null && Content.HiveTasks.Count > 0 && alreadyUploaded && !Content.IsProgressing; 191 } 192 SetEnabledStateOfExecutableButtons(); 193 tabControl_SelectedIndexChanged(this, EventArgs.Empty); // ensure sharing tabpage is disabled 191 if (!Locked) { 192 executionTimeTextBox.Enabled = Content != null; 193 jobsTextBox.ReadOnly = true; 194 calculatingTextBox.ReadOnly = true; 195 finishedTextBox.ReadOnly = true; 196 197 if (Content != null) { 198 bool alreadyUploaded = Content.Id != Guid.Empty; 199 bool jobsLoaded = Content.HiveTasks != null && Content.HiveTasks.All(x => x.Task.Id != Guid.Empty); 200 tabControl.Enabled = !Content.IsProgressing; 201 202 this.nameTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing; 203 this.resourceNamesTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing; 204 this.searchButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Prepared && !alreadyUploaded && !Content.IsProgressing; 205 this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing; 206 207 this.isPrivilegedCheckBox.Enabled = HiveClient.Instance.IsAllowedPrivileged && Content.IsControllable && !(Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded) && !Content.IsProgressing; 208 this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing; 209 this.refreshButton.Enabled = Content.IsDownloadable && alreadyUploaded && !Content.IsProgressing; 210 211 this.UnloadButton.Enabled = Content.HiveTasks != null && Content.HiveTasks.Count > 0 && alreadyUploaded && !Content.IsProgressing; 212 } 213 SetEnabledStateOfExecutableButtons(); 214 tabControl_SelectedIndexChanged(this, EventArgs.Empty); // ensure sharing tabpage is disabled 215 } 194 216 } 195 217
Note: See TracChangeset
for help on using the changeset viewer.