Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/28/14 12:52:24 (10 years ago)
Author:
sbreuer
Message:
  • deleted unused method
  • refactored filter logic
  • added filter changed event
  • changed datagridview validation (cannot modify, if filter is active)
  • update datagridview if preview is active
Location:
branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/DataGridContent.cs

    r10809 r10900  
    123123    }
    124124
    125     public bool Validate(string value, out string errorMessage, int columnIndex) {
    126       return dataGridLogic.Validate(value, out errorMessage, columnIndex);
    127     }
    128 
    129125    public string GetValue(int rowIndex, int columnIndex) {
    130126      return dataGridLogic.GetValue(columnIndex, rowIndex);
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/DataGridLogic.cs

    r10804 r10900  
    6969        throw new ArgumentOutOfRangeException("column index is out of range");
    7070      }
     71
    7172      bool valid = false;
     73      errorMessage = string.Empty;
    7274      if (preprocessingData.IsType<double>(columnIndex)) {
    7375        double val;
    7476        valid = double.TryParse(value, out val);
    75         errorMessage = string.Empty;
    7677        if (!valid) {
    7778          errorMessage = "Invalid Value (Valid Value Format: \"" + FormatPatterns.GetDoubleFormatPattern() + "\")";
     
    7980      } else if (preprocessingData.IsType<string>(columnIndex)) {
    8081        valid = value != null;
    81         errorMessage = string.Empty;
    8282        if (!valid) {
    8383          errorMessage = "Invalid Value (string must not be null)";
     
    8686        DateTime date;
    8787        valid = DateTime.TryParse(value, out date);
    88         errorMessage = string.Empty;
    8988        if (!valid) {
    9089          errorMessage = "Invalid Value (Valid Value Format: \"" + CultureInfo.CurrentCulture.DateTimeFormat + "\"";
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/FilterLogic.cs

    r10849 r10900  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using System.Linq;
     
    3738
    3839      if (activeFilters.Count == 0) {
    39         return new bool[preprocessingData.Rows];
     40        return CreateBoolArray(preprocessingData.Rows, false);
    4041      }
     42      return GetActiveFilterResult(activeFilters, isAndCombination);
     43    }
    4144
     45    private bool[] GetActiveFilterResult(IList<IFilter> activeFilters, bool isAndCombination) {
    4246      bool[] result = CreateBoolArray(preprocessingData.Rows, !isAndCombination);
    4347
     
    5256
    5357    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      }
    5766    }
    5867
     
    7483    }
    7584
     85    public bool IsFiltered() {
     86      return preprocessingData.IsFiltered;
     87    }
     88
    7689    public IPreprocessingData PreprocessingData {
    7790      get { return preprocessingData; }
    7891    }
     92
     93    public event EventHandler FilterChanged {
     94      add { preprocessingData.FilterChanged += value; }
     95      remove { preprocessingData.FilterChanged -= value; }
     96    }
    7997  }
    8098}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/FilteredPreprocessingData.cs

    r10847 r10900  
    118118        }
    119119      }
     120
     121      OnFilterChanged();
    120122    }
    121123
    122124    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      });
    124138      ResetFilter();
    125139    }
     
    127141    public void ResetFilter() {
    128142      filteredData = null;
     143      OnFilterChanged();
     144    }
     145
     146    private void OnFilterChanged() {
     147      if (FilterChanged != null) {
     148        FilterChanged(this, new EventArgs());
     149      }
    129150    }
    130151
     
    171192    }
    172193
     194    public event EventHandler FilterChanged;
     195
    173196    #region IPreprocessingData Members
    174197
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IFilterLogic.cs

    r10844 r10900  
    2020#endregion
    2121
     22using System;
    2223using System.Collections.Generic;
    2324using HeuristicLab.DataPreprocessing.Filter;
     
    2526  public interface IFilterLogic {
    2627    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>
    2734    bool[] Preview(IList<IFilter> filters, bool isAndCombination);
    2835    void Apply(IList<IFilter> filters, bool isAndCombination);
    2936    IPreprocessingData PreprocessingData { get; }
    3037    void Reset();
     38    bool IsFiltered();
     39
     40    event EventHandler FilterChanged;
    3141  }
    3242}
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Interfaces/IFilteredPreprocessingData.cs

    r10783 r10900  
    1111    void PersistFilter();
    1212    void ResetFilter();
     13    bool IsFiltered { get; }
     14
     15    event EventHandler FilterChanged;
    1316   }
    1417}
Note: See TracChangeset for help on using the changeset viewer.