Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/20/11 11:45:18 (13 years ago)
Author:
gkronber
Message:

#1081 merged r7103:7209 from trunk into time series branch

Location:
branches/HeuristicLab.TimeSeries
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.TimeSeries

  • branches/HeuristicLab.TimeSeries/HeuristicLab.Clients.Hive.JobManager/3.3/MenuItems/JobManagerMenuItem.cs

    r6976 r7213  
    2525
    2626namespace HeuristicLab.Optimizer.MenuItems {
    27   public class ExperimentManagerMenuItem : HeuristicLab.MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {
     27  public class JobManagerMenuItem : HeuristicLab.MainForm.WindowsForms.MenuItem, IOptimizerUserInterfaceItemProvider {
    2828    public override string Name {
    2929      get { return "&Job Manager"; }
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobManagerView.Designer.cs

    r6976 r7213  
    7979      this.Controls.Add(this.refreshButton);
    8080      this.Controls.Add(this.hiveExperimentListView);
    81       this.Name = "HiveExperimentManagerView";
     81      this.Name = "JobManagerView";
    8282      this.Size = new System.Drawing.Size(735, 524);
    8383      this.ResumeLayout(false);
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.cs

    r7078 r7213  
    5454
    5555    protected override void removeButton_Click(object sender, EventArgs e) {
    56       DialogResult result = MessageBox.Show("This action will permanently delete this job (also on the hive server). Continue?", "HeuristicLab Hive Job Manager", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
    57       if (result == DialogResult.OK) {
    58         base.removeButton_Click(sender, e);
     56      DialogResult result = MessageBox.Show("This action will permanently delete this job (also on the Hive server). Continue?", "HeuristicLab Hive Job Manager", MessageBoxButtons.YesNo, MessageBoxIcon.Question);
     57      if (result == DialogResult.Yes) {
     58        System.Windows.Forms.ListView.SelectedListViewItemCollection selectedItems = itemsListView.SelectedItems;
     59        bool inProgress = false;
     60        foreach (ListViewItem item in selectedItems) {                                 
     61          RefreshableJob job = item.Tag as RefreshableJob;
     62          if (job != null && job.IsProgressing) {
     63            inProgress = true;
     64            break;
     65          }
     66        }
     67
     68        if (inProgress) {
     69          MessageBox.Show("You can't delete jobs which are currently uploading or downloading." + Environment.NewLine + "Please wait for the jobs to complete and try again. ", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     70          return;
     71        } else {
     72          base.removeButton_Click(sender, e);
     73        }
    5974      }
    6075    }
    6176
    6277    protected override void Content_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<RefreshableJob> e) {
    63       base.Content_ItemsAdded(sender, e);
    64       foreach (ColumnHeader c in this.itemsListView.Columns) {
    65         c.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
    66       }
    67       foreach (var item in e.Items) {
    68         item.ItemImageChanged += new EventHandler(item_ItemImageChanged);
     78      if (InvokeRequired) {
     79        Invoke(new CollectionItemsChangedEventHandler<RefreshableJob>(Content_ItemsAdded), sender, e);
     80      } else {
     81        base.Content_ItemsAdded(sender, e);
     82        foreach (ColumnHeader c in this.itemsListView.Columns) {
     83          c.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
     84        }
     85        foreach (var item in e.Items) {
     86          item.ItemImageChanged += new EventHandler(item_ItemImageChanged);
     87        }
    6988      }
    7089    }
    7190
    7291    void item_ItemImageChanged(object sender, EventArgs e) {
    73         if (this.itemsListView.InvokeRequired) {
    74             Invoke(new EventHandler(item_ItemImageChanged), sender, e);
    75         } else {
    76           RefreshableJob job = sender as RefreshableJob;
    77           if (job != null) {
    78             foreach (ListViewItem item in this.itemsListView.Items) {
    79                 if (item.Tag != null)
    80                 {
    81                     RefreshableJob cur = item.Tag as RefreshableJob;
    82                     if (cur != null && cur == job)
    83                     {
    84                         this.UpdateListViewItemImage(item);
    85                     }
    86                 }
     92      if (this.itemsListView.InvokeRequired) {
     93        Invoke(new EventHandler(item_ItemImageChanged), sender, e);
     94      } else {
     95        RefreshableJob job = sender as RefreshableJob;
     96        if (job != null) {
     97          foreach (ListViewItem item in this.itemsListView.Items) {
     98            if (item.Tag != null) {
     99              RefreshableJob cur = item.Tag as RefreshableJob;
     100              if (cur != null && cur == job) {
     101                this.UpdateListViewItemImage(item);
     102              }
    87103            }
    88          }
     104          }
     105        }
    89106      }
    90107    }
    91108
    92109    protected override void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<RefreshableJob> e) {
    93       base.Content_ItemsRemoved(sender, e);
    94       foreach (var item in e.Items) {
    95         item.ItemImageChanged -= new EventHandler(item_ItemImageChanged);
    96       }
    97       if (Content != null && Content.Count == 0) {
    98         foreach (ColumnHeader c in this.itemsListView.Columns) {
    99           c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
     110      if (InvokeRequired) {
     111        Invoke(new CollectionItemsChangedEventHandler<RefreshableJob>(Content_ItemsRemoved), sender, e);
     112      } else {
     113        base.Content_ItemsRemoved(sender, e);
     114        foreach (var item in e.Items) {
     115          item.ItemImageChanged -= new EventHandler(item_ItemImageChanged);
     116        }
     117        if (Content != null && Content.Count == 0) {
     118          foreach (ColumnHeader c in this.itemsListView.Columns) {
     119            c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
     120          }
    100121        }
    101122      }
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.Designer.cs

    r6976 r7213  
    2828      this.tabControl = new System.Windows.Forms.TabControl();
    2929      this.tasksTabPage = new System.Windows.Forms.TabPage();
    30       this.jobsTreeView = new HeuristicLab.Clients.Hive.Views.ExperimentManager.HiveTaskItemTreeView();
     30      this.jobsTreeView = new HeuristicLab.Clients.Hive.Views.HiveTaskItemTreeView();
    3131      this.permissionTabPage = new System.Windows.Forms.TabPage();
    3232      this.refreshPermissionsButton = new System.Windows.Forms.Button();
    3333      this.hiveExperimentPermissionListView = new HeuristicLab.Clients.Hive.JobManager.Views.HiveJobPermissionListView();
    3434      this.runsTabPage = new System.Windows.Forms.TabPage();
     35      this.runCollectionViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    3536      this.stateTabPage = new System.Windows.Forms.TabPage();
    3637      this.stateLogViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
     
    5859      this.calculatingLabel = new System.Windows.Forms.Label();
    5960      this.jobsLabel = new System.Windows.Forms.Label();
    60       this.runCollectionViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    6161      this.tabControl.SuspendLayout();
    6262      this.tasksTabPage.SuspendLayout();
     
    107107      this.jobsTreeView.ReadOnly = false;
    108108      this.jobsTreeView.Size = new System.Drawing.Size(704, 420);
    109       this.jobsTreeView.TabIndex = 0;
     109      this.jobsTreeView.TabIndex = 4;
    110110      this.jobsTreeView.DragDrop += new System.Windows.Forms.DragEventHandler(this.jobsTreeView_DragDrop);
    111111      this.jobsTreeView.DragEnter += new System.Windows.Forms.DragEventHandler(this.jobsTreeView_DragEnter);
     
    159159      this.runsTabPage.Text = "Runs";
    160160      this.runsTabPage.UseVisualStyleBackColor = true;
     161      //
     162      // runCollectionViewHost
     163      //
     164      this.runCollectionViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     165                  | System.Windows.Forms.AnchorStyles.Left)
     166                  | System.Windows.Forms.AnchorStyles.Right)));
     167      this.runCollectionViewHost.Caption = "View";
     168      this.runCollectionViewHost.Content = null;
     169      this.runCollectionViewHost.Enabled = false;
     170      this.runCollectionViewHost.Location = new System.Drawing.Point(3, 3);
     171      this.runCollectionViewHost.Name = "runCollectionViewHost";
     172      this.runCollectionViewHost.ReadOnly = false;
     173      this.runCollectionViewHost.Size = new System.Drawing.Size(703, 420);
     174      this.runCollectionViewHost.TabIndex = 2;
     175      this.runCollectionViewHost.ViewsLabelVisible = true;
     176      this.runCollectionViewHost.ViewType = null;
    161177      //
    162178      // stateTabPage
     
    294310      this.resourceNamesTextBox.Name = "resourceNamesTextBox";
    295311      this.resourceNamesTextBox.Size = new System.Drawing.Size(415, 20);
    296       this.resourceNamesTextBox.TabIndex = 14;
     312      this.resourceNamesTextBox.TabIndex = 2;
    297313      this.resourceNamesTextBox.Validated += new System.EventHandler(this.resourceNamesTextBox_Validated);
    298314      //
     
    313329      this.nameTextBox.Name = "nameTextBox";
    314330      this.nameTextBox.Size = new System.Drawing.Size(501, 20);
    315       this.nameTextBox.TabIndex = 21;
     331      this.nameTextBox.TabIndex = 1;
    316332      this.nameTextBox.Validated += new System.EventHandler(this.nameTextBox_Validated);
    317333      //
     
    334350      this.isPrivilegedCheckBox.Name = "isPrivilegedCheckBox";
    335351      this.isPrivilegedCheckBox.Size = new System.Drawing.Size(72, 17);
    336       this.isPrivilegedCheckBox.TabIndex = 26;
     352      this.isPrivilegedCheckBox.TabIndex = 3;
    337353      this.isPrivilegedCheckBox.Text = "Privileged";
    338354      this.toolTip.SetToolTip(this.isPrivilegedCheckBox, "If checked, the task will be executed in a privileged sandbox on the slave.");
     
    420436      this.jobsLabel.TabIndex = 0;
    421437      this.jobsLabel.Text = "Waiting:";
    422       //
    423       // runCollectionViewHost
    424       //
    425       this.runCollectionViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    426                   | System.Windows.Forms.AnchorStyles.Left)
    427                   | System.Windows.Forms.AnchorStyles.Right)));
    428       this.runCollectionViewHost.Caption = "View";
    429       this.runCollectionViewHost.Content = null;
    430       this.runCollectionViewHost.Enabled = false;
    431       this.runCollectionViewHost.Location = new System.Drawing.Point(3, 3);
    432       this.runCollectionViewHost.Name = "runCollectionViewHost";
    433       this.runCollectionViewHost.ReadOnly = false;
    434       this.runCollectionViewHost.Size = new System.Drawing.Size(703, 420);
    435       this.runCollectionViewHost.TabIndex = 2;
    436       this.runCollectionViewHost.ViewsLabelVisible = true;
    437       this.runCollectionViewHost.ViewType = null;
    438438      //
    439439      // RefreshableHiveJobView
     
    484484    private Core.Views.LogView logView;
    485485    private System.Windows.Forms.TabPage tasksTabPage;
    486     private HeuristicLab.Clients.Hive.Views.ExperimentManager.HiveTaskItemTreeView jobsTreeView;
     486    private HeuristicLab.Clients.Hive.Views.HiveTaskItemTreeView jobsTreeView;
    487487    private System.Windows.Forms.Label nameLabel;
    488488    private System.Windows.Forms.TextBox nameTextBox;
  • branches/HeuristicLab.TimeSeries/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r7068 r7213  
    2424using System.Linq;
    2525using System.Threading;
     26using System.Threading.Tasks;
    2627using System.Windows.Forms;
    2728using HeuristicLab.Clients.Hive.Views;
     
    301302    }
    302303    private void Content_ExceptionOccured(object sender, EventArgs<Exception> e) {
    303       // don't show exception, it is logged anyway     
     304      throw e.Value;
    304305    }
    305306    private void Content_StateLogListChanged(object sender, EventArgs e) {
     
    317318      }
    318319    }
    319 
    320320
    321321    private void UpdateStateLogList() {
     
    336336      if (nameTextBox.Text.Trim() == string.Empty) {
    337337        MessageBox.Show("Please enter a name for the job before uploading it!", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     338      } else if (Content.ExecutionState == ExecutionState.Paused) {
     339        var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobAsync, Content);
     340        task.ContinueWith((t) => {
     341          FinishProgressView();
     342          MessageBox.Show("An error occured resuming the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
     343          Content.Log.LogException(t.Exception);
     344        }, TaskContinuationOptions.OnlyOnFaulted);
    338345      } else {
    339346        HiveClient.StartJob((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Start failed.", ex), Content, new CancellationToken());
    340347      }
    341348    }
     349
    342350    private void pauseButton_Click(object sender, EventArgs e) {
    343       HiveClient.PauseJob(Content);
    344     }
     351      var task = System.Threading.Tasks.Task.Factory.StartNew(PauseJobAsync, Content);
     352      task.ContinueWith((t) => {
     353        FinishProgressView();
     354        MessageBox.Show("An error occured pausing the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
     355        Content.Log.LogException(t.Exception);
     356      }, TaskContinuationOptions.OnlyOnFaulted);
     357    }
     358
    345359    private void stopButton_Click(object sender, EventArgs e) {
    346       HiveClient.StopJob(Content);
     360      var task = System.Threading.Tasks.Task.Factory.StartNew(StopJobAsync, Content);
     361      task.ContinueWith((t) => {
     362        FinishProgressView();
     363        MessageBox.Show("An error occured stopping the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
     364        Content.Log.LogException(t.Exception);
     365      }, TaskContinuationOptions.OnlyOnFaulted);
    347366    }
    348367    private void resetButton_Click(object sender, EventArgs e) { }
     368
     369    private void PauseJobAsync(object job) {
     370      IProgress prog = new Progress();
     371      prog.Status = "Pausing job...";
     372      SetProgressView(prog);
     373      HiveClient.PauseJob((RefreshableJob)job);
     374      FinishProgressView();
     375    }
     376
     377    private void StopJobAsync(object job) {
     378      IProgress prog = new Progress();
     379      prog.Status = "Stopping job...";
     380      SetProgressView(prog);
     381      HiveClient.StopJob((RefreshableJob)job);
     382      FinishProgressView();
     383    }
     384
     385    private void ResumeJobAsync(object job) {
     386      IProgress prog = new Progress();
     387      prog.Status = "Resuming job...";
     388      SetProgressView(prog);
     389      HiveClient.ResumeJob((RefreshableJob)job);
     390      FinishProgressView();
     391    }
    349392
    350393    private void nameTextBox_Validated(object sender, EventArgs e) {
     
    385428      }
    386429    }
    387 
    388 
    389430    #endregion
    390431
     
    394435        startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;
    395436      } else {
    396         startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 && Content.ExecutionState == ExecutionState.Prepared;
     437        startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused);
    397438        pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started;
    398439        stopButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started;
     
    416457
    417458    private void SetProgressView() {
    418       if (progressView == null) {
    419         progressView = new ProgressView(this, Content.Progress);
    420       }
    421       progressView.Progress = Content.Progress;
     459      if (InvokeRequired) {
     460        Invoke(new Action(SetProgressView));
     461      } else {
     462        if (progressView == null) {
     463          progressView = new ProgressView(this, Content.Progress);
     464        } else {
     465          progressView.Progress = Content.Progress;
     466        }
     467      }
     468    }
     469
     470    private void SetProgressView(IProgress progress) {
     471      if (InvokeRequired) {
     472        Invoke(new Action<IProgress>(SetProgressView), progress);
     473      } else {
     474        if (progressView == null) {
     475          progressView = new ProgressView(this, progress);
     476        } else {
     477          progressView.Progress = progress;
     478        }
     479      }
    422480    }
    423481
    424482    private void FinishProgressView() {
    425       if (progressView != null) {
    426         progressView.Finish();
    427         progressView = null;
    428         SetEnabledStateOfControls();
     483      if (InvokeRequired) {
     484        Invoke(new Action(FinishProgressView));
     485      } else {
     486        if (progressView != null) {
     487          progressView.Finish();
     488          progressView = null;
     489          SetEnabledStateOfControls();
     490        }
    429491      }
    430492    }
     
    471533      if (tabControl.SelectedTab == permissionTabPage) {
    472534        if (!Content.IsSharable) {
    473           MessageBox.Show("Unable to load tab. You have insufficient access privileges.");
     535          MessageBox.Show("Unable to load permissions. You have insufficient access privileges.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
    474536          tabControl.SelectedTab = tasksTabPage;
    475537        }
Note: See TracChangeset for help on using the changeset viewer.