Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/23/11 04:13:08 (14 years ago)
Author:
swagner
Message:

Worked on OKB (#1174)

Location:
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3
Files:
3 added
16 edited

Legend:

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

    r5533 r5550  
    2424using System.Linq;
    2525using HeuristicLab.Clients.Common;
    26 using HeuristicLab.Collections;
    2726using HeuristicLab.Common;
    2827using HeuristicLab.Core;
    29 using HeuristicLab.PluginInfrastructure;
    3028
    3129namespace HeuristicLab.Clients.OKB.Administration {
     
    6361    #endregion
    6462
    65     private AdministrationClient() {
    66       platforms = new ItemCollection<Platform>();
    67       platforms.ItemsRemoved += new CollectionItemsChangedEventHandler<Platform>(platforms_ItemsRemoved);
    68       algorithmClasses = new ItemCollection<AlgorithmClass>();
    69       algorithmClasses.ItemsRemoved += new CollectionItemsChangedEventHandler<AlgorithmClass>(algorithmClasses_ItemsRemoved);
    70       algorithms = new ItemCollection<Algorithm>();
    71       algorithms.ItemsRemoved += new CollectionItemsChangedEventHandler<Algorithm>(algorithms_ItemsRemoved);
    72       problemClasses = new ItemCollection<ProblemClass>();
    73       problemClasses.ItemsRemoved += new CollectionItemsChangedEventHandler<ProblemClass>(problemClasses_ItemsRemoved);
    74       problems = new ItemCollection<Problem>();
    75       problems.ItemsRemoved += new CollectionItemsChangedEventHandler<Problem>(problems_ItemsRemoved);
    76     }
     63    public AdministrationClient() { }
    7764
    7865    #region Refresh
     
    8067      OnRefreshing();
    8168
    82       platforms.Clear();
    83       algorithmClasses.Clear();
    84       algorithms.Clear();
    85       problemClasses.Clear();
    86       problems.Clear();
    87 
     69      platforms = new OKBItemCollection<Platform>();
     70      algorithmClasses = new OKBItemCollection<AlgorithmClass>();
     71      algorithms = new OKBItemCollection<Algorithm>();
     72      problemClasses = new OKBItemCollection<ProblemClass>();
     73      problems = new OKBItemCollection<Problem>();
     74
     75      try {
     76        platforms.AddRange(CallAdministrationService<List<Platform>>(s => s.GetPlatforms()).OrderBy(x => x.Name));
     77        algorithmClasses.AddRange(CallAdministrationService<List<AlgorithmClass>>(s => s.GetAlgorithmClasses()).OrderBy(x => x.Name));
     78        algorithms.AddRange(CallAdministrationService<List<Algorithm>>(s => s.GetAlgorithms()).OrderBy(x => x.Name));
     79        problemClasses.AddRange(CallAdministrationService<List<ProblemClass>>(s => s.GetProblemClasses()).OrderBy(x => x.Name));
     80        problems.AddRange(CallAdministrationService<List<Problem>>(s => s.GetProblems()).OrderBy(x => x.Name));
     81      }
     82      finally {
     83        OnRefreshed();
     84      }
     85    }
     86    public void RefreshAsync(Action<Exception> exceptionCallback) {
    8887      var call = new Func<Exception>(delegate() {
    8988        try {
    90           platforms.AddRange(CallAdministrationService<List<Platform>>(s => s.GetPlatforms()).OrderBy(x => x.Name));
    91           algorithmClasses.AddRange(CallAdministrationService<List<AlgorithmClass>>(s => s.GetAlgorithmClasses()).OrderBy(x => x.Name));
    92           algorithms.AddRange(CallAdministrationService<List<Algorithm>>(s => s.GetAlgorithms()).OrderBy(x => x.Name));
    93           problemClasses.AddRange(CallAdministrationService<List<ProblemClass>>(s => s.GetProblemClasses()).OrderBy(x => x.Name));
    94           problems.AddRange(CallAdministrationService<List<Problem>>(s => s.GetProblems()).OrderBy(x => x.Name));
    95           return null;
     89          Refresh();
    9690        }
    9791        catch (Exception ex) {
    9892          return ex;
    9993        }
     94        return null;
    10095      });
    10196      call.BeginInvoke(delegate(IAsyncResult result) {
    10297        Exception ex = call.EndInvoke(result);
    103         if (ex != null) ErrorHandling.ShowErrorDialog("Refresh failed.", ex);
    104         OnRefreshed();
     98        if (ex != null) exceptionCallback(ex);
    10599      }, null);
    106100    }
     
    108102
    109103    #region Store
    110     public bool Store(IOKBItem item) {
    111       try {
    112         if (item.Id == 0) {
    113           if (item is Platform)
    114             item.Id = CallAdministrationService<long>(s => s.AddPlatform((Platform)item));
    115           else if (item is AlgorithmClass)
    116             item.Id = CallAdministrationService<long>(s => s.AddAlgorithmClass((AlgorithmClass)item));
    117           else if (item is Algorithm)
    118             item.Id = CallAdministrationService<long>(s => s.AddAlgorithm((Algorithm)item));
    119           else if (item is ProblemClass)
    120             item.Id = CallAdministrationService<long>(s => s.AddProblemClass((ProblemClass)item));
    121           else if (item is Problem)
    122             item.Id = CallAdministrationService<long>(s => s.AddProblem((Problem)item));
    123         } else {
    124           if (item is Platform)
    125             CallAdministrationService(s => s.UpdatePlatform((Platform)item));
    126           else if (item is AlgorithmClass)
    127             CallAdministrationService(s => s.UpdateAlgorithmClass((AlgorithmClass)item));
    128           else if (item is Algorithm)
    129             CallAdministrationService(s => s.UpdateAlgorithm((Algorithm)item));
    130           else if (item is ProblemClass)
    131             CallAdministrationService(s => s.UpdateProblemClass((ProblemClass)item));
    132           else if (item is Problem)
    133             CallAdministrationService(s => s.UpdateProblem((Problem)item));
    134         }
    135         return true;
    136       }
    137       catch (Exception ex) {
    138         ErrorHandling.ShowErrorDialog("Store failed.", ex);
    139         return false;
    140       }
     104    public static void Store(IOKBItem item) {
     105      if (item.Id == 0) {
     106        if (item is Platform)
     107          item.Id = CallAdministrationService<long>(s => s.AddPlatform((Platform)item));
     108        else if (item is AlgorithmClass)
     109          item.Id = CallAdministrationService<long>(s => s.AddAlgorithmClass((AlgorithmClass)item));
     110        else if (item is Algorithm)
     111          item.Id = CallAdministrationService<long>(s => s.AddAlgorithm((Algorithm)item));
     112        else if (item is ProblemClass)
     113          item.Id = CallAdministrationService<long>(s => s.AddProblemClass((ProblemClass)item));
     114        else if (item is Problem)
     115          item.Id = CallAdministrationService<long>(s => s.AddProblem((Problem)item));
     116      } else {
     117        if (item is Platform)
     118          CallAdministrationService(s => s.UpdatePlatform((Platform)item));
     119        else if (item is AlgorithmClass)
     120          CallAdministrationService(s => s.UpdateAlgorithmClass((AlgorithmClass)item));
     121        else if (item is Algorithm)
     122          CallAdministrationService(s => s.UpdateAlgorithm((Algorithm)item));
     123        else if (item is ProblemClass)
     124          CallAdministrationService(s => s.UpdateProblemClass((ProblemClass)item));
     125        else if (item is Problem)
     126          CallAdministrationService(s => s.UpdateProblem((Problem)item));
     127      }
     128    }
     129    #endregion
     130
     131    #region Delete
     132    public static void Delete(IOKBItem item) {
     133      if (item is Platform)
     134        CallAdministrationService(s => s.DeletePlatform(item.Id));
     135      else if (item is AlgorithmClass)
     136        CallAdministrationService(s => s.DeleteAlgorithmClass(item.Id));
     137      else if (item is Algorithm)
     138        CallAdministrationService(s => s.DeleteAlgorithm(item.Id));
     139      else if (item is ProblemClass)
     140        CallAdministrationService(s => s.DeleteProblemClass(item.Id));
     141      else if (item is Problem)
     142        CallAdministrationService(s => s.DeleteProblem(item.Id));
     143      item.Id = 0;
    141144    }
    142145    #endregion
    143146
    144147    #region Algorithm Methods
    145     public List<Guid> GetAlgorithmUsers(long algorithmId) {
    146       try {
    147         return CallAdministrationService<List<Guid>>(s => s.GetAlgorithmUsers(algorithmId));
    148       }
    149       catch (Exception ex) {
    150         ErrorHandling.ShowErrorDialog("Refresh authorized algorithm users failed.", ex);
    151         return null;
    152       }
    153     }
    154     public bool UpdateAlgorithmUsers(long algorithmId, List<Guid> users) {
    155       try {
    156         CallAdministrationService(s => s.UpdateAlgorithmUsers(algorithmId, users));
    157         return true;
    158       }
    159       catch (Exception ex) {
    160         ErrorHandling.ShowErrorDialog("Update authorized algorithm users failed.", ex);
    161         return false;
    162       }
    163     }
    164     public byte[] GetAlgorithmData(long algorithmId) {
    165       try {
    166         return CallAdministrationService<byte[]>(s => s.GetAlgorithmData(algorithmId));
    167       }
    168       catch (Exception ex) {
    169         ErrorHandling.ShowErrorDialog("Refresh algorithm data failed.", ex);
    170         return null;
    171       }
    172     }
    173     public bool UpdateAlgorithmData(long algorithmId, byte[] algorithmData) {
    174       try {
    175         CallAdministrationService(s => s.UpdateAlgorithmData(algorithmId, algorithmData));
    176         return true;
    177       }
    178       catch (Exception ex) {
    179         ErrorHandling.ShowErrorDialog("Update algorithm data failed.", ex);
    180         return false;
    181       }
     148    public static List<Guid> GetAlgorithmUsers(long algorithmId) {
     149      return CallAdministrationService<List<Guid>>(s => s.GetAlgorithmUsers(algorithmId));
     150    }
     151    public static void UpdateAlgorithmUsers(long algorithmId, List<Guid> users) {
     152      CallAdministrationService(s => s.UpdateAlgorithmUsers(algorithmId, users));
     153    }
     154    public static byte[] GetAlgorithmData(long algorithmId) {
     155      return CallAdministrationService<byte[]>(s => s.GetAlgorithmData(algorithmId));
     156    }
     157    public static void UpdateAlgorithmData(long algorithmId, byte[] algorithmData) {
     158      CallAdministrationService(s => s.UpdateAlgorithmData(algorithmId, algorithmData));
    182159    }
    183160    #endregion
    184161
    185162    #region Problem Methods
    186     public List<Guid> GetProblemUsers(long problemId) {
    187       try {
    188         return CallAdministrationService<List<Guid>>(s => s.GetProblemUsers(problemId));
    189       }
    190       catch (Exception ex) {
    191         ErrorHandling.ShowErrorDialog("Refresh authorized problem users failed.", ex);
    192         return null;
    193       }
    194     }
    195     public bool UpdateProblemUsers(long problemId, List<Guid> users) {
    196       try {
    197         CallAdministrationService(s => s.UpdateProblemUsers(problemId, users));
    198         return true;
    199       }
    200       catch (Exception ex) {
    201         ErrorHandling.ShowErrorDialog("Update authorized problem users failed.", ex);
    202         return false;
    203       }
    204     }
    205     public byte[] GetProblemData(long problemId) {
    206       try {
    207         return CallAdministrationService<byte[]>(s => s.GetProblemData(problemId));
    208       }
    209       catch (Exception ex) {
    210         ErrorHandling.ShowErrorDialog("Refresh problem data failed.", ex);
    211         return null;
    212       }
    213     }
    214     public bool UpdateProblemData(long problemId, byte[] problemData) {
    215       try {
    216         CallAdministrationService(s => s.UpdateProblemData(problemId, problemData));
    217         return true;
    218       }
    219       catch (Exception ex) {
    220         ErrorHandling.ShowErrorDialog("Update problem data failed.", ex);
    221         return false;
    222       }
     163    public static List<Guid> GetProblemUsers(long problemId) {
     164      return CallAdministrationService<List<Guid>>(s => s.GetProblemUsers(problemId));
     165    }
     166    public static void UpdateProblemUsers(long problemId, List<Guid> users) {
     167      CallAdministrationService(s => s.UpdateProblemUsers(problemId, users));
     168    }
     169    public static byte[] GetProblemData(long problemId) {
     170      return CallAdministrationService<byte[]>(s => s.GetProblemData(problemId));
     171    }
     172    public static void UpdateProblemData(long problemId, byte[] problemData) {
     173      CallAdministrationService(s => s.UpdateProblemData(problemId, problemData));
    223174    }
    224175    #endregion
     
    232183    public event EventHandler Refreshed;
    233184    private void OnRefreshed() {
    234       EventHandler handler = Refreshed;
     185      var handler = Refreshed;
    235186      if (handler != null) handler(this, EventArgs.Empty);
    236187    }
    237 
    238     private void platforms_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<Platform> e) {
    239       try {
    240         foreach (Platform p in e.Items)
    241           CallAdministrationService(s => s.DeletePlatform(p.Id));
    242       }
    243       catch (Exception ex) {
    244         ErrorHandling.ShowErrorDialog("Delete failed.", ex);
    245       }
    246     }
    247     private void algorithmClasses_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<AlgorithmClass> e) {
    248       try {
    249         foreach (AlgorithmClass a in e.Items)
    250           CallAdministrationService(s => s.DeleteAlgorithmClass(a.Id));
    251       }
    252       catch (Exception ex) {
    253         ErrorHandling.ShowErrorDialog("Delete failed.", ex);
    254       }
    255     }
    256     private void algorithms_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<Algorithm> e) {
    257       try {
    258         foreach (Algorithm a in e.Items)
    259           CallAdministrationService(s => s.DeleteAlgorithm(a.Id));
    260       }
    261       catch (Exception ex) {
    262         ErrorHandling.ShowErrorDialog("Delete failed.", ex);
    263       }
    264     }
    265     private void problemClasses_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<ProblemClass> e) {
    266       try {
    267         foreach (ProblemClass p in e.Items)
    268           CallAdministrationService(s => s.DeleteProblemClass(p.Id));
    269       }
    270       catch (Exception ex) {
    271         ErrorHandling.ShowErrorDialog("Delete failed.", ex);
    272       }
    273     }
    274     private void problems_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<Problem> e) {
    275       try {
    276         foreach (Problem p in e.Items)
    277           CallAdministrationService(s => s.DeleteProblem(p.Id));
    278       }
    279       catch (Exception ex) {
    280         ErrorHandling.ShowErrorDialog("Delete failed.", ex);
    281       }
    282     }
    283188    #endregion
    284189
    285190    #region Helpers
    286     private void CallAdministrationService(Action<IAdministrationService> call) {
     191    private static void CallAdministrationService(Action<IAdministrationService> call) {
    287192      AdministrationServiceClient client = ClientFactory.CreateClient<AdministrationServiceClient, IAdministrationService>();
    288193      try {
     
    298203      }
    299204    }
    300     private T CallAdministrationService<T>(Func<IAdministrationService, T> call) {
     205    private static T CallAdministrationService<T>(Func<IAdministrationService, T> call) {
    301206      AdministrationServiceClient client = ClientFactory.CreateClient<AdministrationServiceClient, IAdministrationService>();
    302207      try {
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/ServiceClient/OKBItem.cs

    r5533 r5550  
    8787
    8888    public void Store() {
    89       if (AdministrationClient.Instance.Store(this))
    90         Modified = false;
     89      AdministrationClient.Store(this);
     90      Modified = false;
    9191    }
    9292
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/AdministratorView.cs

    r5533 r5550  
    2424using HeuristicLab.MainForm;
    2525using HeuristicLab.MainForm.WindowsForms;
     26using HeuristicLab.PluginInfrastructure;
    2627
    2728namespace HeuristicLab.Clients.OKB.Administration {
     
    4950      Content.Refreshed += new EventHandler(Content_Refreshed);
    5051    }
     52
    5153
    5254    protected override void OnContentChanged() {
     
    102104
    103105    private void refreshButton_Click(object sender, EventArgs e) {
    104       Content.Refresh();
     106      Content.RefreshAsync(new Action<Exception>((Exception ex) => ErrorHandling.ShowErrorDialog(this, "Refresh failed.", ex)));
    105107    }
    106108  }
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/AlgorithmClassCollectionView.cs

    r5533 r5550  
    2121
    2222using System.Windows.Forms;
    23 using HeuristicLab.Core;
    24 using HeuristicLab.Core.Views;
    2523using HeuristicLab.MainForm;
    2624
    2725namespace HeuristicLab.Clients.OKB.Administration {
    2826  [View("AlgorithmClassCollection View")]
    29   [Content(typeof(IItemCollection<AlgorithmClass>), true)]
    30   public partial class AlgorithmClassCollectionView : ItemCollectionView<AlgorithmClass> {
     27  [Content(typeof(OKBItemCollection<AlgorithmClass>), true)]
     28  public partial class AlgorithmClassCollectionView : OKBItemCollectionView<AlgorithmClass> {
    3129    public AlgorithmClassCollectionView() {
    3230      InitializeComponent();
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/AlgorithmCollectionView.cs

    r5533 r5550  
    2121
    2222using System.Windows.Forms;
    23 using HeuristicLab.Core;
    24 using HeuristicLab.Core.Views;
    2523using HeuristicLab.MainForm;
    2624
    2725namespace HeuristicLab.Clients.OKB.Administration {
    2826  [View("AlgorithmCollection View")]
    29   [Content(typeof(IItemCollection<Algorithm>), true)]
    30   public partial class AlgorithmCollectionView : ItemCollectionView<Algorithm> {
     27  [Content(typeof(OKBItemCollection<Algorithm>), true)]
     28  public partial class AlgorithmCollectionView : OKBItemCollectionView<Algorithm> {
    3129    public AlgorithmCollectionView() {
    3230      InitializeComponent();
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/AlgorithmView.Designer.cs

    r5534 r5550  
    3434    /// </summary>
    3535    private void InitializeComponent() {
     36      System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AlgorithmView));
    3637      this.platformLabel = new System.Windows.Forms.Label();
    3738      this.platformComboBox = new System.Windows.Forms.ComboBox();
     
    122123      this.tabControl.SelectedIndex = 0;
    123124      this.tabControl.Size = new System.Drawing.Size(633, 206);
    124       this.tabControl.TabIndex = 9;
     125      this.tabControl.TabIndex = 10;
    125126      //
    126127      // usersTabPage
     
    134135      this.usersTabPage.Size = new System.Drawing.Size(625, 180);
    135136      this.usersTabPage.TabIndex = 0;
    136       this.usersTabPage.Text = "Authorized Users";
     137      this.usersTabPage.Text = "Authorized Users and Groups";
    137138      this.usersTabPage.UseVisualStyleBackColor = true;
    138139      //
     
    142143                  | System.Windows.Forms.AnchorStyles.Left)
    143144                  | System.Windows.Forms.AnchorStyles.Right)));
     145      this.usersListBox.CheckOnClick = true;
    144146      this.usersListBox.FormattingEnabled = true;
    145147      this.usersListBox.Location = new System.Drawing.Point(6, 35);
    146148      this.usersListBox.Name = "usersListBox";
    147149      this.usersListBox.Size = new System.Drawing.Size(613, 139);
    148       this.usersListBox.TabIndex = 3;
     150      this.usersListBox.TabIndex = 2;
     151      this.usersListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.usersListBox_ItemCheck);
    149152      //
    150153      // storeUsersButton
    151154      //
    152       this.storeUsersButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb;
     155      this.storeUsersButton.Image = ((System.Drawing.Image)(resources.GetObject("storeUsersButton.Image")));
    153156      this.storeUsersButton.Location = new System.Drawing.Point(36, 6);
    154157      this.storeUsersButton.Name = "storeUsersButton";
     
    161164      // refreshUsersButton
    162165      //
    163       this.refreshUsersButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh;
     166      this.refreshUsersButton.Image = ((System.Drawing.Image)(resources.GetObject("refreshUsersButton.Image")));
    164167      this.refreshUsersButton.Location = new System.Drawing.Point(6, 6);
    165168      this.refreshUsersButton.Name = "refreshUsersButton";
     
    186189      this.dataTypeNameLabel.Name = "dataTypeNameLabel";
    187190      this.dataTypeNameLabel.Size = new System.Drawing.Size(38, 13);
    188       this.dataTypeNameLabel.TabIndex = 7;
     191      this.dataTypeNameLabel.TabIndex = 0;
    189192      this.dataTypeNameLabel.Text = "&Name:";
    190193      //
     
    201204      this.dataTypeGroupBox.Name = "dataTypeGroupBox";
    202205      this.dataTypeGroupBox.Size = new System.Drawing.Size(633, 77);
    203       this.dataTypeGroupBox.TabIndex = 10;
     206      this.dataTypeGroupBox.TabIndex = 9;
    204207      this.dataTypeGroupBox.TabStop = false;
    205208      this.dataTypeGroupBox.Text = "Data Type";
     
    212215      this.dataTypeTypeNameTextBox.Name = "dataTypeTypeNameTextBox";
    213216      this.dataTypeTypeNameTextBox.Size = new System.Drawing.Size(507, 20);
    214       this.dataTypeTypeNameTextBox.TabIndex = 8;
    215       this.dataTypeTypeNameTextBox.Validated += new System.EventHandler(this.dataTypeTypeNameTextBox_Validated);
     217      this.dataTypeTypeNameTextBox.TabIndex = 3;
     218      this.toolTip.SetToolTip(this.dataTypeTypeNameTextBox, "Machine Readable Data Type Name (e.g. Assembly Qualified Name)");
     219      this.dataTypeTypeNameTextBox.TextChanged += new System.EventHandler(this.dataTypeTypeNameTextBox_TextChanged);
    216220      //
    217221      // setDataTypeButton
    218222      //
    219223      this.setDataTypeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    220       this.setDataTypeButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Edit;
     224      this.setDataTypeButton.Image = ((System.Drawing.Image)(resources.GetObject("setDataTypeButton.Image")));
    221225      this.setDataTypeButton.Location = new System.Drawing.Point(603, 29);
    222226      this.setDataTypeButton.Name = "setDataTypeButton";
    223227      this.setDataTypeButton.Size = new System.Drawing.Size(24, 24);
    224       this.setDataTypeButton.TabIndex = 1;
     228      this.setDataTypeButton.TabIndex = 4;
    225229      this.toolTip.SetToolTip(this.setDataTypeButton, "Set Data Type");
    226230      this.setDataTypeButton.UseVisualStyleBackColor = true;
     
    234238      this.dataTypeNameTextBox.Name = "dataTypeNameTextBox";
    235239      this.dataTypeNameTextBox.Size = new System.Drawing.Size(507, 20);
    236       this.dataTypeNameTextBox.TabIndex = 8;
    237       this.dataTypeNameTextBox.Validated += new System.EventHandler(this.dataTypeNameTextBox_Validated);
     240      this.dataTypeNameTextBox.TabIndex = 1;
     241      this.toolTip.SetToolTip(this.dataTypeNameTextBox, "Human Readable Data Type Name");
     242      this.dataTypeNameTextBox.TextChanged += new System.EventHandler(this.dataTypeNameTextBox_TextChanged);
    238243      //
    239244      // dataTypeTypeNameLabel
     
    243248      this.dataTypeTypeNameLabel.Name = "dataTypeTypeNameLabel";
    244249      this.dataTypeTypeNameLabel.Size = new System.Drawing.Size(65, 13);
    245       this.dataTypeTypeNameLabel.TabIndex = 7;
     250      this.dataTypeTypeNameLabel.TabIndex = 2;
    246251      this.dataTypeTypeNameLabel.Text = "&Type Name:";
    247252      //
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/AlgorithmView.cs

    r5534 r5550  
    5555    }
    5656
    57     protected override void OnInitialized(System.EventArgs e) {
    58       base.OnInitialized(e);
     57    protected override void OnContentChanged() {
     58      base.OnContentChanged();
     59
    5960      platformComboBoxValues = AdministrationClient.Instance.Platforms.ToList();
    6061      platformComboBox.DataSource = platformComboBoxValues;
    6162      algorithmClassComboBoxValues = AdministrationClient.Instance.AlgorithmClasses.ToList();
    6263      algorithmClassComboBox.DataSource = algorithmClassComboBoxValues;
    63     }
    6464
    65     protected override void OnContentChanged() {
    66       base.OnContentChanged();
    6765      if (Content == null) {
    6866        platformComboBox.SelectedIndex = -1;
    6967        algorithmClassComboBox.SelectedIndex = -1;
    70         dataTypeNameTextBox.Text = "";
    71         dataTypeTypeNameTextBox.Text = "";
     68        dataTypeNameTextBox.Text = string.Empty;
     69        dataTypeTypeNameTextBox.Text = string.Empty;
    7270      } else {
    7371        platformComboBox.SelectedItem = platformComboBoxValues.FirstOrDefault(p => p.Id == Content.PlatformId);
     
    8482      algorithmClassComboBox.Enabled = (Content != null) && !ReadOnly;
    8583      dataTypeGroupBox.Enabled = (Content != null) && !ReadOnly;
    86       refreshUsersButton.Enabled = Content != null;
     84      refreshUsersButton.Enabled = (Content != null) && (Content.Id != 0);
    8785      storeUsersButton.Enabled = (usersListBox.DataSource != null) && !ReadOnly;
    8886      usersListBox.Enabled = (usersListBox.DataSource != null) && !ReadOnly;
     
    9694    protected override void OnContentPropertyChanged(string propertyName) {
    9795      switch (propertyName) {
     96        case "Id":
     97          SetEnabledStateOfControls();
     98          break;
    9899        case "PlatformId":
    99100          platformComboBox.SelectedItem = platformComboBoxValues.FirstOrDefault(p => p.Id == Content.PlatformId);
     
    137138      }
    138139    }
    139     private void dataTypeNameTextBox_Validated(object sender, EventArgs e) {
    140       Content.DataTypeName = dataTypeNameTextBox.Text;
     140    private void dataTypeNameTextBox_TextChanged(object sender, EventArgs e) {
     141      if (dataTypeNameTextBox.Text != Content.DataTypeName)
     142        Content.DataTypeName = dataTypeNameTextBox.Text;
    141143    }
    142     private void dataTypeTypeNameTextBox_Validated(object sender, EventArgs e) {
    143       Content.DataTypeTypeName = dataTypeTypeNameTextBox.Text;
     144    private void dataTypeTypeNameTextBox_TextChanged(object sender, EventArgs e) {
     145      if (dataTypeTypeNameTextBox.Text != Content.DataTypeTypeName)
     146        Content.DataTypeTypeName = dataTypeTypeNameTextBox.Text;
    144147    }
    145148
    146149    private void refreshUsersButton_Click(object sender, System.EventArgs e) {
    147       List<Guid> ids = AdministrationClient.Instance.GetAlgorithmUsers(Content.Id);
     150      List<Guid> ids = AdministrationClient.GetAlgorithmUsers(Content.Id);
    148151      if (ids != null) {
     152        if (AuthenticationClient.Instance.Users == null) AuthenticationClient.Instance.Refresh();
    149153        List<User> users = AuthenticationClient.Instance.Users.ToList();
    150154        usersListBox.DataSource = users;
     
    157161    }
    158162    private void storeUsersButton_Click(object sender, System.EventArgs e) {
    159       if (AdministrationClient.Instance.UpdateAlgorithmUsers(Content.Id, usersListBox.SelectedItems.Cast<User>().Select(u => u.Id).ToList()))
    160         storeUsersButton.Enabled = false;
     163      AdministrationClient.UpdateAlgorithmUsers(Content.Id, usersListBox.SelectedItems.Cast<User>().Select(u => u.Id).ToList());
     164      storeUsersButton.Enabled = false;
    161165    }
    162     private void usersListBox_SelectedIndexChanged(object sender, EventArgs e) {
     166    private void usersListBox_ItemCheck(object sender, ItemCheckEventArgs e) {
    163167      storeUsersButton.Enabled = !ReadOnly;
    164168    }
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/NamedOKBItemView.Designer.cs

    r5533 r5550  
    7373      this.nameTextBox.TabIndex = 2;
    7474      this.nameTextBox.TextChanged += new System.EventHandler(this.nameTextBox_TextChanged);
    75       this.nameTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.nameTextBox_KeyDown);
    7675      //
    7776      // descriptionLabel
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/NamedOKBItemView.cs

    r5533 r5550  
    4949          this.Caption = ViewAttribute.GetViewName(this.GetType());
    5050        else
    51           this.Caption = "NamedEntity View";
     51          this.Caption = "NamedOKBItem View";
    5252      } else {
    5353        nameTextBox.Text = Content.Name;
     
    7979    }
    8080
    81     protected virtual void nameTextBox_KeyDown(object sender, KeyEventArgs e) {
    82       if ((e.KeyCode == Keys.Enter) || (e.KeyCode == Keys.Return))
    83         nameLabel.Focus();  // set focus on label to validate data
    84       if (e.KeyCode == Keys.Escape) {
    85         nameTextBox.Text = Content.Name;
    86         nameLabel.Focus();  // set focus on label to validate data
    87       }
    88     }
    8981    protected virtual void nameTextBox_TextChanged(object sender, EventArgs e) {
    9082      if (nameTextBox.Text != Content.Name)
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/OKBItemView.cs

    r5533 r5550  
    2626using HeuristicLab.MainForm;
    2727using HeuristicLab.MainForm.WindowsForms;
     28using HeuristicLab.PluginInfrastructure;
    2829
    2930namespace HeuristicLab.Clients.OKB.Administration {
     
    7374
    7475    protected virtual void storeButton_Click(object sender, EventArgs e) {
    75       Content.Store();
     76      try {
     77        Content.Store();
     78      }
     79      catch (Exception ex) {
     80        ErrorHandling.ShowErrorDialog(this, "Store failed.", ex);
     81      }
    7682    }
    7783  }
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/PlatformCollectionView.cs

    r5533 r5550  
    2121
    2222using System.Windows.Forms;
    23 using HeuristicLab.Core;
    24 using HeuristicLab.Core.Views;
    2523using HeuristicLab.MainForm;
    2624
    2725namespace HeuristicLab.Clients.OKB.Administration {
    2826  [View("PlatformCollection View")]
    29   [Content(typeof(IItemCollection<Platform>), true)]
    30   public partial class PlatformCollectionView : ItemCollectionView<Platform> {
     27  [Content(typeof(OKBItemCollection<Platform>), true)]
     28  public partial class PlatformCollectionView : OKBItemCollectionView<Platform> {
    3129    public PlatformCollectionView() {
    3230      InitializeComponent();
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/ProblemClassCollectionView.cs

    r5533 r5550  
    2121
    2222using System.Windows.Forms;
    23 using HeuristicLab.Core;
    24 using HeuristicLab.Core.Views;
    2523using HeuristicLab.MainForm;
    2624
    2725namespace HeuristicLab.Clients.OKB.Administration {
    2826  [View("ProblemClassCollection View")]
    29   [Content(typeof(IItemCollection<ProblemClass>), true)]
    30   public partial class ProblemClassCollectionView : ItemCollectionView<ProblemClass> {
     27  [Content(typeof(OKBItemCollection<ProblemClass>), true)]
     28  public partial class ProblemClassCollectionView : OKBItemCollectionView<ProblemClass> {
    3129    public ProblemClassCollectionView() {
    3230      InitializeComponent();
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/ProblemCollectionView.cs

    r5533 r5550  
    2121
    2222using System.Windows.Forms;
    23 using HeuristicLab.Core;
    24 using HeuristicLab.Core.Views;
    2523using HeuristicLab.MainForm;
    2624
    2725namespace HeuristicLab.Clients.OKB.Administration {
    2826  [View("ProblemCollection View")]
    29   [Content(typeof(IItemCollection<Problem>), true)]
    30   public partial class ProblemCollectionView : ItemCollectionView<Problem> {
     27  [Content(typeof(OKBItemCollection<Problem>), true)]
     28  public partial class ProblemCollectionView : OKBItemCollectionView<Problem> {
    3129    public ProblemCollectionView() {
    3230      InitializeComponent();
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/ProblemView.cs

    r5533 r5550  
    9898
    9999    private void refreshUsersButton_Click(object sender, System.EventArgs e) {
    100       List<Guid> ids = AdministrationClient.Instance.GetProblemUsers(Content.Id);
     100      List<Guid> ids = AdministrationClient.GetProblemUsers(Content.Id);
    101101      if (ids != null) {
    102102        List<User> users = AuthenticationClient.Instance.Users.ToList();
     
    111111    }
    112112    private void storeUsersButton_Click(object sender, System.EventArgs e) {
    113       if (AdministrationClient.Instance.UpdateProblemUsers(Content.Id, usersListBox.SelectedItems.Cast<User>().Select(u => u.Id).ToList()))
    114         storeUsersButton.Enabled = false;
     113      AdministrationClient.UpdateProblemUsers(Content.Id, usersListBox.SelectedItems.Cast<User>().Select(u => u.Id).ToList());
     114      storeUsersButton.Enabled = false;
    115115    }
    116116    private void usersListBox_SelectedIndexChanged(object sender, EventArgs e) {
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Authentication/AuthenticationClient.cs

    r5533 r5550  
    5151    public void Refresh() {
    5252      OnRefreshing();
    53 
     53      try {
     54        users = CallAuthenticationService<List<User>>(s => s.GetUsers()).OrderBy(x => x.Name);
     55      }
     56      finally {
     57        OnRefreshed();
     58      }
     59    }
     60    public void RefreshAsync(Action<Exception> exceptionCallback) {
    5461      var call = new Func<Exception>(delegate() {
    5562        try {
    56           users = CallAuthenticationService<List<User>>(s => s.GetUsers()).OrderBy(x => x.Name);
    57           return null;
     63          Refresh();
    5864        }
    5965        catch (Exception ex) {
    6066          return ex;
    6167        }
     68        return null;
    6269      });
    6370      call.BeginInvoke(delegate(IAsyncResult result) {
    6471        Exception ex = call.EndInvoke(result);
    65         if (ex != null) ErrorHandling.ShowErrorDialog("Refresh failed.", ex);
    66         OnRefreshed();
     72        if (ex != null) exceptionCallback(ex);
    6773      }, null);
     74    }
     75    #endregion
     76
     77    #region User Methods
     78    public static IEnumerable<User> GetUsers() {
     79      return CallAuthenticationService<List<User>>(s => s.GetUsers()).OrderBy(x => x.Name);
    6880    }
    6981    #endregion
     
    8395
    8496    #region Helpers
    85     private T CallAuthenticationService<T>(Func<IAuthenticationService, T> call) {
     97    private static T CallAuthenticationService<T>(Func<IAuthenticationService, T> call) {
    8698      AuthenticationServiceClient client = ClientFactory.CreateClient<AuthenticationServiceClient, IAuthenticationService>();
    8799      try {
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/HeuristicLab.Clients.OKB-3.3.csproj

    r5534 r5550  
    104104    <Compile Include="Administration\ServiceClient\Algorithm.cs" />
    105105    <Compile Include="Administration\ServiceClient\AlgorithmClass.cs" />
     106    <Compile Include="Administration\ServiceClient\OKBItemCollection.cs" />
    106107    <Compile Include="Administration\ServiceClient\INamedOKBItem.cs" />
    107108    <Compile Include="Administration\ServiceClient\IOKBItem.cs" />
     
    134135    <Compile Include="Administration\Views\AlgorithmView.Designer.cs">
    135136      <DependentUpon>AlgorithmView.cs</DependentUpon>
     137    </Compile>
     138    <Compile Include="Administration\Views\OKBItemCollectionView.cs">
     139      <SubType>UserControl</SubType>
     140    </Compile>
     141    <Compile Include="Administration\Views\OKBItemCollectionView.Designer.cs">
     142      <DependentUpon>OKBItemCollectionView.cs</DependentUpon>
    136143    </Compile>
    137144    <Compile Include="Administration\Views\NamedOKBItemView.cs">
     
    189196    <None Include="HeuristicLabClientsOKBPlugin.cs.frame" />
    190197  </ItemGroup>
     198  <ItemGroup>
     199    <EmbeddedResource Include="Administration\Views\AlgorithmView.resx">
     200      <DependentUpon>AlgorithmView.cs</DependentUpon>
     201    </EmbeddedResource>
     202  </ItemGroup>
    191203  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
    192204  <PropertyGroup>
Note: See TracChangeset for help on using the changeset viewer.