Free cookie consent management tool by TermsFeed Policy Generator

source: branches/DataPreprocessing/HeuristicLab.DataPreprocessing.Views/3.3/DataPreprocessingView.cs @ 10921

Last change on this file since 10921 was 10921, checked in by pfleck, 10 years ago
  • Changed order of ViewShortcuts in preprocessing main view
File size: 4.5 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          //new DataCompletenessChartContent(dataCompletenessLogic),
70         
71          new FilterContent(filterLogic),
72          new ManipulationContent(manipulationLogic, searchLogic, dataGridLogic),
73          new TransformationContent(data)
74        };
75
76        viewShortcutListView.Content = viewShortcuts.AsReadOnly();
77
78        viewShortcutListView.ItemsListView.Items[0].Selected = true;
79        viewShortcutListView.Select();
80
81      } else {
82        viewShortcutListView.Content = null;
83      }
84    }
85
86    protected override void SetEnabledStateOfControls() {
87      base.SetEnabledStateOfControls();
88      viewShortcutListView.Enabled = Content != null;
89      applyInNewTabButton.Enabled = Content != null;
90      exportProblemButton.Enabled = Content != null;
91      undoButton.Enabled = Content != null;
92    }
93
94    private void exportProblemButton_Click(object sender, EventArgs e) {
95      var problem = Content.ExportProblem();
96
97      var saveFileDialog = new SaveFileDialog {
98        Title = "Save Item",
99        DefaultExt = "hl",
100        Filter = "Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*",
101        FilterIndex = 2
102      };
103
104      var content = problem as IStorableContent;
105      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
106        bool compressed = saveFileDialog.FilterIndex != 1;
107        ContentManager.Save(content, saveFileDialog.FileName, compressed);
108      }
109    }
110
111    private void applyInNewTabButton_Click(object sender, EventArgs e) {
112      var item = Content.ExportAlgorithmOrProblem();
113
114      MainFormManager.MainForm.ShowContent(item);
115    }
116
117    private void undoButton_Click(object sender, EventArgs e) {
118      Content.Data.Undo();
119    }
120  }
121}
Note: See TracBrowser for help on using the repository browser.