Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
03/19/18 10:25:45 (6 years ago)
Author:
pfleck
Message:

#2906 First concept of simple transformation (single target transformation)

Location:
branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/CheckedTransformationListView.cs

    r15583 r15846  
    2020#endregion
    2121
    22 using System;
    23 using System.Collections.Generic;
    24 using System.Reflection;
     22using System.Linq;
    2523using System.Windows.Forms;
    2624using HeuristicLab.Core;
    2725using HeuristicLab.Core.Views;
     26using HeuristicLab.Data;
    2827using HeuristicLab.MainForm;
    29 using HeuristicLab.PluginInfrastructure;
    3028using HeuristicLab.Problems.DataAnalysis;
    3129
    3230namespace HeuristicLab.DataPreprocessing.Views {
    3331  [View("CheckedTransformationList View")]
    34   [Content(typeof(ICheckedItemList<ITransformation>), false)]
    35   public partial class CheckedTransformationListView : CheckedItemListView<ITransformation> {
     32  [Content(typeof(ICheckedItemList<IDataAnalysisTransformation>), false)]
     33  public partial class CheckedTransformationListView : CheckedItemListView<IDataAnalysisTransformation> {
     34
     35    internal IFilteredPreprocessingData PreprocessingData { get; set; }
     36
    3637    public CheckedTransformationListView() {
    3738      InitializeComponent();
     
    3940    }
    4041
    41     protected override ITransformation CreateItem() {
    42       if (typeSelectorDialog == null) {
    43         typeSelectorDialog = new TypeSelectorDialog();
    44         typeSelectorDialog.Caption = "Select Transformation";
    45         typeSelectorDialog.TypeSelector.Caption = "Available Transformations";
    46         typeSelectorDialog.TypeSelector.Configure(typeof(ITransformation), showNotInstantiableTypes: true, showGenericTypes: false, typeCondition: CanInstanciateTransformation);
    47       }
     42    protected override IDataAnalysisTransformation CreateItem() {
     43      var newTransformation = new DataAnalysisTransformation(PreprocessingData.VariableNames.Select(x => new StringValue(x)));
     44      newTransformation.TransformedVariableParameter.ValidValues.Add(new StringValue("<New Variable>"));
     45      return newTransformation;
     46      //if (typeSelectorDialog == null) {
     47      //  typeSelectorDialog = new TypeSelectorDialog();
     48      //  typeSelectorDialog.Caption = "Select Transformation";
     49      //  typeSelectorDialog.TypeSelector.Caption = "Available Transformations";
     50      //  typeSelectorDialog.TypeSelector.Configure(typeof(IDataAnalysisTransformation), showNotInstantiableTypes: true, showGenericTypes: false, typeCondition: CanInstanciateTransformation);
     51      //}
    4852
    49       if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
    50         try {
    51           // TODO: Avoid accessing parent view
    52           var transformationView = (TransformationView)Parent;
    53           var columnNames = transformationView.Content.PreprocessingData.VariableNames;
     53      //if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {
     54      //  try {
     55      //    // TODO: Avoid accessing parent view
     56      //    var transformationView = (TransformationView)Parent;
     57      //    var columnNames = transformationView.Content.PreprocessingData.VariableNames;
    5458
    55           return (ITransformation)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(new[] { columnNames });
    56         } catch (Exception ex) {
    57           ErrorHandling.ShowErrorDialog(this, ex);
    58         }
    59       }
    60       return null;
     59      //    return (IDataAnalysisTransformation)typeSelectorDialog.TypeSelector.CreateInstanceOfSelectedType(new[] { columnNames });
     60      //  } catch (Exception ex) {
     61      //    ErrorHandling.ShowErrorDialog(this, ex);
     62      //  }
     63      //}
     64      //return null;
    6165    }
    6266
    63     private bool CanInstanciateTransformation(Type type) {
    64       foreach (ConstructorInfo ctor in type.GetConstructors(BindingFlags.Public | BindingFlags.Instance)) {
    65         ParameterInfo[] parameters = ctor.GetParameters();
    66         if (parameters.Length == 1 && parameters[0].ParameterType == typeof(IEnumerable<string>)) return true;
    67       }
    68       return false;
    69     }
     67    //private bool CanInstanciateTransformation(Type type) {
     68    //  foreach (ConstructorInfo ctor in type.GetConstructors(BindingFlags.Public | BindingFlags.Instance)) {
     69    //    ParameterInfo[] parameters = ctor.GetParameters();
     70    //    if (parameters.Length == 1 && parameters[0].ParameterType == typeof(IEnumerable<string>)) return true;
     71    //  }
     72    //  return false;
     73    //}
    7074  }
    7175}
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/HeuristicLab.DataPreprocessing.Views-3.4.csproj

    r15837 r15846  
    9191      <SpecificVersion>False</SpecificVersion>
    9292      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Analysis-3.3.dll</HintPath>
     93      <Private>False</Private>
    9394    </Reference>
    9495    <Reference Include="HeuristicLab.Analysis.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    9596      <SpecificVersion>False</SpecificVersion>
    9697      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Analysis.Views-3.3.dll</HintPath>
     98      <Private>False</Private>
    9799    </Reference>
    98100    <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    99101      <SpecificVersion>False</SpecificVersion>
    100102      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Collections-3.3.dll</HintPath>
     103      <Private>False</Private>
    101104    </Reference>
    102105    <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    103106      <SpecificVersion>False</SpecificVersion>
    104107      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Common-3.3.dll</HintPath>
     108      <Private>False</Private>
    105109    </Reference>
    106110    <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    107111      <SpecificVersion>False</SpecificVersion>
    108112      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Common.Resources-3.3.dll</HintPath>
    109     </Reference>
    110     <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec" />
     113      <Private>False</Private>
     114    </Reference>
     115    <Reference Include="HeuristicLab.Core-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
     116      <SpecificVersion>False</SpecificVersion>
     117      <Private>False</Private>
     118    </Reference>
    111119    <Reference Include="HeuristicLab.Core.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    112120      <SpecificVersion>False</SpecificVersion>
    113121      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Core.Views-3.3.dll</HintPath>
     122      <Private>False</Private>
    114123    </Reference>
    115124    <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    116125      <SpecificVersion>False</SpecificVersion>
    117126      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Data-3.3.dll</HintPath>
     127      <Private>False</Private>
    118128    </Reference>
    119129    <Reference Include="HeuristicLab.Data.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    120130      <SpecificVersion>False</SpecificVersion>
    121131      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Data.Views-3.3.dll</HintPath>
     132      <Private>False</Private>
    122133    </Reference>
    123134    <Reference Include="HeuristicLab.MainForm-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    124135      <SpecificVersion>False</SpecificVersion>
    125136      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.MainForm-3.3.dll</HintPath>
     137      <Private>False</Private>
    126138    </Reference>
    127139    <Reference Include="HeuristicLab.MainForm.WindowsForms-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    128140      <SpecificVersion>False</SpecificVersion>
    129141      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.MainForm.WindowsForms-3.3.dll</HintPath>
     142      <Private>False</Private>
    130143    </Reference>
    131144    <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    132145      <SpecificVersion>False</SpecificVersion>
    133146      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Optimization-3.3.dll</HintPath>
     147      <Private>False</Private>
    134148    </Reference>
    135149    <Reference Include="HeuristicLab.Optimizer-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    136150      <SpecificVersion>False</SpecificVersion>
    137151      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Optimizer-3.3.dll</HintPath>
     152      <Private>False</Private>
    138153    </Reference>
    139154    <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    140155      <SpecificVersion>False</SpecificVersion>
    141156      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath>
     157      <Private>False</Private>
    142158    </Reference>
    143159    <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    144160      <SpecificVersion>False</SpecificVersion>
    145161      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath>
     162      <Private>False</Private>
    146163    </Reference>
    147164    <Reference Include="HeuristicLab.Problems.Instances.DataAnalysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    148165      <SpecificVersion>False</SpecificVersion>
    149166      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll</HintPath>
     167      <Private>False</Private>
    150168    </Reference>
    151169    <Reference Include="HeuristicLab.Problems.Instances.DataAnalysis.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    152170      <SpecificVersion>False</SpecificVersion>
    153171      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Problems.Instances.DataAnalysis.Views-3.3.dll</HintPath>
     172      <Private>False</Private>
    154173    </Reference>
    155174    <Reference Include="HeuristicLab.Visualization.ChartControlsExtensions-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL">
    156175      <SpecificVersion>False</SpecificVersion>
    157176      <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Visualization.ChartControlsExtensions-3.3.dll</HintPath>
     177      <Private>False</Private>
    158178    </Reference>
    159179    <Reference Include="System" />
     
    312332      <Project>{3e9e8944-44ff-40bb-a622-3a4a7dd0f198}</Project>
    313333      <Name>HeuristicLab.Problems.DataAnalysis.Views-3.4</Name>
     334      <Private>False</Private>
    314335    </ProjectReference>
    315336    <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj">
    316337      <Project>{df87c13e-a889-46ff-8153-66dcaa8c5674}</Project>
    317338      <Name>HeuristicLab.Problems.DataAnalysis-3.4</Name>
     339      <Private>False</Private>
    318340    </ProjectReference>
    319341  </ItemGroup>
     
    325347    <EmbeddedResource Include="ScatterPlotSingleView.resx">
    326348      <DependentUpon>ScatterPlotSingleView.cs</DependentUpon>
     349    </EmbeddedResource>
     350    <EmbeddedResource Include="TransformationView.resx">
     351      <DependentUpon>TransformationView.cs</DependentUpon>
    327352    </EmbeddedResource>
    328353  </ItemGroup>
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/TransformationView.Designer.cs

    r15583 r15846  
    4646    private void InitializeComponent() {
    4747      this.applyButton = new System.Windows.Forms.Button();
    48       this.preserveColumnsCheckbox = new System.Windows.Forms.CheckBox();
    4948      this.lblFilterNotice = new System.Windows.Forms.Label();
    5049      this.transformationListView = new HeuristicLab.DataPreprocessing.Views.CheckedTransformationListView();
     
    6261      this.applyButton.Click += new System.EventHandler(this.applyButton_Click);
    6362      //
    64       // preserveColumnsCheckbox
    65       //
    66       this.preserveColumnsCheckbox.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
    67       this.preserveColumnsCheckbox.AutoSize = true;
    68       this.preserveColumnsCheckbox.Location = new System.Drawing.Point(337, 492);
    69       this.preserveColumnsCheckbox.Name = "preserveColumnsCheckbox";
    70       this.preserveColumnsCheckbox.Size = new System.Drawing.Size(147, 17);
    71       this.preserveColumnsCheckbox.TabIndex = 2;
    72       this.preserveColumnsCheckbox.Text = "Preserve original Columns";
    73       this.preserveColumnsCheckbox.UseVisualStyleBackColor = true;
    74       //
    7563      // lblFilterNotice
    7664      //
     
    8674      // transformationListView
    8775      //
    88       this.transformationListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
    89             | System.Windows.Forms.AnchorStyles.Left)
     76      this.transformationListView.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
     77            | System.Windows.Forms.AnchorStyles.Left) 
    9078            | System.Windows.Forms.AnchorStyles.Right)));
    9179      this.transformationListView.Caption = "Transformations";
     
    10290      this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
    10391      this.Controls.Add(this.lblFilterNotice);
    104       this.Controls.Add(this.preserveColumnsCheckbox);
    10592      this.Controls.Add(this.applyButton);
    10693      this.Controls.Add(this.transformationListView);
     
    115102    private CheckedTransformationListView transformationListView;
    116103    private System.Windows.Forms.Button applyButton;
    117     private System.Windows.Forms.CheckBox preserveColumnsCheckbox;
    118104    private System.Windows.Forms.Label lblFilterNotice;
    119105  }
  • branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/TransformationView.cs

    r15583 r15846  
    2121
    2222using System;
    23 using System.Linq;
     23using System.Collections.Generic;
    2424using System.Windows.Forms;
    2525using HeuristicLab.MainForm;
    2626using HeuristicLab.MainForm.WindowsForms;
    27 using HeuristicLab.Problems.DataAnalysis;
    2827
    2928namespace HeuristicLab.DataPreprocessing.Views {
     
    4645      } else {
    4746        transformationListView.Content = Content.CheckedTransformationList;
     47        transformationListView.PreprocessingData = Content.PreprocessingData;
    4848        CheckFilters();
    4949      }
     
    7575
    7676    private void applyButton_Click(object sender, EventArgs e) {
    77       var transformations = Content.CheckedTransformationList.CheckedItems.Select(x => x.Value);
     77      bool success = Content.ApplyTransformations(out IEnumerable<string> errorMessages);
    7878
    79       if (transformations.Any(x => ((Transformation)x).ColumnParameter.Value == null)) {
    80         MessageBox.Show(this, "Parameter \"Column\" of a selected Transformation is not set.", "Applying Transformations...", MessageBoxButtons.OK, MessageBoxIcon.Warning);
    81         return;
    82       }
    83 
    84       var transformator = new PreprocessingTransformator(Content.PreprocessingData);
    85       bool preserve = preserveColumnsCheckbox.CheckState == CheckState.Checked;
    86       string errorMsg;
    87       bool success = transformator.ApplyTransformations(transformations, preserve, out errorMsg);
    8879      if (success) {
    8980        Content.CheckedTransformationList.Clear();
    9081        MessageBox.Show(this, "Transformations applied.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
    9182      } else {
    92         MessageBox.Show(this,
    93           "Error in Transformation.\nValue is copied when transformion of cell failed.\n" + errorMsg,
    94           "Transformation failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
     83        MessageBox.Show(this, string.Join(Environment.NewLine, errorMessages), "Transformation failed", MessageBoxButtons.OK, MessageBoxIcon.Warning);
    9584      }
    9685    }
Note: See TracChangeset for help on using the changeset viewer.