Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.DataPreprocessing/3.4/Content/DataGridContent.cs @ 13514

Last change on this file since 13514 was 13514, checked in by pfleck, 8 years ago

#2559

  • Enabled pasting values with headers into preprocessing. The headers will be extracted and the columns renamed.
  • Removed an unnecessary interface.
File size: 4.7 KB
RevLine 
[10539]1#region License Information
2/* HeuristicLab
[12012]3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
[10539]4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
[10236]23using System.Collections.Generic;
[10246]24using System.Drawing;
[11002]25using System.Linq;
[10246]26using HeuristicLab.Common;
[10239]27using HeuristicLab.Core;
[13514]28using HeuristicLab.Data;
[10236]29
30namespace HeuristicLab.DataPreprocessing {
[10239]31
[10313]32  [Item("DataGrid", "Represents a data grid.")]
[13514]33  public class DataGridContent : Item, IStringConvertibleMatrix, IViewShortcut {
[10246]34
[11002]35    public ITransactionalPreprocessingData PreProcessingData { get; private set; }
36
[10999]37    public static new Image StaticItemImage {
38      get { return HeuristicLab.Common.Resources.VSImageLibrary.Table; }
39    }
40
[13508]41    public ManipulationLogic ManipulationLogic { get; private set; }
42    public FilterLogic FilterLogic { get; private set; }
[10614]43
[10236]44    public int Rows {
45      get {
[11002]46        return PreProcessingData.Rows;
[10236]47      }
48      set {
[10246]49        //does nothing
[10236]50      }
51    }
52
53    public int Columns {
54      get {
[11002]55        return PreProcessingData.Columns;
[10236]56      }
57      set {
[10246]58        //does nothing
[10236]59      }
60    }
61
62    public IEnumerable<string> ColumnNames {
63      get {
[11002]64        return PreProcessingData.VariableNames;
[10236]65      }
66      set {
[10246]67
[10236]68      }
69    }
70
71    public IEnumerable<string> RowNames {
72      get {
[12986]73        return Enumerable.Range(1, Rows).Select(n => n.ToString());
[10236]74      }
75      set {
[12983]76        throw new NotSupportedException();
[10236]77      }
78    }
79
80    public bool SortableView {
81      get {
82        return true;
83      }
84      set {
[12983]85        throw new NotSupportedException();
[10236]86      }
87    }
88
89    public bool ReadOnly {
[10312]90      get { return false; }
[10236]91    }
92
[11002]93
94    public IDictionary<int, IList<int>> Selection {
95      get { return PreProcessingData.Selection; }
96      set { PreProcessingData.Selection = value; }
97    }
98
99
[13508]100    public DataGridContent(ITransactionalPreprocessingData preProcessingData, ManipulationLogic theManipulationLogic, FilterLogic theFilterLogic) {
[10977]101      ManipulationLogic = theManipulationLogic;
102      FilterLogic = theFilterLogic;
[11002]103      PreProcessingData = preProcessingData;
[10236]104    }
105
[10964]106    public DataGridContent(DataGridContent dataGridContent, Cloner cloner)
107      : base(dataGridContent, cloner) {
108
109    }
110    public override IDeepCloneable Clone(Cloner cloner) {
111      return new DataGridContent(this, cloner);
112    }
113
[12676]114    public void DeleteRows(IEnumerable<int> rows) {
[11002]115      PreProcessingData.DeleteRowsWithIndices(rows);
116    }
117
[12676]118    public void DeleteColumn(int column) {
119      PreProcessingData.DeleteColumn(column);
120    }
121
[11002]122    public bool Validate(string value, out string errorMessage, int columnIndex) {
123      return PreProcessingData.Validate(value, out errorMessage, columnIndex);
124    }
125
[10236]126    public string GetValue(int rowIndex, int columnIndex) {
[11002]127      return PreProcessingData.GetCellAsString(columnIndex, rowIndex);
[10236]128    }
129
[10629]130    public bool SetValue(string value, int rowIndex, int columnIndex) {
[11002]131      return PreProcessingData.SetValue(value, columnIndex, rowIndex);
[10236]132    }
133
[10964]134    public event DataPreprocessingChangedEventHandler Changed {
[11002]135      add { PreProcessingData.Changed += value; }
136      remove { PreProcessingData.Changed -= value; }
[10964]137    }
138
139
140    #region unused stuff/not implemented but necessary due to IStringConvertibleMatrix
[11070]141#pragma warning disable 0067
[10964]142    // Is not used since DataGridContentView overrides dataGridView_CellValidating and uses
143    // DataGridLogic#Validate(string value, out string errorMessage, int columnIndex)
144    public bool Validate(string value, out string errorMessage) {
145      errorMessage = string.Empty;
146      return true;
147    }
148
[10236]149    public event EventHandler ColumnsChanged;
150    public event EventHandler RowsChanged;
151    public event EventHandler ColumnNamesChanged;
152    public event EventHandler RowNamesChanged;
153    public event EventHandler SortableViewChanged;
[10246]154    public event EventHandler<EventArgs<int, int>> ItemChanged;
[10236]155    public event EventHandler Reset;
[11070]156
157#pragma warning restore 0067
[10964]158    #endregion
[10236]159
160  }
161}
Note: See TracBrowser for help on using the repository browser.