Changeset 6006 for branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager
- Timestamp:
- 04/12/11 13:43:05 (14 years ago)
- Location:
- branches/HeuristicLab.Hive-3.4/sources
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HeuristicLab.Hive-3.4/sources
- Property svn:ignore
-
old new 4 4 PrecompiledWeb 5 5 CreateEventLogSources 6 WindowsFormsTestProject
-
- Property svn:ignore
-
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/HiveExperimentView.Designer.cs
r5955 r6006 54 54 this.viewExperimentButton = new System.Windows.Forms.Button(); 55 55 this.jobsTabPage = new System.Windows.Forms.TabPage(); 56 this.jobsTreeView = new HeuristicLab.Clients.Hive.Views.ItemTreeView ();56 this.jobsTreeView = new HeuristicLab.Clients.Hive.Views.ItemTreeView<HiveJob>(); 57 57 this.logTabPage = new System.Windows.Forms.TabPage(); 58 58 this.logView = new HeuristicLab.Core.Views.LogView(); … … 465 465 private System.Windows.Forms.CheckBox useLocalPluginsCheckBox; 466 466 private System.Windows.Forms.TabPage jobsTabPage; 467 private ItemTreeView jobsTreeView;467 private ItemTreeView<HiveJob> jobsTreeView; 468 468 private System.Windows.Forms.Label nameLabel; 469 469 private System.Windows.Forms.TextBox nameTextBox; -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/HiveExperimentView.cs
r5955 r6006 22 22 using System; 23 23 using System.ComponentModel; 24 using System.Linq; 24 25 using System.Threading; 25 26 using System.Windows.Forms; 27 using HeuristicLab.Collections; 26 28 using HeuristicLab.Common; 27 29 using HeuristicLab.Core; … … 34 36 /// The base class for visual representations of items. 35 37 /// </summary> 36 [View(" Experiment View")]38 [View("Hive Experiment View")] 37 39 [Content(typeof(HiveExperiment), true)] 38 40 public sealed partial class HiveExperimentView : ItemView { … … 52 54 53 55 protected override void DeregisterContentEvents() { 54 //Content.ExceptionOccurred -= new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);55 56 Content.ExecutionStateChanged -= new EventHandler(Content_ExecutionStateChanged); 56 57 Content.ExecutionTimeChanged -= new EventHandler(Content_ExecutionTimeChanged); 57 //Content.Prepared -= new EventHandler(Content_Prepared);58 //Content.Started -= new EventHandler(Content_Started);59 //Content.Paused -= new EventHandler(Content_Paused);60 //Content.Stopped -= new EventHandler(Content_Stopped);61 58 Content.RefreshAutomaticallyChanged -= new EventHandler(Content_RefreshAutomaticallyChanged); 62 Content.HiveJob Changed -= new EventHandler(Content_HiveJobChanged);59 Content.HiveJobsChanged -= new EventHandler(Content_HiveJobChanged); 63 60 Content.IsProgressingChanged -= new EventHandler(Content_IsProgressingChanged); 64 61 Content.PropertyChanged -= new System.ComponentModel.PropertyChangedEventHandler(Content_PropertyChanged); … … 68 65 protected override void RegisterContentEvents() { 69 66 base.RegisterContentEvents(); 70 //Content.ExceptionOccurred += new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred);71 67 Content.ExecutionStateChanged += new EventHandler(Content_ExecutionStateChanged); 72 68 Content.ExecutionTimeChanged += new EventHandler(Content_ExecutionTimeChanged); 73 //Content.Prepared += new EventHandler(Content_Prepared);74 //Content.Started += new EventHandler(Content_Started);75 //Content.Paused += new EventHandler(Content_Paused);76 //Content.Stopped += new EventHandler(Content_Stopped);77 69 Content.RefreshAutomaticallyChanged += new EventHandler(Content_RefreshAutomaticallyChanged); 78 Content.HiveJob Changed += new EventHandler(Content_HiveJobChanged);70 Content.HiveJobsChanged += new EventHandler(Content_HiveJobChanged); 79 71 Content.IsProgressingChanged += new EventHandler(Content_IsProgressingChanged); 80 72 Content.PropertyChanged += new System.ComponentModel.PropertyChangedEventHandler(Content_PropertyChanged); … … 119 111 120 112 if (Content != null) { 121 bool alreadyUploaded = Content. RootJobId != null && Content.Id != Guid.Empty;122 bool jobsLoaded = Content.HiveJob != null && Content.HiveJob.Job.Id != Guid.Empty;113 bool alreadyUploaded = Content.Id != Guid.Empty; 114 bool jobsLoaded = Content.HiveJobs != null && Content.HiveJobs.All(x => x.Job.Id != Guid.Empty); 123 115 124 116 this.nameTextBox.ReadOnly = Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded; … … 127 119 this.useLocalPluginsCheckBox.Enabled = !(Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded); 128 120 this.refreshAutomaticallyCheckBox.Enabled = alreadyUploaded && jobsLoaded && Content.ExecutionState == ExecutionState.Started; 129 this.viewExperimentButton.Enabled = Content.GetExperiment( ) != null;121 this.viewExperimentButton.Enabled = Content.GetExperiment(0) != null; 130 122 this.openExperimentButton.Enabled = !alreadyUploaded && Content.ExecutionState == ExecutionState.Prepared; 131 123 this.newExperimentButton.Enabled = !alreadyUploaded && Content.ExecutionState == ExecutionState.Prepared; … … 146 138 147 139 #region Content Events 140 private void HiveJobs_ItemsAdded_Removed_Reset(object sender, CollectionItemsChangedEventArgs<HiveJob> e) { 141 if (InvokeRequired) 142 Invoke(new CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset), sender, e); 143 else { 144 SetEnabledStateOfControls(); 145 } 146 } 148 147 private void Content_ExecutionStateChanged(object sender, EventArgs e) { 149 148 if (InvokeRequired) … … 192 191 executionTimeTextBox.Text = Content.ExecutionTime.ToString(); 193 192 } 194 private void Content_ExceptionOccurred(object sender, EventArgs<Exception> e) {195 if (InvokeRequired)196 Invoke(new EventHandler<EventArgs<Exception>>(Content_ExceptionOccurred), sender, e);197 else198 ErrorHandling.ShowErrorDialog(this, e.Value);199 }200 193 private void Content_RefreshAutomaticallyChanged(object sender, EventArgs e) { 201 194 if (InvokeRequired) … … 210 203 Invoke(new EventHandler(Content_HiveJobChanged), sender, e); 211 204 else { 212 if (Content != null) { 213 jobsTreeView.Content = Content.HiveJob; 214 experimentNamedItemView.Content = Content.GetExperiment(); 205 if (Content != null && Content.HiveJobs != null) { 206 jobsTreeView.Content = Content.HiveJobs; 207 experimentNamedItemView.Content = Content.GetExperiment(0); 208 RegisterHiveJobEvents(); 215 209 } else { 216 210 jobsTreeView.Content = null; … … 220 214 } 221 215 } 216 217 private void RegisterHiveJobEvents() { 218 Content.HiveJobs.ItemsAdded += new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset); 219 Content.HiveJobs.ItemsRemoved += new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset); 220 Content.HiveJobs.CollectionReset += new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset); 221 } 222 private void DeregisterHiveJobEvents() { 223 Content.HiveJobs.ItemsAdded -= new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset); 224 Content.HiveJobs.ItemsRemoved -= new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset); 225 Content.HiveJobs.CollectionReset -= new Collections.CollectionItemsChangedEventHandler<HiveJob>(HiveJobs_ItemsAdded_Removed_Reset); 226 } 227 222 228 private void Content_PropertyChanged(object sender, PropertyChangedEventArgs e) { 223 229 if (InvokeRequired) … … 241 247 ExperimentManagerClient.StopExperiment(Content); 242 248 } 243 private void resetButton_Click(object sender, EventArgs e) { 249 private void resetButton_Click(object sender, EventArgs e) { } 244 250 245 251 private void nameTextBox_Validated(object sender, EventArgs e) { … … 271 277 272 278 private void showExperimentButton_Click(object sender, EventArgs e) { 273 MainFormManager.MainForm.ShowContent(Content.GetExperiment( ));279 MainFormManager.MainForm.ShowContent(Content.GetExperiment(0)); 274 280 } 275 281 276 282 private void viewExperimentButton_Click(object sender, EventArgs e) { 277 MainFormManager.MainForm.ShowContent(Content.GetExperiment( ));283 MainFormManager.MainForm.ShowContent(Content.GetExperiment(0)); 278 284 } 279 285 … … 310 316 startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false; 311 317 } else { 312 startButton.Enabled = Content.GetExperiment( ) != null && Content.ExecutionState == ExecutionState.Prepared;318 startButton.Enabled = Content.GetExperiment(0) != null && Content.ExecutionState == ExecutionState.Prepared; 313 319 pauseButton.Enabled = Content.ExecutionState == ExecutionState.Started; 314 320 stopButton.Enabled = Content.ExecutionState == ExecutionState.Started; … … 346 352 } 347 353 #endregion 348 354 349 355 } 350 356 } -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/ItemTreeView.cs
r5797 r6006 24 24 using HeuristicLab.Collections; 25 25 using HeuristicLab.Common; 26 using HeuristicLab.Core; 26 27 using HeuristicLab.Core.Views; 27 28 using HeuristicLab.MainForm; … … 30 31 namespace HeuristicLab.Clients.Hive.Views { 31 32 [View("ItemTree View")] 32 [Content(typeof(IItemTree), IsDefaultView = false)] 33 public sealed partial class ItemTreeView : ItemView { 34 public new IItemTree Content { 35 get { return (IItemTree)base.Content; } 33 [Content(typeof(ItemCollection<>), IsDefaultView = false)] 34 [Content(typeof(ItemCollection<IItemTree>), IsDefaultView = true)] 35 public sealed partial class ItemTreeView<T> : ItemView where T : class, IItemTree { 36 public new ItemCollection<T> Content { 37 get { return (ItemCollection<T>)base.Content; } 36 38 set { base.Content = value; } 39 } 40 41 public T SelectedItem { 42 get { 43 if (treeView.SelectedNode != null) 44 return (T)treeView.SelectedNode.Tag; 45 return null; 46 } 37 47 } 38 48 … … 42 52 43 53 protected override void DeregisterContentEvents() { 54 Content.ItemsAdded -= new CollectionItemsChangedEventHandler<T>(Content_ItemsAdded); 55 Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<T>(Content_ItemsRemoved); 56 Content.CollectionReset -= new CollectionItemsChangedEventHandler<T>(Content_CollectionReset); 44 57 foreach (TreeNode node in treeView.Nodes) { 45 DeregisterContentEvents(( IItemTree)node.Tag, node);58 DeregisterContentEvents((T)node.Tag, node); 46 59 } 47 60 base.DeregisterContentEvents(); 48 61 } 49 62 50 private void DeregisterContentEvents( IItemTreeitem, TreeNode node) {63 private void DeregisterContentEvents(T item, TreeNode node) { 51 64 item.ItemsAdded -= new CollectionItemsChangedEventHandler<IItemTree>(item_ItemsAdded); 52 65 item.ItemsRemoved -= new CollectionItemsChangedEventHandler<IItemTree>(item_ItemsRemoved); … … 55 68 item.ItemImageChanged -= new EventHandler(item_ItemImageChanged); 56 69 foreach (TreeNode childNode in node.Nodes) { 57 DeregisterContentEvents(( IItemTree)childNode.Tag, childNode);70 DeregisterContentEvents((T)childNode.Tag, childNode); 58 71 } 59 72 } … … 61 74 protected override void RegisterContentEvents() { 62 75 base.RegisterContentEvents(); 76 Content.ItemsAdded += new CollectionItemsChangedEventHandler<T>(Content_ItemsAdded); 77 Content.ItemsRemoved += new CollectionItemsChangedEventHandler<T>(Content_ItemsRemoved); 78 Content.CollectionReset += new CollectionItemsChangedEventHandler<T>(Content_CollectionReset); 63 79 foreach (TreeNode node in treeView.Nodes) { 64 RegisterContentEvents(( IItemTree)node.Tag, node);65 } 66 } 67 68 private void RegisterContentEvents( IItemTreeitem, TreeNode node) {80 RegisterContentEvents((T)node.Tag, node); 81 } 82 } 83 84 private void RegisterContentEvents(T item, TreeNode node) { 69 85 item.ItemsAdded += new CollectionItemsChangedEventHandler<IItemTree>(item_ItemsAdded); 70 86 item.ItemsRemoved += new CollectionItemsChangedEventHandler<IItemTree>(item_ItemsRemoved); … … 73 89 item.ItemImageChanged += new EventHandler(item_ItemImageChanged); 74 90 foreach (TreeNode childNode in node.Nodes) { 75 RegisterContentEvents(( IItemTree)childNode.Tag, childNode);91 RegisterContentEvents((T)childNode.Tag, childNode); 76 92 } 77 93 } 78 94 79 95 #region Event Handlers (Content) 96 private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<T> e) { 97 if (InvokeRequired) { 98 Invoke(new CollectionItemsChangedEventHandler<T>(Content_ItemsAdded), sender, e); 99 } else { 100 foreach (T item in e.Items) { 101 var node = AddChildNodes(item, treeView.Nodes, true); 102 UpdateNodeItemImage(node); 103 } 104 } 105 } 106 private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<T> e) { 107 if (InvokeRequired) { 108 Invoke(new CollectionItemsChangedEventHandler<T>(Content_ItemsRemoved), sender, e); 109 } else { 110 foreach (T item in e.Items) { 111 RemoveChildNodes(item, treeView.Nodes); 112 } 113 RebuildImageList(); 114 } 115 } 116 private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<T> e) { 117 if (InvokeRequired) { 118 Invoke(new CollectionItemsChangedEventHandler<T>(Content_CollectionReset), sender, e); 119 } else { 120 foreach (T item in e.OldItems) { 121 RemoveChildNodes(item, treeView.Nodes); 122 } 123 RebuildImageList(); 124 foreach (T item in e.Items) { 125 AddChildNodes(item, treeView.Nodes, true); 126 } 127 } 128 } 129 80 130 private void item_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IItemTree> e) { 81 131 if (InvokeRequired) { 82 132 Invoke(new CollectionItemsChangedEventHandler<IItemTree>(item_ItemsAdded), sender, e); 83 133 } else { 84 TreeNode node = GetNodeByItem(sender as IItemTree);134 TreeNode node = GetNodeByItem(sender as T); 85 135 if (node != null) { 86 foreach ( IItemTreeitem in e.Items) {136 foreach (T item in e.Items) { 87 137 AddChildNodes(item, node.Nodes, true); 88 138 node.ExpandAll(); … … 97 147 Invoke(new CollectionItemsChangedEventHandler<IItemTree>(item_ItemsRemoved), sender, e); 98 148 } else { 99 TreeNode node = GetNodeByItem(sender as IItemTree);149 TreeNode node = GetNodeByItem(sender as T); 100 150 if (node != null) { 101 foreach ( IItemTreeitem in e.Items) {151 foreach (T item in e.Items) { 102 152 RemoveChildNodes(item, node.Nodes); 103 153 } … … 111 161 Invoke(new CollectionItemsChangedEventHandler<IItemTree>(item_CollectionReset), sender, e); 112 162 } else { 113 TreeNode node = GetNodeByItem(sender as IItemTree);163 TreeNode node = GetNodeByItem(sender as T); 114 164 if (node != null) { 115 foreach ( IItemTreeitem in e.OldItems) {165 foreach (T item in e.OldItems) { 116 166 RemoveChildNodes(item, node.Nodes); 117 167 } 118 168 RebuildImageList(); 119 foreach ( IItemTreeitem in e.Items) {169 foreach (T item in e.Items) { 120 170 AddChildNodes(item, node.Nodes, true); 121 171 } … … 128 178 Invoke(new EventHandler(item_ToStringChanged), sender, e); 129 179 } else { 130 var item = sender as IItemTree;180 var item = sender as T; 131 181 TreeNode node = GetNodeByItem(item); 132 182 if(node != null) … … 139 189 Invoke(new EventHandler(item_ItemImageChanged), sender, e); 140 190 } else { 141 var item = sender as IItemTree;191 var item = sender as T; 142 192 TreeNode node = GetNodeByItem(item); 143 193 if(node != null) … … 151 201 } else { 152 202 if (treeView.SelectedNode != null) { 153 var item = treeView.SelectedNode.Tag as IItemTree;203 var item = treeView.SelectedNode.Tag as T; 154 204 if (item != null) { 155 205 IContentView view = MainFormManager.MainForm.ShowContent(item); … … 167 217 base.OnContentChanged(); 168 218 if (Content == null) { 169 // Add code when content has been changed and is null170 219 ClearNodes(); 171 220 detailsViewHost.Content = null; 172 221 } else { 173 // Add code when content has been changed and is not null174 222 ClearNodes(); 175 AddChildNodes(Content, treeView.Nodes, false); 223 foreach (T itemTree in Content) { 224 AddChildNodes(itemTree, treeView.Nodes, false); 225 } 176 226 foreach (TreeNode node in treeView.Nodes) { 177 227 UpdateNodeItemImage(node); 178 228 } 229 detailsViewHost.Content = null; 179 230 } 180 231 } … … 184 235 } 185 236 186 private void AddChildNodes(IItemTreeitem, TreeNodeCollection nodes, bool registerEvents) {237 private TreeNode AddChildNodes(T item, TreeNodeCollection nodes, bool registerEvents) { 187 238 TreeNode node = CreateTreeViewNode(item); 188 239 nodes.Add(node); … … 190 241 RegisterContentEvents(item, node); 191 242 var childItems = item.GetChildItems(); 192 foreach ( varchildItem in childItems) {243 foreach (T childItem in childItems) { 193 244 AddChildNodes(childItem, node.Nodes, registerEvents); 194 245 } 195 246 node.ExpandAll(); 196 } 197 198 private void RemoveChildNodes(IItemTree item, TreeNodeCollection treeNodeCollection) { 247 return node; 248 } 249 250 private void RemoveChildNodes(T item, TreeNodeCollection treeNodeCollection) { 199 251 int idx = -1; 200 252 for (int i = 0; i < treeNodeCollection.Count; i++) { … … 207 259 } 208 260 209 private TreeNode GetNodeByItem( IItemTreeitem) {261 private TreeNode GetNodeByItem(T item) { 210 262 TreeNode found = null; 211 263 foreach (TreeNode node in treeView.Nodes) { … … 217 269 } 218 270 219 private TreeNode GetNodeByItem(TreeNode node, IItemTreeitem) {271 private TreeNode GetNodeByItem(TreeNode node, T item) { 220 272 if (node.Tag == item) 221 273 return node; … … 229 281 } 230 282 231 private TreeNode CreateTreeViewNode( IItemTreeitem) {283 private TreeNode CreateTreeViewNode(T item) { 232 284 var node = new TreeNode(item.ToString()); 233 285 node.Tag = item; … … 237 289 private void UpdateNodeItemImage(TreeNode node) { 238 290 if (node == null) throw new ArgumentNullException(); 239 var item = node.Tag as IItemTree;291 var item = node.Tag as T; 240 292 int i = node.ImageIndex; 241 293 this.imageList.Images[i] = item == null ? HeuristicLab.Common.Resources.VSImageLibrary.Nothing : item.ItemImage; … … 268 320 269 321 private void RebuildImageList(TreeNode node) { 270 var item = node.Tag as IItemTree;322 var item = node.Tag as T; 271 323 treeView.ImageList.Images.Add(item == null ? HeuristicLab.Common.Resources.VSImageLibrary.Nothing : item.ItemImage); 272 324 node.ImageIndex = treeView.ImageList.Images.Count - 1; -
branches/HeuristicLab.Hive-3.4/sources/HeuristicLab.Clients.Hive.Views/3.4/ExperimentManager/ItemTreeView.designer.cs
r5793 r6006 1 1 namespace HeuristicLab.Clients.Hive.Views { 2 partial class ItemTreeView {2 partial class ItemTreeView<T> { 3 3 /// <summary> 4 4 /// Required designer variable.
Note: See TracChangeset
for help on using the changeset viewer.