Free cookie consent management tool by TermsFeed Policy Generator

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

Last change on this file since 10970 was 10970, checked in by rstoll, 10 years ago
  • disabled manipulation if a filter is active
  • Reordered code ManipulationContent
File size: 4.6 KB
RevLine 
[10539]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;
[10239]23using System.Windows.Forms;
24using HeuristicLab.Common;
[10625]25using HeuristicLab.Core;
[10254]26using HeuristicLab.Core.Views;
27using HeuristicLab.MainForm;
[10239]28
[10558]29namespace HeuristicLab.DataPreprocessing.Views {
[10239]30  [View("DataPreprocessing View")]
[10614]31  [Content(typeof(PreprocessingContext), true)]
32  [Content(typeof(IPreprocessingContext), false)]
[10239]33  public partial class DataPreprocessingView : ItemView {
34    public DataPreprocessingView() {
35      InitializeComponent();
[10258]36    }
[10239]37
[10614]38    public new IPreprocessingContext Content {
39      get { return (IPreprocessingContext)base.Content; }
[10617]40      set { base.Content = value; }
[10239]41    }
42
[10614]43    protected override void OnContentChanged() {
44      base.OnContentChanged();
45      if (Content != null) {
[10617]46        var data = Content.Data;
47        var searchLogic = new SearchLogic(data);
48        var dataGridLogic = new DataGridLogic(data);
49        var statisticsLogic = new StatisticsLogic(data, searchLogic);
[10672]50        var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic, dataGridLogic);
[10882]51        var chartLogic = new ChartLogic(data);
[10921]52        //var correlationMatrixLogic = new ChartLogic(data);
[10620]53        var filterLogic = new FilterLogic(data);
[10970]54
[10921]55        //var dataCompletenessLogic = new ChartLogic(data);
[10617]56
[10904]57        var viewShortcuts = new ItemList<IViewShortcut> {
[10636]58          new DataGridContent(dataGridLogic, manipulationLogic, filterLogic),
[10617]59          new StatisticsContent(statisticsLogic),
[10921]60
[10882]61          new LineChartContent(chartLogic),
62          new HistogramContent(chartLogic),
[10908]63          new ScatterPlotContent(chartLogic),
[10934]64          new CorrelationMatrixContent(Content),
[10922]65          new DataCompletenessChartContent(dataGridLogic, searchLogic),
[10921]66         
67          new FilterContent(filterLogic),
[10970]68          new ManipulationContent(manipulationLogic, searchLogic, dataGridLogic, filterLogic),
[10921]69          new TransformationContent(data)
[10617]70        };
[10625]71
[10904]72        viewShortcutListView.Content = viewShortcuts.AsReadOnly();
[10735]73
[10904]74        viewShortcutListView.ItemsListView.Items[0].Selected = true;
75        viewShortcutListView.Select();
[10735]76
[10614]77      } else {
[10904]78        viewShortcutListView.Content = null;
[10254]79      }
[10239]80    }
81
[10969]82    protected override void RegisterContentEvents() {
83      base.RegisterContentEvents();
84      Content.Data.FilterChanged += Data_FilterChanged;
85    }
86
87    protected override void DeregisterContentEvents() {
88      base.DeregisterContentEvents();
89      Content.Data.FilterChanged -= Data_FilterChanged;
90    }
91
92    void Data_FilterChanged(object sender, EventArgs e) {
93      lblFilterActive.Visible = Content.Data.IsFiltered;
94    }
95
[10614]96    protected override void SetEnabledStateOfControls() {
97      base.SetEnabledStateOfControls();
[10904]98      viewShortcutListView.Enabled = Content != null;
[10614]99      applyInNewTabButton.Enabled = Content != null;
100      exportProblemButton.Enabled = Content != null;
101      undoButton.Enabled = Content != null;
[10239]102    }
103
[10304]104    private void exportProblemButton_Click(object sender, EventArgs e) {
[10383]105      var problem = Content.ExportProblem();
[10310]106
[10307]107      var saveFileDialog = new SaveFileDialog {
108        Title = "Save Item",
109        DefaultExt = "hl",
110        Filter = "Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*",
111        FilterIndex = 2
112      };
113
[10383]114      var content = problem as IStorableContent;
[10307]115      if (saveFileDialog.ShowDialog() == DialogResult.OK) {
116        bool compressed = saveFileDialog.FilterIndex != 1;
117        ContentManager.Save(content, saveFileDialog.FileName, compressed);
118      }
[10304]119    }
120
121    private void applyInNewTabButton_Click(object sender, EventArgs e) {
[10383]122      var item = Content.ExportAlgorithmOrProblem();
[10239]123
[10254]124      MainFormManager.MainForm.ShowContent(item);
125    }
[10550]126
127    private void undoButton_Click(object sender, EventArgs e) {
128      Content.Data.Undo();
129    }
[10239]130  }
[10310]131}
Note: See TracBrowser for help on using the repository browser.