source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/DataGridContent.cs @ 11070

Last change on this file since 11070 was 11070, checked in by mkommend, 5 years ago

#2206: Clean up of data preprocessing code (removed unused code, used more appropriate collections, hiding of the backtransform button of symreg models).

File size: 4.7 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 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;
28
29namespace HeuristicLab.DataPreprocessing {
30
31  [Item("DataGrid", "Represents a data grid.")]
32  public class DataGridContent : Item, IViewShortcut, IDataGridContent {
33
34    public ITransactionalPreprocessingData PreProcessingData { get; private set; }
35
36    public static new Image StaticItemImage {
37      get { return HeuristicLab.Common.Resources.VSImageLibrary.Table; }
38    }
39
40    public IManipulationLogic ManipulationLogic { get; private set; }
41    public IFilterLogic FilterLogic { get; private set; }
42
43    private IEnumerable<string> rowNames;
44
45    public int Rows {
46      get {
47        return PreProcessingData.Rows;
48      }
49      set {
50        //does nothing
51      }
52    }
53
54    public int Columns {
55      get {
56        return PreProcessingData.Columns;
57      }
58      set {
59        //does nothing
60      }
61    }
62
63    public IEnumerable<string> ColumnNames {
64      get {
65        return PreProcessingData.VariableNames;
66      }
67      set {
68
69      }
70    }
71
72    public IEnumerable<string> RowNames {
73      get {
74        return rowNames;
75      }
76      set {
77        //not supported
78      }
79    }
80
81    public bool SortableView {
82      get {
83        return true;
84      }
85      set {
86        //not supported
87      }
88    }
89
90    public bool ReadOnly {
91      get { return false; }
92    }
93
94
95    public IDictionary<int, IList<int>> Selection {
96      get { return PreProcessingData.Selection; }
97      set { PreProcessingData.Selection = value; }
98    }
99
100
101    public DataGridContent(ITransactionalPreprocessingData preProcessingData, IManipulationLogic theManipulationLogic, IFilterLogic theFilterLogic) {
102      ManipulationLogic = theManipulationLogic;
103      FilterLogic = theFilterLogic;
104      PreProcessingData = preProcessingData;
105      createRowNames();
106    }
107
108    public DataGridContent(DataGridContent dataGridContent, Cloner cloner)
109      : base(dataGridContent, cloner) {
110
111    }
112    public override IDeepCloneable Clone(Cloner cloner) {
113      return new DataGridContent(this, cloner);
114    }
115
116    public void DeleteRow(IEnumerable<int> rows) {
117      PreProcessingData.DeleteRowsWithIndices(rows);
118      createRowNames();
119    }
120
121    public bool Validate(string value, out string errorMessage, int columnIndex) {
122      return PreProcessingData.Validate(value, out errorMessage, columnIndex);
123    }
124
125    public string GetValue(int rowIndex, int columnIndex) {
126      return PreProcessingData.GetCellAsString(columnIndex, rowIndex);
127    }
128
129    public bool SetValue(string value, int rowIndex, int columnIndex) {
130      return PreProcessingData.SetValue(value, columnIndex, rowIndex);
131    }
132
133    private void createRowNames() {
134      rowNames = Enumerable.Range(1, Rows).Select(n => n.ToString());
135    }
136
137    public event DataPreprocessingChangedEventHandler Changed {
138      add { PreProcessingData.Changed += value; }
139      remove { PreProcessingData.Changed -= value; }
140    }
141
142
143    #region unused stuff/not implemented but necessary due to IStringConvertibleMatrix
144#pragma warning disable 0067
145    // Is not used since DataGridContentView overrides dataGridView_CellValidating and uses
146    // DataGridLogic#Validate(string value, out string errorMessage, int columnIndex)
147    public bool Validate(string value, out string errorMessage) {
148      errorMessage = string.Empty;
149      return true;
150    }
151
152    public event EventHandler ColumnsChanged;
153    public event EventHandler RowsChanged;
154    public event EventHandler ColumnNamesChanged;
155    public event EventHandler RowNamesChanged;
156    public event EventHandler SortableViewChanged;
157    public event EventHandler<EventArgs<int, int>> ItemChanged;
158    public event EventHandler Reset;
159
160#pragma warning restore 0067
161    #endregion
162
163  }
164}
Note: See TracBrowser for help on using the repository browser.