- Timestamp:
- 05/07/14 11:04:44 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified branches/DataPreprocessing/HeuristicLab.DataPreprocessing/3.3/Implementations/TransactionalPreprocessingData.cs ¶
r10740 r10805 50 50 private IList<PDSnapshot> undoHistory; 51 51 52 private int transactionDepth = 0; 52 private Stack<DataPreprocessingChangedEventType> eventStack = new Stack<DataPreprocessingChangedEventType>(); 53 54 private DataPreprocessingChangedEventType lastOccuredChangedType = DataPreprocessingChangedEventType.Any; 55 56 public bool IsInTransaction { get { return eventStack.Count > 0; } } 53 57 54 58 public TransactionalPreprocessingData(IDataAnalysisProblemData problemData) … … 63 67 64 68 private void SaveSnapshot(DataPreprocessingChangedEventType changedType, int column, int row) { 65 if ( transactionDepth> 0) return;69 if (eventStack.Count > 0) return; 66 70 67 71 PDSnapshot currentSnapshot = new PDSnapshot(); … … 92 96 SaveSnapshot(DataPreprocessingChangedEventType.ChangeItem, columnIndex, rowIndex); 93 97 base.SetCell<T>(columnIndex, rowIndex, value); 94 if ( transactionDepth <= 0)98 if (!IsInTransaction) 95 99 OnChanged(DataPreprocessingChangedEventType.ChangeItem, columnIndex, rowIndex); 96 100 } … … 99 103 SaveSnapshot(DataPreprocessingChangedEventType.ChangeColumn, columnIndex, -1); 100 104 base.SetValues<T>(columnIndex, values); 101 if ( transactionDepth <= 0)105 if (!IsInTransaction) 102 106 OnChanged(DataPreprocessingChangedEventType.ChangeColumn, columnIndex, -1); 103 107 } … … 106 110 SaveSnapshot(DataPreprocessingChangedEventType.DeleteRow, -1, rowIndex); 107 111 base.InsertRow(rowIndex); 108 if ( transactionDepth <= 0)112 if (!IsInTransaction) 109 113 OnChanged(DataPreprocessingChangedEventType.AddRow, -1, rowIndex); 110 114 } … … 113 117 SaveSnapshot(DataPreprocessingChangedEventType.AddRow, -1, rowIndex); 114 118 base.DeleteRow(rowIndex); 115 if ( transactionDepth <= 0)119 if (!IsInTransaction) 116 120 OnChanged(DataPreprocessingChangedEventType.DeleteRow, -1, rowIndex); 117 121 } … … 120 124 SaveSnapshot(DataPreprocessingChangedEventType.DeleteColumn, columnIndex, -1); 121 125 base.InsertColumn<T>(variableName, columnIndex); 122 if ( transactionDepth <= 0)126 if (!IsInTransaction) 123 127 OnChanged(DataPreprocessingChangedEventType.AddColumn, columnIndex, -1); 124 128 } … … 127 131 SaveSnapshot(DataPreprocessingChangedEventType.AddColumn, columnIndex, -1); 128 132 base.DeleteColumn(columnIndex); 129 if ( transactionDepth <= 0)133 if (!IsInTransaction) 130 134 OnChanged(DataPreprocessingChangedEventType.DeleteColumn, columnIndex, -1); 131 135 } … … 166 170 public void BeginTransaction(DataPreprocessingChangedEventType type) { 167 171 SaveSnapshot(type, -1, -1); 168 transactionDepth++;172 eventStack.Push(type); 169 173 } 170 174 171 175 public void EndTransaction() { 172 transactionDepth--; 173 if (transactionDepth < 0) 176 if (eventStack.Count == 0) 174 177 throw new InvalidOperationException("There is no open transaction that can be ended."); 175 if (transactionDepth == 0) 176 OnChanged(DataPreprocessingChangedEventType.Any, -1, -1); 178 179 var @event = eventStack.Pop(); 180 OnChanged(@event, -1, -1); 177 181 } 178 182
Note: See TracChangeset
for help on using the changeset viewer.