Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 11070 was 11070, checked in by mkommend, 10 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
RevLine 
[10539]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;
[10236]23using System.Collections.Generic;
[10246]24using System.Drawing;
[11002]25using System.Linq;
[10246]26using HeuristicLab.Common;
[10239]27using HeuristicLab.Core;
[10236]28
29namespace HeuristicLab.DataPreprocessing {
[10239]30
[10313]31  [Item("DataGrid", "Represents a data grid.")]
[10614]32  public class DataGridContent : Item, IViewShortcut, IDataGridContent {
[10246]33
[11002]34    public ITransactionalPreprocessingData PreProcessingData { get; private set; }
35
[10999]36    public static new Image StaticItemImage {
37      get { return HeuristicLab.Common.Resources.VSImageLibrary.Table; }
38    }
39
[10977]40    public IManipulationLogic ManipulationLogic { get; private set; }
41    public IFilterLogic FilterLogic { get; private set; }
[10614]42
[11002]43    private IEnumerable<string> rowNames;
44
[10236]45    public int Rows {
46      get {
[11002]47        return PreProcessingData.Rows;
[10236]48      }
49      set {
[10246]50        //does nothing
[10236]51      }
52    }
53
54    public int Columns {
55      get {
[11002]56        return PreProcessingData.Columns;
[10236]57      }
58      set {
[10246]59        //does nothing
[10236]60      }
61    }
62
63    public IEnumerable<string> ColumnNames {
64      get {
[11002]65        return PreProcessingData.VariableNames;
[10236]66      }
67      set {
[10246]68
[10236]69      }
70    }
71
72    public IEnumerable<string> RowNames {
73      get {
[11002]74        return rowNames;
[10236]75      }
76      set {
[10246]77        //not supported
[10236]78      }
79    }
80
81    public bool SortableView {
82      get {
83        return true;
84      }
85      set {
[10246]86        //not supported
[10236]87      }
88    }
89
90    public bool ReadOnly {
[10312]91      get { return false; }
[10236]92    }
93
[11002]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) {
[10977]102      ManipulationLogic = theManipulationLogic;
103      FilterLogic = theFilterLogic;
[11002]104      PreProcessingData = preProcessingData;
105      createRowNames();
[10236]106    }
107
[10964]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
[11002]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
[10236]125    public string GetValue(int rowIndex, int columnIndex) {
[11002]126      return PreProcessingData.GetCellAsString(columnIndex, rowIndex);
[10236]127    }
128
[10629]129    public bool SetValue(string value, int rowIndex, int columnIndex) {
[11002]130      return PreProcessingData.SetValue(value, columnIndex, rowIndex);
[10236]131    }
132
[11002]133    private void createRowNames() {
134      rowNames = Enumerable.Range(1, Rows).Select(n => n.ToString());
135    }
136
[10964]137    public event DataPreprocessingChangedEventHandler Changed {
[11002]138      add { PreProcessingData.Changed += value; }
139      remove { PreProcessingData.Changed -= value; }
[10964]140    }
141
142
143    #region unused stuff/not implemented but necessary due to IStringConvertibleMatrix
[11070]144#pragma warning disable 0067
[10964]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
[10236]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;
[10246]157    public event EventHandler<EventArgs<int, int>> ItemChanged;
[10236]158    public event EventHandler Reset;
[11070]159
160#pragma warning restore 0067
[10964]161    #endregion
[10236]162
163  }
164}
Note: See TracBrowser for help on using the repository browser.