Free cookie consent management tool by TermsFeed Policy Generator

Changeset 9223


Ignore:
Timestamp:
02/18/13 15:08:46 (12 years ago)
Author:
ascheibe
Message:

#2015 jobs are now delete asynchronously in the hive job manager

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  
    2525using System.Windows.Forms;
    2626using HeuristicLab.Clients.Hive.Views;
    27 using HeuristicLab.Collections;
    2827using HeuristicLab.MainForm;
    2928using HeuristicLab.MainForm.WindowsForms;
     
    5453      Content.Refreshing += new EventHandler(Content_Refreshing);
    5554      Content.Refreshed += new EventHandler(Content_Refreshed);
    56       Content.HiveJobsChanged += new EventHandler(Content_HiveJobsChanged);
    5755    }
    5856
     
    6058      Content.Refreshing -= new EventHandler(Content_Refreshing);
    6159      Content.Refreshed -= new EventHandler(Content_Refreshed);
    62       Content.HiveJobsChanged -= new EventHandler(Content_HiveJobsChanged);
    6360      base.DeregisterContentEvents();
    6461    }
     
    130127      } else {
    131128        base.OnClosing(e);
    132         if (Content != null && Content.Jobs != null) {
    133           Content.Jobs.ItemsRemoved -= new CollectionItemsChangedEventHandler<RefreshableJob>(HiveExperiments_ItemsRemoved);
     129        if (Content != null) {
    134130          Content.ClearHiveClient();
    135131          Content = null;
     
    137133      }
    138134    }
    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     }
    151135  }
    152136}
  • trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.Designer.cs

    r8924 r9223  
    2727    private System.ComponentModel.IContainer components = null;
    2828
    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     }
    3929
    4030    #region Component Designer generated code
  • trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.cs

    r9107 r9223  
    2121
    2222using System;
     23using System.Collections.Generic;
     24using System.Threading.Tasks;
    2325using System.Windows.Forms;
    2426using HeuristicLab.Collections;
    2527using HeuristicLab.Core;
    2628using HeuristicLab.MainForm;
     29using HeuristicLab.MainForm.WindowsForms;
    2730
    2831namespace HeuristicLab.Clients.Hive.JobManager.Views {
     
    3033  [Content(typeof(ItemCollection<RefreshableJob>), false)]
    3134  public partial class RefreshableHiveJobListView : HeuristicLab.Core.Views.ItemCollectionView<RefreshableJob> {
     35    private Progress progress;
     36    private ProgressView progressView;
    3237
    3338    public RefreshableHiveJobListView() {
    3439      InitializeComponent();
    3540      itemsGroupBox.Text = "Jobs";
    36       this.itemsListView.View = View.Details;
     41      this.itemsListView.View = System.Windows.Forms.View.Details;
    3742      this.itemsListView.Columns.Clear();
    3843      this.itemsListView.Columns.Add(new ColumnHeader("Date") { Text = "Date" });
     
    4752      this.itemsListView.Sorting = SortOrder.Ascending;
    4853      this.itemsListView.Sort();
     54
     55      progress = new Progress() {
     56        CanBeCanceled = false,
     57        ProgressState = ProgressState.Finished
     58      };
     59      progressView = new ProgressView(this, progress);
    4960    }
    5061
     
    5364      refreshableJob.Job.Name = "New Hive Job";
    5465      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();
    5582    }
    5683
     
    7299          return;
    73100        } 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();
    77133    }
    78134
     
    158214      return newGroup;
    159215    }
     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    }
    160229  }
    161230}
  • trunk/sources/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r9219 r9223  
    166166    }
    167167
     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
    168189    protected override void SetEnabledStateOfControls() {
    169190      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      }
    194216    }
    195217
Note: See TracChangeset for help on using the changeset viewer.