Index: /branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/StatisticalTestsView.cs
===================================================================
--- /branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/StatisticalTestsView.cs	(revision 11695)
+++ /branches/StatisticalTesting/HeuristicLab.Analysis.Statistics/3.3/StatisticalTestsView.cs	(revision 11696)
@@ -91,6 +91,6 @@
     protected override void RegisterContentEvents() {
       base.RegisterContentEvents();
-      Content.ItemsAdded += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
-      Content.ItemsRemoved += new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
+      Content.ColumnsChanged += Content_ColumnsChanged;
+      Content.RowsChanged += Content_RowsChanged;
       Content.CollectionReset += new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
       Content.UpdateOfRunsInProgressChanged += Content_UpdateOfRunsInProgressChanged;
@@ -99,19 +99,19 @@
     protected override void DeregisterContentEvents() {
       base.DeregisterContentEvents();
-      Content.ItemsAdded -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsAdded);
-      Content.ItemsRemoved -= new CollectionItemsChangedEventHandler<IRun>(Content_ItemsRemoved);
+      Content.ColumnsChanged -= Content_ColumnsChanged;
+      Content.RowsChanged -= Content_RowsChanged;
       Content.CollectionReset -= new CollectionItemsChangedEventHandler<IRun>(Content_CollectionReset);
       Content.UpdateOfRunsInProgressChanged -= Content_UpdateOfRunsInProgressChanged;
     }
 
+    void Content_RowsChanged(object sender, EventArgs e) {
+      RebuildDataTable();
+    }
+
+    void Content_ColumnsChanged(object sender, EventArgs e) {
+      RebuildDataTable();
+    }
+
     private void Content_CollectionReset(object sender, CollectionItemsChangedEventArgs<IRun> e) {
-      RebuildDataTable();
-    }
-
-    private void Content_ItemsRemoved(object sender, CollectionItemsChangedEventArgs<IRun> e) {
-      RebuildDataTable();
-    }
-
-    private void Content_ItemsAdded(object sender, CollectionItemsChangedEventArgs<IRun> e) {
       RebuildDataTable();
     }
