Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/03/12 16:46:35 (12 years ago)
Author:
gkronber
Message:

#1847: merged r8084:8205 from trunk into GP move operators branch

Location:
branches/GP-MoveOperators
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/GP-MoveOperators

  • branches/GP-MoveOperators/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelector.cs

    r8085 r8206  
    4242    private ISet<TreeNode> filteredTreeNodes;
    4343    private ISet<TreeNode> nodeStore;
     44    private Progress progress;
     45    private ProgressView progressView;
    4446
    4547    private ISet<Resource> selectedResources;
     
    4749      get { return selectedResources; }
    4850      set { selectedResources = value; }
    49     }
    50 
    51     private ProgressView progressView;
    52     public ProgressView ProgressView {
    53       get { return progressView; }
    54       set { progressView = value; }
    5551    }
    5652
     
    6864      imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.MonitorLarge);
    6965      imageList.Images.Add(HeuristicLab.Common.Resources.VSImageLibrary.NetworkCenterLarge);
     66      progress = new Progress() {
     67        CanBeCanceled = false,
     68        ProgressState = ProgressState.Finished
     69      };
     70    }
     71
     72    protected override void DeregisterContentEvents() {
     73      if (progressView != null) {
     74        progressView.Content = null;
     75        progressView.Dispose();
     76        progressView = null;
     77      }
     78      base.DeregisterContentEvents();
     79    }
     80
     81    protected override void RegisterContentEvents() {
     82      base.RegisterContentEvents();
     83      progressView = new ProgressView(this, progress);
    7084    }
    7185
     
    7488        Invoke(new Action(StartProgressView));
    7589      } else {
    76         if (progressView == null) {
    77           IProgress prog = new Progress();
    78           prog.Status = "Downloading resources. Please be patient.";
    79           progressView = new ProgressView(this, prog);
    80         }
     90        progress.Status = "Downloading resources. Please be patient.";
     91        progress.ProgressState = ProgressState.Started;
    8192      }
    8293    }
     
    8697        Invoke(new Action(FinishProgressView));
    8798      } else {
    88         if (progressView != null) {
    89           progressView.Finish();
    90           progressView = null;
    91           SetEnabledStateOfControls();
    92         }
     99        progress.Finish();
    93100      }
    94101    }
  • branches/GP-MoveOperators/HeuristicLab.Clients.Hive.JobManager/3.3/Views/HiveResourceSelectorDialog.Designer.cs

    r8085 r8206  
    7373      this.hiveResourceSelector.Location = new System.Drawing.Point(12, 12);
    7474      this.hiveResourceSelector.Name = "hiveResourceSelector";
    75       this.hiveResourceSelector.ProgressView = null;
    7675      this.hiveResourceSelector.ReadOnly = false;
    7776      this.hiveResourceSelector.Size = new System.Drawing.Size(549, 591);
  • branches/GP-MoveOperators/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.Designer.cs

    r8085 r8206  
    365365      this.refreshAutomaticallyCheckBox.Text = "&Refresh automatically";
    366366      this.refreshAutomaticallyCheckBox.UseVisualStyleBackColor = true;
    367       this.refreshAutomaticallyCheckBox.Validated += new System.EventHandler(this.refreshAutomaticallyCheckBox_Validated);
     367      this.refreshAutomaticallyCheckBox.CheckedChanged += new System.EventHandler(this.refreshAutomaticallyCheckBox_CheckedChanged);
    368368      //
    369369      // infoGroupBox
  • branches/GP-MoveOperators/HeuristicLab.Clients.Hive.JobManager/3.3/Views/RefreshableHiveJobView.cs

    r8085 r8206  
    4242  [Content(typeof(RefreshableJob), true)]
    4343  public partial class RefreshableHiveJobView : HeuristicLab.Core.Views.ItemView {
     44    private Progress progress;
    4445    private ProgressView progressView;
    4546    private HiveResourceSelectorDialog hiveResourceSelectorDialog;
     
    5556    public RefreshableHiveJobView() {
    5657      InitializeComponent();
     58      progress = new Progress() {
     59        CanBeCanceled = false,
     60        ProgressState = ProgressState.Finished
     61      };
    5762    }
    5863
     
    7277      Content.Loaded += new EventHandler(Content_Loaded);
    7378      Content.TaskReceived += new EventHandler(Content_TaskReceived);
     79      progressView = new ProgressView(this, progress);
    7480    }
    7581
     
    8793      Content.Loaded -= new EventHandler(Content_Loaded);
    8894      Content.TaskReceived -= new EventHandler(Content_TaskReceived);
     95      if (progressView != null) {
     96        progressView.Content = null;
     97        progressView.Dispose();
     98        progressView = null;
     99      }
    89100      base.DeregisterContentEvents();
    90101    }
     
    148159        bool alreadyUploaded = Content.Id != Guid.Empty;
    149160        bool jobsLoaded = Content.HiveTasks != null && Content.HiveTasks.All(x => x.Task.Id != Guid.Empty);
    150 
    151         this.nameTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded;
    152         this.resourceNamesTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded;
    153         this.searchButton.Enabled = Content.IsControllable && !(Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded);
    154         this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded;
    155 
    156         this.isPrivilegedCheckBox.Enabled = Content.IsAllowedPrivileged && Content.IsControllable && !(Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded); // TODO: check if user has the rights to do this       
    157         this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && Content.ExecutionState == ExecutionState.Started;
    158         this.refreshButton.Enabled = Content.IsDownloadable && alreadyUploaded;
    159         this.Locked = !Content.IsControllable || Content.ExecutionState == ExecutionState.Started;
     161        tabControl.Enabled = !Content.IsProgressing;
     162
     163        this.nameTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
     164        this.resourceNamesTextBox.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
     165        this.searchButton.Enabled = (Content.IsControllable && !(Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded)) || !Content.IsProgressing;
     166        this.jobsTreeView.ReadOnly = !Content.IsControllable || Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded || Content.IsProgressing;
     167
     168        this.isPrivilegedCheckBox.Enabled = Content.IsAllowedPrivileged && Content.IsControllable && !(Content.ExecutionState != ExecutionState.Prepared || alreadyUploaded) && !Content.IsProgressing;
     169        this.refreshAutomaticallyCheckBox.Enabled = Content.IsControllable && alreadyUploaded && jobsLoaded && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
     170        this.refreshButton.Enabled = Content.IsDownloadable && alreadyUploaded && !Content.IsProgressing;
     171        this.Locked = !Content.IsControllable || Content.ExecutionState == ExecutionState.Started || Content.IsProgressing;
    160172      }
    161173      SetEnabledStateOfExecutableButtons();
     
    342354        foreach (Resource resource in hiveResourceSelectorDialog.GetSelectedResources()) {
    343355          sb.Append(resource.Name);
    344           sb.Append("; ");
     356          sb.Append(";");
    345357        }
    346358        resourceNamesTextBox.Text = sb.ToString();
     
    354366        var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobAsync, Content);
    355367        task.ContinueWith((t) => {
    356           FinishProgressView();
     368          progress.Finish();
    357369          MessageBox.Show("An error occured resuming the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
    358370          Content.Log.LogException(t.Exception);
     
    366378      var task = System.Threading.Tasks.Task.Factory.StartNew(PauseJobAsync, Content);
    367379      task.ContinueWith((t) => {
    368         FinishProgressView();
     380        progress.Finish();
    369381        MessageBox.Show("An error occured pausing the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
    370382        Content.Log.LogException(t.Exception);
     
    375387      var task = System.Threading.Tasks.Task.Factory.StartNew(StopJobAsync, Content);
    376388      task.ContinueWith((t) => {
    377         FinishProgressView();
     389        progress.Finish();
    378390        MessageBox.Show("An error occured stopping the job. See the log for more information.", "HeuristicLab Hive Job Manager", MessageBoxButtons.OK, MessageBoxIcon.Error);
    379391        Content.Log.LogException(t.Exception);
     
    383395
    384396    private void PauseJobAsync(object job) {
    385       IProgress prog = new Progress();
    386       prog.Status = "Pausing job...";
    387       SetProgressView(prog);
     397      progress.Status = "Pausing job...";
     398      progress.ProgressState = ProgressState.Started;
    388399      HiveClient.PauseJob((RefreshableJob)job);
    389       FinishProgressView();
     400      progress.Finish();
    390401    }
    391402
    392403    private void StopJobAsync(object job) {
    393       IProgress prog = new Progress();
    394       prog.Status = "Stopping job...";
    395       SetProgressView(prog);
     404      progress.Status = "Stopping job...";
     405      progress.ProgressState = ProgressState.Started;
    396406      HiveClient.StopJob((RefreshableJob)job);
    397       FinishProgressView();
     407      progress.Finish();
    398408    }
    399409
    400410    private void ResumeJobAsync(object job) {
    401       IProgress prog = new Progress();
    402       prog.Status = "Resuming job...";
    403       SetProgressView(prog);
     411      progress.Status = "Resuming job...";
     412      progress.ProgressState = ProgressState.Started;
    404413      HiveClient.ResumeJob((RefreshableJob)job);
    405       FinishProgressView();
     414      progress.Finish();
    406415    }
    407416
     
    416425    }
    417426
    418     private void refreshAutomaticallyCheckBox_Validated(object sender, EventArgs e) {
     427    private void refreshAutomaticallyCheckBox_CheckedChanged(object sender, EventArgs e) {
    419428      if (Content != null) Content.RefreshAutomatically = refreshAutomaticallyCheckBox.Checked;
    420429    }
     
    450459        startButton.Enabled = pauseButton.Enabled = stopButton.Enabled = resetButton.Enabled = false;
    451460      } else {
    452         startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused);
    453         pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started;
    454         stopButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started;
     461        startButton.Enabled = Content.IsControllable && Content.HiveTasks != null && Content.HiveTasks.Count > 0 && (Content.ExecutionState == ExecutionState.Prepared || Content.ExecutionState == ExecutionState.Paused) && !Content.IsProgressing;
     462        pauseButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
     463        stopButton.Enabled = Content.IsControllable && Content.ExecutionState == ExecutionState.Started && !Content.IsProgressing;
    455464        resetButton.Enabled = false;
    456465      }
     
    463472        Invoke(new EventHandler(Content_IsProgressingChanged), sender, e);
    464473      } else {
    465         if (Content != null && Content.IsProgressing) {
    466           SetProgressView();
    467         } else {
    468           FinishProgressView();
    469         }
    470       }
    471     }
    472 
    473     private void SetProgressView() {
    474       if (InvokeRequired) {
    475         Invoke(new Action(SetProgressView));
    476       } else {
    477         if (progressView == null) {
    478           progressView = new ProgressView(this, Content.Progress);
    479         } else {
    480           progressView.Progress = Content.Progress;
    481         }
    482       }
    483     }
    484 
    485     private void SetProgressView(IProgress progress) {
    486       if (InvokeRequired) {
    487         Invoke(new Action<IProgress>(SetProgressView), progress);
    488       } else {
    489         if (progressView == null) {
    490           progressView = new ProgressView(this, progress);
    491         } else {
    492           progressView.Progress = progress;
    493         }
    494       }
    495     }
    496 
    497     private void FinishProgressView() {
    498       if (InvokeRequired) {
    499         Invoke(new Action(FinishProgressView));
    500       } else {
    501         if (progressView != null) {
    502           progressView.Finish();
    503           progressView = null;
    504           SetEnabledStateOfControls();
     474        if (Content != null && Content.Progress != null && Content.IsProgressing) {
     475          progressView.Content = Content.Progress;
     476        } else if (Content != null) {
     477          progressView.Content = progress;
    505478        }
    506479      }
Note: See TracChangeset for help on using the changeset viewer.