Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10150 for trunk


Ignore:
Timestamp:
11/22/13 14:23:56 (11 years ago)
Author:
ascheibe
Message:

#2117

  • improved creation of ItemTasks from Items and moved common functionality to ItemTask
  • added a MenuItem for directly uploading tasks (e.g. from experiments, batchruns,...)
  • added a MenuItem for creating RefreshableHiveJobs
Location:
trunk/sources
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/HeuristicLab.Clients.Hive.JobManager-3.3.csproj

    r8718 r10150  
    9898    <Compile Include="ExtensionMethods\TreeNodeExtensions.cs" />
    9999    <Compile Include="ListViewItemDateComparer.cs" />
     100    <Compile Include="MenuItems\CreateHiveJobMenuItem.cs" />
     101    <Compile Include="MenuItems\RunInHiveMenuItem.cs" />
    100102    <Compile Include="Plugin.cs" />
    101103    <Compile Include="Views\HiveJobManagerView.cs">
  • trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r10130 r10150  
    2323using System.ComponentModel;
    2424using System.Linq;
    25 using System.Reflection;
    2625using System.Text;
    2726using System.Threading;
     
    472471      Type objType = obj.GetType();
    473472
    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 
     473      var hiveTaskFound = ItemTask.IsTypeSupported(objType);
    479474      if (hiveTaskFound) {
    480475        if (Content.Id != Guid.Empty) e.Effect = DragDropEffects.None;
     
    486481    private void jobsTreeView_DragDrop(object sender, DragEventArgs e) {
    487482      if (e.Effect != DragDropEffects.None) {
    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;
     483        var obj = e.Data.GetData(Constants.DragDropDataFormat) as IItem;
     484
     485        IItem newObj = null;
    497486        if (e.Effect.HasFlag(DragDropEffects.Copy)) {
    498           newObj = obj.Clone(new Cloner());
     487          newObj = obj.Clone(new Cloner()) as IItem;
    499488        } else {
    500489          newObj = obj;
     
    512501        }
    513502
    514         ItemTask hiveTask = Activator.CreateInstance(hiveTaskType, new object[] { newObj }) as ItemTask;
     503        ItemTask hiveTask = ItemTask.GetItemTaskForItem(newObj);
    515504        Content.HiveTasks.Add(hiveTask.CreateHiveTask());
    516505      }
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/HiveClient.cs

    r10130 r10150  
    351351    /// </summary>
    352352    /// <param name="parentHiveTask">shall be null if its the root task</param>
    353     private void UploadTaskWithChildren(Progress progress, HiveTask hiveTask, HiveTask parentHiveTask, IEnumerable<Guid> groups, int[] taskCount, int totalJobCount, Guid configPluginId, Guid jobId, ILog log, bool isPrivileged, CancellationToken cancellationToken) {
     353    private void UploadTaskWithChildren(IProgress progress, HiveTask hiveTask, HiveTask parentHiveTask, IEnumerable<Guid> groups, int[] taskCount, int totalJobCount, Guid configPluginId, Guid jobId, ILog log, bool isPrivileged, CancellationToken cancellationToken) {
    354354      taskUploadSemaphore.WaitOne();
    355355      bool semaphoreReleased = false;
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/RefreshableJob.cs

    r9893 r10150  
    157157    }
    158158
    159     private Progress progress;
    160     public Progress Progress {
     159    private IProgress progress;
     160    public IProgress Progress {
    161161      get { return progress; }
    162162      set {
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/Tasks/EngineTask.cs

    r10130 r10150  
    6060    }
    6161
    62     public EngineTask(IEngine engine) {
    63       this.Item = engine;
    64     }
     62    public EngineTask(IEngine engine) : base(engine) { }
    6563
    6664    [StorableConstructor]
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/Tasks/ItemTask.cs

    r10130 r10150  
    2222using System;
    2323using System.Drawing;
     24using System.Linq;
    2425using HeuristicLab.Common;
    2526using HeuristicLab.Core;
    2627using HeuristicLab.Hive;
    2728using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
     29using HeuristicLab.PluginInfrastructure;
    2830
    2931namespace HeuristicLab.Clients.Hive {
     
    7678      this.Item = cloner.Clone(original.Item);
    7779    }
     80    public ItemTask(IItem item) {
     81      Item = item;
     82    }
    7883
    7984    [StorableHook(HookType.AfterDeserialization)]
     
    216221      return Name;
    217222    }
     223
     224    #region Helpers
     225    public static bool IsTypeSupported(Type itemType) {
     226      var supportedHiveTaskTypes = ApplicationManager.Manager.GetTypes(typeof(ItemTask))
     227          .Select(t => t.GetProperties().Single(x => x.Name == "Item" && x.PropertyType != typeof(IItem)).PropertyType);
     228      return supportedHiveTaskTypes.Any(x => x.IsAssignableFrom(itemType));
     229    }
     230
     231    public static Type GetHiveTaskType(Type itemType) {
     232      if (!IsTypeSupported(itemType)) throw new Exception("Item " + itemType + " is not supported for Hive.");
     233
     234      var typeHiveTaskMap = ApplicationManager.Manager.GetTypes(typeof(ItemTask))
     235          .Select(t => new Tuple<Type, Type>(t.GetProperties().Single(x => x.Name == "Item" && x.PropertyType != typeof(IItem)).PropertyType, t));
     236
     237      return typeHiveTaskMap.Single(x => x.Item1.IsAssignableFrom(itemType)).Item2;
     238    }
     239
     240    public static ItemTask GetItemTaskForItem(IItem item) {
     241      Type itemType = item.GetType();
     242      Type hiveTaskType = GetHiveTaskType(itemType);
     243      return Activator.CreateInstance(hiveTaskType, new object[] { item }) as ItemTask;
     244    }
     245    #endregion
    218246  }
    219247}
  • trunk/sources/HeuristicLab.Clients.Hive/3.3/Tasks/OptimizerTask.cs

    r10130 r10150  
    5050    }
    5151
    52     public OptimizerTask(IOptimizer optimizer) {
    53       this.Item = optimizer;
     52    public OptimizerTask(IOptimizer optimizer)
     53      : base(optimizer) {
    5454
    5555      if (optimizer is Experiment) {
Note: See TracChangeset for help on using the changeset viewer.