@@ -301,9 +301,7 @@
 
     private void CalculateValuesAsync(string groupName) {
-      TestAllGroups();
-      CalculateNormality();
-      CalculateNormalityDetails();
+      CalculateAllGroupsTest();
+      CalculateNormalityTest();
       CalculatePairwiseTest(groupName);
-      CalculatePairwiseTestDetails(groupName);
 
       MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
@@ -320,10 +318,9 @@
     private void CalculatePairwiseAsync(string groupName) {
       CalculatePairwiseTest(groupName);
-      CalculatePairwiseTestDetails(groupName);
 
       MainFormManager.GetMainForm<HeuristicLab.MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(pairwiseTestGroupBox);
     }
 
-    private void TestAllGroups() {
+    private void CalculateAllGroupsTest() {
       double pval = KruskalWallisTest.Test(data);
       pValTextBox.Text = pval.ToString();
@@ -341,14 +338,18 @@
     }
 
-    private void CalculateNormality() {
+    private void CalculateNormalityTest() {
       double val;
       List<double> res = new List<double>();
+      DoubleMatrix pValsMatrix = new DoubleMatrix(1, stringConvertibleMatrixView.Content.Columns);
+      pValsMatrix.ColumnNames = stringConvertibleMatrixView.Content.ColumnNames;
+      pValsMatrix.RowNames = new string[] { "p-Value" };
 
       for (int i = 0; i < data.Length; i++) {
         alglib.jarqueberatest(data[i], data[i].Length, out val);
         res.Add(val);
-      }
-
-      // p-value is below significance level and thus the null hypothesis (data is normally distributed) is rejected. 
+        pValsMatrix[0, i] = val;
+      }
+
+      // p-value is below significance level and thus the null hypothesis (data is normally distributed) is rejected
       if (res.Any(x => x < significanceLevel)) {
         this.Invoke(new Action(() => {
@@ -361,16 +362,4 @@
           normalityTextLabel.Text = "All sample data is normally distributed";
         }));
-      }
-    }
-
-    private void CalculateNormalityDetails() {
-      DoubleMatrix pValsMatrix = new DoubleMatrix(1, stringConvertibleMatrixView.Content.Columns);
-      pValsMatrix.ColumnNames = stringConvertibleMatrixView.Content.ColumnNames;
-      pValsMatrix.RowNames = new string[] { "p-Value" };
-
-      double val;
-      for (int i = 0; i < data.Length; i++) {
-        alglib.jarqueberatest(data[i], data[i].Length, out val);
-        pValsMatrix[0, i] = val;
       }
 
@@ -381,29 +370,9 @@
     }
 
-    private void CalculatePairwiseTest(string groupName) {
-      int colIndex = 0;
-      IEnumerable<string> columnNames = null;
-      this.Invoke(new Action(() => { columnNames = stringConvertibleMatrixView.Content.ColumnNames; }));
-
-      foreach (string col in columnNames) {
-        if (col == groupName) {
-          break;
-        }
-        colIndex++;
-      }
-
-      double[][] newData = FilterDataForPairwiseTest(colIndex);
-      int cnt = 0;
-      for (int i = 0; i < newData.Length; i++) {
-        double mwuBothtails = PairwiseTest.MannWhitneyUTest(data[colIndex], newData[i]);
-        if (mwuBothtails > significanceLevel) {
-          cnt++;
-        }
-      }
-
-      double ratio = ((double)cnt) / (data.Length - 1) * 100.0;
+    private void ShowPairwiseResult(int nrOfEqualDistributions) {
+      double ratio = ((double)nrOfEqualDistributions) / (data.Length - 1) * 100.0;
       equalDistsTextBox.Text = ratio.ToString() + " %";
 
-      if (cnt == 0) {
+      if (nrOfEqualDistributions == 0) {
         this.Invoke(new Action(() => {
           pairwiseLabel.Image = HeuristicLab.Analysis.Statistics.Resources.Default;
@@ -416,4 +385,58 @@
         }));
       }
+    }
+
+    private void CalculatePairwiseTest(string groupName) {
+      var columnNames = stringConvertibleMatrixView.Content.ColumnNames.ToList();
+      int colIndex = columnNames.IndexOf(groupName);
+      columnNames = columnNames.Where(x => x != groupName).ToList();
+
+      double[][] newData = FilterDataForPairwiseTest(colIndex);
+
+      var rowNames = new string[] { "p-Value of Mann-Whitney U", "Adjusted p-Value of Mann-Whitney U", 
+            "p-Value of T-Test", "Adjusted p-Value of T-Test", "Cohen's d", "Hedges' g" };
+
+      DoubleMatrix pValsMatrix = new DoubleMatrix(rowNames.Length, columnNames.Count());
+      pValsMatrix.ColumnNames = columnNames;
+      pValsMatrix.RowNames = rowNames;
+
+      double mwuBothTails;
+      double tTestBothTails;
+      double[] mwuPValues = new double[newData.Length];
+      double[] tTestPValues = new double[newData.Length];
+      bool[] decision = null;
+      double[] adjustedMwuPValues = null;
+      double[] adjustedTtestPValues = null;
+      int cnt = 0;
+
+      for (int i = 0; i < newData.Length; i++) {
+        mwuBothTails = PairwiseTest.MannWhitneyUTest(data[colIndex], newData[i]);
+        tTestBothTails = PairwiseTest.TTest(data[colIndex], newData[i]);
+        mwuPValues[i] = mwuBothTails;
+        tTestPValues[i] = tTestBothTails;
+
+        if (mwuBothTails > significanceLevel) {
+          cnt++;
+        }
+      }
+
+      adjustedMwuPValues = BonferroniHolm.Calculate(significanceLevel, mwuPValues, out decision);
+      adjustedTtestPValues = BonferroniHolm.Calculate(significanceLevel, tTestPValues, out decision);
+
+      for (int i = 0; i < newData.Length; i++) {
+        pValsMatrix[0, i] = mwuPValues[i];
+        pValsMatrix[1, i] = adjustedMwuPValues[i];
+        pValsMatrix[2, i] = tTestPValues[i];
+        pValsMatrix[3, i] = adjustedTtestPValues[i];
+        pValsMatrix[4, i] = SampleSizeDetermination.CalculateCohensD(data[colIndex], newData[i]);
+        pValsMatrix[5, i] = SampleSizeDetermination.CalculateHedgesG(data[colIndex], newData[i]);
+      }
+
+      this.Invoke(new Action(() => {
+        pairwiseStringConvertibleMatrixView.Content = pValsMatrix;
+        pairwiseStringConvertibleMatrixView.DataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
+      }));
+
+      ShowPairwiseResult(cnt);
     }
 
@@ -447,60 +470,4 @@
     }
 
-    private void CalculatePairwiseTestDetails(string groupName) {
-      int colIndex = 0;
-      IEnumerable<string> columnNames = null;
-      this.Invoke(new Action(() => { columnNames = stringConvertibleMatrixView.Content.ColumnNames; }));
-
-      foreach (string col in columnNames) {
-        if (col == groupName) {
-          break;
-        }
-        colIndex++;
-      }
-
-      double[][] newData = FilterDataForPairwiseTest(colIndex);
-
-      columnNames = columnNames.Where(x => x != groupName).ToList();
-
-      var rowNames = new string[] { "p-Value of Mann-Whitney U", "Adjusted p-Value of Mann-Whitney U", 
-            "p-Value of T-Test", "Adjusted p-Value of T-Test", "Cohen's d", "Hedges' g" };
-
-      DoubleMatrix pValsMatrix = new DoubleMatrix(rowNames.Length, columnNames.Count());
-      pValsMatrix.ColumnNames = columnNames;
-      pValsMatrix.RowNames = rowNames;
-
-      double mwuBothtails;
-      double tTestBothTails;
-      double[] mwuPValues = new double[newData.Length];
-      double[] tTestPValues = new double[newData.Length];
-      bool[] decision = null;
-      double[] adjustedMwuPValues = null;
-      double[] adjustedTtestPValues = null;
-
-      for (int i = 0; i < newData.Length; i++) {
-        mwuBothtails = PairwiseTest.MannWhitneyUTest(data[colIndex], newData[i]);
-        tTestBothTails = PairwiseTest.TTest(data[colIndex], newData[i]);
-        mwuPValues[i] = mwuBothtails;
-        tTestPValues[i] = tTestBothTails;
-      }
-
-      adjustedMwuPValues = BonferroniHolm.Calculate(significanceLevel, mwuPValues, out decision);
-      adjustedTtestPValues = BonferroniHolm.Calculate(significanceLevel, tTestPValues, out decision);
-
-      for (int i = 0; i < newData.Length; i++) {
-        pValsMatrix[0, i] = mwuPValues[i];
-        pValsMatrix[1, i] = adjustedMwuPValues[i];
-        pValsMatrix[2, i] = tTestPValues[i];
-        pValsMatrix[3, i] = adjustedTtestPValues[i];
-        pValsMatrix[4, i] = SampleSizeDetermination.CalculateCohensD(data[colIndex], newData[i]);
-        pValsMatrix[5, i] = SampleSizeDetermination.CalculateHedgesG(data[colIndex], newData[i]);
-      }
-
-      this.Invoke(new Action(() => {
-        pairwiseStringConvertibleMatrixView.Content = pValsMatrix;
-        pairwiseStringConvertibleMatrixView.DataGridView.AutoResizeColumns(DataGridViewAutoSizeColumnsMode.AllCells);
-      }));
-    }
-
     private void openBoxPlotToolStripMenuItem_Click(object sender, EventArgs e) {
       RunCollectionBoxPlotView boxplotView = new RunCollectionBoxPlotView();
