Free cookie consent management tool by TermsFeed Policy Generator

Changeset 7742


Ignore:
Timestamp:
04/19/12 20:39:44 (13 years ago)
Author:
ascheibe
Message:

#1174 worked on experiment upload view

Location:
branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3
Files:
2 deleted
4 edited

Legend:

Unmodified
Added
Removed
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/HeuristicLab.Clients.OKB-3.3.csproj

    r7633 r7742  
    360360      <DependentUpon>OKBProblemView.cs</DependentUpon>
    361361    </Compile>
    362     <Compile Include="RunCreation\Views\OKBRunConfigSelectionView.cs">
    363       <SubType>UserControl</SubType>
    364     </Compile>
    365     <Compile Include="RunCreation\Views\OKBRunConfigSelectionView.Designer.cs">
    366       <DependentUpon>OKBRunConfigSelectionView.cs</DependentUpon>
    367     </Compile>
    368362    <Compile Include="RunCreation\Views\OKBRunView.cs">
    369363      <SubType>UserControl</SubType>
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/CreateFromExperimentMenuItem.cs

    r7592 r7742  
    4040    protected override void OnActiveViewChanged(object sender, EventArgs e) {
    4141      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();
    4343    }
    4444
    4545    public override void Execute() {
    4646      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));
    5148    }
    5249  }
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBExperimentUploadView.Designer.cs

    r7580 r7742  
    2424    /// </summary>
    2525    private void InitializeComponent() {
    26       this.tableLayoutPanel = new System.Windows.Forms.TableLayoutPanel();
     26      this.components = new System.ComponentModel.Container();
    2727      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();
    2840      this.SuspendLayout();
    29       //
    30       // tableLayoutPanel
    31       //
    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;
    4541      //
    4642      // btnUpload
     
    5551      this.btnUpload.Click += new System.EventHandler(this.btnUpload_Click);
    5652      //
     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      //
    57136      // OKBExperimentUploadView
    58137      //
    59138      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    60139      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     140      this.Controls.Add(this.dataGridView);
    61141      this.Controls.Add(this.btnUpload);
    62       this.Controls.Add(this.tableLayoutPanel);
    63142      this.Name = "OKBExperimentUploadView";
    64143      this.Size = new System.Drawing.Size(466, 229);
     144      ((System.ComponentModel.ISupportInitialize)(this.dataGridView)).EndInit();
     145      this.contextMenu.ResumeLayout(false);
    65146      this.ResumeLayout(false);
    66147
     
    69150    #endregion
    70151
    71     private System.Windows.Forms.TableLayoutPanel tableLayoutPanel;
    72152    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;
    73163  }
    74164}
  • branches/OKB (trunk integration)/HeuristicLab.Clients.OKB/3.3/RunCreation/Views/OKBExperimentUploadView.cs

    r7590 r7742  
    2222using System;
    2323using System.Collections.Generic;
     24using System.Drawing;
    2425using System.Linq;
    2526using System.Threading.Tasks;
    2627using System.Windows.Forms;
    2728using HeuristicLab.Clients.Access;
     29using HeuristicLab.Core;
    2830using HeuristicLab.Core.Views;
    2931using HeuristicLab.MainForm;
     
    3436  [View("OKBExperimentUpload View")]
    3537  [Content(typeof(Experiment), false)]
     38  [Content(typeof(RunCollection), false)]
     39  [Content(typeof(IOptimizer), false)]
    3640  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>();
    4456    private List<Problem> problems = new List<Problem>();
    4557    private List<Algorithm> algorithms = new List<Algorithm>();
     58    Algorithm selectedAlgorithm = null;
     59    Problem selectedProblem = null;
     60    private ProgressView progressView;
    4661
    4762    public OKBExperimentUploadView() {
    4863      InitializeComponent();
    49       tableLayoutPanel.RowCount = 0;
    5064    }
    5165
     
    5569        ClearRuns();
    5670      } 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
    5779        DisplayRuns();
    5880      }
     
    84106
    85107    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        }
    94158      }
    95159    }
    96160
    97161    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();
    104164    }
    105165
     
    137197      prog.Status = "Uploading runs to OKB...";
    138198      prog.ProgressValue = 0;
    139       double count = runConfigViews.Count(x => x.UploadToOKB());
     199      double count = dataGridView.Rows.Count;
    140200      int i = 0;
    141201
    142202      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;
    150214      }
    151215      FinishProgressView();
     
    175239      }
    176240    }
     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    }
    177270  }
    178271}
Note: See TracChangeset for help on using the changeset viewer.