Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
12/20/11 13:54:57 (13 years ago)
Author:
spimming
Message:

#1680:

  • merged changes from trunk into branch

' removed pre-build event for multiple app.configs

Location:
branches/HeuristicLab.Hive.Azure
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.Hive.Azure

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

    r6976 r7215  
    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.Hive.Azure/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobManagerView.Designer.cs

    r6976 r7215  
    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.Hive.Azure/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveJobPermissionListView.cs

    r6976 r7215  
    2222using System;
    2323using System.Windows.Forms;
     24using HeuristicLab.Collections;
    2425using HeuristicLab.Core.Views;
    2526using HeuristicLab.MainForm;
     
    4445      return new JobPermission() { JobId = this.hiveExperimentId };
    4546    }
     47
     48    protected override void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<JobPermission> e) {
     49      base.Content_ItemsRemoved(sender, e);
     50      foreach (var item in e.Items) {
     51        if (item.GrantedUserId != Guid.Empty) {
     52          HiveClient.Delete(item);
     53        }
     54      }
     55    }
    4656  }
    4757}
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobListView.cs

    r6976 r7215  
    4848
    4949    protected override RefreshableJob CreateItem() {
    50       return new RefreshableJob() { IsAllowedPrivileged = HiveClient.Instance.IsAllowedPrivileged };
     50      var refreshableJob = new RefreshableJob() { IsAllowedPrivileged = HiveClient.Instance.IsAllowedPrivileged };
     51      refreshableJob.Job.Name = "New Hive Job";
     52      return refreshableJob;
    5153    }
    5254
    5355    protected override void removeButton_Click(object sender, EventArgs e) {
    54       DialogResult result = MessageBox.Show("This action will permanently delete this job (also on the hive server). Continue?", "Delete Job", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
     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);
    5557      if (result == DialogResult.OK) {
    5658        base.removeButton_Click(sender, e);
     
    5961
    6062    protected override void Content_ItemsAdded(object sender, Collections.CollectionItemsChangedEventArgs<RefreshableJob> e) {
    61       base.Content_ItemsAdded(sender, e);
    62       foreach (ColumnHeader c in this.itemsListView.Columns) {
    63         c.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
     63      if (InvokeRequired) {
     64        Invoke(new CollectionItemsChangedEventHandler<RefreshableJob>(Content_ItemsAdded), sender, e);
     65      } else {
     66        base.Content_ItemsAdded(sender, e);
     67        foreach (ColumnHeader c in this.itemsListView.Columns) {
     68          c.AutoResize(ColumnHeaderAutoResizeStyle.ColumnContent);
     69        }
     70        foreach (var item in e.Items) {
     71          item.ItemImageChanged += new EventHandler(item_ItemImageChanged);
     72        }
     73      }
     74    }
     75
     76    void item_ItemImageChanged(object sender, EventArgs e) {
     77      if (this.itemsListView.InvokeRequired) {
     78        Invoke(new EventHandler(item_ItemImageChanged), sender, e);
     79      } else {
     80        RefreshableJob job = sender as RefreshableJob;
     81        if (job != null) {
     82          foreach (ListViewItem item in this.itemsListView.Items) {
     83            if (item.Tag != null) {
     84              RefreshableJob cur = item.Tag as RefreshableJob;
     85              if (cur != null && cur == job) {
     86                this.UpdateListViewItemImage(item);
     87              }
     88            }
     89          }
     90        }
    6491      }
    6592    }
    6693
    6794    protected override void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<RefreshableJob> e) {
    68       base.Content_ItemsRemoved(sender, e);
    69       if (Content != null && Content.Count == 0) {
    70         foreach (ColumnHeader c in this.itemsListView.Columns) {
    71           c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
     95      if (InvokeRequired) {
     96        Invoke(new CollectionItemsChangedEventHandler<RefreshableJob>(Content_ItemsRemoved), sender, e);
     97      } else {
     98        base.Content_ItemsRemoved(sender, e);
     99        foreach (var item in e.Items) {
     100          item.ItemImageChanged -= new EventHandler(item_ItemImageChanged);
     101        }
     102        if (Content != null && Content.Count == 0) {
     103          foreach (ColumnHeader c in this.itemsListView.Columns) {
     104            c.AutoResize(ColumnHeaderAutoResizeStyle.HeaderSize);
     105          }
    72106        }
    73107      }
     
    92126    }
    93127
     128    //drag'n'drop is not supported
     129    protected override void itemsListView_ItemDrag(object sender, ItemDragEventArgs e) { }
     130    protected override void itemsListView_DragEnter(object sender, DragEventArgs e) { }
     131    protected override void itemsListView_DragOver(object sender, DragEventArgs e) { }
     132    protected override void itemsListView_DragDrop(object sender, DragEventArgs e) { }
     133
    94134    private ListViewGroup GetListViewGroup(string groupName) {
    95135      foreach (ListViewGroup group in itemsListView.Groups) {
  • branches/HeuristicLab.Hive.Azure/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.Designer.cs

    r6976 r7215  
    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.Hive.Azure/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r6976 r7215  
    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() {
     
    334334    #region Control events
    335335    private void startButton_Click(object sender, EventArgs e) {
    336       HiveClient.StartJob((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Start failed.", ex), Content, new CancellationToken());
    337     }
     336      if (nameTextBox.Text.Trim() == string.Empty) {
     337        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);
     345      } else {
     346        HiveClient.StartJob((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Start failed.", ex), Content, new CancellationToken());
     347      }
     348    }
     349
    338350    private void pauseButton_Click(object sender, EventArgs e) {
    339       HiveClient.PauseJob(Content);
    340     }
     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
    341359    private void stopButton_Click(object sender, EventArgs e) {
    342       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);
    343366    }
    344367    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    }
    345392
    346393    private void nameTextBox_Validated(object sender, EventArgs e) {
     
    375422
    376423    private void refreshPermissionsButton_Click(object sender, EventArgs e) {
    377       hiveExperimentPermissionListView.Content = HiveClient.GetJobPermissions(this.Content.Job.Id);
    378     }
    379 
    380 
     424      if (this.Content.Job.Id == Guid.Empty) {
     425        MessageBox.Show("You have to upload the Job first before you can share it.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Information);
     426      } else {
     427        hiveExperimentPermissionListView.Content = HiveClient.GetJobPermissions(this.Content.Job.Id);
     428      }
     429    }
    381430    #endregion
    382431
     
    386435        startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;
    387436      } else {
    388         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);
    389438        pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started;
    390439        stopButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started;
     
    408457
    409458    private void SetProgressView() {
    410       if (progressView == null) {
    411         progressView = new ProgressView(this, Content.Progress);
    412       }
    413       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      }
    414480    }
    415481
    416482    private void FinishProgressView() {
    417       if (progressView != null) {
    418         progressView.Finish();
    419         progressView = null;
    420         SetEnabledStateOfControls();
     483      if (InvokeRequired) {
     484        Invoke(new Action(FinishProgressView));
     485      } else {
     486        if (progressView != null) {
     487          progressView.Finish();
     488          progressView = null;
     489          SetEnabledStateOfControls();
     490        }
    421491      }
    422492    }
     
    432502      var obj = e.Data.GetData(Constants.DragDropDataFormat);
    433503      if (obj is IOptimizer) {
    434         if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
     504        if (Content.Id != Guid.Empty) e.Effect = DragDropEffects.None;
     505        else if ((e.KeyState & 32) == 32) e.Effect = DragDropEffects.Link;  // ALT key
    435506        else if (e.AllowedEffect.HasFlag(DragDropEffects.Copy)) e.Effect = DragDropEffects.Copy;
    436507      }
     
    443514        var optimizer = obj as IOptimizer;
    444515        if (optimizer != null) {
    445           Content.HiveTasks.Add(new OptimizerHiveTask(e.Effect.HasFlag(DragDropEffects.Copy) ? (IOptimizer)optimizer.Clone() : optimizer));
     516          IOptimizer newOptimizer = null;
     517          if (e.Effect.HasFlag(DragDropEffects.Copy)) {
     518            newOptimizer = (IOptimizer)optimizer.Clone();
     519          } else {
     520            newOptimizer = optimizer;
     521          }
     522          if (newOptimizer.ExecutionState != ExecutionState.Prepared) {
     523            newOptimizer.Prepare();
     524          }
     525
     526          Content.HiveTasks.Add(new OptimizerHiveTask(newOptimizer));
    446527        }
    447528      }
     
    452533      if (tabControl.SelectedTab == permissionTabPage) {
    453534        if (!Content.IsSharable) {
    454           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);
    455536          tabControl.SelectedTab = tasksTabPage;
    456537        }
Note: See TracChangeset for help on using the changeset viewer.