Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/04/19 14:45:47 (5 years ago)
Author:
mkommend
Message:

#2845: Merged 16430 into stable.

Location:
stable
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Clients.Hive.Administrator

  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectJobsView.cs

    r17059 r17062  
    7575      progress = new Progress();
    7676
    77       removeButton.Enabled = false;     
     77      removeButton.Enabled = false;
    7878    }
    7979
     
    8181      base.RegisterContentEvents();
    8282      matrixView.DataGridView.SelectionChanged += DataGridView_SelectionChanged;
    83       MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, progress);
     83      MainForm.Progress.Show(this, progress);
    8484    }
    8585
    8686    protected override void DeregisterContentEvents() {
    8787      matrixView.DataGridView.SelectionChanged -= DataGridView_SelectionChanged;
    88       MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this, false);
     88      MainForm.Progress.Hide(this, false);
    8989      base.DeregisterContentEvents();
    9090    }
     
    114114        var jobs = GetSelectedJobs().ToList();
    115115        if (jobs.Any()) {
    116                    
     116
    117117          startButton.Enabled = jobs.All(x =>
    118118            !x.IsProgressing && HiveAdminClient.Instance.Tasks.ContainsKey(x.Id) && HiveAdminClient.Instance.Tasks[x.Id].Count > 0
     
    135135    #region Event Handlers
    136136    private void ProjectJobsView_Load(object sender, EventArgs e) {
    137      
     137
    138138    }
    139139
    140140    private void refreshButton_Click(object sender, EventArgs e) {
    141       progress.Start("Refreshing jobs...");
     141      progress.Start("Refreshing jobs...", ProgressMode.Indeterminate);
    142142      SetEnabledStateOfControls();
    143143      var task = System.Threading.Tasks.Task.Factory.StartNew(RefreshJobsAsync);
    144144
    145145      task.ContinueWith((t) => {
    146         progress.Finish();       
     146        progress.Finish();
    147147        SetEnabledStateOfControls();
    148148      });
     
    160160
    161161        if (result == DialogResult.Yes) {
    162           progress.Start("Removing job(s)...");
     162          progress.Start("Removing job(s)...", ProgressMode.Indeterminate);
    163163          SetEnabledStateOfControls();
    164164          var task = System.Threading.Tasks.Task.Factory.StartNew(RemoveJobsAsync, jobs);
     
    191191
    192192        if (result == DialogResult.Yes) {
    193           progress.Start("Resuming job(s)...");
     193          progress.Start("Resuming job(s)...", ProgressMode.Indeterminate);
    194194          SetEnabledStateOfControls();
    195195          var task = System.Threading.Tasks.Task.Factory.StartNew(ResumeJobsAsync, jobs);
    196196
    197197          task.ContinueWith((t) => {
    198             RefreshJobs();           
     198            RefreshJobs();
    199199            progress.Finish();
    200200            SetEnabledStateOfControls();
     
    227227
    228228          task.ContinueWith((t) => {
    229             RefreshJobs();           
     229            RefreshJobs();
    230230            progress.Finish();
    231231            SetEnabledStateOfControls();
     
    253253
    254254        if (result == DialogResult.Yes) {
    255           progress.Start("Stopping job(s)...");
     255          progress.Start("Stopping job(s)...", ProgressMode.Indeterminate);
    256256          SetEnabledStateOfControls();
    257257          var task = System.Threading.Tasks.Task.Factory.StartNew(StopJobsAsync, jobs);
     
    267267            progress.Finish();
    268268            SetEnabledStateOfControls();
    269             MessageBox.Show("An error occured stopping the job(s).", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);           
     269            MessageBox.Show("An error occured stopping the job(s).", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
    270270          }, TaskContinuationOptions.OnlyOnFaulted);
    271271        }
     
    284284    private IEnumerable<RefreshableJob> GetSelectedJobs() {
    285285      if (Content == null || matrixView.DataGridView.SelectedRows == null || matrixView.DataGridView.SelectedRows.Count == 0)
    286         return Enumerable.Empty<RefreshableJob>() ;
     286        return Enumerable.Empty<RefreshableJob>();
    287287
    288288      var jobs = new List<RefreshableJob>();
    289289      foreach (DataGridViewRow r in matrixView.DataGridView.SelectedRows) {
    290290        if (((string)r.Cells[0].Value) == JobState.Online.ToString()) {
    291           jobs.Add(HiveAdminClient.Instance.Jobs[Content.Id].FirstOrDefault(x => x.Id == Guid.Parse((string) r.Cells[11].Value)));
     291          jobs.Add(HiveAdminClient.Instance.Jobs[Content.Id].FirstOrDefault(x => x.Id == Guid.Parse((string)r.Cells[11].Value)));
    292292        }
    293293      }
     
    310310      string[,] values = new string[jobs.Count, 13];
    311311
    312       for(int i = 0; i < jobs.Count; i++) {
    313         var job = jobs.ElementAt(i);       
     312      for (int i = 0; i < jobs.Count; i++) {
     313        var job = jobs.ElementAt(i);
    314314        values[i, 0] = job.Job.State.ToString();
    315315        values[i, 1] = job.ExecutionState.ToString();
     
    322322        values[i, 8] = job.Job.CalculatingCount.ToString();
    323323        values[i, 9] = job.Job.FinishedCount.ToString();
    324         values[i, 10] = job.Job.Description;       
     324        values[i, 10] = job.Job.Description;
    325325        values[i, 11] = job.Job.Id.ToString();
    326326        values[i, 12] = job.Job.OwnerUserId.ToString();
    327327      }
    328      
     328
    329329      var matrix = new StringMatrix(values);
    330330      matrix.ColumnNames = new string[] { JOB_STATE, JOB_EXECUTIONSTATE, JOB_EXECUTIONTIME, JOB_DATECREATED, JOB_OWNER, JOB_NAME, JOB_TASKCOUNT, JOB_WAITINGTASKCOUNT, JOB_CALCULATINGTASKCOUNT, JOB_FINISHEDTASKCOUNT, JOB_DESCRIPTION, JOB_ID, JOB_OWNERID };
     
    332332      return matrix;
    333333    }
    334    
     334
    335335    private void UpdateJobs() {
    336336      if (InvokeRequired) Invoke((Action)UpdateJobs);
    337337      else {
    338         if(Content != null && Content.Id != null && Content.Id != Guid.Empty) {
     338        if (Content != null && Content.Id != null && Content.Id != Guid.Empty) {
    339339          var matrix = CreateValueMatrix();
    340340          matrixView.Content = matrix;
    341           if(matrix != null) {
     341          if (matrix != null) {
    342342            foreach (DataGridViewRow row in matrixView.DataGridView.Rows) {
    343343              string val = ((string)row.Cells[0].Value);
     
    355355            matrixView.DataGridView.Columns[1].MinimumWidth = 108;
    356356          }
    357         } 
     357        }
    358358      }
    359359    }
     
    367367      var jobList = (IEnumerable<RefreshableJob>)jobs;
    368368      foreach (var job in jobList) {
    369         progress.Status = "Resuming job \"" + job.Job.Name + "\"...";
     369        progress.Message = "Resuming job \"" + job.Job.Name + "\"...";
    370370        HiveAdminClient.ResumeJob(job);
    371371      }
     
    375375      var jobList = (IEnumerable<RefreshableJob>)jobs;
    376376      foreach (var job in jobList) {
    377         progress.Status = "Pausing job \"" + job.Job.Name + "\"...";
     377        progress.Message = "Pausing job \"" + job.Job.Name + "\"...";
    378378        HiveAdminClient.PauseJob(job);
    379379      }
     
    381381
    382382    private void StopJobsAsync(object jobs) {
    383       var jobList = (IEnumerable<RefreshableJob>) jobs;
    384       foreach (var job in jobList) {       
    385         progress.Status = "Stopping job \"" + job.Job.Name + "\"...";
     383      var jobList = (IEnumerable<RefreshableJob>)jobs;
     384      foreach (var job in jobList) {
     385        progress.Message = "Stopping job \"" + job.Job.Name + "\"...";
    386386        HiveAdminClient.StopJob(job);
    387387      }
     
    390390    private void RemoveJobsAsync(object jobs) {
    391391      var jobList = (IEnumerable<RefreshableJob>)jobs;
    392       progress.Start();
     392      progress.Start("", ProgressMode.Indeterminate);
    393393      foreach (var job in jobList) {
    394         progress.Status = "Removing job \"" + job.Job.Name + "\"...";
     394        progress.Message = "Removing job \"" + job.Job.Name + "\"...";
    395395        HiveAdminClient.RemoveJob(job);
    396396      }
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs

    r17060 r17062  
    126126      bool enabled = Content != null && !Locked && !ReadOnly;
    127127      nameTextBox.Enabled = enabled;
    128       descriptionTextBox.Enabled = enabled;     
     128      descriptionTextBox.Enabled = enabled;
    129129      ownerComboBox.Enabled = enabled;
    130130      createdTextBox.Enabled = enabled;
     
    160160      if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshing, sender, e);
    161161      else {
    162         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    163         mainForm.AddOperationProgressToView(this, "Refreshing ...");
     162        Progress.Show(this, "Refreshing ...", ProgressMode.Indeterminate);
    164163        SetEnabledStateOfControls();
    165164      }
     
    169168      if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshed, sender, e);
    170169      else {
    171         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    172         mainForm.RemoveOperationProgressFromView(this);
     170        Progress.Hide(this);
    173171        SetEnabledStateOfControls();
    174172      }
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs

    r17059 r17062  
    4343    private const string NOT_STORED_TAG = "*"; // " [not stored]";
    4444    private const string CHANGES_NOT_STORED_TAG = "*"; // " [changes not stored]";
    45     private const string INACTIVE_TAG = " [inactive]"; 
     45    private const string INACTIVE_TAG = " [inactive]";
    4646
    4747    private readonly Color selectedBackColor = Color.DodgerBlue;
     
    111111
    112112    protected override void SetEnabledStateOfControls() {
    113       base.SetEnabledStateOfControls();     
    114 
    115       bool locked = Content == null || Locked || ReadOnly;     
     113      base.SetEnabledStateOfControls();
     114
     115      bool locked = Content == null || Locked || ReadOnly;
    116116      bool parentOwner = selectedProject != null && HiveAdminClient.Instance.CheckOwnershipOfParentProject(selectedProject, UserInformation.Instance.User.Id);
    117       bool selectedProjectDisabled = selectedProject == null 
     117      bool selectedProjectDisabled = selectedProject == null
    118118                                     || selectedProject != null && selectedProject.Id == Guid.Empty;
    119119
     
    183183      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshing, sender, e);
    184184      else {
    185         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    186         mainForm.AddOperationProgressToView(this, "Refreshing ...");
     185        Progress.Show(this, "Refreshing ...", ProgressMode.Indeterminate);
    187186        SetEnabledStateOfControls();
    188187      }
     
    192191      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshed, sender, e);
    193192      else {
    194         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    195         mainForm.RemoveOperationProgressFromView(this);
     193        Progress.Hide(this);
    196194        SetEnabledStateOfControls();
    197195      }
     
    201199      if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshing, sender, e);
    202200      else {
    203         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    204         mainForm.AddOperationProgressToView(this, "Refreshing ...");
     201        Progress.Show(this, "Refreshing ...", ProgressMode.Indeterminate);
    205202        SetEnabledStateOfControls();
    206203      }
     
    210207      if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshed, sender, e);
    211208      else {
    212         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    213         mainForm.RemoveOperationProgressFromView(this);
     209        Progress.Hide(this);
    214210        SetEnabledStateOfControls();
    215211      }
     
    234230    }
    235231
    236     private void addButton_Click(object sender, EventArgs e) {     
     232    private void addButton_Click(object sender, EventArgs e) {
    237233
    238234      if (selectedProject == null && !IsAdmin()) {
     
    244240        return;
    245241      }
    246      
     242
    247243      if (selectedProject != null && selectedProject.Id == Guid.Empty) {
    248244        MessageBox.Show(
     
    256252      var project = new Project {
    257253        Name = "New Project",
    258         OwnerUserId = UserInformation.Instance.User.Id,       
     254        OwnerUserId = UserInformation.Instance.User.Id,
    259255      };
    260       if(selectedProject != null) {
     256      if (selectedProject != null) {
    261257        project.ParentProjectId = selectedProject.Id;
    262258        project.EndDate = selectedProject.EndDate;
     
    285281        await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
    286282          action: () => {
    287             RemoveProject(selectedProject); 
     283            RemoveProject(selectedProject);
    288284          });
    289285      }
     
    304300          foreach (var project in projectsToSave)
    305301            project.Store();
    306          
     302
    307303          UpdateProjects();
    308304        },
     
    316312      if (node == null) return;
    317313      var p = (Project)node.Tag;
    318       if(!HiveAdminClient.Instance.DisabledParentProjects.Contains(p)) ChangeSelectedProjectNode(node);
     314      if (!HiveAdminClient.Instance.DisabledParentProjects.Contains(p)) ChangeSelectedProjectNode(node);
    319315    }
    320316
     
    357353      if (targetNode == null) {
    358354        treeView.Nodes.Add(sourceNode);
    359       } else if(targetProject.Id != Guid.Empty) {
     355      } else if (targetProject.Id != Guid.Empty) {
    360356        targetNode.Nodes.Add(sourceNode);
    361357        sourceProject.ParentProjectId = targetProject.Id;
     
    422418        var newNode = new TreeNode(newProject.Name) { Tag = newProject };
    423419        StyleTreeNode(newNode, newProject);
    424      
     420
    425421        if (selectedProject == null && !disabledParentProjects.Contains(newProject)) {
    426422          SelectedProject = newProject;
     
    533529        if (project.Id != Guid.Empty) {
    534530          SelectedProject = HiveAdminClient.Instance.GetAvailableProjectAncestors(project.Id).LastOrDefault();
    535           HiveAdminClient.Delete(project);         
     531          HiveAdminClient.Delete(project);
    536532          UpdateProjects();
    537         } else {         
     533        } else {
    538534          SelectedProject = Content.FirstOrDefault(x => x.Id == project.ParentProjectId);
    539535          Content.Remove(project);
  • stable/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs

    r17059 r17062  
    185185      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshing, sender, e);
    186186      else {
    187         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    188         mainForm.AddOperationProgressToView(this, "Refreshing ...");
     187        Progress.Show(this, "Refreshing ...", ProgressMode.Indeterminate);
    189188        SetEnabledStateOfControls();
    190189      }
     
    194193      if (InvokeRequired) Invoke((Action<object, EventArgs>)HiveAdminClient_Instance_Refreshed, sender, e);
    195194      else {
    196         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    197         mainForm.RemoveOperationProgressFromView(this);
     195        Progress.Hide(this);
    198196        SetEnabledStateOfControls();
    199197      }
     
    203201      if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshing, sender, e);
    204202      else {
    205         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    206         mainForm.AddOperationProgressToView(this, "Refreshing ...");
     203        Progress.Show(this, "Refreshing ...", ProgressMode.Indeterminate);
    207204        SetEnabledStateOfControls();
    208205      }
     
    212209      if (InvokeRequired) Invoke((Action<object, EventArgs>)AccessClient_Instance_Refreshed, sender, e);
    213210      else {
    214         var mainForm = MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>();
    215         mainForm.RemoveOperationProgressFromView(this);
     211        Progress.Hide(this);
    216212        SetEnabledStateOfControls();
    217213      }
     
    247243    }
    248244
    249     private async void btnRemoveGroup_Click(object sender, EventArgs e) {     
     245    private async void btnRemoveGroup_Click(object sender, EventArgs e) {
    250246      var nodes = GetCheckedNodes(treeView.Nodes).ToList();
    251247      var checkedResources = nodes.Select(x => x.Tag).OfType<Resource>().ToList();
     
    574570          foreach (var nr in newResources) Content.Remove(nr);
    575571
    576           HiveAdminClient.Delete(resource);         
     572          HiveAdminClient.Delete(resource);
    577573          UpdateResources();
    578574        } else {
     
    588584      if (resources == null || !resources.Any()) return;
    589585
    590       var ids = resources.Select(x => x.Id).ToList();     
     586      var ids = resources.Select(x => x.Id).ToList();
    591587      try {
    592588        bool update = false;
    593         foreach (var r in resources) {         
    594           if (r.Id != Guid.Empty)  {
    595             if(r.Id == SelectedResource.Id)
     589        foreach (var r in resources) {
     590          if (r.Id != Guid.Empty) {
     591            if (r.Id == SelectedResource.Id)
    596592              SelectedResource = HiveAdminClient.Instance.GetAvailableResourceAncestors(r.Id).LastOrDefault();
    597593
     
    751747
    752748      foreach (var r in resources) {
    753         if(!resourceDescendants.ContainsKey(r.Id))
     749        if (!resourceDescendants.ContainsKey(r.Id))
    754750          resourceDescendants.Add(r.Id, new HashSet<Resource>());
    755751      }
Note: See TracChangeset for help on using the changeset viewer.