Free cookie consent management tool by TermsFeed Policy Generator

Changeset 16072


Ignore:
Timestamp:
08/10/18 11:35:25 (6 years ago)
Author:
jzenisek
Message:

#2839: worked on HiveProjectMgmt:

  • adapted enabled state of buttons
Location:
branches/2839_HiveProjectManagement
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectJobsView.cs

    r15978 r16072  
    2828using HeuristicLab.MainForm.WindowsForms;
    2929using HeuristicLab.Core.Views;
    30 using HeuristicLab.Data.Views;
    3130using HeuristicLab.Data;
    3231using HeuristicLab.Clients.Hive.Views;
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs

    r16043 r16072  
    102102        projectResourcesView.Content = null;
    103103        projectJobsView.Content = null;
     104        selectedProject = null;
    104105      } else {
    105106        BuildProjectTree(Content);
     
    109110    protected override void SetEnabledStateOfControls() {
    110111      base.SetEnabledStateOfControls();
    111       bool enabled = Content != null && !Locked && !ReadOnly;
    112       refreshButton.Enabled = enabled;
    113       //addButton.Enabled = enabled;
    114       //removeButton.Enabled = enabled;
    115       //saveProjectButton.Enabled = enabled;
    116       projectView.Enabled = enabled;
    117       projectPermissionsView.Enabled = enabled;
    118       projectResourcesView.Enabled = enabled;
    119       projectJobsView.Enabled = enabled;
     112      bool selectedProjectExists = selectedProject != null && selectedProject.Id != Guid.Empty && Content.Contains(selectedProject);
     113      bool locked = Content == null || selectedProject == null || Locked || ReadOnly;
     114      bool parentOwner = HiveAdminClient.Instance.CheckOwnershipOfParentProject(selectedProject, UserInformation.Instance.User.Id);
     115      bool saveLocked = locked || (!IsAdmin() && selectedProject.OwnerUserId != UserInformation.Instance.User.Id && !parentOwner);
     116      bool addLocked = saveLocked || selectedProject.Id == Guid.Empty;
     117      bool deleteLocked = locked || (!IsAdmin() && !parentOwner) || Content.Where(x => x.ParentProjectId == selectedProject.Id).Any();
     118
     119      addButton.Enabled = !addLocked;
     120      removeButton.Enabled = !deleteLocked;
     121      saveProjectButton.Enabled = !saveLocked;
     122      projectView.Enabled = !locked;
     123      projectPermissionsView.Enabled = !locked;
     124      projectResourcesView.Enabled = !locked;
     125      projectJobsView.Enabled = !locked;
    120126    }
    121127    #endregion
     
    265271        && HiveAdminClient.Instance.Jobs[selectedProject.Id].Any()) {
    266272        MessageBox.Show(
    267           "There are " + HiveAdminClient.Instance.Jobs[selectedProject.Id].Count + " jobs using this project and/or child-projects. It is necessary to delete them before the project.",
     273          "There are " + HiveAdminClient.Instance.Jobs[selectedProject.Id].Count + " job(s) using this project and/or child-projects. It is necessary to delete them before the project.",
    268274          "HeuristicLab Hive Administrator",
    269275          MessageBoxButtons.OK,
     
    286292            removeButton.Enabled = true;
    287293          });
     294      } else {
     295        removeButton.Enabled = true;
    288296      }
    289297    }
     
    297305      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
    298306        action: () => {
     307          //if (selectedProject != null && selectedProject.Id == Guid.Empty)
     308          //  SelectedProject = HiveAdminClient.Instance.GetAvailableProjectAncestors(selectedProject.Id).LastOrDefault();
    299309          var projectsToSave = Content.Where(x => x.Id == Guid.Empty || x.Modified);
    300310          foreach (var project in projectsToSave)
    301311            project.Store();
     312         
    302313          UpdateProjects();
    303314        },
     
    552563          foreach (var p in projectsToSave)
    553564            p.Store();
    554           HiveAdminClient.Delete(project);
     565
     566          SelectedProject = HiveAdminClient.Instance.GetAvailableProjectAncestors(project.Id).LastOrDefault();
     567          HiveAdminClient.Delete(project);         
    555568          UpdateProjects();
    556569        } else {
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs

    r16057 r16072  
    106106      this.btnRefresh.Size = new System.Drawing.Size(24, 24);
    107107      this.btnRefresh.TabIndex = 8;
    108       this.toolTip.SetToolTip(this.btnRefresh, "Fetch list from server");
     108      this.toolTip.SetToolTip(this.btnRefresh, "Fetch list from server.");
    109109      this.btnRefresh.UseVisualStyleBackColor = true;
    110110      this.btnRefresh.Click += new System.EventHandler(this.btnRefresh_Click);
     
    117117      this.btnSave.Size = new System.Drawing.Size(24, 24);
    118118      this.btnSave.TabIndex = 5;
    119       this.toolTip.SetToolTip(this.btnSave, "Store slave and group configuration on the server");
     119      this.toolTip.SetToolTip(this.btnSave, "Store slave and group configuration on the server.");
    120120      this.btnSave.UseVisualStyleBackColor = true;
    121121      this.btnSave.Click += new System.EventHandler(this.btnSave_Click);
     
    128128      this.btnRemoveGroup.Size = new System.Drawing.Size(24, 24);
    129129      this.btnRemoveGroup.TabIndex = 2;
    130       this.toolTip.SetToolTip(this.btnRemoveGroup, "Remove a slave or a group");
     130      this.toolTip.SetToolTip(this.btnRemoveGroup, "Remove a slave or a group.");
    131131      this.btnRemoveGroup.UseVisualStyleBackColor = true;
    132132      this.btnRemoveGroup.Click += new System.EventHandler(this.btnRemoveGroup_Click);
     
    139139      this.btnAddGroup.Size = new System.Drawing.Size(24, 24);
    140140      this.btnAddGroup.TabIndex = 1;
    141       this.toolTip.SetToolTip(this.btnAddGroup, "Add a new group");
     141      this.toolTip.SetToolTip(this.btnAddGroup, "Add a new group.");
    142142      this.btnAddGroup.UseVisualStyleBackColor = true;
    143143      this.btnAddGroup.Click += new System.EventHandler(this.btnAddGroup_Click);
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs

    r16064 r16072  
    117117      base.SetEnabledStateOfControls();
    118118
    119       bool locked = Content == null || Locked || ReadOnly || !IsAdmin();
    120       bool scheduleLocked = locked || (selectedResource != null && selectedResource.Id == Guid.Empty);
    121       bool addLocked = locked || (selectedResource != null && selectedResource.Id == Guid.Empty) || selectedResource is Slave;
     119      bool locked = Content == null || selectedResource == null || Locked || ReadOnly;
     120      bool adminLocked = locked || !IsAdmin();
     121      bool addLocked = adminLocked || selectedResource.Id == Guid.Empty || selectedResource is Slave;
     122      bool deleteLocked = adminLocked || HiveAdminClient.Instance.ResourceDescendants[selectedResource.Id].Any();
    122123
    123124      btnAddGroup.Enabled = !addLocked;
    124       btnRemoveGroup.Enabled = !locked;
     125      btnRemoveGroup.Enabled = !deleteLocked;
    125126      btnSave.Enabled = !locked;
    126       viewHost.Enabled = true;
    127       //viewHost.Locked = locked;
    128       viewHost.Locked = false;
    129       viewHost.ReadOnly = false;
    130       scheduleView.Locked = locked;
    131       //scheduleView.SetEnabledStateOfSchedule(!scheduleLocked);
     127      scheduleView.Locked = adminLocked;
    132128    }
    133129    #endregion
     
    228224      }
    229225
    230       if (selectedResource != null && selectedResource is SlaveGroup) parentResourceId = selectedResource.Id;
     226      if (selectedResource != null && selectedResource is SlaveGroup) {
     227        parentResourceId = selectedResource.Id;
     228      } else {
     229        MessageBox.Show(
     230          "You cannot add a resource group to a slave.",
     231          "HeuristicLab Hive Administrator",
     232          MessageBoxButtons.OK,
     233          MessageBoxIcon.Information);
     234        return;
     235      }
     236
    231237      var group = new SlaveGroup {
    232238        Name = "New Group",
     
    250256      if (!IsAdmin()) {
    251257        MessageBox.Show(
    252           "You have no permission to delete resources.",
     258          "You have no permission to delete resource groups.",
    253259          "HeuristicLab Hive Administrator",
    254260          MessageBoxButtons.OK,
     
    259265      if (Content.Any(x => x.ParentResourceId == selectedResource.Id)) {
    260266        MessageBox.Show(
    261           "Only empty resources can be deleted.",
     267          "Only empty resource groups can be deleted.",
    262268          "HeuristicLab Hive Administrator",
    263269          MessageBoxButtons.OK,
     
    279285            btnRemoveGroup.Enabled = true;
    280286          });
     287      } else {
     288        btnRemoveGroup.Enabled = true;
    281289      }
    282290    }
     
    559567          foreach (var r in resourcesToSave)
    560568            r.Store();
     569
     570          SelectedResource = HiveAdminClient.Instance.GetAvailableResourceAncestors(resource.Id).LastOrDefault();
    561571          HiveAdminClient.Delete(resource);
    562572          UpdateResources();
  • branches/2839_HiveProjectManagement/HeuristicLab.Clients.Hive/3.3/HiveAdminClient.cs

    r16057 r16072  
    163163            var unsortedJobs = service.GetJobsByProjectIds(projectIds)
    164164              .OrderBy(x => x.DateCreated).ToList();
    165            
     165
    166166            unsortedJobs.Where(j => j.State == JobState.DeletionPending).ToList().ForEach(j => jobs[j.ProjectId].Add(j));
    167167            unsortedJobs.Where(j => j.State == JobState.StatisticsPending).ToList().ForEach(j => jobs[j.ProjectId].Add(j));
Note: See TracChangeset for help on using the changeset viewer.