Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
01/19/12 17:56:53 (13 years ago)
Author:
ascheibe
Message:

#1174 added the access service user selection control to the algorithm view of the administrator

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/AlgorithmView.cs

    r7331 r7376  
    2525using System.Linq;
    2626using System.Windows.Forms;
    27 using HeuristicLab.Clients.OKB.Authentication;
    2827using HeuristicLab.Common;
    2928using HeuristicLab.Core.Views;
     
    7372      algorithmClassComboBox.SelectedValueChanged += new EventHandler(algorithmClassComboBox_SelectedValueChanged);
    7473
    75       usersListBox.DataSource = null;
    7674      data = null;
    7775      dataViewHost.Content = null;
     
    8179        dataTypeNameTextBox.Text = string.Empty;
    8280        dataTypeTypeNameTextBox.Text = string.Empty;
     81        refreshableLightweightUserView.Content = null;
     82        refreshableLightweightUserView.FetchSelectedUsers = null;
    8383      } else {
    8484        platformComboBox.SelectedItem = platformComboBoxValues.FirstOrDefault(p => p.Id == Content.PlatformId);
     
    8686        dataTypeNameTextBox.Text = Content.DataTypeName;
    8787        dataTypeTypeNameTextBox.Text = Content.DataTypeTypeName;
     88        refreshableLightweightUserView.Content = Access.AccessClient.Instance;
     89        refreshableLightweightUserView.FetchSelectedUsers = new Func<List<Guid>>(delegate { return AdministrationClient.GetAlgorithmUsers(Content.Id); });
    8890      }
    8991    }
     
    9496      algorithmClassComboBox.Enabled = (Content != null) && !ReadOnly;
    9597      dataTypeGroupBox.Enabled = (Content != null) && !ReadOnly;
    96       refreshUsersButton.Enabled = (Content != null) && (Content.Id != 0);
    97       storeUsersButton.Enabled = (usersListBox.DataSource != null) && !ReadOnly;
    98       usersListBox.Enabled = (usersListBox.DataSource != null) && !ReadOnly;
     98      storeUsersButton.Enabled = (refreshableLightweightUserView.GetCheckedUsers() != null) && !ReadOnly;
     99      refreshableLightweightUserView.Enabled = (refreshableLightweightUserView.Content != null) && !ReadOnly;
    99100      refreshDataButton.Enabled = (Content != null) && (Content.Id != 0);
    100101      storeDataButton.Enabled = ((data != null) || (dataViewHost.Content != null)) && !ReadOnly;
     
    155156    }
    156157
    157     private void refreshUsersButton_Click(object sender, System.EventArgs e) {
    158       try {
    159         List<Guid> ids = AdministrationClient.GetAlgorithmUsers(Content.Id);
    160         if (ids != null) {
    161           if (AuthenticationClient.Instance.Users == null) AuthenticationClient.Instance.Refresh();
    162           List<User> users = AuthenticationClient.Instance.Users.ToList();
    163           usersListBox.DataSource = users;
    164           usersListBox.DisplayMember = "Name";
    165           for (int i = 0; i < users.Count; i++)
    166             usersListBox.SetItemChecked(i, ids.Contains(users[i].Id));
    167           usersListBox.Enabled = !ReadOnly;
    168           storeUsersButton.Enabled = false;
    169         }
    170       }
    171       catch (Exception ex) {
    172         ErrorHandling.ShowErrorDialog(this, "Refresh authorized users and groups failed.", ex);
    173       }
    174     }
    175158    private void storeUsersButton_Click(object sender, System.EventArgs e) {
    176159      try {
    177         AdministrationClient.UpdateAlgorithmUsers(Content.Id, usersListBox.SelectedItems.Cast<User>().Select(u => u.Id).ToList());
     160        AdministrationClient.UpdateAlgorithmUsers(Content.Id, refreshableLightweightUserView.GetCheckedUsers().CheckedItems.Select(x => x.Value.Id).ToList());
    178161        storeUsersButton.Enabled = false;
    179162      }
     
    181164        ErrorHandling.ShowErrorDialog(this, "Store authorized users and groups failed.", ex);
    182165      }
    183     }
    184     private void usersListBox_ItemCheck(object sender, ItemCheckEventArgs e) {
    185       storeUsersButton.Enabled = !ReadOnly;
    186166    }
    187167
     
    325305    }
    326306    #endregion
     307
     308    private void refreshableLightweightUserView_SelectedUsersChanged(object sender, EventArgs e) {
     309      storeUsersButton.Enabled = !ReadOnly;
     310    }
    327311  }
    328312}
Note: See TracChangeset for help on using the changeset viewer.