Free cookie consent management tool by TermsFeed Policy Generator

Changeset 15422


Ignore:
Timestamp:
10/17/17 13:44:16 (7 years ago)
Author:
jkarder
Message:

#2839: worked on resources and projects views

Location:
branches/HiveProjectManagement
Files:
6 added
11 edited

Legend:

Unmodified
Added
Removed
  • branches/HiveProjectManagement/HeuristicLab.Clients.Access.Administration/3.3/Views/UserGroupView.cs

    r14185 r15422  
    4040    protected override void RegisterContentEvents() {
    4141      base.RegisterContentEvents();
    42       Access.AccessClient.Instance.Refreshing += new EventHandler(Content_Refreshing);
     42      AccessClient.Instance.Refreshing += new EventHandler(Content_Refreshing);
    4343      refreshableLightweightUserView.StorableStateChanged += new EventHandler(refreshableLightweightUserView_StorableStateChanged);
    4444    }
    4545
    4646    protected override void DeregisterContentEvents() {
    47       Access.AccessClient.Instance.Refreshing -= new EventHandler(Content_Refreshing);
     47      AccessClient.Instance.Refreshing -= new EventHandler(Content_Refreshing);
    4848      refreshableLightweightUserView.StorableStateChanged -= new EventHandler(refreshableLightweightUserView_StorableStateChanged);
    4949      base.DeregisterContentEvents();
     
    6363        idTextBox.Text = Content.Id.ToString();
    6464
    65         refreshableLightweightUserView.Content = Content.Id != Guid.Empty ? Access.AccessClient.Instance : null;
    66         refreshableLightweightUserView.FetchSelectedUsers = Content.Id != Guid.Empty ? new Func<List<Guid>>(delegate { return AccessAdministrationClient.CallAccessService<List<Guid>>(s => s.GetUserGroupIdsOfGroup(Content.Id)); }) : null;
     65        refreshableLightweightUserView.Content = Content.Id != Guid.Empty ? AccessClient.Instance : null;
     66        refreshableLightweightUserView.FetchSelectedUsers = Content.Id != Guid.Empty ? new Func<List<Guid>>(delegate { return AccessAdministrationClient.CallAccessService(s => s.GetUserGroupIdsOfGroup(Content.Id)); }) : null;
    6767      }
    6868    }
    6969
    70     private void groupNameTextBox_TextChanged(object sender, System.EventArgs e) {
    71       if (Content.Name != this.groupNameTextBox.Text)
    72         Content.Name = this.groupNameTextBox.Text;
     70    private void groupNameTextBox_TextChanged(object sender, EventArgs e) {
     71      if (Content != null && Content.Name != groupNameTextBox.Text)
     72        Content.Name = groupNameTextBox.Text;
    7373    }
    7474
  • branches/HiveProjectManagement/HeuristicLab.Clients.Access/3.3/ServiceClients/User.cs

    r14185 r15422  
    5151
    5252    public override string ToString() {
    53       return UserName + "(" + FullName + ")";
     53      return UserName + " (" + FullName + ")";
    5454    }
    5555  }
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/HeuristicLab.Clients.Hive.Administrator-3.3.csproj

    r15401 r15422  
    132132    </Compile>
    133133    <Compile Include="MenuItems\AdministratorMenuItem.cs" />
     134    <Compile Include="Views\ProjectPermissionsView.cs">
     135      <SubType>UserControl</SubType>
     136    </Compile>
     137    <Compile Include="Views\ProjectPermissionsView.Designer.cs">
     138      <DependentUpon>ProjectPermissionsView.cs</DependentUpon>
     139    </Compile>
     140    <Compile Include="Views\ProjectResourcesView.cs">
     141      <SubType>UserControl</SubType>
     142    </Compile>
     143    <Compile Include="Views\ProjectResourcesView.Designer.cs">
     144      <DependentUpon>ProjectResourcesView.cs</DependentUpon>
     145    </Compile>
    134146    <Compile Include="Views\ProjectsView.cs">
    135147      <SubType>UserControl</SubType>
     
    162174    <Compile Include="Views\ScheduleView.Designer.cs">
    163175      <DependentUpon>ScheduleView.cs</DependentUpon>
     176    </Compile>
     177    <Compile Include="Views\ResourceView.cs">
     178      <SubType>UserControl</SubType>
     179    </Compile>
     180    <Compile Include="Views\ResourceView.Designer.cs">
     181      <DependentUpon>ResourceView.cs</DependentUpon>
    164182    </Compile>
    165183    <Compile Include="Views\SlaveView.cs">
     
    178196  </ItemGroup>
    179197  <ItemGroup>
     198    <ProjectReference Include="..\..\HeuristicLab.Clients.Access.Administration\3.3\HeuristicLab.Clients.Access.Administration-3.3.csproj">
     199      <Project>{C9CF6AE8-4637-4A75-9141-042F479B5D50}</Project>
     200      <Name>HeuristicLab.Clients.Access.Administration-3.3</Name>
     201    </ProjectReference>
    180202    <ProjectReference Include="..\..\HeuristicLab.Clients.Access.Views\3.3\HeuristicLab.Clients.Access.Views-3.3.csproj">
    181203      <Project>{FE856595-64CD-46DA-9CD2-FFF3E6B0D4F2}</Project>
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.Designer.cs

    r15412 r15422  
    5757      this.nameTextBox.Size = new System.Drawing.Size(464, 20);
    5858      this.nameTextBox.TabIndex = 1;
     59      this.nameTextBox.TextChanged += new System.EventHandler(this.nameTextBox_TextChanged);
    5960      this.nameTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.nameTextBox_Validating);
    6061      //
     
    7778      this.descriptionTextBox.Size = new System.Drawing.Size(464, 98);
    7879      this.descriptionTextBox.TabIndex = 3;
    79       this.descriptionTextBox.Validating += new System.ComponentModel.CancelEventHandler(this.descriptionTextBox_Validating);
     80      this.descriptionTextBox.TextChanged += new System.EventHandler(this.descriptionTextBox_TextChanged);
    8081      //
    8182      // ownerComboBox
     
    118119      this.startDateTimePicker.Size = new System.Drawing.Size(200, 20);
    119120      this.startDateTimePicker.TabIndex = 9;
    120       this.startDateTimePicker.Validating += new System.ComponentModel.CancelEventHandler(this.startDateTimePicker_Validating);
     121      this.startDateTimePicker.ValueChanged += new System.EventHandler(this.startDateTimePicker_ValueChanged);
    121122      //
    122123      // startLabel
     
    138139      this.endDateTimePicker.Size = new System.Drawing.Size(200, 20);
    139140      this.endDateTimePicker.TabIndex = 11;
    140       this.endDateTimePicker.Validating += new System.ComponentModel.CancelEventHandler(this.endDateTimePicker_Validating);
     141      this.endDateTimePicker.ValueChanged += new System.EventHandler(this.endDateTimePicker_ValueChanged);
    141142      //
    142143      // endLabel
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectView.cs

    r15412 r15422  
    3434  public partial class ProjectView : ItemView {
    3535    private readonly object locker = new object();
    36     private bool updatingUsers = false;
    3736
    3837    public new Project Content {
     
    9190    protected override void SetEnabledStateOfControls() {
    9291      base.SetEnabledStateOfControls();
    93       bool enabled = Content != null;
     92      bool enabled = Content != null && !ReadOnly;
    9493      nameTextBox.Enabled = enabled;
    9594      descriptionTextBox.Enabled = enabled;
     
    138137    private async void refreshButton_Click(object sender, EventArgs e) {
    139138      lock (locker) {
    140         if (updatingUsers) return;
    141         updatingUsers = true;
     139        if (!refreshButton.Enabled) return;
     140        refreshButton.Enabled = false;
    142141      }
    143142
     
    149148          ownerComboBox.SelectedItem = AccessClient.Instance.UsersAndGroups.FirstOrDefault(x => x.Id == Content.OwnerUserId);
    150149          ownerComboBox.SelectedIndexChanged += ownerComboBox_SelectedIndexChanged;
    151           updatingUsers = false;
     150          refreshButton.Enabled = true;
    152151        });
    153152    }
     
    161160          MessageBoxIcon.Error);
    162161        e.Cancel = true;
    163       } else Content.Name = nameTextBox.Text;
    164     }
    165 
    166     private void descriptionTextBox_Validating(object sender, CancelEventArgs e) {
    167       Content.Description = descriptionTextBox.Text;
     162      }
     163    }
     164
     165    private void nameTextBox_TextChanged(object sender, EventArgs e) {
     166      if (Content != null && Content.Name != nameTextBox.Text)
     167        Content.Name = nameTextBox.Text;
     168    }
     169
     170    private void descriptionTextBox_TextChanged(object sender, EventArgs e) {
     171      if (Content != null && Content.Description != descriptionTextBox.Text)
     172        Content.Description = descriptionTextBox.Text;
    168173    }
    169174
    170175    private void ownerComboBox_SelectedIndexChanged(object sender, EventArgs e) {
    171176      var selectedItem = (LightweightUser)ownerComboBox.SelectedItem;
    172       Content.OwnerUserId = selectedItem != null ? selectedItem.Id : Guid.Empty;
    173     }
    174 
    175     private void startDateTimePicker_Validating(object sender, CancelEventArgs e) {
     177      var selectedOwnerUserId = selectedItem != null ? selectedItem.Id : Guid.Empty;
     178      if (Content != null && Content.OwnerUserId != selectedOwnerUserId)
     179        Content.OwnerUserId = selectedOwnerUserId;
     180    }
     181
     182    private void startDateTimePicker_ValueChanged(object sender, EventArgs e) {
     183      if (Content == null) return;
    176184      if (!Content.EndDate.HasValue || startDateTimePicker.Value > Content.EndDate)
    177185        endDateTimePicker.Value = startDateTimePicker.Value;
    178       Content.StartDate = startDateTimePicker.Value;
    179     }
    180 
    181     private void endDateTimePicker_Validating(object sender, CancelEventArgs e) {
     186      if (Content.StartDate != startDateTimePicker.Value)
     187        Content.StartDate = startDateTimePicker.Value;
     188    }
     189
     190    private void endDateTimePicker_ValueChanged(object sender, EventArgs e) {
     191      if (Content == null) return;
    182192      if (endDateTimePicker.Value < startDateTimePicker.Value)
    183193        endDateTimePicker.Value = startDateTimePicker.Value;
    184       Content.EndDate = endDateTimePicker.Value;
     194      if (Content.EndDate != endDateTimePicker.Value)
     195        Content.EndDate = endDateTimePicker.Value;
    185196    }
    186197
    187198    private void indefiniteCheckBox_CheckedChanged(object sender, EventArgs e) {
    188       Content.EndDate = indefiniteCheckBox.Checked ? (DateTime?)null : Content.StartDate;
     199      if (Content == null) return;
     200      var newEndDate = indefiniteCheckBox.Checked ? (DateTime?)null : Content.StartDate;
     201      if (Content.EndDate != newEndDate)
     202        Content.EndDate = newEndDate;
    189203    }
    190204    #endregion
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.Designer.cs

    r15401 r15422  
    3636      this.projectView = new HeuristicLab.Clients.Hive.Administrator.Views.ProjectView();
    3737      this.permissionsTabPage = new System.Windows.Forms.TabPage();
    38       this.savePermissionsButton = new System.Windows.Forms.Button();
    39       this.permissionsView = new HeuristicLab.Clients.Access.Views.RefreshableLightweightUserView();
     38      this.projectPermissionsView = new HeuristicLab.Clients.Hive.Administrator.Views.ProjectPermissionsView();
     39      this.resourcesTabPage = new System.Windows.Forms.TabPage();
     40      this.projectResourcesView = new HeuristicLab.Clients.Hive.Administrator.Views.ProjectResourcesView();
    4041      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    4142      this.splitContainer.Panel1.SuspendLayout();
     
    4546      this.detailsTabPage.SuspendLayout();
    4647      this.permissionsTabPage.SuspendLayout();
     48      this.resourcesTabPage.SuspendLayout();
    4749      this.SuspendLayout();
    4850      //
     
    8284      // saveProjectButton
    8385      //
    84       this.saveProjectButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb;
     86      this.saveProjectButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Save;
    8587      this.saveProjectButton.Location = new System.Drawing.Point(93, 3);
    8688      this.saveProjectButton.Name = "saveProjectButton";
     
    143145      this.tabControl.Controls.Add(this.detailsTabPage);
    144146      this.tabControl.Controls.Add(this.permissionsTabPage);
     147      this.tabControl.Controls.Add(this.resourcesTabPage);
    145148      this.tabControl.Location = new System.Drawing.Point(3, 3);
    146149      this.tabControl.Name = "tabControl";
     
    148151      this.tabControl.Size = new System.Drawing.Size(585, 541);
    149152      this.tabControl.TabIndex = 0;
    150       this.tabControl.SelectedIndexChanged += new System.EventHandler(this.tabControl_SelectedIndexChanged);
    151153      //
    152154      // detailsTabPage
     
    176178      // permissionsTabPage
    177179      //
    178       this.permissionsTabPage.Controls.Add(this.savePermissionsButton);
    179       this.permissionsTabPage.Controls.Add(this.permissionsView);
     180      this.permissionsTabPage.Controls.Add(this.projectPermissionsView);
    180181      this.permissionsTabPage.Location = new System.Drawing.Point(4, 22);
    181182      this.permissionsTabPage.Name = "permissionsTabPage";
     
    186187      this.permissionsTabPage.UseVisualStyleBackColor = true;
    187188      //
    188       // savePermissionsButton
    189       //
    190       this.savePermissionsButton.Enabled = false;
    191       this.savePermissionsButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb;
    192       this.savePermissionsButton.Location = new System.Drawing.Point(39, 9);
    193       this.savePermissionsButton.Name = "savePermissionsButton";
    194       this.savePermissionsButton.Size = new System.Drawing.Size(24, 24);
    195       this.savePermissionsButton.TabIndex = 2;
    196       this.savePermissionsButton.UseVisualStyleBackColor = true;
    197       this.savePermissionsButton.Click += new System.EventHandler(this.savePermissionsButton_Click);
    198       //
    199       // permissionsView
    200       //
    201       this.permissionsView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    202             | System.Windows.Forms.AnchorStyles.Left)
    203             | System.Windows.Forms.AnchorStyles.Right)));
    204       this.permissionsView.Caption = "RefreshableLightweightUser View";
    205       this.permissionsView.Content = null;
    206       this.permissionsView.FetchSelectedUsers = null;
    207       this.permissionsView.Location = new System.Drawing.Point(6, 6);
    208       this.permissionsView.Name = "permissionsView";
    209       this.permissionsView.ReadOnly = false;
    210       this.permissionsView.Size = new System.Drawing.Size(565, 503);
    211       this.permissionsView.TabIndex = 0;
     189      // projectPermissionsView
     190      //
     191      this.projectPermissionsView.Caption = "ProjectView";
     192      this.projectPermissionsView.Content = null;
     193      this.projectPermissionsView.Dock = System.Windows.Forms.DockStyle.Fill;
     194      this.projectPermissionsView.Location = new System.Drawing.Point(3, 3);
     195      this.projectPermissionsView.Name = "projectPermissionsView";
     196      this.projectPermissionsView.ReadOnly = false;
     197      this.projectPermissionsView.Size = new System.Drawing.Size(571, 509);
     198      this.projectPermissionsView.TabIndex = 0;
     199      //
     200      // resourcesTabPage
     201      //
     202      this.resourcesTabPage.Controls.Add(this.projectResourcesView);
     203      this.resourcesTabPage.Location = new System.Drawing.Point(4, 22);
     204      this.resourcesTabPage.Name = "resourcesTabPage";
     205      this.resourcesTabPage.Padding = new System.Windows.Forms.Padding(3);
     206      this.resourcesTabPage.Size = new System.Drawing.Size(577, 515);
     207      this.resourcesTabPage.TabIndex = 2;
     208      this.resourcesTabPage.Text = "Resources";
     209      this.resourcesTabPage.UseVisualStyleBackColor = true;
     210      //
     211      // projectResourcesView
     212      //
     213      this.projectResourcesView.Caption = "ProjectView";
     214      this.projectResourcesView.Content = null;
     215      this.projectResourcesView.Dock = System.Windows.Forms.DockStyle.Fill;
     216      this.projectResourcesView.Location = new System.Drawing.Point(3, 3);
     217      this.projectResourcesView.Name = "projectResourcesView";
     218      this.projectResourcesView.ReadOnly = false;
     219      this.projectResourcesView.Size = new System.Drawing.Size(571, 509);
     220      this.projectResourcesView.TabIndex = 0;
    212221      //
    213222      // ProjectsView
     
    226235      this.detailsTabPage.ResumeLayout(false);
    227236      this.permissionsTabPage.ResumeLayout(false);
     237      this.resourcesTabPage.ResumeLayout(false);
    228238      this.ResumeLayout(false);
    229239
     
    243253    private ProjectView projectView;
    244254    private System.Windows.Forms.ImageList imageList;
    245     private Access.Views.RefreshableLightweightUserView permissionsView;
    246     private System.Windows.Forms.Button savePermissionsButton;
     255    private System.Windows.Forms.TabPage resourcesTabPage;
     256    private ProjectResourcesView projectResourcesView;
     257    private ProjectPermissionsView projectPermissionsView;
    247258  }
    248259}
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ProjectsView.cs

    r15412 r15422  
    4242
    4343    private readonly object locker = new object();
    44     private bool updatingProjects = false;
    45     private bool removingProjects = false;
    46     private bool savingProjects = false;
    4744
    4845    public new IItemList<Project> Content {
     
    8986        projectsTreeView.Nodes.Clear();
    9087        projectView.Content = null;
    91         permissionsView.Content = null;
    92         permissionsView.FetchSelectedUsers = null;
     88        projectPermissionsView.Content = null;
     89        projectResourcesView.Content = null;
    9390      } else {
    9491        var top = BuildProjectTree(Content);
    9592        projectView.Content = top;
    96         permissionsView.Content = AccessClient.Instance;
     93        projectPermissionsView.Content = top;
     94        projectResourcesView.Content = top;
    9795      }
    9896    }
     
    10098    protected override void SetEnabledStateOfControls() {
    10199      base.SetEnabledStateOfControls();
    102       bool enabled = Content != null;
     100      bool enabled = Content != null && !ReadOnly;
     101      refreshButton.Enabled = enabled;
    103102      addButton.Enabled = enabled;
    104103      removeButton.Enabled = enabled;
    105104      saveProjectButton.Enabled = enabled;
    106       savePermissionsButton.Enabled = enabled && permissionsView.Content != null && permissionsView.FetchSelectedUsers != null;
    107       permissionsView.Enabled = enabled && permissionsView.Content != null && permissionsView.FetchSelectedUsers != null;
     105      projectView.Enabled = enabled;
     106      projectPermissionsView.Enabled = enabled;
     107      projectResourcesView.Enabled = enabled;
    108108    }
    109109    #endregion
     
    175175    private async void refreshButton_Click(object sender, EventArgs e) {
    176176      lock (locker) {
    177         if (updatingProjects) return;
    178         updatingProjects = true;
     177        if (!refreshButton.Enabled) return;
     178        refreshButton.Enabled = false;
    179179      }
    180180
     
    183183        finallyCallback: () => {
    184184          Content = HiveAdminClient.Instance.Projects;
    185           updatingProjects = false;
     185          refreshButton.Enabled = true;
    186186        });
    187187    }
     
    197197    private async void removeButton_Click(object sender, EventArgs e) {
    198198      lock (locker) {
    199         if (removingProjects) return;
    200         removingProjects = true;
     199        if (!removeButton.Enabled) return;
     200        removeButton.Enabled = false;
    201201      }
    202202
     
    223223            finallyCallback: () => {
    224224              Content.Remove(project);
    225               removingProjects = false;
     225              removeButton.Enabled = true;
    226226            });
    227227        }
     
    231231    private async void saveProjectButton_Click(object sender, EventArgs e) {
    232232      lock (locker) {
    233         if (savingProjects) return;
    234         savingProjects = true;
     233        if (!saveProjectButton.Enabled) return;
     234        saveProjectButton.Enabled = false;
    235235      }
    236236
     
    241241            project.Store();
    242242        },
    243         finallyCallback: () => savingProjects = false);
    244     }
    245 
    246     private async void projectsTreeView_AfterSelect(object sender, TreeViewEventArgs e) {
     243        finallyCallback: () => saveProjectButton.Enabled = true);
     244    }
     245
     246    private void projectsTreeView_AfterSelect(object sender, TreeViewEventArgs e) {
    247247      var selectedProject = (Project)e.Node.Tag;
    248248
     
    251251
    252252      projectView.Content = selectedProject;
     253      projectPermissionsView.Content = selectedProject;
     254      projectResourcesView.Content = selectedProject;
    253255
    254256      if (selectedProject != null)
     
    258260        if (!tabControl.TabPages.Contains(permissionsTabPage))
    259261          tabControl.TabPages.Add(permissionsTabPage);
    260 
    261         permissionsView.FetchSelectedUsers = () =>
    262           HiveServiceLocator.Instance.CallHiveService(s => s.GetProjectPermissions(selectedProject.Id))
    263                                      .Select(x => x.GrantedUserId)
    264                                      .ToList();
    265 
    266         if (tabControl.SelectedIndex == 1 && permissionsView.Content != null && permissionsView.FetchSelectedUsers != null)
    267           await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
    268             action: () => UpdatePermissions());
     262        if (!tabControl.TabPages.Contains(resourcesTabPage))
     263          tabControl.TabPages.Add(resourcesTabPage);
    269264      } else {
    270265        if (tabControl.TabPages.Contains(permissionsTabPage))
    271266          tabControl.TabPages.Remove(permissionsTabPage);
    272         permissionsView.FetchSelectedUsers = null;
     267        if (tabControl.TabPages.Contains(resourcesTabPage))
     268          tabControl.TabPages.Remove(resourcesTabPage);
    273269      }
    274270    }
     
    317313    private void projectsTreeView_QueryContinueDrag(object sender, QueryContinueDragEventArgs e) {
    318314      e.Action = DragAction.Continue;
    319     }
    320 
    321     private async void tabControl_SelectedIndexChanged(object sender, EventArgs e) {
    322       if (tabControl.SelectedIndex == 1 && permissionsView.Content != null && permissionsView.FetchSelectedUsers != null)
    323         await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
    324           action: () => UpdatePermissions());
    325     }
    326 
    327     private async void savePermissionsButton_Click(object sender, EventArgs e) {
    328       var project = (Project)projectsTreeView.SelectedNode.Tag;
    329 
    330       await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
    331         action: () => HiveServiceLocator.Instance.CallHiveService(s => {
    332           s.GrantProjectPermissions(project.Id, permissionsView.GetAddedUsers().Select(x => x.Id).ToList());
    333           s.RevokeProjectPermissions(project.Id, permissionsView.GetDeletedUsers().Select(x => x.Id).ToList());
    334         }));
    335315    }
    336316    #endregion
     
    401381    }
    402382
    403     private void UpdatePermissions() {
    404       try {
    405         permissionsView.ManualRefresh();
    406       } catch (AnonymousUserException) {
    407         ShowHiveInformationDialog();
    408       }
    409     }
    410 
    411383    private bool IsAuthorized(Project project) {
    412384      return project != null
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.Designer.cs

    r15412 r15422  
    3737        components.Dispose();
    3838      }
    39       HiveAdminClient.Instance.Refreshing -= new EventHandler(HiveAdminClient_Instance_Refreshing);
    40       HiveAdminClient.Instance.Refreshed -= new EventHandler(HiveAdminClient_Instance_Refreshed);
    41 
    42       Access.AccessClient.Instance.Refreshing -= new EventHandler(AccessClient_Instance_Refreshing);
    43       Access.AccessClient.Instance.Refreshed -= new EventHandler(AccessClient_Instance_Refreshed);
    4439      base.Dispose(disposing);
    4540    }
     
    5954      this.btnRemoveGroup = new System.Windows.Forms.Button();
    6055      this.btnAddGroup = new System.Windows.Forms.Button();
    61       this.treeSlaveGroup = new System.Windows.Forms.TreeView();
     56      this.treeView = new System.Windows.Forms.TreeView();
    6257      this.tabSlaveGroup = new System.Windows.Forms.TabControl();
    6358      this.tabDetails = new System.Windows.Forms.TabPage();
     59      this.viewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost();
    6460      this.tabSchedule = new System.Windows.Forms.TabPage();
     61      this.scheduleView = new HeuristicLab.Clients.Hive.Administrator.Views.ScheduleView();
    6562      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    66       this.slaveView = new HeuristicLab.Clients.Hive.Administrator.Views.SlaveView();
    67       this.scheduleView = new HeuristicLab.Clients.Hive.Administrator.Views.ScheduleView();
    6863      ((System.ComponentModel.ISupportInitialize)(this.splitSlaves)).BeginInit();
    6964      this.splitSlaves.Panel1.SuspendLayout();
     
    9590      this.splitSlaves.Panel1.Controls.Add(this.btnRemoveGroup);
    9691      this.splitSlaves.Panel1.Controls.Add(this.btnAddGroup);
    97       this.splitSlaves.Panel1.Controls.Add(this.treeSlaveGroup);
     92      this.splitSlaves.Panel1.Controls.Add(this.treeView);
    9893      //
    9994      // splitSlaves.Panel2
     
    117112      // btnSave
    118113      //
    119       this.btnSave.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb;
     114      this.btnSave.Image = HeuristicLab.Common.Resources.VSImageLibrary.Save;
    120115      this.btnSave.Location = new System.Drawing.Point(93, 3);
    121116      this.btnSave.Name = "btnSave";
     
    148143      this.btnAddGroup.Click += new System.EventHandler(this.btnAddGroup_Click);
    149144      //
    150       // treeSlaveGroup
    151       //
    152       this.treeSlaveGroup.AllowDrop = true;
    153       this.treeSlaveGroup.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    154             | System.Windows.Forms.AnchorStyles.Left)
    155             | System.Windows.Forms.AnchorStyles.Right)));
    156       this.treeSlaveGroup.ImageIndex = 0;
    157       this.treeSlaveGroup.ImageList = this.imageListSlaveGroups;
    158       this.treeSlaveGroup.Location = new System.Drawing.Point(3, 33);
    159       this.treeSlaveGroup.Name = "treeSlaveGroup";
    160       this.treeSlaveGroup.SelectedImageIndex = 0;
    161       this.treeSlaveGroup.Size = new System.Drawing.Size(243, 511);
    162       this.treeSlaveGroup.TabIndex = 0;
    163       this.treeSlaveGroup.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeSlaveGroup_ItemDrag);
    164       this.treeSlaveGroup.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeSlaveGroup_AfterSelect);
    165       this.treeSlaveGroup.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragDrop);
    166       this.treeSlaveGroup.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragEnter);
    167       this.treeSlaveGroup.DragOver += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragOver);
    168       this.treeSlaveGroup.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.treeSlaveGroup_QueryContinueDrag);
     145      // treeView
     146      //
     147      this.treeView.AllowDrop = true;
     148      this.treeView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     149            | System.Windows.Forms.AnchorStyles.Left)
     150            | System.Windows.Forms.AnchorStyles.Right)));
     151      this.treeView.ImageIndex = 0;
     152      this.treeView.ImageList = this.imageListSlaveGroups;
     153      this.treeView.Location = new System.Drawing.Point(3, 33);
     154      this.treeView.Name = "treeView";
     155      this.treeView.SelectedImageIndex = 0;
     156      this.treeView.Size = new System.Drawing.Size(243, 511);
     157      this.treeView.TabIndex = 0;
     158      this.treeView.ItemDrag += new System.Windows.Forms.ItemDragEventHandler(this.treeSlaveGroup_ItemDrag);
     159      this.treeView.AfterSelect += new System.Windows.Forms.TreeViewEventHandler(this.treeSlaveGroup_AfterSelect);
     160      this.treeView.DragDrop += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragDrop);
     161      this.treeView.DragEnter += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragEnter);
     162      this.treeView.DragOver += new System.Windows.Forms.DragEventHandler(this.treeSlaveGroup_DragOver);
     163      this.treeView.QueryContinueDrag += new System.Windows.Forms.QueryContinueDragEventHandler(this.treeSlaveGroup_QueryContinueDrag);
    169164      //
    170165      // tabSlaveGroup
     
    180175      this.tabSlaveGroup.Size = new System.Drawing.Size(585, 541);
    181176      this.tabSlaveGroup.TabIndex = 1;
    182       this.tabSlaveGroup.SelectedIndexChanged += new System.EventHandler(this.tabSlaveGroup_SelectedIndexChanged);
    183177      //
    184178      // tabDetails
    185179      //
    186       this.tabDetails.Controls.Add(this.slaveView);
     180      this.tabDetails.Controls.Add(this.viewHost);
    187181      this.tabDetails.Location = new System.Drawing.Point(4, 22);
    188182      this.tabDetails.Name = "tabDetails";
     
    192186      this.tabDetails.Text = "Details";
    193187      this.tabDetails.UseVisualStyleBackColor = true;
     188      //
     189      // viewHost
     190      //
     191      this.viewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
     192            | System.Windows.Forms.AnchorStyles.Left)
     193            | System.Windows.Forms.AnchorStyles.Right)));
     194      this.viewHost.Caption = "View";
     195      this.viewHost.Content = null;
     196      this.viewHost.Enabled = false;
     197      this.viewHost.Location = new System.Drawing.Point(6, 6);
     198      this.viewHost.Name = "viewHost";
     199      this.viewHost.ReadOnly = false;
     200      this.viewHost.Size = new System.Drawing.Size(565, 503);
     201      this.viewHost.TabIndex = 0;
     202      this.viewHost.ViewsLabelVisible = true;
     203      this.viewHost.ViewType = null;
    194204      //
    195205      // tabSchedule
     
    203213      this.tabSchedule.Text = "Schedule";
    204214      this.tabSchedule.UseVisualStyleBackColor = true;
    205       //
    206       // slaveView
    207       //
    208       this.slaveView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    209             | System.Windows.Forms.AnchorStyles.Left)
    210             | System.Windows.Forms.AnchorStyles.Right)));
    211       this.slaveView.Caption = "SlaveView";
    212       this.slaveView.Content = null;
    213       this.slaveView.Location = new System.Drawing.Point(6, 6);
    214       this.slaveView.Name = "slaveView";
    215       this.slaveView.ReadOnly = false;
    216       this.slaveView.Size = new System.Drawing.Size(565, 503);
    217       this.slaveView.TabIndex = 0;
    218215      //
    219216      // scheduleView
     
    253250    private System.Windows.Forms.Button btnRemoveGroup;
    254251    private System.Windows.Forms.Button btnAddGroup;
    255     private System.Windows.Forms.TreeView treeSlaveGroup;
     252    private System.Windows.Forms.TreeView treeView;
    256253    private System.Windows.Forms.TabControl tabSlaveGroup;
    257254    private System.Windows.Forms.TabPage tabDetails;
    258255    private System.Windows.Forms.TabPage tabSchedule;
    259     private SlaveView slaveView;
    260256    private System.Windows.Forms.ImageList imageListSlaveGroups;
    261257    private ScheduleView scheduleView;
     
    263259    private System.Windows.Forms.Button btnRefresh;
    264260    private System.Windows.Forms.ToolTip toolTip;
     261    private MainForm.WindowsForms.ViewHost viewHost;
    265262  }
    266263}
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/ResourcesView.cs

    r15412 r15422  
    2121
    2222using System;
     23using System.Collections.Generic;
    2324using System.ComponentModel;
    2425using System.Drawing;
     
    3738  [Content(typeof(IItemList<Resource>), false)]
    3839  public partial class ResourcesView : ItemView, IDisposable {
    39     private const string UngroupedGroupName = "UNGROUPED";
    4040    private const int slaveImageIndex = 0;
    4141    private const int slaveGroupImageIndex = 1;
     42    public const string ungroupedGroupName = "UNGROUPED";
     43    public const string ungroupedGroupDescription = "Contains slaves that are not assigned to any group.";
    4244
    4345    private readonly Color ownedResourceColor = Color.LightGreen;
    4446    private readonly object locker = new object();
    45     private bool updatingResources = false;
    46     private bool removingResources = false;
    47     private bool savingResources = false;
    4847
    4948    public new IItemList<Resource> Content {
     
    5554      InitializeComponent();
    5655
    57       treeSlaveGroup.ImageList.Images.Add(VSImageLibrary.MonitorLarge);
    58       treeSlaveGroup.ImageList.Images.Add(VSImageLibrary.NetworkCenterLarge);
     56      treeView.ImageList.Images.Add(VSImageLibrary.MonitorLarge);
     57      treeView.ImageList.Images.Add(VSImageLibrary.NetworkCenterLarge);
    5958
    6059      HiveAdminClient.Instance.Refreshing += HiveAdminClient_Instance_Refreshing;
     
    8887      base.OnContentChanged();
    8988      if (Content == null) {
    90         slaveView.Content = null;
     89        treeView.Nodes.Clear();
     90        viewHost.Content = null;
    9191        scheduleView.Content = null;
    92         treeSlaveGroup.Nodes.Clear();
    9392      } else {
    94         treeSlaveGroup.Nodes.Clear();
    95 
    96         //rebuild
    97         TreeNode ungrp = new TreeNode(UngroupedGroupName);
    98         ungrp.ImageIndex = slaveGroupImageIndex;
    99         ungrp.SelectedImageIndex = ungrp.ImageIndex;
    100         var newGroup = new SlaveGroup();
    101         newGroup.Name = UngroupedGroupName;
    102         newGroup.Id = Guid.NewGuid();
    103         newGroup.Description = "Contains slaves which are in no group";
    104         ungrp.Tag = newGroup;
    105 
    106         foreach (Resource g in Content.OrderBy(x => x.Name)) {
    107           if (g.GetType() == typeof(SlaveGroup)) {
    108             //root node
    109             if (g.ParentResourceId == null) {
    110               TreeNode tn = new TreeNode();
    111               tn.ImageIndex = slaveGroupImageIndex;
    112               tn.SelectedImageIndex = tn.ImageIndex;
    113 
    114               tn.Tag = g;
    115               tn.Text = g.Name;
    116               if (g.OwnerUserId == Access.UserInformation.Instance.User.Id) tn.BackColor = ownedResourceColor;
    117 
    118               BuildSlaveGroupTree(g, tn);
    119               treeSlaveGroup.Nodes.Add(tn);
    120             }
    121           } else if (g.GetType() == typeof(Slave)) {
    122             if (g.ParentResourceId == null) {
    123               var stn = new TreeNode(g.Name);
    124               stn.ImageIndex = slaveImageIndex;
    125               stn.SelectedImageIndex = stn.ImageIndex;
    126               stn.Tag = g;
    127               if (g.OwnerUserId == Access.UserInformation.Instance.User.Id) stn.BackColor = ownedResourceColor;
    128               ungrp.Nodes.Add(stn);
    129             }
    130           }
    131         }
    132         treeSlaveGroup.Nodes.Add(ungrp);
     93        var top = BuildResourceTree(Content);
     94        viewHost.Content = top;
    13395      }
    13496    }
     
    140102      btnRemoveGroup.Enabled = enabled;
    141103      btnSave.Enabled = enabled;
    142       scheduleView.SetEnabledStateOfSchedule(enabled && IsAuthorized(slaveView.Content));
     104      scheduleView.SetEnabledStateOfSchedule(enabled && IsAuthorized((Resource)viewHost.Content));
    143105    }
    144106    #endregion
     
    164126        OnContentChanged();
    165127        if (e.PropertyName == "HbInterval") {
    166           UpdateChildHbIntervall(slaveView.Content);
     128          UpdateChildHbIntervall((Resource)viewHost.Content);
    167129        }
    168130      }
     
    212174    private async void btnRefresh_Click(object sender, EventArgs e) {
    213175      lock (locker) {
    214         if (updatingResources) return;
    215         updatingResources = true;
     176        if (!btnRefresh.Enabled) return;
     177        btnRefresh.Enabled = false;
    216178      }
    217179
    218180      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
    219181        action: () => UpdateResources(),
    220         finallyCallback: () => updatingResources = false);
     182        finallyCallback: () => btnRefresh.Enabled = true);
    221183    }
    222184
     
    231193    private async void btnRemoveGroup_Click(object sender, EventArgs e) {
    232194      lock (locker) {
    233         if (removingResources) return;
    234         removingResources = true;
     195        if (!btnRemoveGroup.Enabled) return;
     196        btnRemoveGroup.Enabled = false;
    235197      }
    236198
    237199      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
    238200        action: () => RemoveResource(),
    239         finallyCallback: () => removingResources = false);
     201        finallyCallback: () => btnRemoveGroup.Enabled = true);
    240202    }
    241203
    242204    private async void btnSave_Click(object sender, EventArgs e) {
    243205      lock (locker) {
    244         if (savingResources) return;
    245         savingResources = true;
     206        if (!btnSave.Enabled) return;
     207        btnSave.Enabled = false;
    246208      }
    247209
     
    252214            resource.Store();
    253215        },
    254         finallyCallback: () => savingResources = false);
     216        finallyCallback: () => btnSave.Enabled = true);
    255217    }
    256218
     
    258220      var selectedResource = (Resource)e.Node.Tag;
    259221
    260       if (slaveView.Content != null && slaveView.Content is SlaveGroup)
    261         slaveView.Content.PropertyChanged -= SlaveViewContent_PropertyChanged;
    262 
    263       slaveView.Content = selectedResource;
     222      if (viewHost.Content != null && viewHost.Content is SlaveGroup)
     223        ((SlaveGroup)viewHost.Content).PropertyChanged -= SlaveViewContent_PropertyChanged;
     224
     225      viewHost.Content = selectedResource;
     226      HiveAdminClient.Instance.DowntimeForResourceId = selectedResource != null ? selectedResource.Id : Guid.Empty;
     227      await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
     228        action: () => UpdateSchedule(),
     229        finallyCallback: () => scheduleView.Content = HiveAdminClient.Instance.Downtimes);
    264230
    265231      if (selectedResource != null && selectedResource is SlaveGroup)
     
    269235        if (!tabSlaveGroup.TabPages.Contains(tabSchedule))
    270236          tabSlaveGroup.TabPages.Add(tabSchedule);
    271 
    272         HiveAdminClient.Instance.DowntimeForResourceId = selectedResource.Id;
    273 
    274         if (tabSlaveGroup.SelectedIndex == 1) {
    275           await SecurityExceptionUtil.TryAsyncAndReportSecurityExceptions(
    276             action: () => UpdateSchedule(),
    277             finallyCallback: () => scheduleView.Content = HiveAdminClient.Instance.Downtimes);
    278         }
    279237      } else {
    280238        if (tabSlaveGroup.TabPages.Contains(tabSchedule))
    281239          tabSlaveGroup.TabPages.Remove(tabSchedule);
    282         HiveAdminClient.Instance.DowntimeForResourceId = Guid.Empty;
    283240      }
    284241    }
    285242
    286243    private void treeSlaveGroup_DragDrop(object sender, DragEventArgs e) {
    287       if (e.Data.GetDataPresent("System.Windows.Forms.TreeNode", false)) {
    288         Point pt = ((TreeView)sender).PointToClient(new Point(e.X, e.Y));
    289         TreeNode destNode = ((TreeView)sender).GetNodeAt(pt);
    290         TreeNode newNode = (TreeNode)e.Data.GetData("System.Windows.Forms.TreeNode");
    291 
    292         if (destNode.TreeView == newNode.TreeView) {
    293           if (destNode.Text == UngroupedGroupName || (destNode.Parent != null && destNode.Parent.Text == UngroupedGroupName)) {
    294             MessageBox.Show(string.Format("You can't drag items to the group \"{0}\".{1}This group only contains slaves which haven't yet been assigned to a real group.",
    295               UngroupedGroupName, Environment.NewLine), "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Information);
    296             return;
    297           }
    298 
    299           SlaveGroup sgrp = null;
    300           TreeNode parentNode = null;
    301           if (destNode.Tag != null && destNode.Tag is SlaveGroup) {
    302             sgrp = (SlaveGroup)destNode.Tag;
    303             parentNode = destNode;
    304           } else if (destNode.Parent != null && destNode.Parent.Tag is SlaveGroup) {
    305             sgrp = (SlaveGroup)destNode.Parent.Tag;
    306             parentNode = destNode.Parent;
    307           }
    308 
    309           if (newNode.Tag is SlaveGroup && CheckParentsEqualsMovedNode(parentNode, newNode)) {
    310             return;
    311           }
    312 
    313           SlaveGroup parent = (SlaveGroup)parentNode.Tag;
    314 
    315           if (parent.OwnerUserId != null && !IsAuthorized(parent)) {
    316             MessageBox.Show(string.Format("You don't have the permissions to drag items to the group \"{0}\".", ((Resource)parentNode.Tag).Name),
    317               "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
    318             return;
    319           }
    320 
    321           if (sgrp != null && newNode.Tag != null) {
    322             //save parent group to get an id
    323             if (sgrp.Id == Guid.Empty) {
    324               sgrp.Store();
    325             }
    326 
    327             if (newNode.Tag is Slave) {
    328               Slave slave = (Slave)newNode.Tag;
    329               if (slave.ParentResourceId == null || (slave.ParentResourceId != null && slave.ParentResourceId != sgrp.Id)) {
    330                 slave.ParentResourceId = sgrp.Id;
    331                 newNode.Remove();
    332                 parentNode.Nodes.Clear();
    333                 BuildSlaveGroupTree(sgrp, parentNode);
    334               }
    335             } else if (newNode.Tag is SlaveGroup) {
    336               SlaveGroup slaveGroup = (SlaveGroup)newNode.Tag;
    337               if (slaveGroup.ParentResourceId == null || (slaveGroup.ParentResourceId != null && slaveGroup.ParentResourceId != sgrp.Id)) {
    338                 slaveGroup.ParentResourceId = sgrp.Id;
    339                 newNode.Remove();
    340                 parentNode.Nodes.Clear();
    341                 BuildSlaveGroupTree(sgrp, parentNode);
    342               }
    343             }
    344           }
    345         }
     244      var sourceNode = (TreeNode)e.Data.GetData(typeof(TreeNode));
     245      if (sourceNode == null) return;
     246
     247      var treeView = (TreeView)sender;
     248      if (sourceNode.TreeView != treeView) return;
     249
     250      var targetPoint = treeView.PointToClient(new Point(e.X, e.Y));
     251      var targetNode = treeView.GetNodeAt(targetPoint);
     252
     253      if (sourceNode == targetNode) return;
     254
     255      if (targetNode.Text == ungroupedGroupName || targetNode.Parent != null && targetNode.Parent.Text == ungroupedGroupName) {
     256        MessageBox.Show(
     257          string.Format(@"You cannot drag resources to group ""{0}"". This group only contains slaves which have not been assigned to a real group yet.", ungroupedGroupName),
     258          "HeuristicLab Hive Administrator",
     259          MessageBoxButtons.OK,
     260          MessageBoxIcon.Information);
     261        return;
     262      }
     263
     264      if (sourceNode.Parent == null)
     265        treeView.Nodes.Remove(sourceNode);
     266      else {
     267        sourceNode.Parent.Nodes.Remove(sourceNode);
     268        ((Resource)sourceNode.Tag).ParentResourceId = null;
     269      }
     270
     271      if (targetNode == null) {
     272        treeView.Nodes.Add(sourceNode);
     273      } else {
     274        targetNode.Nodes.Add(sourceNode);
     275        ((Resource)sourceNode.Tag).ParentResourceId = ((Project)targetNode.Tag).Id;
    346276      }
    347277    }
     
    364294      e.Action = DragAction.Continue;
    365295    }
    366 
    367     private void tabSlaveGroup_SelectedIndexChanged(object sender, EventArgs e) {
    368       if (tabSlaveGroup.SelectedIndex == 1) {
    369         UpdateSchedule();
    370       }
    371     }
    372296    #endregion
    373297
    374298    #region Helpers
    375     private void BuildSlaveGroupTree(Resource g, TreeNode tn) {
    376       foreach (Resource r in Content.Where(s => s.ParentResourceId != null && s.ParentResourceId == g.Id).OrderBy(x => x.Name)) {
    377         TreeNode stn = new TreeNode(r.Name);
    378         if (r is Slave) {
    379           stn.ImageIndex = slaveImageIndex;
    380         } else if (r is SlaveGroup) {
    381           stn.ImageIndex = slaveGroupImageIndex;
    382         }
    383         stn.SelectedImageIndex = stn.ImageIndex;
    384         stn.Tag = r;
    385         if (r.OwnerUserId == Access.UserInformation.Instance.User.Id) stn.BackColor = ownedResourceColor;
    386         tn.Nodes.Add(stn);
    387 
    388         BuildSlaveGroupTree(r, stn);
    389       }
     299    private Resource BuildResourceTree(IEnumerable<Resource> resources) {
     300      treeView.Nodes.Clear();
     301      if (!resources.Any()) return null;
     302
     303      var slaveGroups = new HashSet<SlaveGroup>(resources.OfType<SlaveGroup>());
     304      var slaves = new HashSet<Slave>(resources.OfType<Slave>());
     305
     306      var stack = new Stack<Resource>(slaveGroups.OrderByDescending(x => x.Name));
     307      var top = stack.Peek();
     308
     309      TreeNode currentNode = null;
     310      Resource currentResource = null;
     311
     312      while (stack.Any()) {
     313        var newResource = stack.Pop();
     314        var newNode = new TreeNode(newResource.Name) { Tag = newResource };
     315
     316        while (currentNode != null && newResource.ParentResourceId != currentResource.Id) {
     317          currentNode = currentNode.Parent;
     318          currentResource = currentNode == null ? null : (Resource)currentNode.Tag;
     319        }
     320
     321        if (currentNode == null) {
     322          treeView.Nodes.Add(newNode);
     323        } else {
     324          currentNode.Nodes.Add(newNode);
     325        }
     326
     327        if (newResource is Slave) {
     328          newNode.ImageIndex = slaveImageIndex;
     329        } else {
     330          newNode.ImageIndex = slaveGroupImageIndex;
     331
     332          var childSlaves = slaves.Where(x => x.ParentResourceId == newResource.Id);
     333          foreach (var slave in childSlaves.OrderBy(x => x.Name)) {
     334            slaves.Remove(slave);
     335            var slaveNode = new TreeNode(slave.Name) { Tag = slave };
     336
     337            slaveNode.SelectedImageIndex = slaveNode.ImageIndex = slaveImageIndex;
     338            if (slave.OwnerUserId == UserInformation.Instance.User.Id)
     339              slaveNode.BackColor = ownedResourceColor;
     340
     341            newNode.Nodes.Add(slaveNode);
     342          }
     343
     344          var childSlaveGroups = slaveGroups.Where(x => x.ParentResourceId == newResource.Id);
     345          if (childSlaveGroups.Any()) {
     346            foreach (var slaveGroup in childSlaveGroups.OrderByDescending(x => x.Name)) {
     347              slaveGroups.Remove(slaveGroup);
     348              stack.Push(slaveGroup);
     349            }
     350            currentNode = newNode;
     351            currentResource = newResource;
     352          }
     353        }
     354
     355        newNode.SelectedImageIndex = newNode.ImageIndex;
     356        if (newResource.OwnerUserId == UserInformation.Instance.User.Id)
     357          newNode.BackColor = ownedResourceColor;
     358      }
     359
     360      var ungroupedNode = new TreeNode(ungroupedGroupName) {
     361        ForeColor = SystemColors.GrayText,
     362        Tag = new SlaveGroup() {
     363          Name = ungroupedGroupName,
     364          Description = ungroupedGroupDescription
     365        }
     366      };
     367
     368      foreach (var slave in slaves.OrderBy(x => x.Name)) {
     369        var slaveNode = new TreeNode(slave.Name) { Tag = slave };
     370        ungroupedNode.Nodes.Add(slaveNode);
     371      }
     372
     373      treeView.Nodes.Add(ungroupedNode);
     374      treeView.ExpandAll();
     375
     376      return top;
    390377    }
    391378
     
    414401      if (InvokeRequired) Invoke((Action)ResetView);
    415402      else {
    416         treeSlaveGroup.Nodes.Clear();
    417 
    418         if (slaveView.Content != null && slaveView.Content is SlaveGroup) {
    419           slaveView.Content.PropertyChanged -= SlaveViewContent_PropertyChanged;
    420         }
    421 
    422         slaveView.Content = null;
     403        treeView.Nodes.Clear();
     404
     405        if (viewHost.Content != null && viewHost.Content is SlaveGroup) {
     406          ((SlaveGroup)viewHost.Content).PropertyChanged -= SlaveViewContent_PropertyChanged;
     407        }
     408
     409        viewHost.Content = null;
    423410        if (scheduleView.Content != null) {
    424411          scheduleView.Content.Clear();
     
    435422
    436423    private void RemoveResource() {
    437       var selectedNode = treeSlaveGroup.SelectedNode;
     424      var selectedNode = treeView.SelectedNode;
    438425      if (selectedNode == null || selectedNode.Tag == null) return;
    439426
     
    474461    private bool IsAuthorized(Resource resource) {
    475462      return resource != null
    476           && resource.Name != UngroupedGroupName
     463          && resource.Name != ungroupedGroupName
    477464          && resource.Id != Guid.Empty
    478465          && UserInformation.Instance.UserExists
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.Designer.cs

    r14185 r15422  
    4545    /// </summary>
    4646    private void InitializeComponent() {
    47       this.txtSlaveState = new System.Windows.Forms.TextBox();
    48       this.txtOS = new System.Windows.Forms.TextBox();
    49       this.label15 = new System.Windows.Forms.Label();
    50       this.label14 = new System.Windows.Forms.Label();
    51       this.txtDetailsDescription = new System.Windows.Forms.TextBox();
    52       this.label13 = new System.Windows.Forms.Label();
    53       this.txtName = new System.Windows.Forms.TextBox();
    54       this.txtCPU = new System.Windows.Forms.TextBox();
    55       this.txtMemory = new System.Windows.Forms.TextBox();
    56       this.txtLastHeartbeat = new System.Windows.Forms.TextBox();
    57       this.label12 = new System.Windows.Forms.Label();
    58       this.label11 = new System.Windows.Forms.Label();
    59       this.label10 = new System.Windows.Forms.Label();
    60       this.label9 = new System.Windows.Forms.Label();
    61       this.label1 = new System.Windows.Forms.Label();
    62       this.txtFreeMemory = new System.Windows.Forms.TextBox();
    63       this.txtId = new System.Windows.Forms.TextBox();
    64       this.label2 = new System.Windows.Forms.Label();
    65       this.label3 = new System.Windows.Forms.Label();
    66       this.txtHbIntervall = new System.Windows.Forms.TextBox();
    67       this.cbxDisposable = new System.Windows.Forms.CheckBox();
    68       this.label4 = new System.Windows.Forms.Label();
    69       this.cbxPublic = new System.Windows.Forms.CheckBox();
    70       this.label5 = new System.Windows.Forms.Label();
     47      this.cpuLabel = new System.Windows.Forms.Label();
     48      this.cpuTextBox = new System.Windows.Forms.TextBox();
     49      this.memoryLabel = new System.Windows.Forms.Label();
     50      this.memoryTextBox = new System.Windows.Forms.TextBox();
     51      this.operatingSystemLabel = new System.Windows.Forms.Label();
     52      this.operatingSystemTextBox = new System.Windows.Forms.TextBox();
     53      this.stateLabel = new System.Windows.Forms.Label();
     54      this.stateTextBox = new System.Windows.Forms.TextBox();
     55      this.lastHeartbeatLabel = new System.Windows.Forms.Label();
     56      this.lastHeartbeatTextBox = new System.Windows.Forms.TextBox();
     57      this.disposableLabel = new System.Windows.Forms.Label();
     58      this.disposableCheckBox = new System.Windows.Forms.CheckBox();
     59      ((System.ComponentModel.ISupportInitialize)(this.heartbeatIntervalNumericUpDown)).BeginInit();
    7160      this.SuspendLayout();
    7261      //
    73       // txtSlaveState
    74       //
    75       this.txtSlaveState.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    76             | System.Windows.Forms.AnchorStyles.Right)));
    77       this.txtSlaveState.Enabled = false;
    78       this.txtSlaveState.Location = new System.Drawing.Point(146, 242);
    79       this.txtSlaveState.Name = "txtSlaveState";
    80       this.txtSlaveState.Size = new System.Drawing.Size(390, 20);
    81       this.txtSlaveState.TabIndex = 27;
    82       //
    83       // txtOS
    84       //
    85       this.txtOS.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    86             | System.Windows.Forms.AnchorStyles.Right)));
    87       this.txtOS.Enabled = false;
    88       this.txtOS.Location = new System.Drawing.Point(146, 216);
    89       this.txtOS.Name = "txtOS";
    90       this.txtOS.Size = new System.Drawing.Size(390, 20);
    91       this.txtOS.TabIndex = 26;
    92       //
    93       // label15
    94       //
    95       this.label15.AutoSize = true;
    96       this.label15.Location = new System.Drawing.Point(3, 245);
    97       this.label15.Name = "label15";
    98       this.label15.Size = new System.Drawing.Size(35, 13);
    99       this.label15.TabIndex = 25;
    100       this.label15.Text = "State:";
    101       //
    102       // label14
    103       //
    104       this.label14.AutoSize = true;
    105       this.label14.Location = new System.Drawing.Point(3, 219);
    106       this.label14.Name = "label14";
    107       this.label14.Size = new System.Drawing.Size(93, 13);
    108       this.label14.TabIndex = 24;
    109       this.label14.Text = "Operating System:";
    110       //
    111       // txtDetailsDescription
    112       //
    113       this.txtDetailsDescription.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    114             | System.Windows.Forms.AnchorStyles.Right)));
    115       this.txtDetailsDescription.Enabled = false;
    116       this.txtDetailsDescription.Location = new System.Drawing.Point(146, 112);
    117       this.txtDetailsDescription.Name = "txtDetailsDescription";
    118       this.txtDetailsDescription.Size = new System.Drawing.Size(390, 20);
    119       this.txtDetailsDescription.TabIndex = 23;
    120       //
    121       // label13
    122       //
    123       this.label13.AutoSize = true;
    124       this.label13.Location = new System.Drawing.Point(3, 115);
    125       this.label13.Name = "label13";
    126       this.label13.Size = new System.Drawing.Size(63, 13);
    127       this.label13.TabIndex = 22;
    128       this.label13.Text = "Description:";
    129       //
    130       // txtName
    131       //
    132       this.txtName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    133             | System.Windows.Forms.AnchorStyles.Right)));
    134       this.txtName.Location = new System.Drawing.Point(146, 8);
    135       this.txtName.Name = "txtName";
    136       this.txtName.Size = new System.Drawing.Size(390, 20);
    137       this.txtName.TabIndex = 21;
    138       this.txtName.TextChanged += new System.EventHandler(this.txtName_TextChanged);
    139       //
    140       // txtCPU
    141       //
    142       this.txtCPU.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    143             | System.Windows.Forms.AnchorStyles.Right)));
    144       this.txtCPU.Enabled = false;
    145       this.txtCPU.Location = new System.Drawing.Point(146, 138);
    146       this.txtCPU.Name = "txtCPU";
    147       this.txtCPU.Size = new System.Drawing.Size(390, 20);
    148       this.txtCPU.TabIndex = 20;
    149       //
    150       // txtMemory
    151       //
    152       this.txtMemory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    153             | System.Windows.Forms.AnchorStyles.Right)));
    154       this.txtMemory.Enabled = false;
    155       this.txtMemory.Location = new System.Drawing.Point(146, 164);
    156       this.txtMemory.Name = "txtMemory";
    157       this.txtMemory.Size = new System.Drawing.Size(390, 20);
    158       this.txtMemory.TabIndex = 19;
    159       //
    160       // txtLastHeartbeat
    161       //
    162       this.txtLastHeartbeat.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    163             | System.Windows.Forms.AnchorStyles.Right)));
    164       this.txtLastHeartbeat.Enabled = false;
    165       this.txtLastHeartbeat.Location = new System.Drawing.Point(146, 268);
    166       this.txtLastHeartbeat.Name = "txtLastHeartbeat";
    167       this.txtLastHeartbeat.Size = new System.Drawing.Size(390, 20);
    168       this.txtLastHeartbeat.TabIndex = 18;
    169       //
    170       // label12
    171       //
    172       this.label12.AutoSize = true;
    173       this.label12.Location = new System.Drawing.Point(3, 271);
    174       this.label12.Name = "label12";
    175       this.label12.Size = new System.Drawing.Size(80, 13);
    176       this.label12.TabIndex = 17;
    177       this.label12.Text = "Last Heartbeat:";
    178       //
    179       // label11
    180       //
    181       this.label11.AutoSize = true;
    182       this.label11.Location = new System.Drawing.Point(3, 167);
    183       this.label11.Name = "label11";
    184       this.label11.Size = new System.Drawing.Size(47, 13);
    185       this.label11.TabIndex = 16;
    186       this.label11.Text = "Memory:";
    187       //
    188       // label10
    189       //
    190       this.label10.AutoSize = true;
    191       this.label10.Location = new System.Drawing.Point(3, 141);
    192       this.label10.Name = "label10";
    193       this.label10.Size = new System.Drawing.Size(32, 13);
    194       this.label10.TabIndex = 15;
    195       this.label10.Text = "CPU:";
    196       //
    197       // label9
    198       //
    199       this.label9.AutoSize = true;
    200       this.label9.Location = new System.Drawing.Point(3, 11);
    201       this.label9.Name = "label9";
    202       this.label9.Size = new System.Drawing.Size(38, 13);
    203       this.label9.TabIndex = 14;
    204       this.label9.Text = "Name:";
    205       //
    206       // label1
    207       //
    208       this.label1.AutoSize = true;
    209       this.label1.Location = new System.Drawing.Point(3, 193);
    210       this.label1.Name = "label1";
    211       this.label1.Size = new System.Drawing.Size(70, 13);
    212       this.label1.TabIndex = 28;
    213       this.label1.Text = "Free memory:";
    214       //
    215       // txtFreeMemory
    216       //
    217       this.txtFreeMemory.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    218             | System.Windows.Forms.AnchorStyles.Right)));
    219       this.txtFreeMemory.Enabled = false;
    220       this.txtFreeMemory.Location = new System.Drawing.Point(146, 190);
    221       this.txtFreeMemory.Name = "txtFreeMemory";
    222       this.txtFreeMemory.Size = new System.Drawing.Size(390, 20);
    223       this.txtFreeMemory.TabIndex = 29;
    224       //
    225       // txtId
    226       //
    227       this.txtId.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    228             | System.Windows.Forms.AnchorStyles.Right)));
    229       this.txtId.Enabled = false;
    230       this.txtId.Location = new System.Drawing.Point(146, 86);
    231       this.txtId.Name = "txtId";
    232       this.txtId.Size = new System.Drawing.Size(390, 20);
    233       this.txtId.TabIndex = 30;
    234       //
    235       // label2
    236       //
    237       this.label2.AutoSize = true;
    238       this.label2.Location = new System.Drawing.Point(3, 89);
    239       this.label2.Name = "label2";
    240       this.label2.Size = new System.Drawing.Size(19, 13);
    241       this.label2.TabIndex = 31;
    242       this.label2.Text = "Id:";
    243       //
    244       // label3
    245       //
    246       this.label3.AutoSize = true;
    247       this.label3.Location = new System.Drawing.Point(3, 37);
    248       this.label3.Name = "label3";
    249       this.label3.Size = new System.Drawing.Size(137, 13);
    250       this.label3.TabIndex = 32;
    251       this.label3.Text = "Heartbeat Intervall (in sec) :";
    252       //
    253       // txtHbIntervall
    254       //
    255       this.txtHbIntervall.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
    256             | System.Windows.Forms.AnchorStyles.Right)));
    257       this.txtHbIntervall.Location = new System.Drawing.Point(146, 34);
    258       this.txtHbIntervall.Name = "txtHbIntervall";
    259       this.txtHbIntervall.Size = new System.Drawing.Size(390, 20);
    260       this.txtHbIntervall.TabIndex = 33;
    261       this.txtHbIntervall.TextChanged += new System.EventHandler(this.txtHbIntervall_TextChanged);
    262       //
    263       // cbxDisposable
    264       //
    265       this.cbxDisposable.AutoSize = true;
    266       this.cbxDisposable.Enabled = false;
    267       this.cbxDisposable.Location = new System.Drawing.Point(146, 297);
    268       this.cbxDisposable.Name = "cbxDisposable";
    269       this.cbxDisposable.Size = new System.Drawing.Size(15, 14);
    270       this.cbxDisposable.TabIndex = 34;
    271       this.cbxDisposable.UseVisualStyleBackColor = true;
    272       this.cbxDisposable.CheckedChanged += new System.EventHandler(this.cbxDisposable_CheckedChanged);
    273       //
    274       // label4
    275       //
    276       this.label4.AutoSize = true;
    277       this.label4.Location = new System.Drawing.Point(3, 297);
    278       this.label4.Name = "label4";
    279       this.label4.Size = new System.Drawing.Size(62, 13);
    280       this.label4.TabIndex = 35;
    281       this.label4.Text = "Disposable:";
    282       //
    283       // cbxPublic
    284       //
    285       this.cbxPublic.AutoSize = true;
    286       this.cbxPublic.Enabled = false;
    287       this.cbxPublic.Location = new System.Drawing.Point(146, 63);
    288       this.cbxPublic.Name = "cbxPublic";
    289       this.cbxPublic.Size = new System.Drawing.Size(15, 14);
    290       this.cbxPublic.TabIndex = 36;
    291       this.cbxPublic.UseVisualStyleBackColor = true;
    292       this.cbxPublic.CheckedChanged += new System.EventHandler(this.cbxPublic_CheckedChanged);
    293       //
    294       // label5
    295       //
    296       this.label5.AutoSize = true;
    297       this.label5.Location = new System.Drawing.Point(3, 63);
    298       this.label5.Name = "label5";
    299       this.label5.Size = new System.Drawing.Size(39, 13);
    300       this.label5.TabIndex = 37;
    301       this.label5.Text = "Public:";
     62      // nameTextBox
     63      //
     64      this.nameTextBox.ReadOnly = true;
     65      //
     66      // cpuLabel
     67      //
     68      this.cpuLabel.AutoSize = true;
     69      this.cpuLabel.Location = new System.Drawing.Point(3, 141);
     70      this.cpuLabel.Name = "cpuLabel";
     71      this.cpuLabel.Size = new System.Drawing.Size(32, 13);
     72      this.cpuLabel.TabIndex = 16;
     73      this.cpuLabel.Text = "CPU:";
     74      //
     75      // cpuTextBox
     76      //
     77      this.cpuTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     78            | System.Windows.Forms.AnchorStyles.Right)));
     79      this.cpuTextBox.Location = new System.Drawing.Point(130, 138);
     80      this.cpuTextBox.Name = "cpuTextBox";
     81      this.cpuTextBox.ReadOnly = true;
     82      this.cpuTextBox.Size = new System.Drawing.Size(397, 20);
     83      this.cpuTextBox.TabIndex = 17;
     84      //
     85      // memoryLabel
     86      //
     87      this.memoryLabel.AutoSize = true;
     88      this.memoryLabel.Location = new System.Drawing.Point(3, 167);
     89      this.memoryLabel.Name = "memoryLabel";
     90      this.memoryLabel.Size = new System.Drawing.Size(47, 13);
     91      this.memoryLabel.TabIndex = 18;
     92      this.memoryLabel.Text = "Memory:";
     93      //
     94      // memoryTextBox
     95      //
     96      this.memoryTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     97            | System.Windows.Forms.AnchorStyles.Right)));
     98      this.memoryTextBox.Location = new System.Drawing.Point(130, 164);
     99      this.memoryTextBox.Name = "memoryTextBox";
     100      this.memoryTextBox.ReadOnly = true;
     101      this.memoryTextBox.Size = new System.Drawing.Size(397, 20);
     102      this.memoryTextBox.TabIndex = 19;
     103      //
     104      // operatingSystemLabel
     105      //
     106      this.operatingSystemLabel.AutoSize = true;
     107      this.operatingSystemLabel.Location = new System.Drawing.Point(3, 193);
     108      this.operatingSystemLabel.Name = "operatingSystemLabel";
     109      this.operatingSystemLabel.Size = new System.Drawing.Size(93, 13);
     110      this.operatingSystemLabel.TabIndex = 20;
     111      this.operatingSystemLabel.Text = "Operating System:";
     112      //
     113      // operatingSystemTextBox
     114      //
     115      this.operatingSystemTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     116            | System.Windows.Forms.AnchorStyles.Right)));
     117      this.operatingSystemTextBox.Location = new System.Drawing.Point(130, 190);
     118      this.operatingSystemTextBox.Name = "operatingSystemTextBox";
     119      this.operatingSystemTextBox.ReadOnly = true;
     120      this.operatingSystemTextBox.Size = new System.Drawing.Size(397, 20);
     121      this.operatingSystemTextBox.TabIndex = 21;
     122      //
     123      // stateLabel
     124      //
     125      this.stateLabel.AutoSize = true;
     126      this.stateLabel.Location = new System.Drawing.Point(3, 219);
     127      this.stateLabel.Name = "stateLabel";
     128      this.stateLabel.Size = new System.Drawing.Size(35, 13);
     129      this.stateLabel.TabIndex = 22;
     130      this.stateLabel.Text = "State:";
     131      //
     132      // stateTextBox
     133      //
     134      this.stateTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     135            | System.Windows.Forms.AnchorStyles.Right)));
     136      this.stateTextBox.Location = new System.Drawing.Point(130, 216);
     137      this.stateTextBox.Name = "stateTextBox";
     138      this.stateTextBox.ReadOnly = true;
     139      this.stateTextBox.Size = new System.Drawing.Size(397, 20);
     140      this.stateTextBox.TabIndex = 23;
     141      //
     142      // lastHeartbeatLabel
     143      //
     144      this.lastHeartbeatLabel.AutoSize = true;
     145      this.lastHeartbeatLabel.Location = new System.Drawing.Point(3, 245);
     146      this.lastHeartbeatLabel.Name = "lastHeartbeatLabel";
     147      this.lastHeartbeatLabel.Size = new System.Drawing.Size(80, 13);
     148      this.lastHeartbeatLabel.TabIndex = 24;
     149      this.lastHeartbeatLabel.Text = "Last Heartbeat:";
     150      //
     151      // lastHeartbeatTextBox
     152      //
     153      this.lastHeartbeatTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
     154            | System.Windows.Forms.AnchorStyles.Right)));
     155      this.lastHeartbeatTextBox.Location = new System.Drawing.Point(130, 242);
     156      this.lastHeartbeatTextBox.Name = "lastHeartbeatTextBox";
     157      this.lastHeartbeatTextBox.ReadOnly = true;
     158      this.lastHeartbeatTextBox.Size = new System.Drawing.Size(397, 20);
     159      this.lastHeartbeatTextBox.TabIndex = 25;
     160      //
     161      // disposableLabel
     162      //
     163      this.disposableLabel.AutoSize = true;
     164      this.disposableLabel.Location = new System.Drawing.Point(3, 271);
     165      this.disposableLabel.Name = "disposableLabel";
     166      this.disposableLabel.Size = new System.Drawing.Size(62, 13);
     167      this.disposableLabel.TabIndex = 28;
     168      this.disposableLabel.Text = "Disposable:";
     169      //
     170      // disposableCheckBox
     171      //
     172      this.disposableCheckBox.AutoSize = true;
     173      this.disposableCheckBox.Location = new System.Drawing.Point(130, 270);
     174      this.disposableCheckBox.Name = "disposableCheckBox";
     175      this.disposableCheckBox.Size = new System.Drawing.Size(15, 14);
     176      this.disposableCheckBox.TabIndex = 29;
     177      this.disposableCheckBox.UseVisualStyleBackColor = true;
     178      this.disposableCheckBox.CheckedChanged += new System.EventHandler(this.disposableCheckBox_CheckedChanged);
    302179      //
    303180      // SlaveView
    304181      //
    305       this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    306182      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Inherit;
    307       this.Controls.Add(this.label5);
    308       this.Controls.Add(this.cbxPublic);
    309       this.Controls.Add(this.label4);
    310       this.Controls.Add(this.cbxDisposable);
    311       this.Controls.Add(this.txtHbIntervall);
    312       this.Controls.Add(this.label3);
    313       this.Controls.Add(this.label2);
    314       this.Controls.Add(this.txtId);
    315       this.Controls.Add(this.txtFreeMemory);
    316       this.Controls.Add(this.label1);
    317       this.Controls.Add(this.txtSlaveState);
    318       this.Controls.Add(this.txtOS);
    319       this.Controls.Add(this.label15);
    320       this.Controls.Add(this.label14);
    321       this.Controls.Add(this.txtDetailsDescription);
    322       this.Controls.Add(this.label13);
    323       this.Controls.Add(this.txtName);
    324       this.Controls.Add(this.txtCPU);
    325       this.Controls.Add(this.txtMemory);
    326       this.Controls.Add(this.txtLastHeartbeat);
    327       this.Controls.Add(this.label12);
    328       this.Controls.Add(this.label11);
    329       this.Controls.Add(this.label10);
    330       this.Controls.Add(this.label9);
     183      this.Controls.Add(this.disposableCheckBox);
     184      this.Controls.Add(this.disposableLabel);
     185      this.Controls.Add(this.lastHeartbeatTextBox);
     186      this.Controls.Add(this.lastHeartbeatLabel);
     187      this.Controls.Add(this.stateTextBox);
     188      this.Controls.Add(this.stateLabel);
     189      this.Controls.Add(this.operatingSystemTextBox);
     190      this.Controls.Add(this.operatingSystemLabel);
     191      this.Controls.Add(this.memoryTextBox);
     192      this.Controls.Add(this.memoryLabel);
     193      this.Controls.Add(this.cpuTextBox);
     194      this.Controls.Add(this.cpuLabel);
    331195      this.Name = "SlaveView";
    332       this.Size = new System.Drawing.Size(539, 407);
     196      this.Controls.SetChildIndex(this.idTextBox, 0);
     197      this.Controls.SetChildIndex(this.descriptionTextBox, 0);
     198      this.Controls.SetChildIndex(this.heartbeatIntervalNumericUpDown, 0);
     199      this.Controls.SetChildIndex(this.publicCheckBox, 0);
     200      this.Controls.SetChildIndex(this.nameTextBox, 0);
     201      this.Controls.SetChildIndex(this.cpuLabel, 0);
     202      this.Controls.SetChildIndex(this.cpuTextBox, 0);
     203      this.Controls.SetChildIndex(this.memoryLabel, 0);
     204      this.Controls.SetChildIndex(this.memoryTextBox, 0);
     205      this.Controls.SetChildIndex(this.operatingSystemLabel, 0);
     206      this.Controls.SetChildIndex(this.operatingSystemTextBox, 0);
     207      this.Controls.SetChildIndex(this.stateLabel, 0);
     208      this.Controls.SetChildIndex(this.stateTextBox, 0);
     209      this.Controls.SetChildIndex(this.lastHeartbeatLabel, 0);
     210      this.Controls.SetChildIndex(this.lastHeartbeatTextBox, 0);
     211      this.Controls.SetChildIndex(this.disposableLabel, 0);
     212      this.Controls.SetChildIndex(this.disposableCheckBox, 0);
     213      ((System.ComponentModel.ISupportInitialize)(this.heartbeatIntervalNumericUpDown)).EndInit();
    333214      this.ResumeLayout(false);
    334215      this.PerformLayout();
     
    338219    #endregion
    339220
    340     private System.Windows.Forms.TextBox txtSlaveState;
    341     private System.Windows.Forms.TextBox txtOS;
    342     private System.Windows.Forms.Label label15;
    343     private System.Windows.Forms.Label label14;
    344     private System.Windows.Forms.TextBox txtDetailsDescription;
    345     private System.Windows.Forms.Label label13;
    346     private System.Windows.Forms.TextBox txtName;
    347     private System.Windows.Forms.TextBox txtCPU;
    348     private System.Windows.Forms.TextBox txtMemory;
    349     private System.Windows.Forms.TextBox txtLastHeartbeat;
    350     private System.Windows.Forms.Label label12;
    351     private System.Windows.Forms.Label label11;
    352     private System.Windows.Forms.Label label10;
    353     private System.Windows.Forms.Label label9;
    354     private System.Windows.Forms.Label label1;
    355     private System.Windows.Forms.TextBox txtFreeMemory;
    356     private System.Windows.Forms.TextBox txtId;
    357     private System.Windows.Forms.Label label2;
    358     private System.Windows.Forms.Label label3;
    359     private System.Windows.Forms.TextBox txtHbIntervall;
    360     private System.Windows.Forms.CheckBox cbxDisposable;
    361     private System.Windows.Forms.Label label4;
    362     private System.Windows.Forms.CheckBox cbxPublic;
    363     private System.Windows.Forms.Label label5;
     221    private System.Windows.Forms.Label cpuLabel;
     222    private System.Windows.Forms.TextBox cpuTextBox;
     223    private System.Windows.Forms.Label memoryLabel;
     224    private System.Windows.Forms.TextBox memoryTextBox;
     225    private System.Windows.Forms.Label operatingSystemLabel;
     226    private System.Windows.Forms.TextBox operatingSystemTextBox;
     227    private System.Windows.Forms.Label stateLabel;
     228    private System.Windows.Forms.TextBox stateTextBox;
     229    private System.Windows.Forms.Label lastHeartbeatLabel;
     230    private System.Windows.Forms.TextBox lastHeartbeatTextBox;
     231    private System.Windows.Forms.Label disposableLabel;
     232    private System.Windows.Forms.CheckBox disposableCheckBox;
    364233  }
    365234}
  • branches/HiveProjectManagement/HeuristicLab.Clients.Hive.Administrator/3.3/Views/SlaveView.cs

    r15412 r15422  
    11#region License Information
    22/* HeuristicLab
    3  * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
     3 * Copyright (C) 2002-2017 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
    44 *
    55 * This file is part of HeuristicLab.
     
    2222using System;
    2323using System.Windows.Forms;
    24 using HeuristicLab.Clients.Access;
    25 using HeuristicLab.Core.Views;
    2624using HeuristicLab.MainForm;
    2725using HeuristicLab.MainForm.WindowsForms;
    2826
    2927namespace HeuristicLab.Clients.Hive.Administrator.Views {
    30   [View("SlaveView")]
    31   [Content(typeof(Resource), IsDefaultView = true)]
    32   public partial class SlaveView : ItemView {
    33     public new Resource Content {
    34       get { return (Resource)base.Content; }
     28  [View("Slave View")]
     29  [Content(typeof(Slave), IsDefaultView = true)]
     30  public sealed partial class SlaveView : ResourceView {
     31    public new Slave Content {
     32      get { return (Slave)base.Content; }
    3533      set { base.Content = value; }
    3634    }
     
    4038    }
    4139
    42     #region Register Content Events
    43     protected override void DeregisterContentEvents() {
    44       base.DeregisterContentEvents();
    45     }
    46     protected override void RegisterContentEvents() {
    47       base.RegisterContentEvents();
    48     }
    49     #endregion
    50 
     40    #region Overrides
    5141    protected override void OnContentChanged() {
    5242      base.OnContentChanged();
    5343      if (Content == null) {
    54         ShowSlaveUI(true);
    55         txtName.Clear();
    56         txtCPU.Clear();
    57         txtDetailsDescription.Clear();
    58         txtMemory.Clear();
    59         txtOS.Clear();
    60         txtSlaveState.Clear();
    61         txtLastHeartbeat.Clear();
    62         txtFreeMemory.Clear();
    63         txtId.Clear();
    64         txtHbIntervall.Clear();
    65         cbxDisposable.Checked = false;
    66         cbxPublic.Checked = false;
     44        cpuTextBox.Clear();
     45        memoryTextBox.Clear();
     46        operatingSystemTextBox.Clear();
     47        stateTextBox.Clear();
     48        lastHeartbeatTextBox.Clear();
     49        disposableCheckBox.Checked = false;
    6750      } else {
    68         if (Content.GetType() == typeof(Slave)) {
    69           ShowSlaveUI(true);
    70           Slave ct = (Slave)Content;
    71           bool authorized = UserInformation.Instance.UserExists && (ct.OwnerUserId == UserInformation.Instance.User.Id || HiveRoles.CheckAdminUserPermissions());
    72           txtName.Text = ct.Name;
    73           txtHbIntervall.Text = ct.HbInterval.ToString();
    74           cbxPublic.Enabled = authorized;
    75           cbxPublic.CheckedChanged -= new EventHandler(cbxPublic_CheckedChanged);
    76           cbxPublic.Checked = ct.OwnerUserId == null;
    77           cbxPublic.CheckedChanged += new EventHandler(cbxPublic_CheckedChanged);
    78           txtCPU.Text = string.Format("{0} Cores @ {1} Mhz, Arch.: {2}", ct.Cores.ToString(), ct.CpuSpeed.ToString(), ct.CpuArchitecture.ToString());
    79           txtDetailsDescription.Text = ct.Description;
    80           txtMemory.Text = ct.Memory.ToString();
    81           txtOS.Text = ct.OperatingSystem;
    82           txtSlaveState.Text = ct.SlaveState.ToString();
    83           txtLastHeartbeat.Text = ct.LastHeartbeat.ToString();
    84           txtFreeMemory.Text = ct.FreeMemory.ToString();
    85           txtId.Text = ct.Id.ToString();
    86           cbxDisposable.Enabled = authorized;
    87           cbxDisposable.Checked = ct.IsDisposable.GetValueOrDefault();
    88         } else if (Content.GetType() == typeof(SlaveGroup)) {
    89           SlaveGroup ct = (SlaveGroup)Content;
    90           txtName.Text = ct.Name;
    91           txtHbIntervall.Text = ct.HbInterval.ToString();
    92           cbxPublic.Enabled = ct.Name != "UNGROUPED" && HiveRoles.CheckAdminUserPermissions();
    93           cbxPublic.CheckedChanged -= new EventHandler(cbxPublic_CheckedChanged);
    94           cbxPublic.Checked = ct.OwnerUserId == null;
    95           cbxPublic.CheckedChanged += new EventHandler(cbxPublic_CheckedChanged);
    96           ShowSlaveUI(false);
    97         } else {
    98           throw new Exception("Unknown Resource in SlaveView");
    99         }
     51        cpuTextBox.Text = string.Format("{0} Cores @ {1} MHz, Arch.: {2}", Content.Cores, Content.CpuSpeed, Content.CpuArchitecture);
     52        memoryTextBox.Text = string.Format("{0} ({1} Free)", Content.Memory, Content.FreeMemory);
     53        operatingSystemTextBox.Text = Content.OperatingSystem;
     54        stateTextBox.Text = Content.SlaveState.ToString();
     55        lastHeartbeatTextBox.Text = Content.LastHeartbeat.ToString();
     56        disposableCheckBox.Checked = Content.IsDisposable.GetValueOrDefault();
    10057      }
    101     }
    102 
    103     private void ShowSlaveUI(bool show) {
    104       label1.Visible = show;
    105       label2.Visible = show;
    106       label4.Visible = show;
    107       label10.Visible = show;
    108       label11.Visible = show;
    109       label12.Visible = show;
    110       label13.Visible = show;
    111       label14.Visible = show;
    112       label15.Visible = show;
    113       txtCPU.Visible = show;
    114       txtDetailsDescription.Visible = show;
    115       txtMemory.Visible = show;
    116       txtOS.Visible = show;
    117       txtSlaveState.Visible = show;
    118       txtLastHeartbeat.Visible = show;
    119       txtFreeMemory.Visible = show;
    120       txtId.Visible = show;
    121       txtName.Enabled = !show;
    122       cbxDisposable.Visible = show;
    12358    }
    12459
    12560    protected override void SetEnabledStateOfControls() {
    12661      base.SetEnabledStateOfControls();
    127       bool enabled = Content != null;
    128       txtName.Enabled = enabled;
    129       txtHbIntervall.Enabled = enabled;
    130       cbxPublic.Enabled = enabled;
     62      disposableCheckBox.Enabled = Content != null;
    13163    }
     64    #endregion
    13265
    133     private void txtName_TextChanged(object sender, EventArgs e) {
    134       if (Content != null && Content is SlaveGroup) {
    135         Content.Name = txtName.Text;
    136       }
     66    #region Event Handlers
     67    private void disposableCheckBox_CheckedChanged(object sender, EventArgs e) {
     68      if (Content != null)
     69        Content.IsDisposable = disposableCheckBox.Checked;
    13770    }
    138 
    139     private void txtHbIntervall_TextChanged(object sender, EventArgs e) {
    140       if (Content != null) {
    141         if (txtHbIntervall.Text.Length > 0) {
    142           try {
    143             int interval = int.Parse(txtHbIntervall.Text);
    144             Content.HbInterval = interval;
    145           } catch (Exception) {
    146             MessageBox.Show("Please enter a numeric value for the Heartbeat Interval.", "HeuristicLab Hive Administrator", MessageBoxButtons.OK, MessageBoxIcon.Error);
    147             txtHbIntervall.Text = "10";
    148           }
    149         }
    150       }
    151     }
    152 
    153     private void cbxDisposable_CheckedChanged(object sender, EventArgs e) {
    154       if (Content != null) {
    155         ((Slave)Content).IsDisposable = cbxDisposable.Checked;
    156       }
    157     }
    158 
    159     private void cbxPublic_CheckedChanged(object sender, EventArgs e) {
    160       if (Content != null) {
    161         Content.OwnerUserId = cbxPublic.Checked ? null : new Guid?(UserInformation.Instance.User.Id);
    162       }
    163     }
     71    #endregion
    16472  }
    16573}
Note: See TracChangeset for help on using the changeset viewer.