Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
07/08/14 19:03:36 (10 years ago)
Author:
mkommend
Message:

#1758: Merged r10173:10176 and r10540, r10541, r10543, r10545 and r11031 into stable.

Location:
stable
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • stable

  • stable/HeuristicLab.Problems.DataAnalysis.Views

  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/ClassificationEnsembleSolutionView.cs

    r9456 r11144  
    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;
  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/ClassificationSolutionView.cs

    r9456 r11144  
    4343
    4444      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    45       if (dropData is ClassificationProblemData) validDragOperation = true;
     45      if (dropData is IClassificationProblemData) validDragOperation = true;
     46      else if (dropData is IClassificationProblem) validDragOperation = true;
    4647      else if (dropData is IValueParameter) {
    4748        var param = (IValueParameter)dropData;
  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/ClusteringSolutionView.cs

    r9456 r11144  
    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;
  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.Designer.cs

    r9999 r11144  
    1919 */
    2020#endregion
     21
    2122namespace HeuristicLab.Problems.DataAnalysis.Views {
    2223  partial class DataAnalysisSolutionView {
     
    4445    /// </summary>
    4546    private void InitializeComponent() {
    46       this.exportButton = new System.Windows.Forms.Button();
    47       this.exportFileDialog = new System.Windows.Forms.SaveFileDialog();
     47      this.flowLayoutPanel = new System.Windows.Forms.FlowLayoutPanel();
     48      this.loadProblemDataButton = new System.Windows.Forms.Button();
     49      this.loadProblemDataFileDialog = new System.Windows.Forms.OpenFileDialog();
    4850      ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit();
    4951      this.splitContainer.Panel1.SuspendLayout();
     
    5355      this.detailsGroupBox.SuspendLayout();
    5456      this.SuspendLayout();
     57      //
     58      // itemslistView
     59      //
     60      this.itemsListView.Location = new System.Drawing.Point(this.itemsListView.Location.X, this.itemsListView.Location.Y + 3);
     61      //
     62      // detailsGroupBox
     63      //
     64      this.detailsGroupBox.Location = new System.Drawing.Point(this.detailsGroupBox.Location.X, this.detailsGroupBox.Location.Y + 3);
     65      //
    5566      //
    5667      // splitContainer
     
    5970      // splitContainer.Panel2
    6071      //
    61       this.splitContainer.Panel2.Controls.Add(this.exportButton);
     72      this.splitContainer.Panel2.Controls.Add(this.flowLayoutPanel);
    6273      //
    6374      // itemsGroupBox
    6475      //
    6576      this.itemsGroupBox.Text = "Data Analysis Solution";
     77      //
     78      // flowLayoutPanel
     79      //
     80      this.flowLayoutPanel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left | System.Windows.Forms.AnchorStyles.Right)));
     81      this.flowLayoutPanel.FlowDirection = System.Windows.Forms.FlowDirection.LeftToRight;
     82      this.flowLayoutPanel.Location = new System.Drawing.Point(0, 0);
     83      this.flowLayoutPanel.Padding = new System.Windows.Forms.Padding(3, 0, 3, 0);
     84      this.flowLayoutPanel.Size = new System.Drawing.Size(266, 30);
     85      this.flowLayoutPanel.Controls.Add(this.loadProblemDataButton);
     86      //
     87      // loadProblemDataButton
     88      //
     89      this.loadProblemDataButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)));
     90      this.loadProblemDataButton.AutoSize = true;
     91      this.loadProblemDataButton.Image = HeuristicLab.Common.Resources.VSImageLibrary.Open;
     92      this.loadProblemDataButton.ImageAlign = System.Drawing.ContentAlignment.MiddleLeft;
     93      this.loadProblemDataButton.Name = "loadProblemDataButton";
     94      this.loadProblemDataButton.Size = new System.Drawing.Size(105, 24);
     95      this.loadProblemDataButton.TabIndex = 6;
     96      this.loadProblemDataButton.Text = "Load new Data";
     97      this.loadProblemDataButton.TextAlign = System.Drawing.ContentAlignment.MiddleRight;
     98      this.loadProblemDataButton.UseVisualStyleBackColor = true;
     99      this.loadProblemDataButton.Click += new System.EventHandler(this.loadProblemDataButton_Click);
     100      this.toolTip.SetToolTip(this.loadProblemDataButton, "Creates a new data analysis solution with the same model and the loaded problem data.");
    66101      //
    67       // addButton
     102      // openFileDialog
    68103      //
    69       this.toolTip.SetToolTip(this.addButton, "Add");
    70       //
    71       // removeButton
    72       //
    73       this.toolTip.SetToolTip(this.removeButton, "Remove");
    74       //
    75       // exportButton
    76       //
    77       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);
    79       this.exportButton.Name = "exportButton";
    80       this.exportButton.Size = new System.Drawing.Size(54, 23);
    81       this.exportButton.TabIndex = 6;
    82       this.exportButton.Text = "Export";
    83       this.exportButton.UseVisualStyleBackColor = true;
    84       this.exportButton.Click += new System.EventHandler(this.exportButton_Click);
     104      this.loadProblemDataFileDialog.Filter = "HL files|*.hl";
     105      this.loadProblemDataFileDialog.Title = "Load new ProblemData or Problem...";
    85106      //
    86107      // DataAnalysisSolutionView
     
    100121    #endregion
    101122
    102     private System.Windows.Forms.SaveFileDialog exportFileDialog;
    103     protected System.Windows.Forms.Button exportButton;
     123    protected System.Windows.Forms.Button loadProblemDataButton;
     124    protected System.Windows.Forms.OpenFileDialog loadProblemDataFileDialog;
     125    protected System.Windows.Forms.FlowLayoutPanel flowLayoutPanel;
    104126
    105127  }
  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.cs

    r9999 r11144  
    2222using System;
    2323using System.Collections.Generic;
    24 using System.ComponentModel;
    2524using System.Drawing;
    2625using System.Linq;
     
    3130using HeuristicLab.Optimization;
    3231using HeuristicLab.Optimization.Views;
     32using HeuristicLab.Persistence.Default.Xml;
    3333using HeuristicLab.PluginInfrastructure;
    3434
     
    5252      addButton.Enabled = false;
    5353      removeButton.Enabled = false;
    54       if (Content == null) {
    55         exportButton.Enabled = false;
    56       } else {
    57         exportButton.Enabled = !Locked;
    58       }
     54      loadProblemDataButton.Enabled = Content != null && !Locked;
    5955    }
    6056
     
    127123    }
    128124
    129 
    130     private void exportButton_Click(object sender, EventArgs e) {
    131       var exporters = ApplicationManager.Manager.GetInstances<IDataAnalysisSolutionExporter>()
    132         .Where(exporter => exporter.Supports(Content)).ToArray();
    133       exportFileDialog.Filter = exporters.Skip(1)
    134         .Aggregate(exporters.First().FileTypeFilter, (s, exporter) => s + "|" + exporter.FileTypeFilter);
    135       var result = exportFileDialog.ShowDialog();
    136       if (result == DialogResult.OK) {
    137 
    138         var name = exportFileDialog.FileName;
    139         var selectedExporter = exporters.Single(exporter => exporter.FileTypeFilter == exportFileDialog.Filter);
    140 
    141         using (BackgroundWorker bg = new BackgroundWorker()) {
    142           MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().AddOperationProgressToView(this, "Exportion solution to " + name + ".");
    143           bg.DoWork += (_, __) => selectedExporter.Export(Content, name);
    144           bg.RunWorkerCompleted += (_, __) => MainFormManager.GetMainForm<MainForm.WindowsForms.MainForm>().RemoveOperationProgressFromView(this);
    145           bg.RunWorkerAsync();
     125    protected virtual void loadProblemDataButton_Click(object sender, EventArgs e) {
     126      if (loadProblemDataFileDialog.ShowDialog(this) != DialogResult.OK) return;
     127      try {
     128        object hlFile = XmlParser.Deserialize(loadProblemDataFileDialog.FileName);
     129
     130        IDataAnalysisProblemData problemData = null;
     131        if (hlFile is IDataAnalysisProblemData) {
     132          problemData = (IDataAnalysisProblemData)hlFile;
     133        } else if (hlFile is IDataAnalysisProblem) {
     134          problemData = ((IDataAnalysisProblem)hlFile).ProblemData;
     135        } else if (hlFile is IDataAnalysisSolution) {
     136          problemData = ((IDataAnalysisSolution)hlFile).ProblemData;
    146137        }
     138
     139        if (problemData == null)
     140          throw new InvalidOperationException("The chosen HeuristicLab file does not contain a ProblemData, Problem, or DataAnalysisSolution.");
     141
     142        var solution = (IDataAnalysisSolution)Content.Clone();
     143        problemData.AdjustProblemDataProperties(solution.ProblemData);
     144        solution.ProblemData = problemData;
     145        if (!solution.Name.EndsWith(" with loaded problemData"))
     146          solution.Name += " with loaded problemData";
     147        MainFormManager.MainForm.ShowContent(solution);
     148      }
     149      catch (InvalidOperationException invalidOperationException) {
     150        ErrorHandling.ShowErrorDialog(this, invalidOperationException);
     151      }
     152      catch (ArgumentException argumentException) {
     153        ErrorHandling.ShowErrorDialog(this, argumentException);
    147154      }
    148155    }
     
    194201      validDragOperation = false;
    195202      if (ReadOnly) return;
     203      if (e.Effect != DragDropEffects.Copy) return;
    196204
    197205      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    198       if (dropData is DataAnalysisProblemData) validDragOperation = true;
     206      if (dropData is IDataAnalysisProblemData) validDragOperation = true;
     207      else if (dropData is IDataAnalysisProblem) validDragOperation = true;
    199208      else if (dropData is IValueParameter) {
    200209        var param = (IValueParameter)dropData;
    201         if (param.Value is DataAnalysisProblemData) validDragOperation = true;
     210        if (param.Value is IDataAnalysisProblemData) validDragOperation = true;
    202211      }
    203212    }
    204213
    205214    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         }
     215      if (e.Effect == DragDropEffects.None) return;
     216
     217      IDataAnalysisProblemData problemData = null;
     218      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
     219      if (dropData is IDataAnalysisProblemData)
     220        problemData = (IDataAnalysisProblemData)dropData;
     221      else if (dropData is IDataAnalysisProblem)
     222        problemData = ((IDataAnalysisProblem)dropData).ProblemData;
     223      else if (dropData is IValueParameter) {
     224        var param = (IValueParameter)dropData;
     225        problemData = param.Value as DataAnalysisProblemData;
     226      }
     227      if (problemData == null) return;
     228
     229      try {
     230        problemData.AdjustProblemDataProperties(Content.ProblemData);
     231        Content.ProblemData = problemData;
     232
     233        if (!Content.Name.EndsWith(" with changed problemData"))
     234          Content.Name += " with changed problemData";
     235      }
     236      catch (InvalidOperationException invalidOperationException) {
     237        ErrorHandling.ShowErrorDialog(this, invalidOperationException);
     238      }
     239      catch (ArgumentException argumentException) {
     240        ErrorHandling.ShowErrorDialog(this, argumentException);
    217241      }
    218242    }
    219243    #endregion
     244
    220245  }
    221246}
  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionEnsembleSolutionView.cs

    r9456 r11144  
    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();
  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs

    r9456 r11144  
    4343
    4444      var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat);
    45       if (dropData is RegressionProblemData) validDragOperation = true;
     45      if (dropData is IRegressionProblemData) validDragOperation = true;
     46      else if (dropData is IRegressionProblem) validDragOperation = true;
    4647      else if (dropData is IValueParameter) {
    4748        var param = (IValueParameter)dropData;
  • stable/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/TimeSeriesPrognosisSolutionView.cs

    r9456 r11144  
    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.