Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/05/14 14:48:13 (10 years ago)
Author:
pfleck
Message:
  • merged trunk
Location:
branches/DataPreprocessing
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • branches/DataPreprocessing

  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views

  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/ClassificationEnsembleSolutionView.cs

    r9456 r10538  
    3737    }
    3838
     39    protected override void SetEnabledStateOfControls() {
     40      base.SetEnabledStateOfControls();
     41      //loading of problemdata is currently not support for ensemble solutions
     42      loadProblemDataButton.Enabled = false;
     43      loadProblemDataButton.Visible = false;
     44    }
     45
    3946    protected override void OnContentChanged() {
    4047      base.OnContentChanged();
     
    4754        var droppedData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    4855        if (droppedData is IValueParameter) droppedData = ((IValueParameter)droppedData).Value;
     56        else if (droppedData is IClassificationProblem) droppedData = ((IClassificationProblem)droppedData).ProblemData;
    4957
    5058        ClassificationEnsembleProblemData ensembleProblemData = droppedData as ClassificationEnsembleProblemData;
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/ClassificationSolutionView.cs

    r9456 r10538  
    2020#endregion
    2121
     22using System;
    2223using System.Windows.Forms;
     24using HeuristicLab.Common;
    2325using HeuristicLab.Core;
    2426using HeuristicLab.MainForm;
     27using HeuristicLab.PluginInfrastructure;
    2528
    2629namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    4346
    4447      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    45       if (dropData is ClassificationProblemData) validDragOperation = true;
     48      if (dropData is IClassificationProblemData) validDragOperation = true;
     49      else if (dropData is IClassificationProblem) validDragOperation = true;
    4650      else if (dropData is IValueParameter) {
    4751        var param = (IValueParameter)dropData;
     
    5054    }
    5155    #endregion
     56
     57    protected override bool CheckCompatibilityOfProblemData(IDataAnalysisProblemData problemData) {
     58      IClassificationProblemData classificationProblemData = problemData as IClassificationProblemData;
     59      if (classificationProblemData == null) {
     60        ErrorHandling.ShowErrorDialog(this, new ArgumentException("The problem data is no classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided."));
     61        return false;
     62      }
     63
     64      if (!classificationProblemData.TargetVariable.Equals(Content.ProblemData.TargetVariable)) {
     65        string message = "The target variables are not matching. Old target variable: '"
     66                         + Content.ProblemData.TargetVariable
     67                         + "'. New targetvariable: '" + classificationProblemData.TargetVariable + "'";
     68        ErrorHandling.ShowErrorDialog(this, new InvalidOperationException(message));
     69        return false;
     70      }
     71
     72      return base.CheckCompatibilityOfProblemData(problemData);
     73    }
    5274  }
    5375}
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/ClusteringSolutionView.cs

    r9456 r10538  
    4343
    4444      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    45       if (dropData is ClusteringProblemData) validDragOperation = true;
     45      if (dropData is IClusteringProblemData) validDragOperation = true;
     46      else if (dropData is IClusteringProblem) validDragOperation = true;
    4647      else if (dropData is IValueParameter) {
    4748        var param = (IValueParameter)dropData;
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.Designer.cs

    r9973 r10538  
    1919 */
    2020#endregion
     21
     22
    2123namespace HeuristicLab.Problems.DataAnalysis.Views {
    2224  partial class DataAnalysisSolutionView {
     
    4648      this.exportButton = new System.Windows.Forms.Button();
    4749      this.exportFileDialog = new System.Windows.Forms.SaveFileDialog();
     50      this.loadProblemDataButton = new System.Windows.Forms.Button();
     51      this.loadProblemDataFileDialog = new System.Windows.Forms.OpenFileDialog();
    4852      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    4953      this.splitContainer.Panel1.SuspendLayout();
     
    5963      // splitContainer.Panel2
    6064      //
     65      this.splitContainer.Panel2.Controls.Add(this.loadProblemDataButton);
    6166      this.splitContainer.Panel2.Controls.Add(this.exportButton);
    6267      //
     
    7681      //
    7782      this.exportButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
    78       this.exportButton.Location = new System.Drawing.Point(215, 4);
     83      this.exportButton.Location = new System.Drawing.Point(194, 3);
    7984      this.exportButton.Name = "exportButton";
    80       this.exportButton.Size = new System.Drawing.Size(54, 23);
     85      this.exportButton.Size = new System.Drawing.Size(75, 24);
    8186      this.exportButton.TabIndex = 6;
    8287      this.exportButton.Text = "Export";
    8388      this.exportButton.UseVisualStyleBackColor = true;
    8489      this.exportButton.Click += new System.EventHandler(this.exportButton_Click);
     90      //
     91      // loadProblemDataButton
     92      //
     93      this.loadProblemDataButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)));
     94      this.loadProblemDataButton.Location = new System.Drawing.Point(3, 3);
     95      this.loadProblemDataButton.Name = "loadProblemDataButton";
     96      this.loadProblemDataButton.Size = new System.Drawing.Size(75, 24);
     97      this.loadProblemDataButton.TabIndex = 7;
     98      this.loadProblemDataButton.Text = "Load Data";
     99      this.loadProblemDataButton.UseVisualStyleBackColor = true;
     100      this.loadProblemDataButton.Click += new System.EventHandler(this.loadProblemDataButton_Click);
     101      this.toolTip.SetToolTip(this.loadProblemDataButton, "Load new data");
     102      //
     103      // openFileDialog
     104      //
     105      this.loadProblemDataFileDialog.Filter = "HL files|*.hl";
     106      this.loadProblemDataFileDialog.Title = "Load new ProblemData or Problem...";
    85107      //
    86108      // DataAnalysisSolutionView
     
    102124    private System.Windows.Forms.SaveFileDialog exportFileDialog;
    103125    protected System.Windows.Forms.Button exportButton;
     126    protected System.Windows.Forms.Button loadProblemDataButton;
     127    protected System.Windows.Forms.OpenFileDialog loadProblemDataFileDialog;
    104128
    105129  }
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.cs

    r9974 r10538  
    2525using System.Drawing;
    2626using System.Linq;
     27using System.Text;
    2728using System.Windows.Forms;
    2829using HeuristicLab.Core;
     
    3132using HeuristicLab.Optimization;
    3233using HeuristicLab.Optimization.Views;
     34using HeuristicLab.Persistence.Default.Xml;
    3335using HeuristicLab.PluginInfrastructure;
    3436
     
    5456      if (Content == null) {
    5557        exportButton.Enabled = false;
     58        loadProblemDataButton.Enabled = false;
    5659      } else {
    5760        exportButton.Enabled = !Locked;
     61        loadProblemDataButton.Enabled = !Locked;
    5862      }
    5963    }
     
    127131    }
    128132
     133    protected virtual void loadProblemDataButton_Click(object sender, EventArgs e) {
     134      if (loadProblemDataFileDialog.ShowDialog(this) != DialogResult.OK) return;
     135      object hlFile = XmlParser.Deserialize(loadProblemDataFileDialog.FileName);
     136
     137      IDataAnalysisProblemData problemData = null;
     138      if (hlFile is IDataAnalysisProblemData) {
     139        problemData = (IDataAnalysisProblemData)hlFile;
     140      } else if (hlFile is IDataAnalysisProblem) {
     141        problemData = ((IDataAnalysisProblem)hlFile).ProblemData;
     142      } else if (hlFile is IDataAnalysisSolution) {
     143        problemData = ((IDataAnalysisSolution)hlFile).ProblemData;
     144      }
     145
     146      if (problemData == null) {
     147        ErrorHandling.ShowErrorDialog(this, new NullReferenceException("The problem data is null." + Environment.NewLine
     148                                      + "The .hl-file contains no DataAnalysisProblemData or DataAnylsisProblem."));
     149        return;
     150      }
     151
     152      if (CheckCompatibilityOfProblemData(problemData)) {
     153        var solution = (IDataAnalysisSolution)Content.Clone();
     154        solution.ProblemData = problemData;
     155        solution.Name += " with loaded problem data (" + loadProblemDataFileDialog + ")";
     156        MainFormManager.MainForm.ShowContent(solution);
     157      }
     158    }
    129159
    130160    private void exportButton_Click(object sender, EventArgs e) {
     
    197227      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    198228      if (dropData is DataAnalysisProblemData) validDragOperation = true;
     229      else if (dropData is IDataAnalysisProblem) validDragOperation = true;
    199230      else if (dropData is IValueParameter) {
    200231        var param = (IValueParameter)dropData;
    201         if (param.Value is DataAnalysisProblemData) validDragOperation = true;
     232        if (param.Value is IDataAnalysisProblemData) validDragOperation = true;
    202233      }
    203234    }
    204235
    205236    protected override void itemsListView_DragDrop(object sender, DragEventArgs e) {
    206       if (e.Effect != DragDropEffects.None) {
    207         var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    208         if (dropData is DataAnalysisProblemData) {
    209           DataAnalysisProblemData problemData = (DataAnalysisProblemData)dropData;
    210           Content.ProblemData = (DataAnalysisProblemData)problemData.Clone();
    211         } else if (dropData is IValueParameter) {
    212           var param = (IValueParameter)dropData;
    213           DataAnalysisProblemData problemData = param.Value as DataAnalysisProblemData;
    214           if (problemData != null)
    215             Content.ProblemData = (DataAnalysisProblemData)problemData.Clone();
    216         }
    217       }
     237      if (e.Effect == DragDropEffects.None) return;
     238
     239      IDataAnalysisProblemData problemData = null;
     240      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     241      if (dropData is IDataAnalysisProblemData)
     242        problemData = (IDataAnalysisProblemData)dropData;
     243      else if (dropData is IDataAnalysisProblem)
     244        problemData = ((IDataAnalysisProblem)dropData).ProblemData;
     245      else if (dropData is IValueParameter) {
     246        var param = (IValueParameter)dropData;
     247        problemData = param.Value as DataAnalysisProblemData;
     248      }
     249      if (problemData == null) return;
     250      CheckCompatibilityOfProblemData(problemData);
     251      Content.ProblemData = (IDataAnalysisProblemData)problemData.Clone();
     252    }
     253    #endregion
     254
     255    #region load problem data
     256    protected virtual bool CheckCompatibilityOfProblemData(IDataAnalysisProblemData problemData) {
     257      StringBuilder message = new StringBuilder();
     258      List<string> variables = problemData.InputVariables.Select(x => x.Value).ToList();
     259      foreach (var item in Content.ProblemData.InputVariables.CheckedItems) {
     260        if (!variables.Contains(item.Value.Value))
     261          message.AppendLine("Input variable '" + item.Value.Value + "' is not in the new problem data.");
     262      }
     263
     264      if (message.Length != 0) {
     265        ErrorHandling.ShowErrorDialog(this, new InvalidOperationException(message.ToString()));
     266        return false;
     267      }
     268      return true;
    218269    }
    219270    #endregion
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionEnsembleSolutionView.cs

    r9456 r10538  
    3232    }
    3333
     34    protected override void SetEnabledStateOfControls() {
     35      base.SetEnabledStateOfControls();
     36      //loading of problemdata is currently not support for ensemble solutions
     37      loadProblemDataButton.Enabled = false;
     38      loadProblemDataButton.Visible = false;
     39    }
     40
    3441    public new RegressionEnsembleSolution Content {
    3542      get { return (RegressionEnsembleSolution)base.Content; }
     
    4754        var droppedData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    4855        if (droppedData is IValueParameter) droppedData = ((IValueParameter)droppedData).Value;
     56        if (droppedData is IRegressionProblem) droppedData = ((IRegressionProblem)droppedData).ProblemData;
    4957
    5058        RegressionEnsembleProblemData ensembleProblemData = droppedData as RegressionEnsembleProblemData;
    51         RegressionProblemData problemData = droppedData as RegressionProblemData;
     59        IRegressionProblemData problemData = droppedData as IRegressionProblemData;
    5260        if (ensembleProblemData != null) {
    5361          Content.ProblemData = (RegressionEnsembleProblemData)ensembleProblemData.Clone();
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs

    r9456 r10538  
    2020#endregion
    2121
     22using System;
    2223using System.Windows.Forms;
     24using HeuristicLab.Common;
    2325using HeuristicLab.Core;
    2426using HeuristicLab.MainForm;
     27using HeuristicLab.PluginInfrastructure;
    2528
    2629namespace HeuristicLab.Problems.DataAnalysis.Views {
     
    4346
    4447      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    45       if (dropData is RegressionProblemData) validDragOperation = true;
     48      if (dropData is IRegressionProblemData) validDragOperation = true;
     49      else if (dropData is IRegressionProblem) validDragOperation = true;
    4650      else if (dropData is IValueParameter) {
    4751        var param = (IValueParameter)dropData;
     
    5054    }
    5155    #endregion
     56
     57    protected override bool CheckCompatibilityOfProblemData(IDataAnalysisProblemData problemData) {
     58      IRegressionProblemData regressionProblemData = problemData as IRegressionProblemData;
     59      if (regressionProblemData == null) {
     60        ErrorHandling.ShowErrorDialog(this, new ArgumentException("The problem data is no regression problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided."));
     61        return false;
     62      }
     63
     64      if (!regressionProblemData.TargetVariable.Equals(Content.ProblemData.TargetVariable)) {
     65        string message = "The target variables are not matching. Old target variable: '"
     66                         + Content.ProblemData.TargetVariable
     67                         + "'. New targetvariable: '" + regressionProblemData.TargetVariable + "'";
     68        ErrorHandling.ShowErrorDialog(this, new InvalidOperationException(message));
     69        return false;
     70      }
     71
     72      return base.CheckCompatibilityOfProblemData(problemData);
     73    }
    5274  }
    5375}
  • branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/TimeSeriesPrognosisSolutionView.cs

    r9456 r10538  
    4444      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    4545      if (dropData is ITimeSeriesPrognosisProblemData) validDragOperation = true;
     46      else if (dropData is ITimeSeriesPrognosisProblem) validDragOperation = true;
    4647      else if (dropData is IValueParameter) {
    4748        var param = (IValueParameter)dropData;
Note: See TracChangeset for help on using the changeset viewer.