Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10174


Ignore:
Timestamp:
12/02/13 15:13:37 (11 years ago)
Author:
mkommend
Message:

#1758: Added check of target and inputvariables of dropped ProblemData.

Location:
trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/ClassificationSolutionView.cs

    r10173 r10174  
    2020#endregion
    2121
     22using System;
    2223using System.Windows.Forms;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.MainForm;
     26using HeuristicLab.PluginInfrastructure;
    2527
    2628namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    5153    }
    5254    #endregion
     55
     56    protected override bool CheckCompatibilityOfProblemData(IDataAnalysisProblemData problemData) {
     57      IClassificationProblemData classificationProblemData = (IClassificationProblemData)problemData;
     58
     59      if (!classificationProblemData.TargetVariable.Equals(Content.ProblemData.TargetVariable)) {
     60        string message = "The target variables are not matching. Old target variable: '"
     61                         + Content.ProblemData.TargetVariable
     62                         + "'. New targetvariable: '" + classificationProblemData.TargetVariable + "'";
     63        ErrorHandling.ShowErrorDialog(this, new InvalidOperationException(message));
     64        return false;
     65      }
     66
     67      return base.CheckCompatibilityOfProblemData(problemData);
     68    }
    5369  }
    5470}
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.cs

    r10173 r10174  
    2525using System.Drawing;
    2626using System.Linq;
     27using System.Text;
    2728using System.Windows.Forms;
    2829using HeuristicLab.Core;
     
    205206
    206207    protected override void itemsListView_DragDrop(object sender, DragEventArgs e) {
    207       if (e.Effect != DragDropEffects.None) {
    208         var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    209         if (dropData is IDataAnalysisProblemData) {
    210           DataAnalysisProblemData problemData = (DataAnalysisProblemData)dropData;
    211           Content.ProblemData = (DataAnalysisProblemData)problemData.Clone();
    212         } else if (dropData is IDataAnalysisProblem) {
    213           IDataAnalysisProblemData problemData = ((IDataAnalysisProblem)dropData).ProblemData;
    214           Content.ProblemData = (IDataAnalysisProblemData)problemData.Clone();
    215         } else if (dropData is IValueParameter) {
    216           var param = (IValueParameter)dropData;
    217           DataAnalysisProblemData problemData = param.Value as DataAnalysisProblemData;
    218           if (problemData != null)
    219             Content.ProblemData = (DataAnalysisProblemData)problemData.Clone();
    220         }
    221       }
     208      if (e.Effect == DragDropEffects.None) return;
     209
     210      IDataAnalysisProblemData problemData = null;
     211      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     212      if (dropData is IDataAnalysisProblemData)
     213        problemData = (IDataAnalysisProblemData)dropData;
     214      else if (dropData is IDataAnalysisProblem)
     215        problemData = ((IDataAnalysisProblem)dropData).ProblemData;
     216      else if (dropData is IValueParameter) {
     217        var param = (IValueParameter)dropData;
     218        problemData = param.Value as DataAnalysisProblemData;
     219      }
     220      if (problemData == null) return;
     221      CheckCompatibilityOfProblemData(problemData);
     222      Content.ProblemData = (IDataAnalysisProblemData)problemData.Clone();
     223    }
     224    #endregion
     225
     226    #region load problem data
     227    protected virtual bool CheckCompatibilityOfProblemData(IDataAnalysisProblemData problemData) {
     228      StringBuilder message = new StringBuilder();
     229      List<string> variables = problemData.InputVariables.Select(x => x.Value).ToList();
     230      foreach (var item in Content.ProblemData.InputVariables.CheckedItems) {
     231        if (!variables.Contains(item.Value.Value))
     232          message.AppendLine("Input variable '" + item.Value.Value + "' is not in the new problem data.");
     233      }
     234
     235      if (message.Length != 0) {
     236        ErrorHandling.ShowErrorDialog(this, new InvalidOperationException(message.ToString()));
     237        return false;
     238      }
     239      return true;
    222240    }
    223241    #endregion
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs

    r10173 r10174  
    2020#endregion
    2121
     22using System;
    2223using System.Windows.Forms;
    2324using HeuristicLab.Core;
    2425using HeuristicLab.MainForm;
     26using HeuristicLab.PluginInfrastructure;
    2527
    2628namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    5153    }
    5254    #endregion
     55
     56    protected override bool CheckCompatibilityOfProblemData(IDataAnalysisProblemData problemData) {
     57      IRegressionProblemData regressionProblemData = (IRegressionProblemData)problemData;
     58
     59      if (!regressionProblemData.TargetVariable.Equals(Content.ProblemData.TargetVariable)) {
     60        string message = "The target variables are not matching. Old target variable: '"
     61                         + Content.ProblemData.TargetVariable
     62                         + "'. New targetvariable: '" + regressionProblemData.TargetVariable + "'";
     63        ErrorHandling.ShowErrorDialog(this, new InvalidOperationException(message));
     64        return false;
     65      }
     66
     67      return base.CheckCompatibilityOfProblemData(problemData);
     68    }
    5369  }
    5470}
Note: See TracChangeset for help on using the changeset viewer.