Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 10772 was 10772, checked in by pfleck, 11 years ago
  • Current Transformations from GUI stored in TransformationContent.
  • Corrected namespace from Transformation interfaces.
File size: 4.0 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;
28
29namespace HeuristicLab.DataPreprocessing.Views {
30  [View("DataPreprocessing View")]
31  [Content(typeof(PreprocessingContext), true)]
32  [Content(typeof(IPreprocessingContext), false)]
33  public partial class DataPreprocessingView : ItemView {
34    public DataPreprocessingView() {
35      InitializeComponent();
36    }
37
38    public new IPreprocessingContext Content {
39      get { return (IPreprocessingContext)base.Content; }
40      set { base.Content = value; }
41    }
42
43    protected override void OnContentChanged() {
44      base.OnContentChanged();
45      if (Content != null) {
46        var data = Content.Data;
47        var searchLogic = new SearchLogic(data);
48        var dataGridLogic = new DataGridLogic(data);
49        var statisticsLogic = new StatisticsLogic(data, searchLogic);
50        var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic, dataGridLogic);
51        var lineChartLogic = new ChartLogic(data);
52        var histogramLogic = new ChartLogic(data);
53        var filterLogic = new FilterLogic(data);
54
55        var viewShortcuts = new ItemCollection<IViewShortcut> {
56          new DataGridContent(dataGridLogic, manipulationLogic, filterLogic),
57          new StatisticsContent(statisticsLogic),
58          new FilterContent(filterLogic),
59          new TransformationContent(data),
60          new ManipulationContent(manipulationLogic),
61          new LineChartContent(lineChartLogic),
62          new HistogramContent(histogramLogic)
63        };
64
65        viewShortcutCollectionView.Content = viewShortcuts.AsReadOnly();
66
67        viewShortcutCollectionView.ItemsListView.Items[0].Selected = true;
68        viewShortcutCollectionView.Select();
69
70      } else {
71        viewShortcutCollectionView.Content = null;
72      }
73    }
74
75    protected override void SetEnabledStateOfControls() {
76      base.SetEnabledStateOfControls();
77      viewShortcutCollectionView.Enabled = Content != null;
78      applyInNewTabButton.Enabled = Content != null;
79      exportProblemButton.Enabled = Content != null;
80      undoButton.Enabled = Content != null;
81    }
82
83    private void exportProblemButton_Click(object sender, EventArgs e) {
84      var problem = Content.ExportProblem();
85
86      var saveFileDialog = new SaveFileDialog {
87        Title = "Save Item",
88        DefaultExt = "hl",
89        Filter = "Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*",
90        FilterIndex = 2
91      };
92
93      var content = problem as IStorableContent;
94      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
95        bool compressed = saveFileDialog.FilterIndex != 1;
96        ContentManager.Save(content, saveFileDialog.FileName, compressed);
97      }
98    }
99
100    private void applyInNewTabButton_Click(object sender, EventArgs e) {
101      var item = Content.ExportAlgorithmOrProblem();
102
103      MainFormManager.MainForm.ShowContent(item);
104    }
105
106    private void undoButton_Click(object sender, EventArgs e) {
107      Content.Data.Undo();
108    }
109  }
110}
Note: See TracBrowser for help on using the repository browser.