Free cookie consent management tool by TermsFeed Policy Generator

source: stable/HeuristicLab.DataPreprocessing/3.4/Implementations/DataGridContent.cs @ 13289

Last change on this file since 13289 was 13289, checked in by mkommend, 8 years ago

#2486: Merged r12983, r12986, r13252 and r13271 into stable.

File size: 4.7 KB
RevLine 
[10539]1#region License Information
2/* HeuristicLab
[12009]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;
[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
[10236]43    public int Rows {
44      get {
[11002]45        return PreProcessingData.Rows;
[10236]46      }
47      set {
[10246]48        //does nothing
[10236]49      }
50    }
51
52    public int Columns {
53      get {
[11002]54        return PreProcessingData.Columns;
[10236]55      }
56      set {
[10246]57        //does nothing
[10236]58      }
59    }
60
61    public IEnumerable<string> ColumnNames {
62      get {
[11002]63        return PreProcessingData.VariableNames;
[10236]64      }
65      set {
[10246]66
[10236]67      }
68    }
69
70    public IEnumerable<string> RowNames {
71      get {
[13289]72        return Enumerable.Range(1, Rows).Select(n => n.ToString());
[10236]73      }
74      set {
[13289]75        throw new NotSupportedException();
[10236]76      }
77    }
78
79    public bool SortableView {
80      get {
81        return true;
82      }
83      set {
[13289]84        throw new NotSupportedException();
[10236]85      }
86    }
87
88    public bool ReadOnly {
[10312]89      get { return false; }
[10236]90    }
91
[11002]92
93    public IDictionary<int, IList<int>> Selection {
94      get { return PreProcessingData.Selection; }
95      set { PreProcessingData.Selection = value; }
96    }
97
98
99    public DataGridContent(ITransactionalPreprocessingData preProcessingData, IManipulationLogic theManipulationLogic, IFilterLogic theFilterLogic) {
[10977]100      ManipulationLogic = theManipulationLogic;
101      FilterLogic = theFilterLogic;
[11002]102      PreProcessingData = preProcessingData;
[10236]103    }
104
[10964]105    public DataGridContent(DataGridContent dataGridContent, Cloner cloner)
106      : base(dataGridContent, cloner) {
107
108    }
109    public override IDeepCloneable Clone(Cloner cloner) {
110      return new DataGridContent(this, cloner);
111    }
112
[12718]113    public void DeleteRows(IEnumerable<int> rows) {
[11002]114      PreProcessingData.DeleteRowsWithIndices(rows);
115    }
116
[12718]117    public void DeleteColumn(int column) {
118      PreProcessingData.DeleteColumn(column);
119    }
120
[11002]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
[10964]133    public event DataPreprocessingChangedEventHandler Changed {
[11002]134      add { PreProcessingData.Changed += value; }
135      remove { PreProcessingData.Changed -= value; }
[10964]136    }
137
138
139    #region unused stuff/not implemented but necessary due to IStringConvertibleMatrix
[11070]140#pragma warning disable 0067
[10964]141    // Is not used since DataGridContentView overrides dataGridView_CellValidating and uses
142    // DataGridLogic#Validate(string value, out string errorMessage, int columnIndex)
143    public bool Validate(string value, out string errorMessage) {
144      errorMessage = string.Empty;
145      return true;
146    }
147
[10236]148    public event EventHandler ColumnsChanged;
149    public event EventHandler RowsChanged;
150    public event EventHandler ColumnNamesChanged;
151    public event EventHandler RowNamesChanged;
152    public event EventHandler SortableViewChanged;
[10246]153    public event EventHandler<EventArgs<int, int>> ItemChanged;
[10236]154    public event EventHandler Reset;
[11070]155
156#pragma warning restore 0067
[10964]157    #endregion
[10236]158
159  }
160}
Note: See TracBrowser for help on using the repository browser.