Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13252


Ignore:
Timestamp:
11/18/15 14:10:12 (9 years ago)
Author:
pfleck
Message:

#2486

  • Added the possibility to add rows or columns by middle-click on a row or column header.
  • Added a rename columns button which shows the new RenameColumnsDialog.
  • Fixed a bug where no input variables where checked after exporting to a DataAnalysisProblemData.
Location:
trunk/sources
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.Designer.cs

    r12986 r13252  
    6363      this.btnReplace = new System.Windows.Forms.Button();
    6464      this.toolTip = new System.Windows.Forms.ToolTip(this.components);
    65       this.addLineButton = new System.Windows.Forms.Button();
     65      this.addRowButton = new System.Windows.Forms.Button();
    6666      this.addColumnButton = new System.Windows.Forms.Button();
     67      this.renameColumnsButton = new System.Windows.Forms.Button();
    6768      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit();
    6869      this.contextMenuCell.SuspendLayout();
     
    8182      this.columnsTextBox.Size = new System.Drawing.Size(71, 20);
    8283      //
     84      // statisticsTextBox
     85      //
     86      this.statisticsTextBox.Location = new System.Drawing.Point(3, 387);
     87      this.statisticsTextBox.Size = new System.Drawing.Size(421, 13);
     88      //
    8389      // btnApplySort
    8490      //
    85       this.btnApplySort.Location = new System.Drawing.Point(320, -1);
     91      this.btnApplySort.Location = new System.Drawing.Point(234, 0);
    8692      this.btnApplySort.Name = "btnApplySort";
    87       this.btnApplySort.Size = new System.Drawing.Size(87, 23);
     93      this.btnApplySort.Size = new System.Drawing.Size(104, 23);
    8894      this.btnApplySort.TabIndex = 7;
    8995      this.btnApplySort.Text = "Apply Sort";
     
    196202      // btnSearch
    197203      //
    198       this.btnSearch.Location = new System.Drawing.Point(173, -1);
     204      this.btnSearch.Location = new System.Drawing.Point(173, 0);
    199205      this.btnSearch.Name = "btnSearch";
    200       this.btnSearch.Size = new System.Drawing.Size(53, 23);
     206      this.btnSearch.Size = new System.Drawing.Size(55, 23);
    201207      this.btnSearch.TabIndex = 8;
    202208      this.btnSearch.Text = "Search";
     
    207213      // btnReplace
    208214      //
    209       this.btnReplace.Location = new System.Drawing.Point(232, -1);
     215      this.btnReplace.Location = new System.Drawing.Point(173, 26);
    210216      this.btnReplace.Name = "btnReplace";
    211217      this.btnReplace.Size = new System.Drawing.Size(55, 23);
     
    216222      this.btnReplace.Click += new System.EventHandler(this.btnReplace_Click);
    217223      //
    218       // addLineButton
    219       //
    220       this.addLineButton.Location = new System.Drawing.Point(173, 25);
    221       this.addLineButton.Name = "addLineButton";
    222       this.addLineButton.Size = new System.Drawing.Size(114, 23);
    223       this.addLineButton.TabIndex = 10;
    224       this.addLineButton.Text = "Add Line";
    225       this.addLineButton.UseVisualStyleBackColor = true;
    226       this.addLineButton.Click += new System.EventHandler(this.addLineButton_Click);
     224      // addRowButton
     225      //
     226      this.addRowButton.Location = new System.Drawing.Point(344, 26);
     227      this.addRowButton.Name = "addRowButton";
     228      this.addRowButton.Size = new System.Drawing.Size(76, 23);
     229      this.addRowButton.TabIndex = 10;
     230      this.addRowButton.Text = "Add Row";
     231      this.addRowButton.UseVisualStyleBackColor = true;
     232      this.addRowButton.Click += new System.EventHandler(this.addRowButton_Click);
    227233      //
    228234      // addColumnButton
    229235      //
    230       this.addColumnButton.Location = new System.Drawing.Point(293, 25);
     236      this.addColumnButton.Location = new System.Drawing.Point(344, 0);
    231237      this.addColumnButton.Name = "addColumnButton";
    232       this.addColumnButton.Size = new System.Drawing.Size(114, 23);
     238      this.addColumnButton.Size = new System.Drawing.Size(76, 23);
    233239      this.addColumnButton.TabIndex = 10;
    234240      this.addColumnButton.Text = "Add Column";
     
    236242      this.addColumnButton.Click += new System.EventHandler(this.addColumnButton_Click);
    237243      //
     244      // renameColumnsButton
     245      //
     246      this.renameColumnsButton.Location = new System.Drawing.Point(234, 26);
     247      this.renameColumnsButton.Name = "renameColumnsButton";
     248      this.renameColumnsButton.Size = new System.Drawing.Size(104, 23);
     249      this.renameColumnsButton.TabIndex = 11;
     250      this.renameColumnsButton.Text = "Rename Columns";
     251      this.renameColumnsButton.UseVisualStyleBackColor = true;
     252      this.renameColumnsButton.Click += new System.EventHandler(this.renameColumnsButton_Click);
     253      //
    238254      // DataGridContentView
    239255      //
    240256      this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
    241257      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
     258      this.Controls.Add(this.renameColumnsButton);
    242259      this.Controls.Add(this.addColumnButton);
    243       this.Controls.Add(this.addLineButton);
     260      this.Controls.Add(this.addRowButton);
    244261      this.Controls.Add(this.btnReplace);
    245262      this.Controls.Add(this.btnSearch);
    246263      this.Controls.Add(this.btnApplySort);
    247264      this.Name = "DataGridContentView";
     265      this.Size = new System.Drawing.Size(430, 403);
     266      this.Controls.SetChildIndex(this.btnApplySort, 0);
     267      this.Controls.SetChildIndex(this.btnSearch, 0);
     268      this.Controls.SetChildIndex(this.btnReplace, 0);
     269      this.Controls.SetChildIndex(this.addRowButton, 0);
     270      this.Controls.SetChildIndex(this.addColumnButton, 0);
     271      this.Controls.SetChildIndex(this.renameColumnsButton, 0);
    248272      this.Controls.SetChildIndex(this.statisticsTextBox, 0);
    249273      this.Controls.SetChildIndex(this.rowsLabel, 0);
     
    251275      this.Controls.SetChildIndex(this.rowsTextBox, 0);
    252276      this.Controls.SetChildIndex(this.columnsTextBox, 0);
    253       this.Controls.SetChildIndex(this.btnApplySort, 0);
    254       this.Controls.SetChildIndex(this.btnSearch, 0);
    255       this.Controls.SetChildIndex(this.btnReplace, 0);
    256       this.Controls.SetChildIndex(this.addLineButton, 0);
    257       this.Controls.SetChildIndex(this.addColumnButton, 0);
    258277      ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).EndInit();
    259278      this.contextMenuCell.ResumeLayout(false);
     
    282301    private System.Windows.Forms.ToolTip toolTip;
    283302    private System.Windows.Forms.ToolStripMenuItem smoothingToolStripMenuItem_Column;
    284     private System.Windows.Forms.Button addLineButton;
     303    private System.Windows.Forms.Button addRowButton;
    285304    private System.Windows.Forms.Button addColumnButton;
     305    private System.Windows.Forms.Button renameColumnsButton;
    286306  }
    287307}
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs

    r12986 r13252  
    5959      InitializeComponent();
    6060      dataGridView.CellMouseClick += dataGridView_CellMouseClick;
     61      dataGridView.RowHeaderMouseClick += dataGridView_RowHeaderMouseClick;
    6162      dataGridView.KeyDown += dataGridView_KeyDown;
    6263      dataGridView.MouseUp += dataGridView_MouseUp;
     
    184185    protected override void dataGridView_ColumnHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
    185186      if (Content != null) {
    186         if (e.Button == System.Windows.Forms.MouseButtons.Left) {
     187        if (e.Button == MouseButtons.Left) {
    187188          dataGridView.Focus();
    188189          dataGridView.ClearSelection();
     
    193194            dataGridView[e.ColumnIndex, i].Selected = true;
    194195          }
    195         } else if (Content.SortableView) {
     196        } else if (e.Button == MouseButtons.Middle) {
     197          int newIndex = e.ColumnIndex >= 0 ? e.ColumnIndex : 0;
     198          Content.PreProcessingData.InsertColumn<double>(newIndex.ToString(), newIndex);
     199        } else if (e.Button == MouseButtons.Right && Content.SortableView) {
    196200          SortColumn(e.ColumnIndex);
    197201        }
    198202      }
    199203      searchIterator = null;
     204    }
     205    private void dataGridView_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
     206      if (Content != null) {
     207        if (e.Button == MouseButtons.Middle) {
     208          int newIndex = e.RowIndex >= 0 ? e.RowIndex : 0;
     209          Content.PreProcessingData.InsertRow(newIndex);
     210        }
     211      }
    200212    }
    201213
     
    469481    private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
    470482      if (Content == null) return;
    471       if (e.Button == System.Windows.Forms.MouseButtons.Right && !(e.ColumnIndex != -1 && e.RowIndex == -1)) {
     483      if (e.Button == MouseButtons.Right && !(e.ColumnIndex != -1 && e.RowIndex == -1)) {
    472484        if (e.ColumnIndex == -1 || e.RowIndex == -1) {
    473485          replaceValueOverColumnToolStripMenuItem.Visible = false;
     
    631643    #endregion
    632644
    633     private void addLineButton_Click(object sender, EventArgs e) {
     645    private void addRowButton_Click(object sender, EventArgs e) {
    634646      Content.PreProcessingData.InsertRow(Content.Rows);
    635647    }
     
    639651    }
    640652
     653    private void renameColumnsButton_Click(object sender, EventArgs e) {
     654      var renameDialog = new RenameColumnsDialog(Content.ColumnNames);
     655
     656      if (renameDialog.ShowDialog(this) == DialogResult.OK) {
     657        Content.PreProcessingData.RenameColumns(renameDialog.ColumnNames);
     658      }
     659    }
    641660  }
    642661}
  • trunk/sources/HeuristicLab.DataPreprocessing.Views/3.4/HeuristicLab.DataPreprocessing.Views-3.4.csproj

    r12683 r13252  
    120120    <Compile Include="ComparisonFilterView.Designer.cs">
    121121      <DependentUpon>ComparisonFilterView.cs</DependentUpon>
     122    </Compile>
     123    <Compile Include="RenameColumnsDialog.cs">
     124      <SubType>Form</SubType>
     125    </Compile>
     126    <Compile Include="RenameColumnsDialog.Designer.cs">
     127      <DependentUpon>RenameColumnsDialog.cs</DependentUpon>
    122128    </Compile>
    123129    <Compile Include="ScatterPlotSingleView.cs">
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/FilteredPreprocessingData.cs

    r12059 r13252  
    119119        throw new InvalidOperationException("DeleteColumn not possible while data is filtered");
    120120      originalData.DeleteColumn(columnIndex);
     121    }
     122
     123    public void RenameColumn(int columnIndex, string name) {
     124      if (IsFiltered)
     125        throw new InvalidOperationException("RenameColumn not possible while data is filtered");
     126      originalData.RenameColumn(columnIndex, name);
     127    }
     128
     129    public void RenameColumns(IList<string> names) {
     130      if (IsFiltered)
     131        throw new InvalidOperationException("RenameColumns not possible while data is filtered");
     132      originalData.RenameColumns(names);
    121133    }
    122134
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/PreprocessingData.cs

    r12509 r13252  
    196196    public abstract void DeleteColumn(int columnIndex);
    197197
     198    public abstract void RenameColumn(int columnIndex, string name);
     199    public abstract void RenameColumns(IList<string> list);
     200
    198201    public abstract Dataset ExportToDataset();
    199202
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Implementations/TransactionalPreprocessingData.cs

    r12986 r13252  
    265265    }
    266266
     267    public override void RenameColumn(int columnIndex, string name) {
     268      SaveSnapshot(DataPreprocessingChangedEventType.ChangeColumn, columnIndex, -1);
     269      if (columnIndex < 0 || columnIndex > variableNames.Count)
     270        throw new ArgumentOutOfRangeException("columnIndex");
     271      variableNames[columnIndex] = name;
     272
     273      if (!IsInTransaction)
     274        OnChanged(DataPreprocessingChangedEventType.ChangeColumn, -1, -1);
     275    }
     276
     277    public override void RenameColumns(IList<string> names) {
     278      if (names == null) throw new ArgumentNullException("names");
     279      if (names.Count != variableNames.Count) throw new ArgumentException("number of names must match the number of columns.", "names");
     280
     281      SaveSnapshot(DataPreprocessingChangedEventType.ChangeColumn, -1, -1);
     282      for (int i = 0; i < names.Count; i++)
     283        variableNames[i] = names[i];
     284
     285      if (!IsInTransaction)
     286        OnChanged(DataPreprocessingChangedEventType.ChangeColumn, -1, -1);
     287    }
     288
    267289    public override Dataset ExportToDataset() {
    268290      IList<IList> values = new List<IList>();
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/Interfaces/IPreprocessingData.cs

    r12059 r13252  
    4747    void DeleteColumn(int columnIndex);
    4848
     49    void RenameColumn(int columnIndex, string name);
     50    void RenameColumns(IList<string> names);
     51
    4952    bool AreAllStringColumns(IEnumerable<int> columnIndices);
    5053    bool Validate(string value, out string errorMessage, int columnIndex);
  • trunk/sources/HeuristicLab.DataPreprocessing/3.4/ProblemDataCreator.cs

    r12983 r13252  
    6363      var inputVariables = oldProblemData.InputVariables.ToDictionary(x => x.Value, x => x);
    6464      foreach (var variable in problemData.InputVariables) {
    65         bool isChecked = oldProblemData.InputVariables.Contains(variable) && oldProblemData.InputVariables.ItemChecked(inputVariables[variable.Value]);
     65        bool isChecked = inputVariables.ContainsKey(variable.Value) && oldProblemData.InputVariables.ItemChecked(inputVariables[variable.Value]);
    6666        problemData.InputVariables.SetItemCheckedState(variable, isChecked);
    6767      }
     
    7272    private IDataAnalysisProblemData CreateRegressionData(RegressionProblemData oldProblemData) {
    7373      var targetVariable = oldProblemData.TargetVariable;
    74       // target variable must be double and must exist in the new dataset
    75       return new RegressionProblemData(ExportedDataset, GetDoubleInputVariables(targetVariable), targetVariable, Transformations);
     74      if (!context.Data.VariableNames.Contains(targetVariable))
     75        targetVariable = context.Data.VariableNames.First();
     76      var inputVariables = GetDoubleInputVariables(targetVariable);
     77      var newProblemData = new RegressionProblemData(ExportedDataset, inputVariables, targetVariable, Transformations);
     78      return newProblemData;
    7679    }
    7780
    7881    private IDataAnalysisProblemData CreateClassificationData(ClassificationProblemData oldProblemData) {
    79       // target variable must be double and must exist in the new dataset
    8082      var targetVariable = oldProblemData.TargetVariable;
    81       var newProblemData = new ClassificationProblemData(ExportedDataset, GetDoubleInputVariables(targetVariable), targetVariable, Transformations);
     83      if (!context.Data.VariableNames.Contains(targetVariable))
     84        targetVariable = context.Data.VariableNames.First();
     85      var inputVariables = GetDoubleInputVariables(targetVariable);
     86      var newProblemData = new ClassificationProblemData(ExportedDataset, inputVariables, targetVariable, Transformations);
    8287      newProblemData.PositiveClass = oldProblemData.PositiveClass;
    8388      return newProblemData;
Note: See TracChangeset for help on using the changeset viewer.