Changeset 5587 for branches/OKB (trunk integration)
- Timestamp:
- 03/02/11 04:28:19 (13 years ago)
- Location:
- branches/OKB (trunk integration)
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/AlgorithmView.Designer.cs
r5550 r5587 34 34 /// </summary> 35 35 private void InitializeComponent() { 36 System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(AlgorithmView));37 36 this.platformLabel = new System.Windows.Forms.Label(); 38 37 this.platformComboBox = new System.Windows.Forms.ComboBox(); … … 45 44 this.refreshUsersButton = new System.Windows.Forms.Button(); 46 45 this.dataTabPage = new System.Windows.Forms.TabPage(); 46 this.noViewAvailableLabel = new System.Windows.Forms.Label(); 47 this.dataViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 48 this.saveFileButton = new System.Windows.Forms.Button(); 49 this.openFileButton = new System.Windows.Forms.Button(); 50 this.newDataButton = new System.Windows.Forms.Button(); 51 this.storeDataButton = new System.Windows.Forms.Button(); 52 this.refreshDataButton = new System.Windows.Forms.Button(); 47 53 this.dataTypeNameLabel = new System.Windows.Forms.Label(); 48 54 this.dataTypeGroupBox = new System.Windows.Forms.GroupBox(); 49 55 this.dataTypeTypeNameTextBox = new System.Windows.Forms.TextBox(); 50 this.setDataTypeButton = new System.Windows.Forms.Button();51 56 this.dataTypeNameTextBox = new System.Windows.Forms.TextBox(); 52 57 this.dataTypeTypeNameLabel = new System.Windows.Forms.Label(); 58 this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); 59 this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); 53 60 this.tabControl.SuspendLayout(); 54 61 this.usersTabPage.SuspendLayout(); 62 this.dataTabPage.SuspendLayout(); 55 63 this.dataTypeGroupBox.SuspendLayout(); 56 64 this.SuspendLayout(); … … 153 161 // storeUsersButton 154 162 // 155 this.storeUsersButton.Image = ((System.Drawing.Image)(resources.GetObject("storeUsersButton.Image")));163 this.storeUsersButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb; 156 164 this.storeUsersButton.Location = new System.Drawing.Point(36, 6); 157 165 this.storeUsersButton.Name = "storeUsersButton"; … … 164 172 // refreshUsersButton 165 173 // 166 this.refreshUsersButton.Image = ((System.Drawing.Image)(resources.GetObject("refreshUsersButton.Image")));174 this.refreshUsersButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh; 167 175 this.refreshUsersButton.Location = new System.Drawing.Point(6, 6); 168 176 this.refreshUsersButton.Name = "refreshUsersButton"; … … 175 183 // dataTabPage 176 184 // 185 this.dataTabPage.Controls.Add(this.noViewAvailableLabel); 186 this.dataTabPage.Controls.Add(this.dataViewHost); 187 this.dataTabPage.Controls.Add(this.saveFileButton); 188 this.dataTabPage.Controls.Add(this.openFileButton); 189 this.dataTabPage.Controls.Add(this.newDataButton); 190 this.dataTabPage.Controls.Add(this.storeDataButton); 191 this.dataTabPage.Controls.Add(this.refreshDataButton); 177 192 this.dataTabPage.Location = new System.Drawing.Point(4, 22); 178 193 this.dataTabPage.Name = "dataTabPage"; … … 183 198 this.dataTabPage.UseVisualStyleBackColor = true; 184 199 // 200 // noViewAvailableLabel 201 // 202 this.noViewAvailableLabel.Anchor = System.Windows.Forms.AnchorStyles.None; 203 this.noViewAvailableLabel.AutoSize = true; 204 this.noViewAvailableLabel.Location = new System.Drawing.Point(265, 84); 205 this.noViewAvailableLabel.Name = "noViewAvailableLabel"; 206 this.noViewAvailableLabel.Size = new System.Drawing.Size(94, 13); 207 this.noViewAvailableLabel.TabIndex = 6; 208 this.noViewAvailableLabel.Text = "No view available."; 209 // 210 // dataViewHost 211 // 212 this.dataViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 213 | System.Windows.Forms.AnchorStyles.Left) 214 | System.Windows.Forms.AnchorStyles.Right))); 215 this.dataViewHost.Caption = "View"; 216 this.dataViewHost.Content = null; 217 this.dataViewHost.Enabled = false; 218 this.dataViewHost.Location = new System.Drawing.Point(6, 36); 219 this.dataViewHost.Name = "dataViewHost"; 220 this.dataViewHost.ReadOnly = false; 221 this.dataViewHost.Size = new System.Drawing.Size(613, 138); 222 this.dataViewHost.TabIndex = 5; 223 this.dataViewHost.ViewsLabelVisible = true; 224 this.dataViewHost.ViewType = null; 225 // 226 // saveFileButton 227 // 228 this.saveFileButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Save; 229 this.saveFileButton.Location = new System.Drawing.Point(126, 6); 230 this.saveFileButton.Name = "saveFileButton"; 231 this.saveFileButton.Size = new System.Drawing.Size(24, 24); 232 this.saveFileButton.TabIndex = 4; 233 this.toolTip.SetToolTip(this.saveFileButton, "Save Algorithm Data into File"); 234 this.saveFileButton.UseVisualStyleBackColor = true; 235 this.saveFileButton.Click += new System.EventHandler(this.saveFileButton_Click); 236 // 237 // openFileButton 238 // 239 this.openFileButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open; 240 this.openFileButton.Location = new System.Drawing.Point(96, 6); 241 this.openFileButton.Name = "openFileButton"; 242 this.openFileButton.Size = new System.Drawing.Size(24, 24); 243 this.openFileButton.TabIndex = 3; 244 this.toolTip.SetToolTip(this.openFileButton, "Load Algorithm Data from File"); 245 this.openFileButton.UseVisualStyleBackColor = true; 246 this.openFileButton.Click += new System.EventHandler(this.openFileButton_Click); 247 // 248 // newDataButton 249 // 250 this.newDataButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument; 251 this.newDataButton.Location = new System.Drawing.Point(66, 6); 252 this.newDataButton.Name = "newDataButton"; 253 this.newDataButton.Size = new System.Drawing.Size(24, 24); 254 this.newDataButton.TabIndex = 2; 255 this.toolTip.SetToolTip(this.newDataButton, "Create New Algorithm Data"); 256 this.newDataButton.UseVisualStyleBackColor = true; 257 this.newDataButton.Click += new System.EventHandler(this.newDataButton_Click); 258 // 259 // storeDataButton 260 // 261 this.storeDataButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb; 262 this.storeDataButton.Location = new System.Drawing.Point(36, 6); 263 this.storeDataButton.Name = "storeDataButton"; 264 this.storeDataButton.Size = new System.Drawing.Size(24, 24); 265 this.storeDataButton.TabIndex = 1; 266 this.toolTip.SetToolTip(this.storeDataButton, "Store Algorithm Data"); 267 this.storeDataButton.UseVisualStyleBackColor = true; 268 this.storeDataButton.Click += new System.EventHandler(this.storeDataButton_Click); 269 // 270 // refreshDataButton 271 // 272 this.refreshDataButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh; 273 this.refreshDataButton.Location = new System.Drawing.Point(6, 6); 274 this.refreshDataButton.Name = "refreshDataButton"; 275 this.refreshDataButton.Size = new System.Drawing.Size(24, 24); 276 this.refreshDataButton.TabIndex = 0; 277 this.toolTip.SetToolTip(this.refreshDataButton, "Refresh Algorithm Data"); 278 this.refreshDataButton.UseVisualStyleBackColor = true; 279 this.refreshDataButton.Click += new System.EventHandler(this.refreshDataButton_Click); 280 // 185 281 // dataTypeNameLabel 186 282 // … … 197 293 | System.Windows.Forms.AnchorStyles.Right))); 198 294 this.dataTypeGroupBox.Controls.Add(this.dataTypeTypeNameTextBox); 199 this.dataTypeGroupBox.Controls.Add(this.setDataTypeButton);200 295 this.dataTypeGroupBox.Controls.Add(this.dataTypeNameTextBox); 201 296 this.dataTypeGroupBox.Controls.Add(this.dataTypeTypeNameLabel); … … 214 309 this.dataTypeTypeNameTextBox.Location = new System.Drawing.Point(90, 45); 215 310 this.dataTypeTypeNameTextBox.Name = "dataTypeTypeNameTextBox"; 216 this.dataTypeTypeNameTextBox.Size = new System.Drawing.Size(5 07, 20);311 this.dataTypeTypeNameTextBox.Size = new System.Drawing.Size(537, 20); 217 312 this.dataTypeTypeNameTextBox.TabIndex = 3; 218 313 this.toolTip.SetToolTip(this.dataTypeTypeNameTextBox, "Machine Readable Data Type Name (e.g. Assembly Qualified Name)"); 219 314 this.dataTypeTypeNameTextBox.TextChanged += new System.EventHandler(this.dataTypeTypeNameTextBox_TextChanged); 220 315 // 221 // setDataTypeButton222 //223 this.setDataTypeButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));224 this.setDataTypeButton.Image = ((System.Drawing.Image)(resources.GetObject("setDataTypeButton.Image")));225 this.setDataTypeButton.Location = new System.Drawing.Point(603, 29);226 this.setDataTypeButton.Name = "setDataTypeButton";227 this.setDataTypeButton.Size = new System.Drawing.Size(24, 24);228 this.setDataTypeButton.TabIndex = 4;229 this.toolTip.SetToolTip(this.setDataTypeButton, "Set Data Type");230 this.setDataTypeButton.UseVisualStyleBackColor = true;231 this.setDataTypeButton.Click += new System.EventHandler(this.setDataTypeButton_Click);232 //233 316 // dataTypeNameTextBox 234 317 // … … 237 320 this.dataTypeNameTextBox.Location = new System.Drawing.Point(90, 19); 238 321 this.dataTypeNameTextBox.Name = "dataTypeNameTextBox"; 239 this.dataTypeNameTextBox.Size = new System.Drawing.Size(5 07, 20);322 this.dataTypeNameTextBox.Size = new System.Drawing.Size(537, 20); 240 323 this.dataTypeNameTextBox.TabIndex = 1; 241 324 this.toolTip.SetToolTip(this.dataTypeNameTextBox, "Human Readable Data Type Name"); … … 250 333 this.dataTypeTypeNameLabel.TabIndex = 2; 251 334 this.dataTypeTypeNameLabel.Text = "&Type Name:"; 335 // 336 // openFileDialog 337 // 338 this.openFileDialog.FileName = "data"; 339 this.openFileDialog.Filter = "All Files (*.*)|*.*"; 340 this.openFileDialog.Title = "Load Algorithm Data"; 341 // 342 // saveFileDialog 343 // 344 this.saveFileDialog.FileName = "data"; 345 this.saveFileDialog.Filter = "All Files (*.*)|*.*"; 346 this.saveFileDialog.Title = "Save Algorithm Data"; 252 347 // 253 348 // AlgorithmView … … 275 370 this.tabControl.ResumeLayout(false); 276 371 this.usersTabPage.ResumeLayout(false); 372 this.dataTabPage.ResumeLayout(false); 373 this.dataTabPage.PerformLayout(); 277 374 this.dataTypeGroupBox.ResumeLayout(false); 278 375 this.dataTypeGroupBox.PerformLayout(); … … 299 396 private System.Windows.Forms.TextBox dataTypeNameTextBox; 300 397 private System.Windows.Forms.Label dataTypeTypeNameLabel; 301 private System.Windows.Forms.Button setDataTypeButton; 398 private System.Windows.Forms.Button storeDataButton; 399 private System.Windows.Forms.Button refreshDataButton; 400 private System.Windows.Forms.Button openFileButton; 401 private System.Windows.Forms.Button newDataButton; 402 private System.Windows.Forms.Button saveFileButton; 403 private System.Windows.Forms.OpenFileDialog openFileDialog; 404 private System.Windows.Forms.SaveFileDialog saveFileDialog; 405 private MainForm.WindowsForms.ViewHost dataViewHost; 406 private System.Windows.Forms.Label noViewAvailableLabel; 302 407 303 408 } -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/AlgorithmView.cs
r5550 r5587 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.IO; 24 25 using System.Linq; 25 26 using System.Windows.Forms; 26 27 using HeuristicLab.Clients.OKB.Authentication; 28 using HeuristicLab.Common; 27 29 using HeuristicLab.Core.Views; 28 30 using HeuristicLab.MainForm; 29 31 using HeuristicLab.MainForm.WindowsForms; 30 32 using HeuristicLab.Optimization; 33 using HeuristicLab.Persistence.Default.Xml; 34 using HeuristicLab.PluginInfrastructure; 31 35 32 36 namespace HeuristicLab.Clients.OKB.Administration { … … 37 41 private List<AlgorithmClass> algorithmClassComboBoxValues; 38 42 private TypeSelectorDialog typeSelectorDialog; 43 private byte[] data; 39 44 40 45 public new Algorithm Content { … … 58 63 base.OnContentChanged(); 59 64 65 platformComboBox.SelectedValueChanged -= new EventHandler(platformComboBox_SelectedValueChanged); 60 66 platformComboBoxValues = AdministrationClient.Instance.Platforms.ToList(); 61 67 platformComboBox.DataSource = platformComboBoxValues; 68 platformComboBox.SelectedValueChanged += new EventHandler(platformComboBox_SelectedValueChanged); 69 70 algorithmClassComboBox.SelectedValueChanged -= new EventHandler(algorithmClassComboBox_SelectedValueChanged); 62 71 algorithmClassComboBoxValues = AdministrationClient.Instance.AlgorithmClasses.ToList(); 63 72 algorithmClassComboBox.DataSource = algorithmClassComboBoxValues; 64 73 algorithmClassComboBox.SelectedValueChanged += new EventHandler(algorithmClassComboBox_SelectedValueChanged); 74 75 usersListBox.DataSource = null; 76 data = null; 77 dataViewHost.Content = null; 65 78 if (Content == null) { 66 79 platformComboBox.SelectedIndex = -1; … … 74 87 dataTypeTypeNameTextBox.Text = Content.DataTypeTypeName; 75 88 } 76 usersListBox.DataSource = null;77 89 } 78 90 … … 85 97 storeUsersButton.Enabled = (usersListBox.DataSource != null) && !ReadOnly; 86 98 usersListBox.Enabled = (usersListBox.DataSource != null) && !ReadOnly; 99 refreshDataButton.Enabled = (Content != null) && (Content.Id != 0); 100 storeDataButton.Enabled = ((data != null) || (dataViewHost.Content != null)) && !ReadOnly; 101 openFileButton.Enabled = (Content != null) && (Content.Id != 0); 102 saveFileButton.Enabled = (data != null) || (dataViewHost.Content != null); 103 noViewAvailableLabel.Visible = dataViewHost.Content == null; 87 104 88 105 bool isHL33Platform = platformComboBox.Text == "HeuristicLab 3.3"; 89 setDataTypeButton.Enabled = isHL33Platform && !ReadOnly;90 106 dataTypeNameTextBox.ReadOnly = isHL33Platform; 91 107 dataTypeTypeNameTextBox.ReadOnly = isHL33Platform; 92 } 93 108 newDataButton.Enabled = isHL33Platform && (Content.Id != 0) && !ReadOnly; 109 } 110 111 #region Content Events 94 112 protected override void OnContentPropertyChanged(string propertyName) { 95 113 switch (propertyName) { … … 112 130 } 113 131 } 114 132 #endregion 133 134 #region Control Events 115 135 private void platformComboBox_SelectedValueChanged(object sender, System.EventArgs e) { 116 136 if (Content != null) { … … 126 146 } 127 147 128 private void setDataTypeButton_Click(object sender, EventArgs e) { 148 private void dataTypeNameTextBox_TextChanged(object sender, EventArgs e) { 149 if (dataTypeNameTextBox.Text != Content.DataTypeName) 150 Content.DataTypeName = dataTypeNameTextBox.Text; 151 } 152 private void dataTypeTypeNameTextBox_TextChanged(object sender, EventArgs e) { 153 if (dataTypeTypeNameTextBox.Text != Content.DataTypeTypeName) 154 Content.DataTypeTypeName = dataTypeTypeNameTextBox.Text; 155 } 156 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 } 175 private void storeUsersButton_Click(object sender, System.EventArgs e) { 176 try { 177 AdministrationClient.UpdateAlgorithmUsers(Content.Id, usersListBox.SelectedItems.Cast<User>().Select(u => u.Id).ToList()); 178 storeUsersButton.Enabled = false; 179 } 180 catch (Exception ex) { 181 ErrorHandling.ShowErrorDialog(this, "Store authorized users and groups failed.", ex); 182 } 183 } 184 private void usersListBox_ItemCheck(object sender, ItemCheckEventArgs e) { 185 storeUsersButton.Enabled = !ReadOnly; 186 } 187 188 private void refreshDataButton_Click(object sender, EventArgs e) { 189 CallAsync( 190 () => { 191 data = null; 192 dataViewHost.Content = null; 193 data = AdministrationClient.GetAlgorithmData(Content.Id); 194 if (data != null) { 195 using (MemoryStream stream = new MemoryStream(data)) { 196 try { 197 dataViewHost.Content = XmlParser.Deserialize<IContent>(stream); 198 } 199 catch (Exception) { } 200 stream.Close(); 201 } 202 } 203 }, 204 "Refresh algorithm data failed.", 205 () => SetEnabledStateOfControls() 206 ); 207 } 208 private void storeDataButton_Click(object sender, EventArgs e) { 209 CallAsync( 210 () => { 211 if (dataViewHost.Content != null) { 212 using (MemoryStream stream = new MemoryStream()) { 213 IAlgorithm algorithm = dataViewHost.Content as IAlgorithm; 214 algorithm.Prepare(true); 215 XmlGenerator.Serialize(algorithm, stream); 216 stream.Close(); 217 data = stream.ToArray(); 218 } 219 } 220 AdministrationClient.UpdateAlgorithmData(Content.Id, data); 221 }, 222 "Store algorithm data failed.", 223 null 224 ); 225 } 226 private void newDataButton_Click(object sender, EventArgs e) { 129 227 if (typeSelectorDialog == null) { 130 228 typeSelectorDialog = new TypeSelectorDialog(); … … 134 232 } 135 233 if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { 136 Content.DataTypeName = typeSelectorDialog.TypeSelector.SelectedType.Name; 137 Content.DataTypeTypeName = typeSelectorDialog.TypeSelector.SelectedType.AssemblyQualifiedName; 138 } 139 } 140 private void dataTypeNameTextBox_TextChanged(object sender, EventArgs e) { 141 if (dataTypeNameTextBox.Text != Content.DataTypeName) 142 Content.DataTypeName = dataTypeNameTextBox.Text; 143 } 144 private void dataTypeTypeNameTextBox_TextChanged(object sender, EventArgs e) { 145 if (dataTypeTypeNameTextBox.Text != Content.DataTypeTypeName) 146 Content.DataTypeTypeName = dataTypeTypeNameTextBox.Text; 147 } 148 149 private void refreshUsersButton_Click(object sender, System.EventArgs e) { 150 List<Guid> ids = AdministrationClient.GetAlgorithmUsers(Content.Id); 151 if (ids != null) { 152 if (AuthenticationClient.Instance.Users == null) AuthenticationClient.Instance.Refresh(); 153 List<User> users = AuthenticationClient.Instance.Users.ToList(); 154 usersListBox.DataSource = users; 155 usersListBox.DisplayMember = "Name"; 156 for (int i = 0; i < users.Count; i++) 157 usersListBox.SetItemChecked(i, ids.Contains(users[i].Id)); 158 usersListBox.Enabled = !ReadOnly; 159 storeUsersButton.Enabled = false; 160 } 161 } 162 private void storeUsersButton_Click(object sender, System.EventArgs e) { 163 AdministrationClient.UpdateAlgorithmUsers(Content.Id, usersListBox.SelectedItems.Cast<User>().Select(u => u.Id).ToList()); 164 storeUsersButton.Enabled = false; 165 } 166 private void usersListBox_ItemCheck(object sender, ItemCheckEventArgs e) { 167 storeUsersButton.Enabled = !ReadOnly; 168 } 234 try { 235 Content.DataTypeName = typeSelectorDialog.TypeSelector.SelectedType.Name; 236 Content.DataTypeTypeName = typeSelectorDialog.TypeSelector.SelectedType.AssemblyQualifiedName; 237 data = null; 238 dataViewHost.Content = (IContent)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 239 } 240 catch (Exception ex) { 241 ErrorHandling.ShowErrorDialog(this, "Create new algorithm data failed.", ex); 242 } 243 SetEnabledStateOfControls(); 244 } 245 } 246 private void openFileButton_Click(object sender, EventArgs e) { 247 if (openFileDialog.ShowDialog(this) == DialogResult.OK) { 248 CallAsync( 249 () => { 250 IContent algorithm = null; 251 try { 252 algorithm = XmlParser.Deserialize<IContent>(openFileDialog.FileName); 253 } 254 catch (Exception) { } 255 256 if (algorithm != null) { 257 Content.DataTypeName = algorithm.GetType().Name; 258 Content.DataTypeTypeName = algorithm.GetType().AssemblyQualifiedName; 259 data = null; 260 } else { 261 using (FileStream stream = new FileStream(openFileDialog.FileName, FileMode.Open, FileAccess.Read)) { 262 data = new byte[stream.Length]; 263 stream.Read(data, 0, data.Length); 264 stream.Close(); 265 } 266 } 267 dataViewHost.Content = algorithm; 268 }, 269 "Save algorithm data into file failed.", 270 () => SetEnabledStateOfControls() 271 ); 272 } 273 } 274 private void saveFileButton_Click(object sender, EventArgs e) { 275 if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { 276 CallAsync( 277 () => { 278 if (dataViewHost.Content != null) { 279 XmlGenerator.Serialize(dataViewHost.Content, saveFileDialog.FileName); 280 } else { 281 using (FileStream stream = new FileStream(saveFileDialog.FileName, FileMode.Create, FileAccess.Write)) { 282 stream.Write(data, 0, data.Length); 283 stream.Close(); 284 } 285 } 286 }, 287 "Save algorithm data into file failed.", 288 null 289 ); 290 } 291 } 292 #endregion 293 294 #region Helpers 295 private void CallAsync(Action call, string errorMessage, Action continueWith) { 296 BeginAsyncCall(); 297 call.BeginInvoke(delegate(IAsyncResult result) { 298 Exception exception = null; 299 try { 300 call.EndInvoke(result); 301 } 302 catch (Exception ex) { 303 exception = ex; 304 } 305 EndAsyncCall(errorMessage, exception, continueWith); 306 }, null); 307 } 308 private void BeginAsyncCall() { 309 if (InvokeRequired) 310 Invoke(new Action(BeginAsyncCall)); 311 else { 312 Cursor = Cursors.AppStarting; 313 Enabled = false; 314 } 315 } 316 private void EndAsyncCall(string errorMessage, Exception exception, Action continueWith) { 317 if (InvokeRequired) 318 Invoke(new Action<string, Exception, Action>(EndAsyncCall), errorMessage, exception, continueWith); 319 else { 320 Cursor = Cursors.Default; 321 Enabled = true; 322 if (exception != null) ErrorHandling.ShowErrorDialog(this, errorMessage, exception); 323 if (continueWith != null) continueWith(); 324 } 325 } 326 #endregion 169 327 } 170 328 } -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/ProblemView.Designer.cs
r5534 r5587 27 27 private System.ComponentModel.IContainer components = null; 28 28 29 /// <summary>30 /// Clean up any resources being used.31 /// </summary>32 /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>33 protected override void Dispose(bool disposing) {34 if (disposing) {35 if (components != null) components.Dispose();36 }37 base.Dispose(disposing);38 }39 40 29 #region Component Designer generated code 41 30 … … 51 40 this.tabControl = new System.Windows.Forms.TabControl(); 52 41 this.usersTabPage = new System.Windows.Forms.TabPage(); 42 this.usersListBox = new System.Windows.Forms.CheckedListBox(); 53 43 this.storeUsersButton = new System.Windows.Forms.Button(); 54 44 this.refreshUsersButton = new System.Windows.Forms.Button(); 55 45 this.dataTabPage = new System.Windows.Forms.TabPage(); 56 this.usersListBox = new System.Windows.Forms.CheckedListBox(); 46 this.noViewAvailableLabel = new System.Windows.Forms.Label(); 47 this.dataViewHost = new HeuristicLab.MainForm.WindowsForms.ViewHost(); 48 this.saveFileButton = new System.Windows.Forms.Button(); 49 this.openFileButton = new System.Windows.Forms.Button(); 50 this.newDataButton = new System.Windows.Forms.Button(); 51 this.storeDataButton = new System.Windows.Forms.Button(); 52 this.refreshDataButton = new System.Windows.Forms.Button(); 53 this.dataTypeNameLabel = new System.Windows.Forms.Label(); 54 this.dataTypeGroupBox = new System.Windows.Forms.GroupBox(); 55 this.dataTypeTypeNameTextBox = new System.Windows.Forms.TextBox(); 56 this.dataTypeNameTextBox = new System.Windows.Forms.TextBox(); 57 this.dataTypeTypeNameLabel = new System.Windows.Forms.Label(); 58 this.openFileDialog = new System.Windows.Forms.OpenFileDialog(); 59 this.saveFileDialog = new System.Windows.Forms.SaveFileDialog(); 57 60 this.tabControl.SuspendLayout(); 58 61 this.usersTabPage.SuspendLayout(); 62 this.dataTabPage.SuspendLayout(); 63 this.dataTypeGroupBox.SuspendLayout(); 59 64 this.SuspendLayout(); 60 65 // … … 99 104 this.problemClassLabel.Location = new System.Drawing.Point(3, 111); 100 105 this.problemClassLabel.Name = "problemClassLabel"; 101 this.problemClassLabel.Size = new System.Drawing.Size( 76, 13);106 this.problemClassLabel.Size = new System.Drawing.Size(81, 13); 102 107 this.problemClassLabel.TabIndex = 7; 103 108 this.problemClassLabel.Text = "&Problem Class:"; … … 122 127 this.tabControl.Controls.Add(this.usersTabPage); 123 128 this.tabControl.Controls.Add(this.dataTabPage); 124 this.tabControl.Location = new System.Drawing.Point(0, 162);129 this.tabControl.Location = new System.Drawing.Point(0, 239); 125 130 this.tabControl.Name = "tabControl"; 126 131 this.tabControl.SelectedIndex = 0; 127 this.tabControl.Size = new System.Drawing.Size(633, 2 83);128 this.tabControl.TabIndex = 9;132 this.tabControl.Size = new System.Drawing.Size(633, 206); 133 this.tabControl.TabIndex = 10; 129 134 // 130 135 // usersTabPage … … 136 141 this.usersTabPage.Name = "usersTabPage"; 137 142 this.usersTabPage.Padding = new System.Windows.Forms.Padding(3); 138 this.usersTabPage.Size = new System.Drawing.Size(625, 257);143 this.usersTabPage.Size = new System.Drawing.Size(625, 180); 139 144 this.usersTabPage.TabIndex = 0; 140 this.usersTabPage.Text = "Authorized Users ";145 this.usersTabPage.Text = "Authorized Users and Groups"; 141 146 this.usersTabPage.UseVisualStyleBackColor = true; 147 // 148 // usersListBox 149 // 150 this.usersListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 151 | System.Windows.Forms.AnchorStyles.Left) 152 | System.Windows.Forms.AnchorStyles.Right))); 153 this.usersListBox.CheckOnClick = true; 154 this.usersListBox.FormattingEnabled = true; 155 this.usersListBox.Location = new System.Drawing.Point(6, 35); 156 this.usersListBox.Name = "usersListBox"; 157 this.usersListBox.Size = new System.Drawing.Size(613, 139); 158 this.usersListBox.TabIndex = 2; 159 this.usersListBox.ItemCheck += new System.Windows.Forms.ItemCheckEventHandler(this.usersListBox_ItemCheck); 142 160 // 143 161 // storeUsersButton … … 165 183 // dataTabPage 166 184 // 185 this.dataTabPage.Controls.Add(this.noViewAvailableLabel); 186 this.dataTabPage.Controls.Add(this.dataViewHost); 187 this.dataTabPage.Controls.Add(this.saveFileButton); 188 this.dataTabPage.Controls.Add(this.openFileButton); 189 this.dataTabPage.Controls.Add(this.newDataButton); 190 this.dataTabPage.Controls.Add(this.storeDataButton); 191 this.dataTabPage.Controls.Add(this.refreshDataButton); 167 192 this.dataTabPage.Location = new System.Drawing.Point(4, 22); 168 193 this.dataTabPage.Name = "dataTabPage"; 169 194 this.dataTabPage.Padding = new System.Windows.Forms.Padding(3); 170 this.dataTabPage.Size = new System.Drawing.Size(625, 266);195 this.dataTabPage.Size = new System.Drawing.Size(625, 180); 171 196 this.dataTabPage.TabIndex = 1; 172 197 this.dataTabPage.Text = "Platform-Specific Problem Data"; 173 198 this.dataTabPage.UseVisualStyleBackColor = true; 174 199 // 175 // usersListBox 176 // 177 this.usersListBox.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 200 // noViewAvailableLabel 201 // 202 this.noViewAvailableLabel.Anchor = System.Windows.Forms.AnchorStyles.None; 203 this.noViewAvailableLabel.AutoSize = true; 204 this.noViewAvailableLabel.Location = new System.Drawing.Point(265, 84); 205 this.noViewAvailableLabel.Name = "noViewAvailableLabel"; 206 this.noViewAvailableLabel.Size = new System.Drawing.Size(94, 13); 207 this.noViewAvailableLabel.TabIndex = 6; 208 this.noViewAvailableLabel.Text = "No view available."; 209 // 210 // dataViewHost 211 // 212 this.dataViewHost.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 178 213 | System.Windows.Forms.AnchorStyles.Left) 179 214 | System.Windows.Forms.AnchorStyles.Right))); 180 this.usersListBox.FormattingEnabled = true; 181 this.usersListBox.Location = new System.Drawing.Point(6, 36); 182 this.usersListBox.Name = "usersListBox"; 183 this.usersListBox.Size = new System.Drawing.Size(613, 214); 184 this.usersListBox.TabIndex = 3; 215 this.dataViewHost.Caption = "View"; 216 this.dataViewHost.Content = null; 217 this.dataViewHost.Enabled = false; 218 this.dataViewHost.Location = new System.Drawing.Point(6, 36); 219 this.dataViewHost.Name = "dataViewHost"; 220 this.dataViewHost.ReadOnly = false; 221 this.dataViewHost.Size = new System.Drawing.Size(613, 138); 222 this.dataViewHost.TabIndex = 5; 223 this.dataViewHost.ViewsLabelVisible = true; 224 this.dataViewHost.ViewType = null; 225 // 226 // saveFileButton 227 // 228 this.saveFileButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Save; 229 this.saveFileButton.Location = new System.Drawing.Point(126, 6); 230 this.saveFileButton.Name = "saveFileButton"; 231 this.saveFileButton.Size = new System.Drawing.Size(24, 24); 232 this.saveFileButton.TabIndex = 4; 233 this.toolTip.SetToolTip(this.saveFileButton, "Save Problem Data into File"); 234 this.saveFileButton.UseVisualStyleBackColor = true; 235 this.saveFileButton.Click += new System.EventHandler(this.saveFileButton_Click); 236 // 237 // openFileButton 238 // 239 this.openFileButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open; 240 this.openFileButton.Location = new System.Drawing.Point(96, 6); 241 this.openFileButton.Name = "openFileButton"; 242 this.openFileButton.Size = new System.Drawing.Size(24, 24); 243 this.openFileButton.TabIndex = 3; 244 this.toolTip.SetToolTip(this.openFileButton, "Load Problem Data from File"); 245 this.openFileButton.UseVisualStyleBackColor = true; 246 this.openFileButton.Click += new System.EventHandler(this.openFileButton_Click); 247 // 248 // newDataButton 249 // 250 this.newDataButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.NewDocument; 251 this.newDataButton.Location = new System.Drawing.Point(66, 6); 252 this.newDataButton.Name = "newDataButton"; 253 this.newDataButton.Size = new System.Drawing.Size(24, 24); 254 this.newDataButton.TabIndex = 2; 255 this.toolTip.SetToolTip(this.newDataButton, "Create New Problem Data"); 256 this.newDataButton.UseVisualStyleBackColor = true; 257 this.newDataButton.Click += new System.EventHandler(this.newDataButton_Click); 258 // 259 // storeDataButton 260 // 261 this.storeDataButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.PublishToWeb; 262 this.storeDataButton.Location = new System.Drawing.Point(36, 6); 263 this.storeDataButton.Name = "storeDataButton"; 264 this.storeDataButton.Size = new System.Drawing.Size(24, 24); 265 this.storeDataButton.TabIndex = 1; 266 this.toolTip.SetToolTip(this.storeDataButton, "Store Problem Data"); 267 this.storeDataButton.UseVisualStyleBackColor = true; 268 this.storeDataButton.Click += new System.EventHandler(this.storeDataButton_Click); 269 // 270 // refreshDataButton 271 // 272 this.refreshDataButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Refresh; 273 this.refreshDataButton.Location = new System.Drawing.Point(6, 6); 274 this.refreshDataButton.Name = "refreshDataButton"; 275 this.refreshDataButton.Size = new System.Drawing.Size(24, 24); 276 this.refreshDataButton.TabIndex = 0; 277 this.toolTip.SetToolTip(this.refreshDataButton, "Refresh Problem Data"); 278 this.refreshDataButton.UseVisualStyleBackColor = true; 279 this.refreshDataButton.Click += new System.EventHandler(this.refreshDataButton_Click); 280 // 281 // dataTypeNameLabel 282 // 283 this.dataTypeNameLabel.AutoSize = true; 284 this.dataTypeNameLabel.Location = new System.Drawing.Point(6, 22); 285 this.dataTypeNameLabel.Name = "dataTypeNameLabel"; 286 this.dataTypeNameLabel.Size = new System.Drawing.Size(38, 13); 287 this.dataTypeNameLabel.TabIndex = 0; 288 this.dataTypeNameLabel.Text = "&Name:"; 289 // 290 // dataTypeGroupBox 291 // 292 this.dataTypeGroupBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 293 | System.Windows.Forms.AnchorStyles.Right))); 294 this.dataTypeGroupBox.Controls.Add(this.dataTypeTypeNameTextBox); 295 this.dataTypeGroupBox.Controls.Add(this.dataTypeNameTextBox); 296 this.dataTypeGroupBox.Controls.Add(this.dataTypeTypeNameLabel); 297 this.dataTypeGroupBox.Controls.Add(this.dataTypeNameLabel); 298 this.dataTypeGroupBox.Location = new System.Drawing.Point(0, 146); 299 this.dataTypeGroupBox.Name = "dataTypeGroupBox"; 300 this.dataTypeGroupBox.Size = new System.Drawing.Size(633, 77); 301 this.dataTypeGroupBox.TabIndex = 9; 302 this.dataTypeGroupBox.TabStop = false; 303 this.dataTypeGroupBox.Text = "Data Type"; 304 // 305 // dataTypeTypeNameTextBox 306 // 307 this.dataTypeTypeNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 308 | System.Windows.Forms.AnchorStyles.Right))); 309 this.dataTypeTypeNameTextBox.Location = new System.Drawing.Point(90, 45); 310 this.dataTypeTypeNameTextBox.Name = "dataTypeTypeNameTextBox"; 311 this.dataTypeTypeNameTextBox.Size = new System.Drawing.Size(537, 20); 312 this.dataTypeTypeNameTextBox.TabIndex = 3; 313 this.toolTip.SetToolTip(this.dataTypeTypeNameTextBox, "Machine Readable Data Type Name (e.g. Assembly Qualified Name)"); 314 this.dataTypeTypeNameTextBox.TextChanged += new System.EventHandler(this.dataTypeTypeNameTextBox_TextChanged); 315 // 316 // dataTypeNameTextBox 317 // 318 this.dataTypeNameTextBox.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left) 319 | System.Windows.Forms.AnchorStyles.Right))); 320 this.dataTypeNameTextBox.Location = new System.Drawing.Point(90, 19); 321 this.dataTypeNameTextBox.Name = "dataTypeNameTextBox"; 322 this.dataTypeNameTextBox.Size = new System.Drawing.Size(537, 20); 323 this.dataTypeNameTextBox.TabIndex = 1; 324 this.toolTip.SetToolTip(this.dataTypeNameTextBox, "Human Readable Data Type Name"); 325 this.dataTypeNameTextBox.TextChanged += new System.EventHandler(this.dataTypeNameTextBox_TextChanged); 326 // 327 // dataTypeTypeNameLabel 328 // 329 this.dataTypeTypeNameLabel.AutoSize = true; 330 this.dataTypeTypeNameLabel.Location = new System.Drawing.Point(6, 48); 331 this.dataTypeTypeNameLabel.Name = "dataTypeTypeNameLabel"; 332 this.dataTypeTypeNameLabel.Size = new System.Drawing.Size(65, 13); 333 this.dataTypeTypeNameLabel.TabIndex = 2; 334 this.dataTypeTypeNameLabel.Text = "&Type Name:"; 335 // 336 // openFileDialog 337 // 338 this.openFileDialog.FileName = "data"; 339 this.openFileDialog.Filter = "All Files (*.*)|*.*"; 340 this.openFileDialog.Title = "Load Problem Data"; 341 // 342 // saveFileDialog 343 // 344 this.saveFileDialog.FileName = "data"; 345 this.saveFileDialog.Filter = "All Files (*.*)|*.*"; 346 this.saveFileDialog.Title = "Save Problem Data"; 185 347 // 186 348 // ProblemView 187 349 // 188 350 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 351 this.Controls.Add(this.dataTypeGroupBox); 189 352 this.Controls.Add(this.tabControl); 190 353 this.Controls.Add(this.platformComboBox); … … 199 362 this.Controls.SetChildIndex(this.platformComboBox, 0); 200 363 this.Controls.SetChildIndex(this.tabControl, 0); 364 this.Controls.SetChildIndex(this.dataTypeGroupBox, 0); 201 365 this.Controls.SetChildIndex(this.storeButton, 0); 202 366 this.Controls.SetChildIndex(this.nameTextBox, 0); … … 206 370 this.tabControl.ResumeLayout(false); 207 371 this.usersTabPage.ResumeLayout(false); 372 this.dataTabPage.ResumeLayout(false); 373 this.dataTabPage.PerformLayout(); 374 this.dataTypeGroupBox.ResumeLayout(false); 375 this.dataTypeGroupBox.PerformLayout(); 208 376 this.ResumeLayout(false); 209 377 this.PerformLayout(); … … 223 391 private System.Windows.Forms.TabPage dataTabPage; 224 392 private System.Windows.Forms.CheckedListBox usersListBox; 393 private System.Windows.Forms.Label dataTypeNameLabel; 394 private System.Windows.Forms.GroupBox dataTypeGroupBox; 395 private System.Windows.Forms.TextBox dataTypeTypeNameTextBox; 396 private System.Windows.Forms.TextBox dataTypeNameTextBox; 397 private System.Windows.Forms.Label dataTypeTypeNameLabel; 398 private System.Windows.Forms.Button storeDataButton; 399 private System.Windows.Forms.Button refreshDataButton; 400 private System.Windows.Forms.Button openFileButton; 401 private System.Windows.Forms.Button newDataButton; 402 private System.Windows.Forms.Button saveFileButton; 403 private System.Windows.Forms.OpenFileDialog openFileDialog; 404 private System.Windows.Forms.SaveFileDialog saveFileDialog; 405 private MainForm.WindowsForms.ViewHost dataViewHost; 406 private System.Windows.Forms.Label noViewAvailableLabel; 225 407 226 408 } -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/Administration/Views/ProblemView.cs
r5550 r5587 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.IO; 24 25 using System.Linq; 25 26 using System.Windows.Forms; 26 27 using HeuristicLab.Clients.OKB.Authentication; 28 using HeuristicLab.Common; 29 using HeuristicLab.Core.Views; 27 30 using HeuristicLab.MainForm; 28 31 using HeuristicLab.MainForm.WindowsForms; 32 using HeuristicLab.Optimization; 33 using HeuristicLab.Persistence.Default.Xml; 34 using HeuristicLab.PluginInfrastructure; 29 35 30 36 namespace HeuristicLab.Clients.OKB.Administration { … … 34 40 private List<Platform> platformComboBoxValues; 35 41 private List<ProblemClass> problemClassComboBoxValues; 42 private TypeSelectorDialog typeSelectorDialog; 43 private byte[] data; 36 44 37 45 public new Problem Content { … … 44 52 } 45 53 46 protected override void OnInitialized(System.EventArgs e) { 47 base.OnInitialized(e); 54 protected override void Dispose(bool disposing) { 55 if (disposing) { 56 if (components != null) components.Dispose(); 57 if (typeSelectorDialog != null) typeSelectorDialog.Dispose(); 58 } 59 base.Dispose(disposing); 60 } 61 62 protected override void OnContentChanged() { 63 base.OnContentChanged(); 64 65 platformComboBox.SelectedValueChanged -= new EventHandler(platformComboBox_SelectedValueChanged); 48 66 platformComboBoxValues = AdministrationClient.Instance.Platforms.ToList(); 49 67 platformComboBox.DataSource = platformComboBoxValues; 68 platformComboBox.SelectedValueChanged += new EventHandler(platformComboBox_SelectedValueChanged); 69 70 problemClassComboBox.SelectedValueChanged -= new EventHandler(problemClassComboBox_SelectedValueChanged); 50 71 problemClassComboBoxValues = AdministrationClient.Instance.ProblemClasses.ToList(); 51 72 problemClassComboBox.DataSource = problemClassComboBoxValues; 52 } 53 54 protected override void OnContentChanged() { 55 base.OnContentChanged(); 73 problemClassComboBox.SelectedValueChanged += new EventHandler(problemClassComboBox_SelectedValueChanged); 74 75 usersListBox.DataSource = null; 76 data = null; 77 dataViewHost.Content = null; 56 78 if (Content == null) { 57 79 platformComboBox.SelectedIndex = -1; 58 80 problemClassComboBox.SelectedIndex = -1; 81 dataTypeNameTextBox.Text = string.Empty; 82 dataTypeTypeNameTextBox.Text = string.Empty; 59 83 } else { 60 84 platformComboBox.SelectedItem = platformComboBoxValues.FirstOrDefault(p => p.Id == Content.PlatformId); 61 85 problemClassComboBox.SelectedItem = problemClassComboBoxValues.FirstOrDefault(a => a.Id == Content.ProblemClassId); 62 } 63 usersListBox.DataSource = null; 86 dataTypeNameTextBox.Text = Content.DataTypeName; 87 dataTypeTypeNameTextBox.Text = Content.DataTypeTypeName; 88 } 64 89 } 65 90 … … 68 93 platformComboBox.Enabled = (Content != null) && !ReadOnly; 69 94 problemClassComboBox.Enabled = (Content != null) && !ReadOnly; 70 refreshUsersButton.Enabled = Content != null; 95 dataTypeGroupBox.Enabled = (Content != null) && !ReadOnly; 96 refreshUsersButton.Enabled = (Content != null) && (Content.Id != 0); 71 97 storeUsersButton.Enabled = (usersListBox.DataSource != null) && !ReadOnly; 72 98 usersListBox.Enabled = (usersListBox.DataSource != null) && !ReadOnly; 73 } 74 99 refreshDataButton.Enabled = (Content != null) && (Content.Id != 0); 100 storeDataButton.Enabled = ((data != null) || (dataViewHost.Content != null)) && !ReadOnly; 101 openFileButton.Enabled = (Content != null) && (Content.Id != 0); 102 saveFileButton.Enabled = (data != null) || (dataViewHost.Content != null); 103 noViewAvailableLabel.Visible = dataViewHost.Content == null; 104 105 bool isHL33Platform = platformComboBox.Text == "HeuristicLab 3.3"; 106 dataTypeNameTextBox.ReadOnly = isHL33Platform; 107 dataTypeTypeNameTextBox.ReadOnly = isHL33Platform; 108 newDataButton.Enabled = isHL33Platform && (Content.Id != 0) && !ReadOnly; 109 } 110 111 #region Content Events 75 112 protected override void OnContentPropertyChanged(string propertyName) { 76 113 switch (propertyName) { 114 case "Id": 115 SetEnabledStateOfControls(); 116 break; 77 117 case "PlatformId": 78 118 platformComboBox.SelectedItem = platformComboBoxValues.FirstOrDefault(p => p.Id == Content.PlatformId); 119 SetEnabledStateOfControls(); 79 120 break; 80 121 case "ProblemClassId": 81 122 problemClassComboBox.SelectedItem = problemClassComboBoxValues.FirstOrDefault(a => a.Id == Content.ProblemClassId); 82 123 break; 83 } 84 } 85 124 case "DataTypeName": 125 dataTypeNameTextBox.Text = Content.DataTypeName; 126 break; 127 case "DataTypeTypeName": 128 dataTypeTypeNameTextBox.Text = Content.DataTypeTypeName; 129 break; 130 } 131 } 132 #endregion 133 134 #region Control Events 86 135 private void platformComboBox_SelectedValueChanged(object sender, System.EventArgs e) { 87 136 if (Content != null) { … … 97 146 } 98 147 148 private void dataTypeNameTextBox_TextChanged(object sender, EventArgs e) { 149 if (dataTypeNameTextBox.Text != Content.DataTypeName) 150 Content.DataTypeName = dataTypeNameTextBox.Text; 151 } 152 private void dataTypeTypeNameTextBox_TextChanged(object sender, EventArgs e) { 153 if (dataTypeTypeNameTextBox.Text != Content.DataTypeTypeName) 154 Content.DataTypeTypeName = dataTypeTypeNameTextBox.Text; 155 } 156 99 157 private void refreshUsersButton_Click(object sender, System.EventArgs e) { 100 List<Guid> ids = AdministrationClient.GetProblemUsers(Content.Id); 101 if (ids != null) { 102 List<User> users = AuthenticationClient.Instance.Users.ToList(); 103 usersListBox.DataSource = users; 104 usersListBox.DisplayMember = "Name"; 105 usersListBox.SelectedItems.Clear(); 106 foreach (Guid id in ids) 107 usersListBox.SelectedItems.Add(users.First(u => u.Id == id)); 108 usersListBox.Enabled = !ReadOnly; 158 try { 159 List<Guid> ids = AdministrationClient.GetProblemUsers(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 } 175 private void storeUsersButton_Click(object sender, System.EventArgs e) { 176 try { 177 AdministrationClient.UpdateProblemUsers(Content.Id, usersListBox.SelectedItems.Cast<User>().Select(u => u.Id).ToList()); 109 178 storeUsersButton.Enabled = false; 110 179 } 111 } 112 private void storeUsersButton_Click(object sender, System.EventArgs e) { 113 AdministrationClient.UpdateProblemUsers(Content.Id, usersListBox.SelectedItems.Cast<User>().Select(u => u.Id).ToList()); 114 storeUsersButton.Enabled = false; 115 } 116 private void usersListBox_SelectedIndexChanged(object sender, EventArgs e) { 180 catch (Exception ex) { 181 ErrorHandling.ShowErrorDialog(this, "Store authorized users and groups failed.", ex); 182 } 183 } 184 private void usersListBox_ItemCheck(object sender, ItemCheckEventArgs e) { 117 185 storeUsersButton.Enabled = !ReadOnly; 118 186 } 187 188 private void refreshDataButton_Click(object sender, EventArgs e) { 189 CallAsync( 190 () => { 191 data = null; 192 dataViewHost.Content = null; 193 data = AdministrationClient.GetProblemData(Content.Id); 194 if (data != null) { 195 using (MemoryStream stream = new MemoryStream(data)) { 196 try { 197 dataViewHost.Content = XmlParser.Deserialize<IContent>(stream); 198 } 199 catch (Exception) { } 200 stream.Close(); 201 } 202 } 203 }, 204 "Refresh problem data failed.", 205 () => SetEnabledStateOfControls() 206 ); 207 } 208 private void storeDataButton_Click(object sender, EventArgs e) { 209 CallAsync( 210 () => { 211 if (dataViewHost.Content != null) { 212 using (MemoryStream stream = new MemoryStream()) { 213 XmlGenerator.Serialize(dataViewHost.Content, stream); 214 stream.Close(); 215 data = stream.ToArray(); 216 } 217 } 218 AdministrationClient.UpdateProblemData(Content.Id, data); 219 }, 220 "Store problem data failed.", 221 null 222 ); 223 } 224 private void newDataButton_Click(object sender, EventArgs e) { 225 if (typeSelectorDialog == null) { 226 typeSelectorDialog = new TypeSelectorDialog(); 227 typeSelectorDialog.Caption = "Select Problem"; 228 typeSelectorDialog.TypeSelector.Caption = "Available Problems"; 229 typeSelectorDialog.TypeSelector.Configure(typeof(IProblem), false, true); 230 } 231 if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) { 232 try { 233 Content.DataTypeName = typeSelectorDialog.TypeSelector.SelectedType.Name; 234 Content.DataTypeTypeName = typeSelectorDialog.TypeSelector.SelectedType.AssemblyQualifiedName; 235 data = null; 236 dataViewHost.Content = (IContent)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(); 237 } 238 catch (Exception ex) { 239 ErrorHandling.ShowErrorDialog(this, "Create new problem data failed.", ex); 240 } 241 SetEnabledStateOfControls(); 242 } 243 } 244 private void openFileButton_Click(object sender, EventArgs e) { 245 if (openFileDialog.ShowDialog(this) == DialogResult.OK) { 246 CallAsync( 247 () => { 248 IContent problem = null; 249 try { 250 problem = XmlParser.Deserialize<IContent>(openFileDialog.FileName); 251 } 252 catch (Exception) { } 253 254 if (problem != null) { 255 Content.DataTypeName = problem.GetType().Name; 256 Content.DataTypeTypeName = problem.GetType().AssemblyQualifiedName; 257 data = null; 258 } else { 259 using (FileStream stream = new FileStream(openFileDialog.FileName, FileMode.Open, FileAccess.Read)) { 260 data = new byte[stream.Length]; 261 stream.Read(data, 0, data.Length); 262 stream.Close(); 263 } 264 } 265 dataViewHost.Content = problem; 266 }, 267 "Save problem data into file failed.", 268 () => SetEnabledStateOfControls() 269 ); 270 } 271 } 272 private void saveFileButton_Click(object sender, EventArgs e) { 273 if (saveFileDialog.ShowDialog(this) == DialogResult.OK) { 274 CallAsync( 275 () => { 276 if (dataViewHost.Content != null) { 277 XmlGenerator.Serialize(dataViewHost.Content, saveFileDialog.FileName); 278 } else { 279 using (FileStream stream = new FileStream(saveFileDialog.FileName, FileMode.Create, FileAccess.Write)) { 280 stream.Write(data, 0, data.Length); 281 stream.Close(); 282 } 283 } 284 }, 285 "Save problem data into file failed.", 286 null 287 ); 288 } 289 } 290 #endregion 291 292 #region Helpers 293 private void CallAsync(Action call, string errorMessage, Action continueWith) { 294 BeginAsyncCall(); 295 call.BeginInvoke(delegate(IAsyncResult result) { 296 Exception exception = null; 297 try { 298 call.EndInvoke(result); 299 } 300 catch (Exception ex) { 301 exception = ex; 302 } 303 EndAsyncCall(errorMessage, exception, continueWith); 304 }, null); 305 } 306 private void BeginAsyncCall() { 307 if (InvokeRequired) 308 Invoke(new Action(BeginAsyncCall)); 309 else { 310 Cursor = Cursors.AppStarting; 311 Enabled = false; 312 } 313 } 314 private void EndAsyncCall(string errorMessage, Exception exception, Action continueWith) { 315 if (InvokeRequired) 316 Invoke(new Action<string, Exception, Action>(EndAsyncCall), errorMessage, exception, continueWith); 317 else { 318 Cursor = Cursors.Default; 319 Enabled = true; 320 if (exception != null) ErrorHandling.ShowErrorDialog(this, errorMessage, exception); 321 if (continueWith != null) continueWith(); 322 } 323 } 324 #endregion 119 325 } 120 326 } -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/HeuristicLab.Clients.OKB-3.3.csproj
r5550 r5587 196 196 <None Include="HeuristicLabClientsOKBPlugin.cs.frame" /> 197 197 </ItemGroup> 198 <ItemGroup>199 <EmbeddedResource Include="Administration\Views\AlgorithmView.resx">200 <DependentUpon>AlgorithmView.cs</DependentUpon>201 </EmbeddedResource>202 </ItemGroup>203 198 <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> 204 199 <PropertyGroup> -
branches/OKB (trunk integration)/HeuristicLab.Services.OKB.DataAccess/3.3/OKB.dbml
r5534 r5587 99 99 <Column Name="Id" Type="System.Int64" DbType="BigInt NOT NULL IDENTITY" IsPrimaryKey="true" IsDbGenerated="true" CanBeNull="false" /> 100 100 <Column Name="Data" Type="System.Data.Linq.Binary" DbType="VarBinary(MAX) NOT NULL" CanBeNull="false" UpdateCheck="Never" /> 101 <Column Name="Hash" Type="System. Data.Linq.Binary" DbType="VarBinary(20)" IsDbGenerated="true" CanBeNull="true" UpdateCheck="Never" />101 <Column Name="Hash" Type="System.Byte[]" DbType="VarBinary(20) NOT NULL" CanBeNull="false" UpdateCheck="Never" /> 102 102 <Association Name="BinaryData_Algorithm" Member="Algorithms" ThisKey="Id" OtherKey="BinaryDataId" Type="Algorithm" /> 103 103 <Association Name="BinaryData_Problem" Member="Problems" ThisKey="Id" OtherKey="BinaryDataId" Type="Problem" /> -
branches/OKB (trunk integration)/HeuristicLab.Services.OKB.DataAccess/3.3/OKB.designer.cs
r5534 r5587 2188 2188 private System.Data.Linq.Binary _Data; 2189 2189 2190 private System.Data.Linq.Binary_Hash;2190 private byte[] _Hash; 2191 2191 2192 2192 private EntitySet<Algorithm> _Algorithms; … … 2204 2204 partial void OnDataChanging(System.Data.Linq.Binary value); 2205 2205 partial void OnDataChanged(); 2206 partial void OnHashChanging( System.Data.Linq.Binaryvalue);2206 partial void OnHashChanging(byte[] value); 2207 2207 partial void OnHashChanged(); 2208 2208 #endregion … … 2256 2256 } 2257 2257 2258 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Hash", AutoSync=AutoSync.Always, DbType="VarBinary(20)", IsDbGenerated=true, UpdateCheck=UpdateCheck.Never)]2259 public System.Data.Linq.BinaryHash2258 [global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_Hash", DbType="VarBinary(20) NOT NULL", CanBeNull=false, UpdateCheck=UpdateCheck.Never)] 2259 public byte[] Hash 2260 2260 { 2261 2261 get -
branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/Administration/Convert.cs
r5534 r5587 126 126 var entity = okb.BinaryDatas.Where(x => x.Hash.Equals(hash)).FirstOrDefault(); 127 127 if (entity == null) 128 entity = new DA.BinaryData() { Id = 0, Data = data };128 entity = new DA.BinaryData() { Id = 0, Data = data, Hash = hash }; 129 129 return entity; 130 130 } -
branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/RunCreation/Convert.cs
r5478 r5587 122 122 var entity = okb.BinaryDatas.Where(x => x.Hash.Equals(hash)).FirstOrDefault(); 123 123 if (entity == null) 124 entity = new DA.BinaryData() { Id = 0, Data = data };124 entity = new DA.BinaryData() { Id = 0, Data = data, Hash = hash }; 125 125 return entity; 126 126 }
Note: See TracChangeset
for help on using the changeset viewer.