Free cookie consent management tool by TermsFeed Policy Generator

source: branches/WebJobManager/HeuristicLab.DataPreprocessing/3.4/Content/DataGridContent.cs @ 13656

Last change on this file since 13656 was 13656, checked in by ascheibe, 8 years ago

#2582 created branch for Hive Web Job Manager

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