Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
11/12/13 20:35:30 (11 years ago)
Author:
ascheibe
Message:

#2117

  • fixed drag and drop check in the RefreshableHiveJobView to be more generic
  • fixed TaskDownloader to generate the correct HiveTasks when downloading tasks
  • fixed some variable names (job => task) which were forgotten
  • the IsParallelizable property of a task can now be set (e.g. if a task gets parallelized, the generated child tasks should sometimes not be able to get further parallelized)
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r9894 r10130  
    2323using System.ComponentModel;
    2424using System.Linq;
     25using System.Reflection;
    2526using System.Text;
    2627using System.Threading;
     
    468469    private void jobsTreeView_DragEnter(object sender, DragEventArgs e) {
    469470      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) {
    472480        if (Content.Id != Guid.Empty) e.Effect = DragDropEffects.None;
    473481        else if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
     
    478486    private void jobsTreeView_DragDrop(object sender, DragEventArgs e) {
    479487      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();
    490511          }
    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());
    497516      }
    498517    }
Note: See TracChangeset for help on using the changeset viewer.