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)

File:
1 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}
Note: See TracChangeset for help on using the changeset viewer.