Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.4/DataPreprocessingView.cs @ 10925

Last change on this file since 10925 was 10922, checked in by pfleck, 10 years ago
  • changed storage of Transformations from Collection to List.
File size: 4.4 KB
Line 
1#region License Information
2/* HeuristicLab
3 * Copyright (C) 2002-2013 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
4 *
5 * This file is part of HeuristicLab.
6 *
7 * HeuristicLab is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * HeuristicLab is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
19 */
20#endregion
21
22using System;
23using System.Windows.Forms;
24using HeuristicLab.Common;
25using HeuristicLab.Core;
26using HeuristicLab.Core.Views;
27using HeuristicLab.MainForm;
28using HeuristicLab.DataPreprocessing;
29using HeuristicLab.Problems.DataAnalysis;
30
31namespace HeuristicLab.DataPreprocessing.Views {
32  [View("DataPreprocessing View")]
33  [Content(typeof(PreprocessingContext), true)]
34  [Content(typeof(IPreprocessingContext), false)]
35  public partial class DataPreprocessingView : ItemView {
36    public DataPreprocessingView() {
37      InitializeComponent();
38    }
39
40    public new IPreprocessingContext Content {
41      get { return (IPreprocessingContext)base.Content; }
42      set { base.Content = value; }
43    }
44
45    protected override void OnContentChanged() {
46      base.OnContentChanged();
47      if (Content != null) {
48        var data = Content.Data;
49        var searchLogic = new SearchLogic(data);
50        var dataGridLogic = new DataGridLogic(data);
51        var statisticsLogic = new StatisticsLogic(data, searchLogic);
52        var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic, dataGridLogic);
53        var chartLogic = new ChartLogic(data);
54        //var correlationMatrixLogic = new ChartLogic(data);
55        var filterLogic = new FilterLogic(data);
56        var creator = new ProblemDataCreator(Content);
57        var problemData = (DataAnalysisProblemData)creator.CreateProblemData();
58        //var dataCompletenessLogic = new ChartLogic(data);
59
60        var viewShortcuts = new ItemList<IViewShortcut> {
61          new DataGridContent(dataGridLogic, manipulationLogic, filterLogic),
62          new StatisticsContent(statisticsLogic),
63
64          new LineChartContent(chartLogic),
65          new HistogramContent(chartLogic),
66          new ScatterPlotContent(chartLogic),
67          new CorrelationMatrixContent(problemData),
68          new DataCompletenessChartContent(dataGridLogic, searchLogic),
69         
70          new FilterContent(filterLogic),
71          new ManipulationContent(manipulationLogic, searchLogic, dataGridLogic),
72          new TransformationContent(data)
73        };
74
75        viewShortcutListView.Content = viewShortcuts.AsReadOnly();
76
77        viewShortcutListView.ItemsListView.Items[0].Selected = true;
78        viewShortcutListView.Select();
79
80      } else {
81        viewShortcutListView.Content = null;
82      }
83    }
84
85    protected override void SetEnabledStateOfControls() {
86      base.SetEnabledStateOfControls();
87      viewShortcutListView.Enabled = Content != null;
88      applyInNewTabButton.Enabled = Content != null;
89      exportProblemButton.Enabled = Content != null;
90      undoButton.Enabled = Content != null;
91    }
92
93    private void exportProblemButton_Click(object sender, EventArgs e) {
94      var problem = Content.ExportProblem();
95
96      var saveFileDialog = new SaveFileDialog {
97        Title = "Save Item",
98        DefaultExt = "hl",
99        Filter = "Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*",
100        FilterIndex = 2
101      };
102
103      var content = problem as IStorableContent;
104      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
105        bool compressed = saveFileDialog.FilterIndex != 1;
106        ContentManager.Save(content, saveFileDialog.FileName, compressed);
107      }
108    }
109
110    private void applyInNewTabButton_Click(object sender, EventArgs e) {
111      var item = Content.ExportAlgorithmOrProblem();
112
113      MainFormManager.MainForm.ShowContent(item);
114    }
115
116    private void undoButton_Click(object sender, EventArgs e) {
117      Content.Data.Undo();
118    }
119  }
120}
Note: See TracBrowser for help on using the repository browser.