Changeset 10900
- Timestamp:
- 05/28/14 12:52:24 (10 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataGridContentView.cs
r10898 r10900 96 96 base.RegisterContentEvents(); 97 97 Content.Changed += Content_Changed; 98 } 98 Content.FilterLogic.FilterChanged += FilterLogic_FilterChanged; 99 } 100 101 void FilterLogic_FilterChanged(object sender, EventArgs e) { 102 OnContentChanged(); 103 searchIterator = null; 104 } 99 105 100 106 protected override void DeregisterContentEvents() { 101 107 base.DeregisterContentEvents(); 102 108 Content.Changed -= Content_Changed; 109 Content.FilterLogic.FilterChanged -= FilterLogic_FilterChanged; 103 110 } 104 111 … … 121 128 if (!dataGridView.ReadOnly) { 122 129 string errorMessage; 123 if (Content != null && !Content.DataGridLogic.Validate(e.FormattedValue.ToString(), out errorMessage, e.ColumnIndex)) { 124 e.Cancel = true; 125 dataGridView.Rows[e.RowIndex].ErrorText = errorMessage; 130 if (Content != null){ 131 if (dataGridView.IsCurrentCellInEditMode && Content.FilterLogic.IsFiltered()) { 132 errorMessage = "A filter is active, you cannot modify data. Press ESC to exit edit mode."; 133 } else { 134 Content.DataGridLogic.Validate(e.FormattedValue.ToString(), out errorMessage, e.ColumnIndex); 135 } 136 137 if (!String.IsNullOrEmpty(errorMessage)) { 138 e.Cancel = true; 139 dataGridView.Rows[e.RowIndex].ErrorText = errorMessage; 140 } 126 141 } 127 142 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/FilterView.cs
r10877 r10900 93 93 filter.ConstrainedValue = Content.FilterLogic.PreprocessingData; 94 94 } 95 UpdateFilterInfo();96 95 } 97 96 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/DataGridContent.cs
r10809 r10900 123 123 } 124 124 125 public bool Validate(string value, out string errorMessage, int columnIndex) {126 return dataGridLogic.Validate(value, out errorMessage, columnIndex);127 }128 129 125 public string GetValue(int rowIndex, int columnIndex) { 130 126 return dataGridLogic.GetValue(columnIndex, rowIndex); -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/DataGridLogic.cs
r10804 r10900 69 69 throw new ArgumentOutOfRangeException("column index is out of range"); 70 70 } 71 71 72 bool valid = false; 73 errorMessage = string.Empty; 72 74 if (preprocessingData.IsType<double>(columnIndex)) { 73 75 double val; 74 76 valid = double.TryParse(value, out val); 75 errorMessage = string.Empty;76 77 if (!valid) { 77 78 errorMessage = "Invalid Value (Valid Value Format: \"" + FormatPatterns.GetDoubleFormatPattern() + "\")"; … … 79 80 } else if (preprocessingData.IsType<string>(columnIndex)) { 80 81 valid = value != null; 81 errorMessage = string.Empty;82 82 if (!valid) { 83 83 errorMessage = "Invalid Value (string must not be null)"; … … 86 86 DateTime date; 87 87 valid = DateTime.TryParse(value, out date); 88 errorMessage = string.Empty;89 88 if (!valid) { 90 89 errorMessage = "Invalid Value (Valid Value Format: \"" + CultureInfo.CurrentCulture.DateTimeFormat + "\""; -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/FilterLogic.cs
r10849 r10900 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using System.Linq; … … 37 38 38 39 if (activeFilters.Count == 0) { 39 return new bool[preprocessingData.Rows];40 return CreateBoolArray(preprocessingData.Rows, false); 40 41 } 42 return GetActiveFilterResult(activeFilters, isAndCombination); 43 } 41 44 45 private bool[] GetActiveFilterResult(IList<IFilter> activeFilters, bool isAndCombination) { 42 46 bool[] result = CreateBoolArray(preprocessingData.Rows, !isAndCombination); 43 47 … … 52 56 53 57 public bool[] Preview(IList<IFilter> filters, bool isAndCombination) { 54 var result = GetFilterResult(filters, isAndCombination); 55 preprocessingData.SetFilter(result); 56 return result; 58 IList<IFilter> activeFilters = filters.Where(f => f.Active && f.ConstraintData != null).ToList<IFilter>(); 59 if (activeFilters.Count > 0) { 60 var result = GetActiveFilterResult(activeFilters, isAndCombination); 61 preprocessingData.SetFilter(result); 62 return result; 63 } else { 64 return CreateBoolArray(preprocessingData.Rows, false); 65 } 57 66 } 58 67 … … 74 83 } 75 84 85 public bool IsFiltered() { 86 return preprocessingData.IsFiltered; 87 } 88 76 89 public IPreprocessingData PreprocessingData { 77 90 get { return preprocessingData; } 78 91 } 92 93 public event EventHandler FilterChanged { 94 add { preprocessingData.FilterChanged += value; } 95 remove { preprocessingData.FilterChanged -= value; } 96 } 79 97 } 80 98 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/FilteredPreprocessingData.cs
r10847 r10900 118 118 } 119 119 } 120 121 OnFilterChanged(); 120 122 } 121 123 122 124 public void PersistFilter() { 123 originalData = (ITransactionalPreprocessingData)filteredData.Clone(); 125 originalData.InTransaction(() => { 126 for (int i = 0; i < filteredData.Columns; ++i) { 127 if (filteredData.IsType<double>(i)) { 128 originalData.SetValues<double>(i, filteredData.GetValues<double>(i)); 129 } else if (filteredData.IsType<string>(i)) { 130 originalData.SetValues<string>(i, filteredData.GetValues<string>(i)); 131 } else if (filteredData.IsType<DateTime>(i)) { 132 originalData.SetValues<DateTime>(i, filteredData.GetValues<DateTime>(i)); 133 } else { 134 throw new ArgumentException("Data types of columns do not match"); 135 } 136 } 137 }); 124 138 ResetFilter(); 125 139 } … … 127 141 public void ResetFilter() { 128 142 filteredData = null; 143 OnFilterChanged(); 144 } 145 146 private void OnFilterChanged() { 147 if (FilterChanged != null) { 148 FilterChanged(this, new EventArgs()); 149 } 129 150 } 130 151 … … 171 192 } 172 193 194 public event EventHandler FilterChanged; 195 173 196 #region IPreprocessingData Members 174 197 -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IFilterLogic.cs
r10844 r10900 20 20 #endregion 21 21 22 using System; 22 23 using System.Collections.Generic; 23 24 using HeuristicLab.DataPreprocessing.Filter; … … 25 26 public interface IFilterLogic { 26 27 bool[] GetFilterResult(IList<IFilter> filters, bool isAndCombination); 28 /// <summary> 29 /// Return an array which indicates whether the corresponding row should be filtered (true) or kept (false) 30 /// </summary> 31 /// <param name="filters"></param> 32 /// <param name="isAndCombination"></param> 33 /// <returns></returns> 27 34 bool[] Preview(IList<IFilter> filters, bool isAndCombination); 28 35 void Apply(IList<IFilter> filters, bool isAndCombination); 29 36 IPreprocessingData PreprocessingData { get; } 30 37 void Reset(); 38 bool IsFiltered(); 39 40 event EventHandler FilterChanged; 31 41 } 32 42 } -
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IFilteredPreprocessingData.cs
r10783 r10900 11 11 void PersistFilter(); 12 12 void ResetFilter(); 13 bool IsFiltered { get; } 14 15 event EventHandler FilterChanged; 13 16 } 14 17 }
Note: See TracChangeset
for help on using the changeset viewer.