Free cookie consent management tool by TermsFeed Policy Generator

Changeset 10175


Ignore:
Timestamp:
12/02/13 17:18:26 (11 years ago)
Author:
mkommend
Message:

#1758: Added button to load new data into data analysis solutions.

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

Legend:

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

    r10173 r10175  
    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();
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/ClassificationSolutionView.cs

    r10174 r10175  
    2222using System;
    2323using System.Windows.Forms;
     24using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.MainForm;
     
    5556
    5657    protected override bool CheckCompatibilityOfProblemData(IDataAnalysisProblemData problemData) {
    57       IClassificationProblemData classificationProblemData = (IClassificationProblemData)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      }
    5863
    5964      if (!classificationProblemData.TargetVariable.Equals(Content.ProblemData.TargetVariable)) {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.Designer.cs

    r9973 r10175  
    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  }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.cs

    r10174 r10175  
    3232using HeuristicLab.Optimization;
    3333using HeuristicLab.Optimization.Views;
     34using HeuristicLab.Persistence.Default.Xml;
    3435using HeuristicLab.PluginInfrastructure;
    3536
     
    5556      if (Content == null) {
    5657        exportButton.Enabled = false;
     58        loadProblemDataButton.Enabled = false;
    5759      } else {
    5860        exportButton.Enabled = !Locked;
     61        loadProblemDataButton.Enabled = !Locked;
    5962      }
    6063    }
     
    128131    }
    129132
     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    }
    130159
    131160    private void exportButton_Click(object sender, EventArgs e) {
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionEnsembleSolutionView.cs

    r10173 r10175  
    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; }
  • trunk/sources/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs

    r10174 r10175  
    2222using System;
    2323using System.Windows.Forms;
     24using HeuristicLab.Common;
    2425using HeuristicLab.Core;
    2526using HeuristicLab.MainForm;
     
    5556
    5657    protected override bool CheckCompatibilityOfProblemData(IDataAnalysisProblemData problemData) {
    57       IRegressionProblemData regressionProblemData = (IRegressionProblemData)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      }
    5863
    5964      if (!regressionProblemData.TargetVariable.Equals(Content.ProblemData.TargetVariable)) {
Note: See TracChangeset for help on using the changeset viewer.