- Timestamp:
- 11/12/13 20:35:30 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs
r9894 r10130 23 23 using System.ComponentModel; 24 24 using System.Linq; 25 using System.Reflection; 25 26 using System.Text; 26 27 using System.Threading; … … 468 469 private void jobsTreeView_DragEnter(object sender, DragEventArgs e) { 469 470 e.Effect = DragDropEffects.None; 470 var obj = e.Data.GetData(Constants.DragDropDataFormat); 471 if (obj is IOptimizer) { 471 var obj = e.Data.GetData(Constants.DragDropDataFormat) as IDeepCloneable; 472 Type objType = obj.GetType(); 473 474 var typeHiveTaskMap = ApplicationManager.Manager.GetTypes(typeof(ItemTask)) 475 .Select(t => new Tuple<PropertyInfo, Type>(t.GetProperties().Single(x => x.Name == "Item" && x.PropertyType != typeof(IItem)), t)); 476 477 var hiveTaskFound = typeHiveTaskMap.Any(x => x.Item1.PropertyType.IsAssignableFrom(objType)); 478 479 if (hiveTaskFound) { 472 480 if (Content.Id != Guid.Empty) e.Effect = DragDropEffects.None; 473 481 else if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link; // ALT key … … 478 486 private void jobsTreeView_DragDrop(object sender, DragEventArgs e) { 479 487 if (e.Effect != DragDropEffects.None) { 480 var obj = e.Data.GetData(Constants.DragDropDataFormat); 481 482 var optimizer = obj as IOptimizer; 483 if (optimizer != null) { 484 IOptimizer newOptimizer = null; 485 if (e.Effect.HasFlag(DragDropEffects.Copy)) { 486 newOptimizer = (IOptimizer)optimizer.Clone(); 487 newOptimizer.Runs.Clear(); 488 } else { 489 newOptimizer = optimizer; 488 var obj = e.Data.GetData(Constants.DragDropDataFormat) as IDeepCloneable; 489 Type objType = obj.GetType(); 490 491 var typeHiveTaskMap = ApplicationManager.Manager.GetTypes(typeof(ItemTask)) 492 .Select(t => new Tuple<PropertyInfo, Type>(t.GetProperties().Single(x => x.Name == "Item" && x.PropertyType != typeof(IItem)), t)); 493 494 var hiveTaskType = typeHiveTaskMap.Single(x => x.Item1.PropertyType.IsAssignableFrom(objType)).Item2; 495 496 IDeepCloneable newObj = null; 497 if (e.Effect.HasFlag(DragDropEffects.Copy)) { 498 newObj = obj.Clone(new Cloner()); 499 } else { 500 newObj = obj; 501 } 502 503 //IOptimizer and IExecutables need some special care 504 if (newObj is IOptimizer) { 505 ((IOptimizer)newObj).Runs.Clear(); 506 } 507 if (newObj is IExecutable) { 508 IExecutable exec = newObj as IExecutable; 509 if (exec.ExecutionState != ExecutionState.Prepared) { 510 exec.Prepare(); 490 511 } 491 if (newOptimizer.ExecutionState != ExecutionState.Prepared) { 492 newOptimizer.Prepare(); 493 } 494 495 Content.HiveTasks.Add(new OptimizerHiveTask(newOptimizer)); 496 } 512 } 513 514 ItemTask hiveTask = Activator.CreateInstance(hiveTaskType, new object[] { newObj }) as ItemTask; 515 Content.HiveTasks.Add(hiveTask.CreateHiveTask()); 497 516 } 498 517 }
Note: See TracChangeset
for help on using the changeset viewer.