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
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
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;
23using System.Collections.Generic;
24using System.Drawing;
25using System.Linq;
26using HeuristicLab.Common;
27using HeuristicLab.Core;
28using HeuristicLab.Data;
29
30namespace HeuristicLab.DataPreprocessing {
31
32  [Item("DataGrid", "Represents a data grid.")]
33  public class DataGridContent : Item, IStringConvertibleMatrix, IViewShortcut {
34
35    public ITransactionalPreprocessingData PreProcessingData { get; private set; }
36
37    public static new Image StaticItemImage {
38      get { return HeuristicLab.Common.Resources.VSImageLibrary.Table; }
39    }
40
41    public ManipulationLogic ManipulationLogic { get; private set; }
42    public FilterLogic FilterLogic { get; private set; }
43
44    public int Rows {
45      get {
46        return PreProcessingData.Rows;
47      }
48      set {
49        //does nothing
50      }
51    }
52
53    public int Columns {
54      get {
55        return PreProcessingData.Columns;
56      }
57      set {
58        //does nothing
59      }
60    }
61
62    public IEnumerable<string> ColumnNames {
63      get {
64        return PreProcessingData.VariableNames;
65      }
66      set {
67
68      }
69    }
70
71    public IEnumerable<string> RowNames {
72      get {
73        return Enumerable.Range(1, Rows).Select(n => n.ToString());
74      }
75      set {
76        throw new NotSupportedException();
77      }
78    }
79
80    public bool SortableView {
81      get {
82        return true;
83      }
84      set {
85        throw new NotSupportedException();
86      }
87    }
88
89    public bool ReadOnly {
90      get { return false; }
91    }
92
93
94    public IDictionary<int, IList<int>> Selection {
95      get { return PreProcessingData.Selection; }
96      set { PreProcessingData.Selection = value; }
97    }
98
99
100    public DataGridContent(ITransactionalPreprocessingData preProcessingData, ManipulationLogic theManipulationLogic, FilterLogic theFilterLogic) {
101      ManipulationLogic = theManipulationLogic;
102      FilterLogic = theFilterLogic;
103      PreProcessingData = preProcessingData;
104    }
105
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
114    public void DeleteRows(IEnumerable<int> rows) {
115      PreProcessingData.DeleteRowsWithIndices(rows);
116    }
117
118    public void DeleteColumn(int column) {
119      PreProcessingData.DeleteColumn(column);
120    }
121
122    public bool Validate(string value, out string errorMessage, int columnIndex) {
123      return PreProcessingData.Validate(value, out errorMessage, columnIndex);
124    }
125
126    public string GetValue(int rowIndex, int columnIndex) {
127      return PreProcessingData.GetCellAsString(columnIndex, rowIndex);
128    }
129
130    public bool SetValue(string value, int rowIndex, int columnIndex) {
131      return PreProcessingData.SetValue(value, columnIndex, rowIndex);
132    }
133
134    public event DataPreprocessingChangedEventHandler Changed {
135      add { PreProcessingData.Changed += value; }
136      remove { PreProcessingData.Changed -= value; }
137    }
138
139
140    #region unused stuff/not implemented but necessary due to IStringConvertibleMatrix
141#pragma warning disable 0067
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
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;
154    public event EventHandler<EventArgs<int, int>> ItemChanged;
155    public event EventHandler Reset;
156
157#pragma warning restore 0067
158    #endregion
159
160  }
161}
Note: See TracBrowser for help on using the repository browser.