[10539] | 1 | #region License Information
|
---|
| 2 | /* HeuristicLab
|
---|
[12012] | 3 | * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
|
---|
[10539] | 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 |
|
---|
| 22 | using System;
|
---|
[13507] | 23 | using System.Collections.Generic;
|
---|
| 24 | using System.Linq;
|
---|
[10239] | 25 | using System.Windows.Forms;
|
---|
| 26 | using HeuristicLab.Common;
|
---|
[10625] | 27 | using HeuristicLab.Core;
|
---|
[10254] | 28 | using HeuristicLab.Core.Views;
|
---|
| 29 | using HeuristicLab.MainForm;
|
---|
[10239] | 30 |
|
---|
[10558] | 31 | namespace HeuristicLab.DataPreprocessing.Views {
|
---|
[10239] | 32 | [View("DataPreprocessing View")]
|
---|
[10614] | 33 | [Content(typeof(PreprocessingContext), true)]
|
---|
[13507] | 34 | public partial class DataPreprocessingView : NamedItemView {
|
---|
[10998] | 35 |
|
---|
[10239] | 36 | public DataPreprocessingView() {
|
---|
| 37 | InitializeComponent();
|
---|
[10258] | 38 | }
|
---|
[10239] | 39 |
|
---|
[13502] | 40 | public new PreprocessingContext Content {
|
---|
| 41 | get { return (PreprocessingContext)base.Content; }
|
---|
[10617] | 42 | set { base.Content = value; }
|
---|
[10239] | 43 | }
|
---|
| 44 |
|
---|
[10614] | 45 | protected override void OnContentChanged() {
|
---|
| 46 | base.OnContentChanged();
|
---|
| 47 | if (Content != null) {
|
---|
[10617] | 48 | var data = Content.Data;
|
---|
[12676] | 49 | var filterLogic = new FilterLogic(data);
|
---|
| 50 | var searchLogic = new SearchLogic(data, filterLogic);
|
---|
[10617] | 51 | var statisticsLogic = new StatisticsLogic(data, searchLogic);
|
---|
[11002] | 52 | var manipulationLogic = new ManipulationLogic(data, searchLogic, statisticsLogic);
|
---|
[10970] | 53 |
|
---|
[10904] | 54 | var viewShortcuts = new ItemList<IViewShortcut> {
|
---|
[11002] | 55 | new DataGridContent(data, manipulationLogic, filterLogic),
|
---|
[10617] | 56 | new StatisticsContent(statisticsLogic),
|
---|
[10921] | 57 |
|
---|
[10992] | 58 | new LineChartContent(data),
|
---|
| 59 | new HistogramContent(data),
|
---|
| 60 | new ScatterPlotContent(data),
|
---|
[10934] | 61 | new CorrelationMatrixContent(Content),
|
---|
[11002] | 62 | new DataCompletenessChartContent(searchLogic),
|
---|
[13502] | 63 |
|
---|
[10921] | 64 | new FilterContent(filterLogic),
|
---|
[11002] | 65 | new ManipulationContent(manipulationLogic, searchLogic, filterLogic),
|
---|
[10977] | 66 | new TransformationContent(data, filterLogic)
|
---|
[10617] | 67 | };
|
---|
[10625] | 68 |
|
---|
[10904] | 69 | viewShortcutListView.Content = viewShortcuts.AsReadOnly();
|
---|
[10735] | 70 |
|
---|
[10904] | 71 | viewShortcutListView.ItemsListView.Items[0].Selected = true;
|
---|
| 72 | viewShortcutListView.Select();
|
---|
[10735] | 73 |
|
---|
[13507] | 74 | applyComboBox.Items.Clear();
|
---|
| 75 | applyComboBox.DataSource = Content.ExportPossibilities.ToList();
|
---|
| 76 | applyComboBox.DisplayMember = "Key";
|
---|
| 77 | if (applyComboBox.Items.Count > 0)
|
---|
| 78 | applyComboBox.SelectedIndex = 0;
|
---|
[10614] | 79 | } else {
|
---|
[10904] | 80 | viewShortcutListView.Content = null;
|
---|
[10254] | 81 | }
|
---|
[10239] | 82 | }
|
---|
| 83 |
|
---|
[10969] | 84 | protected override void RegisterContentEvents() {
|
---|
| 85 | base.RegisterContentEvents();
|
---|
| 86 | Content.Data.FilterChanged += Data_FilterChanged;
|
---|
| 87 | }
|
---|
| 88 |
|
---|
| 89 | protected override void DeregisterContentEvents() {
|
---|
| 90 | base.DeregisterContentEvents();
|
---|
| 91 | Content.Data.FilterChanged -= Data_FilterChanged;
|
---|
| 92 | }
|
---|
| 93 |
|
---|
| 94 | void Data_FilterChanged(object sender, EventArgs e) {
|
---|
| 95 | lblFilterActive.Visible = Content.Data.IsFiltered;
|
---|
| 96 | }
|
---|
| 97 |
|
---|
[10614] | 98 | protected override void SetEnabledStateOfControls() {
|
---|
| 99 | base.SetEnabledStateOfControls();
|
---|
[10904] | 100 | viewShortcutListView.Enabled = Content != null;
|
---|
[10614] | 101 | applyInNewTabButton.Enabled = Content != null;
|
---|
[13502] | 102 | exportProblemButton.Enabled = Content != null && Content.CanExport;
|
---|
[10614] | 103 | undoButton.Enabled = Content != null;
|
---|
[10239] | 104 | }
|
---|
| 105 |
|
---|
[10304] | 106 | private void exportProblemButton_Click(object sender, EventArgs e) {
|
---|
[13507] | 107 | var exportOption = (KeyValuePair<string, Func<IItem>>)applyComboBox.SelectedItem;
|
---|
| 108 | var exportItem = exportOption.Value();
|
---|
[10310] | 109 |
|
---|
[10307] | 110 | var saveFileDialog = new SaveFileDialog {
|
---|
| 111 | Title = "Save Item",
|
---|
| 112 | DefaultExt = "hl",
|
---|
| 113 | Filter = "Uncompressed HeuristicLab Files|*.hl|HeuristicLab Files|*.hl|All Files|*.*",
|
---|
| 114 | FilterIndex = 2
|
---|
| 115 | };
|
---|
| 116 |
|
---|
[13507] | 117 | var content = exportItem as IStorableContent;
|
---|
[10307] | 118 | if (saveFileDialog.ShowDialog() == DialogResult.OK) {
|
---|
| 119 | bool compressed = saveFileDialog.FilterIndex != 1;
|
---|
| 120 | ContentManager.Save(content, saveFileDialog.FileName, compressed);
|
---|
| 121 | }
|
---|
[10304] | 122 | }
|
---|
| 123 |
|
---|
| 124 | private void applyInNewTabButton_Click(object sender, EventArgs e) {
|
---|
[13507] | 125 | var exportOption = (KeyValuePair<string, Func<IItem>>)applyComboBox.SelectedItem;
|
---|
| 126 | var exportItem = exportOption.Value();
|
---|
[10239] | 127 |
|
---|
[13507] | 128 | MainFormManager.MainForm.ShowContent(exportItem);
|
---|
[10254] | 129 | }
|
---|
[10550] | 130 |
|
---|
| 131 | private void undoButton_Click(object sender, EventArgs e) {
|
---|
| 132 | Content.Data.Undo();
|
---|
| 133 | }
|
---|
[10239] | 134 | }
|
---|
[10310] | 135 | } |
---|