- Timestamp:
- 03/19/18 10:25:45 (6 years ago)
- 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 20 20 #endregion 21 21 22 using System; 23 using System.Collections.Generic; 24 using System.Reflection; 22 using System.Linq; 25 23 using System.Windows.Forms; 26 24 using HeuristicLab.Core; 27 25 using HeuristicLab.Core.Views; 26 using HeuristicLab.Data; 28 27 using HeuristicLab.MainForm; 29 using HeuristicLab.PluginInfrastructure;30 28 using HeuristicLab.Problems.DataAnalysis; 31 29 32 30 namespace HeuristicLab.DataPreprocessing.Views { 33 31 [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 36 37 public CheckedTransformationListView() { 37 38 InitializeComponent(); … … 39 40 } 40 41 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 //} 48 52 49 if (typeSelectorDialog.ShowDialog(this) == DialogResult.OK) {50 try {51 // TODO: Avoid accessing parent view52 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; 54 58 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; 61 65 } 62 66 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 //} 70 74 } 71 75 } -
branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/HeuristicLab.DataPreprocessing.Views-3.4.csproj
r15837 r15846 91 91 <SpecificVersion>False</SpecificVersion> 92 92 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Analysis-3.3.dll</HintPath> 93 <Private>False</Private> 93 94 </Reference> 94 95 <Reference Include="HeuristicLab.Analysis.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 95 96 <SpecificVersion>False</SpecificVersion> 96 97 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Analysis.Views-3.3.dll</HintPath> 98 <Private>False</Private> 97 99 </Reference> 98 100 <Reference Include="HeuristicLab.Collections-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 99 101 <SpecificVersion>False</SpecificVersion> 100 102 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Collections-3.3.dll</HintPath> 103 <Private>False</Private> 101 104 </Reference> 102 105 <Reference Include="HeuristicLab.Common-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 103 106 <SpecificVersion>False</SpecificVersion> 104 107 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Common-3.3.dll</HintPath> 108 <Private>False</Private> 105 109 </Reference> 106 110 <Reference Include="HeuristicLab.Common.Resources-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 107 111 <SpecificVersion>False</SpecificVersion> 108 112 <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> 111 119 <Reference Include="HeuristicLab.Core.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 112 120 <SpecificVersion>False</SpecificVersion> 113 121 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Core.Views-3.3.dll</HintPath> 122 <Private>False</Private> 114 123 </Reference> 115 124 <Reference Include="HeuristicLab.Data-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 116 125 <SpecificVersion>False</SpecificVersion> 117 126 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Data-3.3.dll</HintPath> 127 <Private>False</Private> 118 128 </Reference> 119 129 <Reference Include="HeuristicLab.Data.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 120 130 <SpecificVersion>False</SpecificVersion> 121 131 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Data.Views-3.3.dll</HintPath> 132 <Private>False</Private> 122 133 </Reference> 123 134 <Reference Include="HeuristicLab.MainForm-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 124 135 <SpecificVersion>False</SpecificVersion> 125 136 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.MainForm-3.3.dll</HintPath> 137 <Private>False</Private> 126 138 </Reference> 127 139 <Reference Include="HeuristicLab.MainForm.WindowsForms-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 128 140 <SpecificVersion>False</SpecificVersion> 129 141 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.MainForm.WindowsForms-3.3.dll</HintPath> 142 <Private>False</Private> 130 143 </Reference> 131 144 <Reference Include="HeuristicLab.Optimization-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 132 145 <SpecificVersion>False</SpecificVersion> 133 146 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Optimization-3.3.dll</HintPath> 147 <Private>False</Private> 134 148 </Reference> 135 149 <Reference Include="HeuristicLab.Optimizer-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 136 150 <SpecificVersion>False</SpecificVersion> 137 151 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Optimizer-3.3.dll</HintPath> 152 <Private>False</Private> 138 153 </Reference> 139 154 <Reference Include="HeuristicLab.PluginInfrastructure-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 140 155 <SpecificVersion>False</SpecificVersion> 141 156 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.PluginInfrastructure-3.3.dll</HintPath> 157 <Private>False</Private> 142 158 </Reference> 143 159 <Reference Include="HeuristicLab.Problems.Instances-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 144 160 <SpecificVersion>False</SpecificVersion> 145 161 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Problems.Instances-3.3.dll</HintPath> 162 <Private>False</Private> 146 163 </Reference> 147 164 <Reference Include="HeuristicLab.Problems.Instances.DataAnalysis-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 148 165 <SpecificVersion>False</SpecificVersion> 149 166 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Problems.Instances.DataAnalysis-3.3.dll</HintPath> 167 <Private>False</Private> 150 168 </Reference> 151 169 <Reference Include="HeuristicLab.Problems.Instances.DataAnalysis.Views-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 152 170 <SpecificVersion>False</SpecificVersion> 153 171 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Problems.Instances.DataAnalysis.Views-3.3.dll</HintPath> 172 <Private>False</Private> 154 173 </Reference> 155 174 <Reference Include="HeuristicLab.Visualization.ChartControlsExtensions-3.3, Version=3.3.0.0, Culture=neutral, PublicKeyToken=ba48961d6f65dcec, processorArchitecture=MSIL"> 156 175 <SpecificVersion>False</SpecificVersion> 157 176 <HintPath>..\..\..\..\trunk\bin\HeuristicLab.Visualization.ChartControlsExtensions-3.3.dll</HintPath> 177 <Private>False</Private> 158 178 </Reference> 159 179 <Reference Include="System" /> … … 312 332 <Project>{3e9e8944-44ff-40bb-a622-3a4a7dd0f198}</Project> 313 333 <Name>HeuristicLab.Problems.DataAnalysis.Views-3.4</Name> 334 <Private>False</Private> 314 335 </ProjectReference> 315 336 <ProjectReference Include="..\..\HeuristicLab.Problems.DataAnalysis\3.4\HeuristicLab.Problems.DataAnalysis-3.4.csproj"> 316 337 <Project>{df87c13e-a889-46ff-8153-66dcaa8c5674}</Project> 317 338 <Name>HeuristicLab.Problems.DataAnalysis-3.4</Name> 339 <Private>False</Private> 318 340 </ProjectReference> 319 341 </ItemGroup> … … 325 347 <EmbeddedResource Include="ScatterPlotSingleView.resx"> 326 348 <DependentUpon>ScatterPlotSingleView.cs</DependentUpon> 349 </EmbeddedResource> 350 <EmbeddedResource Include="TransformationView.resx"> 351 <DependentUpon>TransformationView.cs</DependentUpon> 327 352 </EmbeddedResource> 328 353 </ItemGroup> -
branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/TransformationView.Designer.cs
r15583 r15846 46 46 private void InitializeComponent() { 47 47 this.applyButton = new System.Windows.Forms.Button(); 48 this.preserveColumnsCheckbox = new System.Windows.Forms.CheckBox();49 48 this.lblFilterNotice = new System.Windows.Forms.Label(); 50 49 this.transformationListView = new HeuristicLab.DataPreprocessing.Views.CheckedTransformationListView(); … … 62 61 this.applyButton.Click += new System.EventHandler(this.applyButton_Click); 63 62 // 64 // preserveColumnsCheckbox65 //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 //75 63 // lblFilterNotice 76 64 // … … 86 74 // transformationListView 87 75 // 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) 90 78 | System.Windows.Forms.AnchorStyles.Right))); 91 79 this.transformationListView.Caption = "Transformations"; … … 102 90 this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; 103 91 this.Controls.Add(this.lblFilterNotice); 104 this.Controls.Add(this.preserveColumnsCheckbox);105 92 this.Controls.Add(this.applyButton); 106 93 this.Controls.Add(this.transformationListView); … … 115 102 private CheckedTransformationListView transformationListView; 116 103 private System.Windows.Forms.Button applyButton; 117 private System.Windows.Forms.CheckBox preserveColumnsCheckbox;118 104 private System.Windows.Forms.Label lblFilterNotice; 119 105 } -
branches/2906_Transformations/HeuristicLab.DataPreprocessing.Views/3.4/TransformationView.cs
r15583 r15846 21 21 22 22 using System; 23 using System. Linq;23 using System.Collections.Generic; 24 24 using System.Windows.Forms; 25 25 using HeuristicLab.MainForm; 26 26 using HeuristicLab.MainForm.WindowsForms; 27 using HeuristicLab.Problems.DataAnalysis;28 27 29 28 namespace HeuristicLab.DataPreprocessing.Views { … … 46 45 } else { 47 46 transformationListView.Content = Content.CheckedTransformationList; 47 transformationListView.PreprocessingData = Content.PreprocessingData; 48 48 CheckFilters(); 49 49 } … … 75 75 76 76 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); 78 78 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);88 79 if (success) { 89 80 Content.CheckedTransformationList.Clear(); 90 81 MessageBox.Show(this, "Transformations applied.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); 91 82 } 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); 95 84 } 96 85 }
Note: See TracChangeset
for help on using the changeset viewer.