Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
06/11/14 12:36:39 (10 years ago)
Author:
mleitner
Message:

Refactoring

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.4/Implementations/FilteredPreprocessingData.cs

    r10939 r10978  
    1010namespace HeuristicLab.DataPreprocessing.Implementations {
    1111  public class FilteredPreprocessingData : NamedItem, IFilteredPreprocessingData {
    12     protected ITransactionalPreprocessingData originalData;
    13     protected ITransactionalPreprocessingData filteredData;
     12    private readonly ITransactionalPreprocessingData originalData;
     13    private ITransactionalPreprocessingData filteredData;
     14
     15     public IDictionary<int, IList<int>> Selection {
     16      get { return originalData.Selection; }
     17      set { originalData.Selection = value; }
     18    }
    1419
    1520    protected FilteredPreprocessingData(FilteredPreprocessingData original, Cloner cloner)
    1621      : base(original, cloner) {
    17       originalData = (ITransactionalPreprocessingData)original.originalData;
    18       filteredData = (ITransactionalPreprocessingData)original.filteredData;
     22      originalData = original.originalData;
     23      filteredData = original.filteredData;
    1924    }
    2025
     
    3439
    3540    public void SetCell<T>(int columnIndex, int rowIndex, T value) {
    36       ReadOnlyOnFilterData.SetCell<T>(columnIndex, rowIndex, value);
     41      if (IsFiltered)
     42        throw new InvalidOperationException("SetCell not possible while data is filtered");
     43
     44      originalData.SetCell<T>(columnIndex, rowIndex, value);
    3745    }
    3846
     
    5058
    5159    public void SetValues<T>(int columnIndex, IList<T> values) {
    52       ReadOnlyOnFilterData.SetValues<T>(columnIndex, values);
     60      if (IsFiltered)
     61        throw new InvalidOperationException("SetValues not possible while data is filtered");
     62
     63      originalData.SetValues<T>(columnIndex, values);
    5364    }
    5465
    5566    public void InsertRow(int rowIndex) {
    56       ReadOnlyOnFilterData.InsertRow(rowIndex);
     67      if (IsFiltered)
     68        throw new InvalidOperationException("InsertRow not possible while data is filtered");
     69
     70      originalData.InsertRow(rowIndex);
    5771    }
    5872
    5973    public void DeleteRow(int rowIndex) {
    60       ReadOnlyOnFilterData.DeleteRow(rowIndex);
     74      if (IsFiltered)
     75        throw new InvalidOperationException("DeleteRow not possible while data is filtered");
     76
     77      originalData.DeleteRow(rowIndex);
    6178    }
    6279
    6380    public void InsertColumn<T>(string variableName, int columnIndex) {
    64       ReadOnlyOnFilterData.InsertColumn<T>(variableName, columnIndex);
     81      if (IsFiltered)
     82        throw new InvalidOperationException("InsertColumn not possible while data is filtered");
     83
     84      originalData.InsertColumn<T>(variableName, columnIndex);
    6585    }
    6686
    6787    public void DeleteColumn(int columnIndex) {
    68       ReadOnlyOnFilterData.DeleteColumn(columnIndex);
     88      if (IsFiltered)
     89        throw new InvalidOperationException("DeleteColumn not possible while data is filtered");
     90      originalData.DeleteColumn(columnIndex);
    6991    }
    7092
     
    153175    }
    154176
    155     public ITransactionalPreprocessingData ReadOnlyOnFilterData {
    156       get {
    157         if (IsFiltered)
    158           throw new InvalidOperationException();
    159 
    160         return originalData;
    161       }
    162     }
     177
     178    public bool IsUndoAvailable {
     179      get { return IsFiltered ? false : originalData.IsUndoAvailable; }
     180    }
     181
    163182
    164183    public bool IsFiltered {
     
    171190    }
    172191
    173     public bool IsUndoAvailable {
    174       get { return IsFiltered ? false : originalData.IsUndoAvailable; }
    175     }
    176192
    177193    public void Undo() {
    178       ReadOnlyOnFilterData.Undo();
     194      if (IsFiltered)
     195        throw new InvalidOperationException("Undo not possible while data is filtered");
     196
     197      originalData.Undo();
    179198    }
    180199
    181200    public void InTransaction(Action action, DataPreprocessingChangedEventType type = DataPreprocessingChangedEventType.Any) {
    182       ReadOnlyOnFilterData.InTransaction(action, type);
     201      if (IsFiltered)
     202        throw new InvalidOperationException("Transaction not possible while data is filtered");
     203      originalData.InTransaction(action, type);
    183204    }
    184205
    185206    public void BeginTransaction(DataPreprocessingChangedEventType type) {
    186       ReadOnlyOnFilterData.BeginTransaction(type);
     207      if (IsFiltered)
     208        throw new InvalidOperationException("Transaction not possible while data is filtered");
     209      originalData.BeginTransaction(type);
    187210    }
    188211
     
    194217
    195218    #region IPreprocessingData Members
    196 
    197 
    198     public void SetSelection(IDictionary<int, IList<int>> selection) {
    199       originalData.SetSelection(selection);
    200     }
    201 
    202     public IDictionary<int, IList<int>> GetSelection() {
    203       return originalData.GetSelection();
    204     }
    205219
    206220    public void ClearSelection() {
Note: See TracChangeset for help on using the changeset viewer.