Index: branches/2839_HiveProjectManagement/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs
===================================================================
--- branches/2839_HiveProjectManagement/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs	(revision 15761)
+++ branches/2839_HiveProjectManagement/HeuristicLab.DataPreprocessing.Views/3.4/DataGridContentView.cs	(revision 16057)
@@ -1,5 +1,5 @@
 ﻿#region License Information
 /* HeuristicLab
- * Copyright (C) 2002-2016 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ * Copyright (C) 2002-2018 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
  *
  * This file is part of HeuristicLab.
@@ -85,5 +85,5 @@
       base.RegisterContentEvents();
       Content.Changed += Content_Changed;
-      Content.FilterLogic.FilterChanged += FilterLogic_FilterChanged;
+      Content.PreprocessingData.FilterChanged += FilterLogic_FilterChanged;
     }
 
@@ -91,5 +91,5 @@
       base.DeregisterContentEvents();
       Content.Changed -= Content_Changed;
-      Content.FilterLogic.FilterChanged -= FilterLogic_FilterChanged;
+      Content.PreprocessingData.FilterChanged -= FilterLogic_FilterChanged;
     }
 
@@ -98,5 +98,5 @@
       searchIterator = null;
       if (findAndReplaceDialog != null && !findAndReplaceDialog.IsDisposed) {
-        if (Content.FilterLogic.IsFiltered) {
+        if (Content.PreprocessingData.IsFiltered) {
           findAndReplaceDialog.DisableReplace();
         } else {
@@ -104,5 +104,5 @@
         }
       }
-      btnReplace.Enabled = !Content.FilterLogic.IsFiltered;
+      btnReplace.Enabled = !Content.PreprocessingData.IsFiltered;
     }
 
@@ -126,5 +126,5 @@
       string errorMessage;
       if (!String.IsNullOrEmpty(e.FormattedValue.ToString())) {
-        if (dataGridView.IsCurrentCellInEditMode && Content.FilterLogic.IsFiltered) {
+        if (dataGridView.IsCurrentCellInEditMode && Content.PreprocessingData.IsFiltered) {
           errorMessage = "A filter is active, you cannot modify data. Press ESC to exit edit mode.";
         } else {
@@ -167,5 +167,5 @@
 
       ReplaceTransaction(() => {
-        Content.PreProcessingData.InTransaction(() => {
+        Content.PreprocessingData.InTransaction(() => {
           for (int row = containsHeader ? 1 : 0; row < values.GetLength(1); row++) {
             for (int col = 0; col < values.GetLength(0); col++) {
@@ -177,5 +177,5 @@
               if (string.IsNullOrWhiteSpace(firstRow[i]))
                 firstRow[i] = string.Format("<{0}>", i);
-            Content.PreProcessingData.RenameColumns(firstRow);
+            Content.PreprocessingData.RenameColumns(firstRow);
           }
         });
@@ -224,5 +224,5 @@
       if (e.Button == MouseButtons.Middle) {
         int newIndex = e.ColumnIndex >= 0 ? e.ColumnIndex : 0;
-        Content.PreProcessingData.InsertColumn<double>(newIndex.ToString(), newIndex);
+        Content.PreprocessingData.InsertColumn<double>(newIndex.ToString(), newIndex);
       } else if (e.Button == MouseButtons.Right && Content.SortableView) {
         SortColumn(e.ColumnIndex);
@@ -235,5 +235,5 @@
         if (e.Button == MouseButtons.Middle) {
           int newIndex = e.RowIndex >= 0 ? e.RowIndex : 0;
-          Content.PreProcessingData.InsertRow(newIndex);
+          Content.PreprocessingData.InsertRow(newIndex);
         }
       }
@@ -248,6 +248,6 @@
     }
 
-    private void btnApplySort_Click(object sender, System.EventArgs e) {
-      Content.ManipulationLogic.ReOrderToIndices(virtualRowIndices);
+    private void btnApplySort_Click(object sender, EventArgs e) {
+      Content.ReOrderToIndices(virtualRowIndices);
       OnContentChanged();
     }
@@ -271,5 +271,5 @@
         searchIterator = null;
         DataGridView.SelectionChanged += DataGridView_SelectionChanged_FindAndReplace;
-        if (Content.FilterLogic.IsFiltered) {
+        if (Content.PreprocessingData.IsFiltered) {
           findAndReplaceDialog.DisableReplace();
         }
@@ -405,8 +405,8 @@
       ComparisonOperation comparisonOperation = findAndReplaceDialog.GetComparisonOperation();
       var foundCells = new Dictionary<int, IList<int>>();
-      for (int i = 0; i < Content.FilterLogic.PreprocessingData.Columns; i++) {
+      for (int i = 0; i < Content.PreprocessingData.Columns; i++) {
         var filters = CreateFilters(match, comparisonOperation, i);
 
-        bool[] filteredRows = Content.FilterLogic.GetFilterResult(filters, true);
+        bool[] filteredRows = GetFilterResult(filters, true);
         var foundIndices = new List<int>();
         for (int idx = 0; idx < filteredRows.Length; ++idx) {
@@ -427,6 +427,23 @@
     }
 
+    private bool[] GetFilterResult(IList<IFilter> filters, bool isAndCombination) {
+      IList<IFilter> activeFilters = filters.Where(f => f.Active && f.ConstraintData != null).ToList();
+
+      if (activeFilters.Count == 0) {
+        return Enumerable.Repeat(false, Content.PreprocessingData.Rows).ToArray(); ;
+      }
+
+      var result = Enumerable.Repeat(!isAndCombination, Content.PreprocessingData.Rows).ToArray();
+      foreach (IFilter filter in activeFilters) {
+        bool[] filterResult = filter.Check();
+        for (int row = 0; row < result.Length; ++row) {
+          result[row] = isAndCombination ? result[row] || filterResult[row] : result[row] && filterResult[row];
+        }
+      }
+      return result;
+    }
+
     private List<IFilter> CreateFilters(string match, ComparisonOperation comparisonOperation, int columnIndex) {
-      IPreprocessingData preprocessingData = Content.FilterLogic.PreprocessingData;
+      IPreprocessingData preprocessingData = Content.PreprocessingData;
       IStringConvertibleValue value;
       if (preprocessingData.VariableHasType<double>(columnIndex)) {
@@ -473,20 +490,20 @@
           switch (findAndReplaceDialog.GetReplaceAction()) {
             case ReplaceAction.Value:
-              Content.ManipulationLogic.ReplaceIndicesByValue(cells, findAndReplaceDialog.GetReplaceText());
+              Content.ReplaceIndicesByString(cells, findAndReplaceDialog.GetReplaceText());
               break;
             case ReplaceAction.Average:
-              Content.ManipulationLogic.ReplaceIndicesByAverageValue(cells, false);
+              Content.ReplaceIndicesByMean(cells, false);
               break;
             case ReplaceAction.Median:
-              Content.ManipulationLogic.ReplaceIndicesByMedianValue(cells, false);
+              Content.ReplaceIndicesByMedianValue(cells, false);
               break;
             case ReplaceAction.Random:
-              Content.ManipulationLogic.ReplaceIndicesByRandomValue(cells, false);
+              Content.ReplaceIndicesByRandomValue(cells, false);
               break;
             case ReplaceAction.MostCommon:
-              Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(cells, false);
+              Content.ReplaceIndicesByMode(cells, false);
               break;
             case ReplaceAction.Interpolation:
-              Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(cells);
+              Content.ReplaceIndicesByLinearInterpolationOfNeighbours(cells);
               break;
           }
@@ -506,5 +523,4 @@
 
     #endregion FindAndReplaceDialog
-
     private void dataGridView_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) {
       if (Content == null) return;
@@ -531,10 +547,5 @@
             medianToolStripMenuItem_Selection.Enabled =
             randomToolStripMenuItem_Column.Enabled =
-            randomToolStripMenuItem_Selection.Enabled = !Content.PreProcessingData.AreAllStringColumns(columnIndices);
-
-          smoothingToolStripMenuItem_Column.Enabled =
-            interpolationToolStripMenuItem_Column.Enabled = !dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, 0])
-            && !dataGridView.SelectedCells.Contains(dataGridView[e.ColumnIndex, Content.Rows - 1])
-            && !Content.PreProcessingData.AreAllStringColumns(columnIndices);
+            randomToolStripMenuItem_Selection.Enabled = !Content.PreprocessingData.AreAllStringColumns(columnIndices);
 
           replaceValueOverColumnToolStripMenuItem.Visible = true;
@@ -547,5 +558,5 @@
       base.dataGridView_KeyDown(sender, e);
       //data is in read only mode....
-      if (Content.FilterLogic.IsFiltered) return;
+      if (Content.PreprocessingData.IsFiltered) return;
 
       if (e.KeyCode == Keys.Delete) {
@@ -581,8 +592,7 @@
       }
 
-      foreach (var selectedCell in dataGridView.SelectedCells) {
-        var cell = (DataGridViewCell)selectedCell;
+      foreach (DataGridViewCell cell in dataGridView.SelectedCells) {
         if (!selectedCells.ContainsKey(cell.ColumnIndex))
-          selectedCells.Add(cell.ColumnIndex, new List<int>(1024));
+          selectedCells.Add(cell.ColumnIndex, new List<int>());
         selectedCells[cell.ColumnIndex].Add(cell.RowIndex);
       }
@@ -591,16 +601,8 @@
     }
 
-    private void StartReplacing() {
+    private void ReplaceTransaction(Action action) {
       SuspendRepaint();
-    }
-
-    private void StopReplacing() {
+      action();
       ResumeRepaint(true);
-    }
-
-    private void ReplaceTransaction(Action action) {
-      StartReplacing();
-      action();
-      StopReplacing();
     }
 
@@ -616,13 +618,12 @@
 
     #region ContextMenu Events
-
     private void ReplaceWithAverage_Column_Click(object sender, EventArgs e) {
       ReplaceTransaction(() => {
-        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), false);
+        Content.ReplaceIndicesByMean(GetSelectedCells(), false);
       });
     }
     private void ReplaceWithAverage_Selection_Click(object sender, EventArgs e) {
       ReplaceTransaction(() => {
-        Content.ManipulationLogic.ReplaceIndicesByAverageValue(GetSelectedCells(), true);
+        Content.ReplaceIndicesByMean(GetSelectedCells(), true);
       });
     }
@@ -630,10 +631,10 @@
     private void ReplaceWithMedian_Column_Click(object sender, EventArgs e) {
       ReplaceTransaction(() => {
-        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), false);
+        Content.ReplaceIndicesByMedianValue(GetSelectedCells(), false);
       });
     }
     private void ReplaceWithMedian_Selection_Click(object sender, EventArgs e) {
       ReplaceTransaction(() => {
-        Content.ManipulationLogic.ReplaceIndicesByMedianValue(GetSelectedCells(), true);
+        Content.ReplaceIndicesByMedianValue(GetSelectedCells(), true);
       });
     }
@@ -641,10 +642,10 @@
     private void ReplaceWithRandom_Column_Click(object sender, EventArgs e) {
       ReplaceTransaction(() => {
-        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), false);
+        Content.ReplaceIndicesByRandomValue(GetSelectedCells(), false);
       });
     }
     private void ReplaceWithRandom_Selection_Click(object sender, EventArgs e) {
       ReplaceTransaction(() => {
-        Content.ManipulationLogic.ReplaceIndicesByRandomValue(GetSelectedCells(), true);
+        Content.ReplaceIndicesByRandomValue(GetSelectedCells(), true);
       });
     }
@@ -652,10 +653,10 @@
     private void ReplaceWithMostCommon_Column_Click(object sender, EventArgs e) {
       ReplaceTransaction(() => {
-        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), false);
+        Content.ReplaceIndicesByMode(GetSelectedCells(), false);
       });
     }
     private void ReplaceWithMostCommon_Selection_Click(object sender, EventArgs e) {
       ReplaceTransaction(() => {
-        Content.ManipulationLogic.ReplaceIndicesByMostCommonValue(GetSelectedCells(), true);
+        Content.ReplaceIndicesByMode(GetSelectedCells(), true);
       });
     }
@@ -663,11 +664,5 @@
     private void ReplaceWithInterpolation_Column_Click(object sender, EventArgs e) {
       ReplaceTransaction(() => {
-        Content.ManipulationLogic.ReplaceIndicesByLinearInterpolationOfNeighbours(GetSelectedCells());
-      });
-    }
-
-    private void ReplaceWithSmoothing_Selection_Click(object sender, EventArgs e) {
-      ReplaceTransaction(() => {
-        Content.ManipulationLogic.ReplaceIndicesBySmoothing(GetSelectedCells());
+        Content.ReplaceIndicesByLinearInterpolationOfNeighbours(GetSelectedCells());
       });
     }
@@ -675,9 +670,9 @@
 
     private void addRowButton_Click(object sender, EventArgs e) {
-      Content.PreProcessingData.InsertRow(Content.Rows);
+      Content.PreprocessingData.InsertRow(Content.Rows);
     }
 
     private void addColumnButton_Click(object sender, EventArgs e) {
-      Content.PreProcessingData.InsertColumn<double>(Content.Columns.ToString(), Content.Columns);
+      Content.PreprocessingData.InsertColumn<double>(Content.Columns.ToString(), Content.Columns);
     }
 
@@ -686,5 +681,5 @@
 
       if (renameDialog.ShowDialog(this) == DialogResult.OK) {
-        Content.PreProcessingData.RenameColumns(renameDialog.ColumnNames);
+        Content.PreprocessingData.RenameColumns(renameDialog.ColumnNames);
       }
     }
@@ -693,6 +688,6 @@
       foreach (DataGridViewColumn column in DataGridView.Columns) {
         var variable = column.HeaderText;
-        bool isInputTarget = Content.PreProcessingData.InputVariables.Contains(variable)
-          || Content.PreProcessingData.TargetVariable == variable;
+        bool isInputTarget = Content.PreprocessingData.InputVariables.Contains(variable)
+          || Content.PreprocessingData.TargetVariable == variable;
         column.Visible = isInputTarget;
       }
@@ -710,4 +705,8 @@
       }
     }
+
+    private void shuffleAllButton_Click(object sender, EventArgs e) {
+      Content.Shuffle(shuffleWithinPartitionsCheckBox.Checked);
+    }
   }
 }
