Changeset 5550 for branches/OKB (trunk integration)
- Timestamp:
- 02/23/11 04:13:08 (14 years ago)
- 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 24 24 using System.Linq; 25 25 using HeuristicLab.Clients.Common; 26 using HeuristicLab.Collections;27 26 using HeuristicLab.Common; 28 27 using HeuristicLab.Core; 29 using HeuristicLab.PluginInfrastructure;30 28 31 29 namespace HeuristicLab.Clients.OKB.Administration { … … 63 61 #endregion 64 62 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() { } 77 64 78 65 #region Refresh … … 80 67 OnRefreshing(); 81 68 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) { 88 87 var call = new Func<Exception>(delegate() { 89 88 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(); 96 90 } 97 91 catch (Exception ex) { 98 92 return ex; 99 93 } 94 return null; 100 95 }); 101 96 call.BeginInvoke(delegate(IAsyncResult result) { 102 97 Exception ex = call.EndInvoke(result); 103 if (ex != null) ErrorHandling.ShowErrorDialog("Refresh failed.", ex); 104 OnRefreshed(); 98 if (ex != null) exceptionCallback(ex); 105 99 }, null); 106 100 } … … 108 102 109 103 #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; 141 144 } 142 145 #endregion 143 146 144 147 #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)); 182 159 } 183 160 #endregion 184 161 185 162 #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)); 223 174 } 224 175 #endregion … … 232 183 public event EventHandler Refreshed; 233 184 private void OnRefreshed() { 234 EventHandler handler = Refreshed;185 var handler = Refreshed; 235 186 if (handler != null) handler(this, EventArgs.Empty); 236 187 } 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 }283 188 #endregion 284 189 285 190 #region Helpers 286 private void CallAdministrationService(Action<IAdministrationService> call) {191 private static void CallAdministrationService(Action<IAdministrationService> call) { 287 192 AdministrationServiceClient client = ClientFactory.CreateClient<AdministrationServiceClient, IAdministrationService>(); 288 193 try { … … 298 203 } 299 204 } 300 private T CallAdministrationService<T>(Func<IAdministrationService, T> call) {205 private static T CallAdministrationService<T>(Func<IAdministrationService, T> call) { 301 206 AdministrationServiceClient client = ClientFactory.CreateClient<AdministrationServiceClient, IAdministrationService>(); 302 207 try { -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/ServiceClient/OKBItem.cs
r5533 r5550 87 87 88 88 public void Store() { 89 if (AdministrationClient.Instance.Store(this))90 89 AdministrationClient.Store(this); 90 Modified = false; 91 91 } 92 92 -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/AdministratorView.cs
r5533 r5550 24 24 using HeuristicLab.MainForm; 25 25 using HeuristicLab.MainForm.WindowsForms; 26 using HeuristicLab.PluginInfrastructure; 26 27 27 28 namespace HeuristicLab.Clients.OKB.Administration { … … 49 50 Content.Refreshed += new EventHandler(Content_Refreshed); 50 51 } 52 51 53 52 54 protected override void OnContentChanged() { … … 102 104 103 105 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))); 105 107 } 106 108 } -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/AlgorithmClassCollectionView.cs
r5533 r5550 21 21 22 22 using System.Windows.Forms; 23 using HeuristicLab.Core;24 using HeuristicLab.Core.Views;25 23 using HeuristicLab.MainForm; 26 24 27 25 namespace HeuristicLab.Clients.OKB.Administration { 28 26 [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> { 31 29 public AlgorithmClassCollectionView() { 32 30 InitializeComponent(); -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/AlgorithmCollectionView.cs
r5533 r5550 21 21 22 22 using System.Windows.Forms; 23 using HeuristicLab.Core;24 using HeuristicLab.Core.Views;25 23 using HeuristicLab.MainForm; 26 24 27 25 namespace HeuristicLab.Clients.OKB.Administration { 28 26 [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> { 31 29 public AlgorithmCollectionView() { 32 30 InitializeComponent(); -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/AlgorithmView.Designer.cs
r5534 r5550 34 34 /// </summary> 35 35 private void InitializeComponent() { 36 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AlgorithmView)); 36 37 this.platformLabel = new System.Windows.Forms.Label(); 37 38 this.platformComboBox = new System.Windows.Forms.ComboBox(); … … 122 123 this.tabControl.SelectedIndex = 0; 123 124 this.tabControl.Size = new System.Drawing.Size(633, 206); 124 this.tabControl.TabIndex = 9;125 this.tabControl.TabIndex = 10; 125 126 // 126 127 // usersTabPage … … 134 135 this.usersTabPage.Size = new System.Drawing.Size(625, 180); 135 136 this.usersTabPage.TabIndex = 0; 136 this.usersTabPage.Text = "Authorized Users ";137 this.usersTabPage.Text = "Authorized Users and Groups"; 137 138 this.usersTabPage.UseVisualStyleBackColor = true; 138 139 // … … 142 143 | System.Windows.Forms.AnchorStyles.Left) 143 144 | System.Windows.Forms.AnchorStyles.Right))); 145 this.usersListBox.CheckOnClick = true; 144 146 this.usersListBox.FormattingEnabled = true; 145 147 this.usersListBox.Location = new System.Drawing.Point(6, 35); 146 148 this.usersListBox.Name = "usersListBox"; 147 149 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); 149 152 // 150 153 // storeUsersButton 151 154 // 152 this.storeUsersButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb;155 this.storeUsersButton.Image = ((System.Drawing.Image)(resources.GetObject("storeUsersButton.Image"))); 153 156 this.storeUsersButton.Location = new System.Drawing.Point(36, 6); 154 157 this.storeUsersButton.Name = "storeUsersButton"; … … 161 164 // refreshUsersButton 162 165 // 163 this.refreshUsersButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh;166 this.refreshUsersButton.Image = ((System.Drawing.Image)(resources.GetObject("refreshUsersButton.Image"))); 164 167 this.refreshUsersButton.Location = new System.Drawing.Point(6, 6); 165 168 this.refreshUsersButton.Name = "refreshUsersButton"; … … 186 189 this.dataTypeNameLabel.Name = "dataTypeNameLabel"; 187 190 this.dataTypeNameLabel.Size = new System.Drawing.Size(38, 13); 188 this.dataTypeNameLabel.TabIndex = 7;191 this.dataTypeNameLabel.TabIndex = 0; 189 192 this.dataTypeNameLabel.Text = "&Name:"; 190 193 // … … 201 204 this.dataTypeGroupBox.Name = "dataTypeGroupBox"; 202 205 this.dataTypeGroupBox.Size = new System.Drawing.Size(633, 77); 203 this.dataTypeGroupBox.TabIndex = 10;206 this.dataTypeGroupBox.TabIndex = 9; 204 207 this.dataTypeGroupBox.TabStop = false; 205 208 this.dataTypeGroupBox.Text = "Data Type"; … … 212 215 this.dataTypeTypeNameTextBox.Name = "dataTypeTypeNameTextBox"; 213 216 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); 216 220 // 217 221 // setDataTypeButton 218 222 // 219 223 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"))); 221 225 this.setDataTypeButton.Location = new System.Drawing.Point(603, 29); 222 226 this.setDataTypeButton.Name = "setDataTypeButton"; 223 227 this.setDataTypeButton.Size = new System.Drawing.Size(24, 24); 224 this.setDataTypeButton.TabIndex = 1;228 this.setDataTypeButton.TabIndex = 4; 225 229 this.toolTip.SetToolTip(this.setDataTypeButton, "Set Data Type"); 226 230 this.setDataTypeButton.UseVisualStyleBackColor = true; … … 234 238 this.dataTypeNameTextBox.Name = "dataTypeNameTextBox"; 235 239 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); 238 243 // 239 244 // dataTypeTypeNameLabel … … 243 248 this.dataTypeTypeNameLabel.Name = "dataTypeTypeNameLabel"; 244 249 this.dataTypeTypeNameLabel.Size = new System.Drawing.Size(65, 13); 245 this.dataTypeTypeNameLabel.TabIndex = 7;250 this.dataTypeTypeNameLabel.TabIndex = 2; 246 251 this.dataTypeTypeNameLabel.Text = "&Type Name:"; 247 252 // -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/AlgorithmView.cs
r5534 r5550 55 55 } 56 56 57 protected override void OnInitialized(System.EventArgs e) { 58 base.OnInitialized(e); 57 protected override void OnContentChanged() { 58 base.OnContentChanged(); 59 59 60 platformComboBoxValues = AdministrationClient.Instance.Platforms.ToList(); 60 61 platformComboBox.DataSource = platformComboBoxValues; 61 62 algorithmClassComboBoxValues = AdministrationClient.Instance.AlgorithmClasses.ToList(); 62 63 algorithmClassComboBox.DataSource = algorithmClassComboBoxValues; 63 }64 64 65 protected override void OnContentChanged() {66 base.OnContentChanged();67 65 if (Content == null) { 68 66 platformComboBox.SelectedIndex = -1; 69 67 algorithmClassComboBox.SelectedIndex = -1; 70 dataTypeNameTextBox.Text = "";71 dataTypeTypeNameTextBox.Text = "";68 dataTypeNameTextBox.Text = string.Empty; 69 dataTypeTypeNameTextBox.Text = string.Empty; 72 70 } else { 73 71 platformComboBox.SelectedItem = platformComboBoxValues.FirstOrDefault(p => p.Id == Content.PlatformId); … … 84 82 algorithmClassComboBox.Enabled = (Content != null) && !ReadOnly; 85 83 dataTypeGroupBox.Enabled = (Content != null) && !ReadOnly; 86 refreshUsersButton.Enabled = Content != null;84 refreshUsersButton.Enabled = (Content != null) && (Content.Id != 0); 87 85 storeUsersButton.Enabled = (usersListBox.DataSource != null) && !ReadOnly; 88 86 usersListBox.Enabled = (usersListBox.DataSource != null) && !ReadOnly; … … 96 94 protected override void OnContentPropertyChanged(string propertyName) { 97 95 switch (propertyName) { 96 case "Id": 97 SetEnabledStateOfControls(); 98 break; 98 99 case "PlatformId": 99 100 platformComboBox.SelectedItem = platformComboBoxValues.FirstOrDefault(p => p.Id == Content.PlatformId); … … 137 138 } 138 139 } 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; 141 143 } 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; 144 147 } 145 148 146 149 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); 148 151 if (ids != null) { 152 if (AuthenticationClient.Instance.Users == null) AuthenticationClient.Instance.Refresh(); 149 153 List<User> users = AuthenticationClient.Instance.Users.ToList(); 150 154 usersListBox.DataSource = users; … … 157 161 } 158 162 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 163 AdministrationClient.UpdateAlgorithmUsers(Content.Id, usersListBox.SelectedItems.Cast<User>().Select(u => u.Id).ToList()); 164 storeUsersButton.Enabled = false; 161 165 } 162 private void usersListBox_ SelectedIndexChanged(object sender,EventArgs e) {166 private void usersListBox_ItemCheck(object sender, ItemCheckEventArgs e) { 163 167 storeUsersButton.Enabled = !ReadOnly; 164 168 } -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/NamedOKBItemView.Designer.cs
r5533 r5550 73 73 this.nameTextBox.TabIndex = 2; 74 74 this.nameTextBox.TextChanged += new System.EventHandler(this.nameTextBox_TextChanged); 75 this.nameTextBox.KeyDown += new System.Windows.Forms.KeyEventHandler(this.nameTextBox_KeyDown);76 75 // 77 76 // descriptionLabel -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/NamedOKBItemView.cs
r5533 r5550 49 49 this.Caption = ViewAttribute.GetViewName(this.GetType()); 50 50 else 51 this.Caption = "Named EntityView";51 this.Caption = "NamedOKBItem View"; 52 52 } else { 53 53 nameTextBox.Text = Content.Name; … … 79 79 } 80 80 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 data84 if (e.KeyCode == Keys.Escape) {85 nameTextBox.Text = Content.Name;86 nameLabel.Focus(); // set focus on label to validate data87 }88 }89 81 protected virtual void nameTextBox_TextChanged(object sender, EventArgs e) { 90 82 if (nameTextBox.Text != Content.Name) -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/OKBItemView.cs
r5533 r5550 26 26 using HeuristicLab.MainForm; 27 27 using HeuristicLab.MainForm.WindowsForms; 28 using HeuristicLab.PluginInfrastructure; 28 29 29 30 namespace HeuristicLab.Clients.OKB.Administration { … … 73 74 74 75 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 } 76 82 } 77 83 } -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/PlatformCollectionView.cs
r5533 r5550 21 21 22 22 using System.Windows.Forms; 23 using HeuristicLab.Core;24 using HeuristicLab.Core.Views;25 23 using HeuristicLab.MainForm; 26 24 27 25 namespace HeuristicLab.Clients.OKB.Administration { 28 26 [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> { 31 29 public PlatformCollectionView() { 32 30 InitializeComponent(); -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/ProblemClassCollectionView.cs
r5533 r5550 21 21 22 22 using System.Windows.Forms; 23 using HeuristicLab.Core;24 using HeuristicLab.Core.Views;25 23 using HeuristicLab.MainForm; 26 24 27 25 namespace HeuristicLab.Clients.OKB.Administration { 28 26 [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> { 31 29 public ProblemClassCollectionView() { 32 30 InitializeComponent(); -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/ProblemCollectionView.cs
r5533 r5550 21 21 22 22 using System.Windows.Forms; 23 using HeuristicLab.Core;24 using HeuristicLab.Core.Views;25 23 using HeuristicLab.MainForm; 26 24 27 25 namespace HeuristicLab.Clients.OKB.Administration { 28 26 [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> { 31 29 public ProblemCollectionView() { 32 30 InitializeComponent(); -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/ProblemView.cs
r5533 r5550 98 98 99 99 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); 101 101 if (ids != null) { 102 102 List<User> users = AuthenticationClient.Instance.Users.ToList(); … … 111 111 } 112 112 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 113 AdministrationClient.UpdateProblemUsers(Content.Id, usersListBox.SelectedItems.Cast<User>().Select(u => u.Id).ToList()); 114 storeUsersButton.Enabled = false; 115 115 } 116 116 private void usersListBox_SelectedIndexChanged(object sender, EventArgs e) { -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Authentication/AuthenticationClient.cs
r5533 r5550 51 51 public void Refresh() { 52 52 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) { 54 61 var call = new Func<Exception>(delegate() { 55 62 try { 56 users = CallAuthenticationService<List<User>>(s => s.GetUsers()).OrderBy(x => x.Name); 57 return null; 63 Refresh(); 58 64 } 59 65 catch (Exception ex) { 60 66 return ex; 61 67 } 68 return null; 62 69 }); 63 70 call.BeginInvoke(delegate(IAsyncResult result) { 64 71 Exception ex = call.EndInvoke(result); 65 if (ex != null) ErrorHandling.ShowErrorDialog("Refresh failed.", ex); 66 OnRefreshed(); 72 if (ex != null) exceptionCallback(ex); 67 73 }, 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); 68 80 } 69 81 #endregion … … 83 95 84 96 #region Helpers 85 private T CallAuthenticationService<T>(Func<IAuthenticationService, T> call) {97 private static T CallAuthenticationService<T>(Func<IAuthenticationService, T> call) { 86 98 AuthenticationServiceClient client = ClientFactory.CreateClient<AuthenticationServiceClient, IAuthenticationService>(); 87 99 try { -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/HeuristicLab.Clients.OKB-3.3.csproj
r5534 r5550 104 104 <Compile Include="Administration\ServiceClient\Algorithm.cs" /> 105 105 <Compile Include="Administration\ServiceClient\AlgorithmClass.cs" /> 106 <Compile Include="Administration\ServiceClient\OKBItemCollection.cs" /> 106 107 <Compile Include="Administration\ServiceClient\INamedOKBItem.cs" /> 107 108 <Compile Include="Administration\ServiceClient\IOKBItem.cs" /> … … 134 135 <Compile Include="Administration\Views\AlgorithmView.Designer.cs"> 135 136 <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> 136 143 </Compile> 137 144 <Compile Include="Administration\Views\NamedOKBItemView.cs"> … … 189 196 <None Include="HeuristicLabClientsOKBPlugin.cs.frame" /> 190 197 </ItemGroup> 198 <ItemGroup> 199 <EmbeddedResource Include="Administration\Views\AlgorithmView.resx"> 200 <DependentUpon>AlgorithmView.cs</DependentUpon> 201 </EmbeddedResource> 202 </ItemGroup> 191 203 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 192 204 <PropertyGroup>
Note: See TracChangeset
for help on using the changeset viewer.