- Timestamp:
- 04/19/12 20:39:44 (13 years ago)
- Location:
- branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation
- Files:
-
- 2 deleted
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/CreateFromExperimentMenuItem.cs
r7592 r7742 40 40 protected override void OnActiveViewChanged(object sender, EventArgs e) { 41 41 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 42 ToolStripItem.Enabled = (activeView != null) && (activeView.Content != null) && ( activeView.Content is Experiment) && !activeView.Locked && OKBRoles.CheckUserPermissions();42 ToolStripItem.Enabled = (activeView != null) && (activeView.Content != null) && ((activeView.Content is Experiment) || (activeView.Content is RunCollection) || (activeView.Content is IOptimizer)) && !activeView.Locked && OKBRoles.CheckUserPermissions(); 43 43 } 44 44 45 45 public override void Execute() { 46 46 IContentView activeView = MainFormManager.MainForm.ActiveView as IContentView; 47 Experiment experiment = activeView.Content as Experiment; 48 if (experiment != null) { 49 MainFormManager.MainForm.ShowContent(experiment, typeof(OKBExperimentUploadView)); 50 } 47 MainFormManager.MainForm.ShowContent(activeView.Content, typeof(OKBExperimentUploadView)); 51 48 } 52 49 } -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBExperimentUploadView.Designer.cs
r7580 r7742 24 24 /// </summary> 25 25 private void InitializeComponent() { 26 this. tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();26 this.components = new System.ComponentModel.Container(); 27 27 this.btnUpload = new System.Windows.Forms.Button(); 28 this.dataGridView = new System.Windows.Forms.DataGridView(); 29 this.RunNameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); 30 this.AlgorithmNameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); 31 this.AlgorithmTypeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); 32 this.OKBAlgorithmColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); 33 this.ProblemNameColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); 34 this.ProblemTypeColumn = new System.Windows.Forms.DataGridViewTextBoxColumn(); 35 this.OKBProblemColumn = new System.Windows.Forms.DataGridViewComboBoxColumn(); 36 this.contextMenu = new System.Windows.Forms.ContextMenuStrip(this.components); 37 this.setColumnToThisValueToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); 38 ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).BeginInit(); 39 this.contextMenu.SuspendLayout(); 28 40 this.SuspendLayout(); 29 //30 // tableLayoutPanel31 //32 this.tableLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)33 | System.Windows.Forms.AnchorStyles.Left)34 | System.Windows.Forms.AnchorStyles.Right)));35 this.tableLayoutPanel.AutoScroll = true;36 this.tableLayoutPanel.BackColor = System.Drawing.SystemColors.Control;37 this.tableLayoutPanel.ColumnCount = 1;38 this.tableLayoutPanel.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F));39 this.tableLayoutPanel.Location = new System.Drawing.Point(3, 3);40 this.tableLayoutPanel.Name = "tableLayoutPanel";41 this.tableLayoutPanel.RowCount = 1;42 this.tableLayoutPanel.RowStyles.Add(new System.Windows.Forms.RowStyle());43 this.tableLayoutPanel.Size = new System.Drawing.Size(460, 190);44 this.tableLayoutPanel.TabIndex = 0;45 41 // 46 42 // btnUpload … … 55 51 this.btnUpload.Click += new System.EventHandler(this.btnUpload_Click); 56 52 // 53 // dataGridView 54 // 55 this.dataGridView.AllowUserToAddRows = false; 56 this.dataGridView.AllowUserToDeleteRows = false; 57 this.dataGridView.AllowUserToOrderColumns = true; 58 this.dataGridView.AllowUserToResizeRows = false; 59 this.dataGridView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 60 | System.Windows.Forms.AnchorStyles.Left) 61 | System.Windows.Forms.AnchorStyles.Right))); 62 this.dataGridView.AutoSizeColumnsMode = System.Windows.Forms.DataGridViewAutoSizeColumnsMode.Fill; 63 this.dataGridView.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize; 64 this.dataGridView.Columns.AddRange(new System.Windows.Forms.DataGridViewColumn[] { 65 this.RunNameColumn, 66 this.AlgorithmNameColumn, 67 this.AlgorithmTypeColumn, 68 this.OKBAlgorithmColumn, 69 this.ProblemNameColumn, 70 this.ProblemTypeColumn, 71 this.OKBProblemColumn}); 72 this.dataGridView.Location = new System.Drawing.Point(3, 3); 73 this.dataGridView.Name = "dataGridView"; 74 this.dataGridView.Size = new System.Drawing.Size(460, 191); 75 this.dataGridView.TabIndex = 2; 76 this.dataGridView.CellMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView_CellMouseClick); 77 // 78 // RunNameColumn 79 // 80 this.RunNameColumn.HeaderText = "Run Name"; 81 this.RunNameColumn.Name = "RunNameColumn"; 82 this.RunNameColumn.ReadOnly = true; 83 // 84 // AlgorithmNameColumn 85 // 86 this.AlgorithmNameColumn.HeaderText = "Algorithm Name"; 87 this.AlgorithmNameColumn.Name = "AlgorithmNameColumn"; 88 this.AlgorithmNameColumn.ReadOnly = true; 89 // 90 // AlgorithmTypeColumn 91 // 92 this.AlgorithmTypeColumn.HeaderText = "Algorithm Type"; 93 this.AlgorithmTypeColumn.Name = "AlgorithmTypeColumn"; 94 this.AlgorithmTypeColumn.ReadOnly = true; 95 // 96 // OKBAlgorithmColumn 97 // 98 this.OKBAlgorithmColumn.HeaderText = "OKB Algorithm"; 99 this.OKBAlgorithmColumn.Name = "OKBAlgorithmColumn"; 100 // 101 // ProblemNameColumn 102 // 103 this.ProblemNameColumn.HeaderText = "Problem Name"; 104 this.ProblemNameColumn.Name = "ProblemNameColumn"; 105 this.ProblemNameColumn.ReadOnly = true; 106 this.ProblemNameColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; 107 this.ProblemNameColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; 108 // 109 // ProblemTypeColumn 110 // 111 this.ProblemTypeColumn.HeaderText = "Problem Type"; 112 this.ProblemTypeColumn.Name = "ProblemTypeColumn"; 113 this.ProblemTypeColumn.ReadOnly = true; 114 this.ProblemTypeColumn.Resizable = System.Windows.Forms.DataGridViewTriState.True; 115 this.ProblemTypeColumn.SortMode = System.Windows.Forms.DataGridViewColumnSortMode.NotSortable; 116 // 117 // OKBProblemColumn 118 // 119 this.OKBProblemColumn.HeaderText = "OKB Problem"; 120 this.OKBProblemColumn.Name = "OKBProblemColumn"; 121 // 122 // contextMenu 123 // 124 this.contextMenu.Items.AddRange(new System.Windows.Forms.ToolStripItem[] { 125 this.setColumnToThisValueToolStripMenuItem}); 126 this.contextMenu.Name = "contextMenu"; 127 this.contextMenu.Size = new System.Drawing.Size(202, 26); 128 // 129 // setColumnToThisValueToolStripMenuItem 130 // 131 this.setColumnToThisValueToolStripMenuItem.Name = "setColumnToThisValueToolStripMenuItem"; 132 this.setColumnToThisValueToolStripMenuItem.Size = new System.Drawing.Size(201, 22); 133 this.setColumnToThisValueToolStripMenuItem.Text = "Set column to this value"; 134 this.setColumnToThisValueToolStripMenuItem.Click += new System.EventHandler(this.setColumnToThisValueToolStripMenuItem_Click); 135 // 57 136 // OKBExperimentUploadView 58 137 // 59 138 this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); 60 139 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 140 this.Controls.Add(this.dataGridView); 61 141 this.Controls.Add(this.btnUpload); 62 this.Controls.Add(this.tableLayoutPanel);63 142 this.Name = "OKBExperimentUploadView"; 64 143 this.Size = new System.Drawing.Size(466, 229); 144 ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit(); 145 this.contextMenu.ResumeLayout(false); 65 146 this.ResumeLayout(false); 66 147 … … 69 150 #endregion 70 151 71 private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;72 152 private System.Windows.Forms.Button btnUpload; 153 private System.Windows.Forms.DataGridView dataGridView; 154 private System.Windows.Forms.DataGridViewTextBoxColumn RunNameColumn; 155 private System.Windows.Forms.DataGridViewTextBoxColumn AlgorithmNameColumn; 156 private System.Windows.Forms.DataGridViewTextBoxColumn AlgorithmTypeColumn; 157 private System.Windows.Forms.DataGridViewComboBoxColumn OKBAlgorithmColumn; 158 private System.Windows.Forms.DataGridViewTextBoxColumn ProblemNameColumn; 159 private System.Windows.Forms.DataGridViewTextBoxColumn ProblemTypeColumn; 160 private System.Windows.Forms.DataGridViewComboBoxColumn OKBProblemColumn; 161 private System.Windows.Forms.ContextMenuStrip contextMenu; 162 private System.Windows.Forms.ToolStripMenuItem setColumnToThisValueToolStripMenuItem; 73 163 } 74 164 } -
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBExperimentUploadView.cs
r7590 r7742 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.Drawing; 24 25 using System.Linq; 25 26 using System.Threading.Tasks; 26 27 using System.Windows.Forms; 27 28 using HeuristicLab.Clients.Access; 29 using HeuristicLab.Core; 28 30 using HeuristicLab.Core.Views; 29 31 using HeuristicLab.MainForm; … … 34 36 [View("OKBExperimentUpload View")] 35 37 [Content(typeof(Experiment), false)] 38 [Content(typeof(RunCollection), false)] 39 [Content(typeof(IOptimizer), false)] 36 40 public partial class OKBExperimentUploadView : ItemView { 37 public new Experiment Content { 38 get { return (Experiment)base.Content; } 39 set { base.Content = value; } 40 } 41 42 private ProgressView progressView; 43 List<OKBRunConfigSelectionView> runConfigViews = new List<OKBRunConfigSelectionView>(); 41 public new IItem Content { 42 get { return base.Content; } 43 set { 44 base.Content = value; 45 } 46 } 47 48 private const string algorithmTypeParameterName = "Algorithm Type"; 49 private const string problemTypeParameterName = "Problem Type"; 50 private const string algorithmNameParameterName = "Algorithm Name"; 51 private const string problemNameParameterName = "Problem Name"; 52 private const int algorithmColumnIndex = 3; 53 private const int problemColumnIndex = 6; 54 55 private List<IRun> runs = new List<IRun>(); 44 56 private List<Problem> problems = new List<Problem>(); 45 57 private List<Algorithm> algorithms = new List<Algorithm>(); 58 Algorithm selectedAlgorithm = null; 59 Problem selectedProblem = null; 60 private ProgressView progressView; 46 61 47 62 public OKBExperimentUploadView() { 48 63 InitializeComponent(); 49 tableLayoutPanel.RowCount = 0;50 64 } 51 65 … … 55 69 ClearRuns(); 56 70 } else { 71 if (Content is Experiment) { 72 runs.AddRange((Content as Experiment).Runs); 73 } else if (Content is RunCollection) { 74 runs.AddRange((Content as RunCollection)); 75 } else if (Content is IOptimizer) { 76 runs.AddRange((Content as IOptimizer).Runs); 77 } 78 57 79 DisplayRuns(); 58 80 } … … 84 106 85 107 private void CreateUI() { 86 problems.AddRange(RunCreationClient.Instance.Problems); 87 algorithms.AddRange(RunCreationClient.Instance.Algorithms); 88 89 foreach (var run in Content.Runs) { 90 OKBRunConfigSelectionView orcsv = new OKBRunConfigSelectionView(run, algorithms, problems); 91 orcsv.Anchor = AnchorStyles.Left | AnchorStyles.Right | AnchorStyles.Top; 92 runConfigViews.Add(orcsv); 93 tableLayoutPanel.Controls.Add(orcsv); 108 if (problems.Count == 0) 109 problems.AddRange(RunCreationClient.Instance.Problems); 110 if (algorithms.Count == 0) 111 algorithms.AddRange(RunCreationClient.Instance.Algorithms); 112 113 IItem algorithmType; 114 IItem problemType; 115 IItem algorithmName; 116 IItem problemName; 117 118 DataGridViewComboBoxColumn cmbAlgorithm = dataGridView.Columns[algorithmColumnIndex] as DataGridViewComboBoxColumn; 119 cmbAlgorithm.DataSource = algorithms; 120 cmbAlgorithm.DisplayMember = "Name"; 121 122 DataGridViewComboBoxColumn cmbProblem = dataGridView.Columns[problemColumnIndex] as DataGridViewComboBoxColumn; 123 cmbProblem.DataSource = problems; 124 cmbProblem.DisplayMember = "Name"; 125 126 foreach (IRun run in runs) { 127 int idx = dataGridView.Rows.Add(run.Name); 128 DataGridViewRow curRow = dataGridView.Rows[idx]; 129 curRow.Tag = run; 130 131 if (run.Parameters.TryGetValue(algorithmTypeParameterName, out algorithmType)) { 132 HeuristicLab.Data.StringValue algStr = algorithmType as HeuristicLab.Data.StringValue; 133 if (algStr != null) { 134 curRow.Cells[1].Value = algStr; 135 } 136 } 137 138 if (run.Parameters.TryGetValue(algorithmNameParameterName, out algorithmName)) { 139 HeuristicLab.Data.StringValue algStr = algorithmName as HeuristicLab.Data.StringValue; 140 if (algStr != null) { 141 curRow.Cells[2].Value = algStr; 142 } 143 } 144 145 if (run.Parameters.TryGetValue(problemTypeParameterName, out problemType)) { 146 HeuristicLab.Data.StringValue prbStr = problemType as HeuristicLab.Data.StringValue; 147 if (prbStr != null) { 148 curRow.Cells[4].Value = prbStr; 149 } 150 } 151 152 if (run.Parameters.TryGetValue(problemNameParameterName, out problemName)) { 153 HeuristicLab.Data.StringValue prbStr = problemName as HeuristicLab.Data.StringValue; 154 if (prbStr != null) { 155 curRow.Cells[5].Value = prbStr; 156 } 157 } 94 158 } 95 159 } 96 160 97 161 private void ClearRuns() { 98 foreach (var runConfigView in runConfigViews) { 99 runConfigView.Hide(); 100 tableLayoutPanel.Controls.Remove(runConfigView); 101 runConfigView.Dispose(); 102 } 103 runConfigViews.Clear(); 162 dataGridView.Rows.Clear(); 163 runs.Clear(); 104 164 } 105 165 … … 137 197 prog.Status = "Uploading runs to OKB..."; 138 198 prog.ProgressValue = 0; 139 double count = runConfigViews.Count(x => x.UploadToOKB());199 double count = dataGridView.Rows.Count; 140 200 int i = 0; 141 201 142 202 SetProgressView(prog); 143 foreach (var runConfigView in runConfigViews) { 144 if (runConfigView.UploadToOKB()) { 145 OKBRun run = new OKBRun(runConfigView.GetSelectedAlgorithm().Id, runConfigView.GetSelectedProblem().Id, runConfigView.ExperimentRun, UserInformation.Instance.User.Id); 146 run.Store(); 147 i++; 148 prog.ProgressValue = ((double)i) / count; 149 } 203 foreach (DataGridViewRow row in dataGridView.Rows) { 204 selectedAlgorithm = algorithms.Where(x => x.Name == row.Cells[algorithmColumnIndex].Value.ToString()).FirstOrDefault(); 205 selectedProblem = problems.Where(x => x.Name == row.Cells[problemColumnIndex].Value.ToString()).FirstOrDefault(); 206 if (selectedAlgorithm == null || selectedProblem == null) { 207 throw new ArgumentException("Can't retrieve the algorithm/problem to upload"); 208 } 209 210 OKBRun run = new OKBRun(selectedAlgorithm.Id, selectedProblem.Id, row.Tag as IRun, UserInformation.Instance.User.Id); 211 run.Store(); 212 i++; 213 prog.ProgressValue = ((double)i) / count; 150 214 } 151 215 FinishProgressView(); … … 175 239 } 176 240 } 241 242 private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { 243 if (e.Button == System.Windows.Forms.MouseButtons.Right && dataGridView[e.ColumnIndex, e.RowIndex].Value != null) { 244 string curVal = dataGridView[e.ColumnIndex, e.RowIndex].Value.ToString(); 245 selectedAlgorithm = algorithms.Where(x => x.Name == curVal).FirstOrDefault(); 246 selectedProblem = problems.Where(x => x.Name == curVal).FirstOrDefault(); 247 248 if (selectedAlgorithm != null || selectedProblem != null) { 249 Point pos = this.PointToClient(Cursor.Position); 250 contextMenu.Show(this, pos); 251 } 252 } 253 } 254 255 private void setColumnToThisValueToolStripMenuItem_Click(object sender, EventArgs e) { 256 if (selectedAlgorithm != null) { 257 for (int i = 0; i < dataGridView.Rows.Count; i++) { 258 var row = dataGridView.Rows[i]; 259 row.Cells[algorithmColumnIndex].Value = selectedAlgorithm.Name; 260 } 261 } else if (selectedProblem != null) { 262 for (int i = 0; i < dataGridView.Rows.Count; i++) { 263 var row = dataGridView.Rows[i]; 264 row.Cells[problemColumnIndex].Value = selectedProblem.Name; 265 } 266 } 267 selectedAlgorithm = null; 268 selectedProblem = null; 269 } 177 270 } 178 271 }
Note: See TracChangeset
for help on using the changeset viewer.