Changeset 10538 for branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views
- Timestamp:
- 03/05/14 14:48:13 (11 years ago)
- Location:
- branches/DataPreprocessing
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/DataPreprocessing
- Property svn:mergeinfo changed
-
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views
- Property svn:mergeinfo changed
/trunk/sources/HeuristicLab.Problems.DataAnalysis.Views (added) merged: 10173-10176,10500,10526
- Property svn:mergeinfo changed
-
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/ClassificationEnsembleSolutionView.cs
r9456 r10538 37 37 } 38 38 39 protected override void SetEnabledStateOfControls() { 40 base.SetEnabledStateOfControls(); 41 //loading of problemdata is currently not support for ensemble solutions 42 loadProblemDataButton.Enabled = false; 43 loadProblemDataButton.Visible = false; 44 } 45 39 46 protected override void OnContentChanged() { 40 47 base.OnContentChanged(); … … 47 54 var droppedData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 48 55 if (droppedData is IValueParameter) droppedData = ((IValueParameter)droppedData).Value; 56 else if (droppedData is IClassificationProblem) droppedData = ((IClassificationProblem)droppedData).ProblemData; 49 57 50 58 ClassificationEnsembleProblemData ensembleProblemData = droppedData as ClassificationEnsembleProblemData; -
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/ClassificationSolutionView.cs
r9456 r10538 20 20 #endregion 21 21 22 using System; 22 23 using System.Windows.Forms; 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Core; 24 26 using HeuristicLab.MainForm; 27 using HeuristicLab.PluginInfrastructure; 25 28 26 29 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 43 46 44 47 var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 45 if (dropData is ClassificationProblemData) validDragOperation = true; 48 if (dropData is IClassificationProblemData) validDragOperation = true; 49 else if (dropData is IClassificationProblem) validDragOperation = true; 46 50 else if (dropData is IValueParameter) { 47 51 var param = (IValueParameter)dropData; … … 50 54 } 51 55 #endregion 56 57 protected override bool CheckCompatibilityOfProblemData(IDataAnalysisProblemData problemData) { 58 IClassificationProblemData classificationProblemData = problemData as IClassificationProblemData; 59 if (classificationProblemData == null) { 60 ErrorHandling.ShowErrorDialog(this, new ArgumentException("The problem data is no classification problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.")); 61 return false; 62 } 63 64 if (!classificationProblemData.TargetVariable.Equals(Content.ProblemData.TargetVariable)) { 65 string message = "The target variables are not matching. Old target variable: '" 66 + Content.ProblemData.TargetVariable 67 + "'. New targetvariable: '" + classificationProblemData.TargetVariable + "'"; 68 ErrorHandling.ShowErrorDialog(this, new InvalidOperationException(message)); 69 return false; 70 } 71 72 return base.CheckCompatibilityOfProblemData(problemData); 73 } 52 74 } 53 75 } -
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/ClusteringSolutionView.cs
r9456 r10538 43 43 44 44 var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 45 if (dropData is ClusteringProblemData) validDragOperation = true; 45 if (dropData is IClusteringProblemData) validDragOperation = true; 46 else if (dropData is IClusteringProblem) validDragOperation = true; 46 47 else if (dropData is IValueParameter) { 47 48 var param = (IValueParameter)dropData; -
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.Designer.cs
r9973 r10538 19 19 */ 20 20 #endregion 21 22 21 23 namespace HeuristicLab.Problems.DataAnalysis.Views { 22 24 partial class DataAnalysisSolutionView { … … 46 48 this.exportButton = new System.Windows.Forms.Button(); 47 49 this.exportFileDialog = new System.Windows.Forms.SaveFileDialog(); 50 this.loadProblemDataButton = new System.Windows.Forms.Button(); 51 this.loadProblemDataFileDialog = new System.Windows.Forms.OpenFileDialog(); 48 52 ((System.ComponentModel.ISupportInitialize)(this.splitContainer)).BeginInit(); 49 53 this.splitContainer.Panel1.SuspendLayout(); … … 59 63 // splitContainer.Panel2 60 64 // 65 this.splitContainer.Panel2.Controls.Add(this.loadProblemDataButton); 61 66 this.splitContainer.Panel2.Controls.Add(this.exportButton); 62 67 // … … 76 81 // 77 82 this.exportButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right))); 78 this.exportButton.Location = new System.Drawing.Point( 215, 4);83 this.exportButton.Location = new System.Drawing.Point(194, 3); 79 84 this.exportButton.Name = "exportButton"; 80 this.exportButton.Size = new System.Drawing.Size( 54, 23);85 this.exportButton.Size = new System.Drawing.Size(75, 24); 81 86 this.exportButton.TabIndex = 6; 82 87 this.exportButton.Text = "Export"; 83 88 this.exportButton.UseVisualStyleBackColor = true; 84 89 this.exportButton.Click += new System.EventHandler(this.exportButton_Click); 90 // 91 // loadProblemDataButton 92 // 93 this.loadProblemDataButton.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left))); 94 this.loadProblemDataButton.Location = new System.Drawing.Point(3, 3); 95 this.loadProblemDataButton.Name = "loadProblemDataButton"; 96 this.loadProblemDataButton.Size = new System.Drawing.Size(75, 24); 97 this.loadProblemDataButton.TabIndex = 7; 98 this.loadProblemDataButton.Text = "Load Data"; 99 this.loadProblemDataButton.UseVisualStyleBackColor = true; 100 this.loadProblemDataButton.Click += new System.EventHandler(this.loadProblemDataButton_Click); 101 this.toolTip.SetToolTip(this.loadProblemDataButton, "Load new data"); 102 // 103 // openFileDialog 104 // 105 this.loadProblemDataFileDialog.Filter = "HL files|*.hl"; 106 this.loadProblemDataFileDialog.Title = "Load new ProblemData or Problem..."; 85 107 // 86 108 // DataAnalysisSolutionView … … 102 124 private System.Windows.Forms.SaveFileDialog exportFileDialog; 103 125 protected System.Windows.Forms.Button exportButton; 126 protected System.Windows.Forms.Button loadProblemDataButton; 127 protected System.Windows.Forms.OpenFileDialog loadProblemDataFileDialog; 104 128 105 129 } -
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/DataAnalysisSolutionView.cs
r9974 r10538 25 25 using System.Drawing; 26 26 using System.Linq; 27 using System.Text; 27 28 using System.Windows.Forms; 28 29 using HeuristicLab.Core; … … 31 32 using HeuristicLab.Optimization; 32 33 using HeuristicLab.Optimization.Views; 34 using HeuristicLab.Persistence.Default.Xml; 33 35 using HeuristicLab.PluginInfrastructure; 34 36 … … 54 56 if (Content == null) { 55 57 exportButton.Enabled = false; 58 loadProblemDataButton.Enabled = false; 56 59 } else { 57 60 exportButton.Enabled = !Locked; 61 loadProblemDataButton.Enabled = !Locked; 58 62 } 59 63 } … … 127 131 } 128 132 133 protected virtual void loadProblemDataButton_Click(object sender, EventArgs e) { 134 if (loadProblemDataFileDialog.ShowDialog(this) != DialogResult.OK) return; 135 object hlFile = XmlParser.Deserialize(loadProblemDataFileDialog.FileName); 136 137 IDataAnalysisProblemData problemData = null; 138 if (hlFile is IDataAnalysisProblemData) { 139 problemData = (IDataAnalysisProblemData)hlFile; 140 } else if (hlFile is IDataAnalysisProblem) { 141 problemData = ((IDataAnalysisProblem)hlFile).ProblemData; 142 } else if (hlFile is IDataAnalysisSolution) { 143 problemData = ((IDataAnalysisSolution)hlFile).ProblemData; 144 } 145 146 if (problemData == null) { 147 ErrorHandling.ShowErrorDialog(this, new NullReferenceException("The problem data is null." + Environment.NewLine 148 + "The .hl-file contains no DataAnalysisProblemData or DataAnylsisProblem.")); 149 return; 150 } 151 152 if (CheckCompatibilityOfProblemData(problemData)) { 153 var solution = (IDataAnalysisSolution)Content.Clone(); 154 solution.ProblemData = problemData; 155 solution.Name += " with loaded problem data (" + loadProblemDataFileDialog + ")"; 156 MainFormManager.MainForm.ShowContent(solution); 157 } 158 } 129 159 130 160 private void exportButton_Click(object sender, EventArgs e) { … … 197 227 var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 198 228 if (dropData is DataAnalysisProblemData) validDragOperation = true; 229 else if (dropData is IDataAnalysisProblem) validDragOperation = true; 199 230 else if (dropData is IValueParameter) { 200 231 var param = (IValueParameter)dropData; 201 if (param.Value is DataAnalysisProblemData) validDragOperation = true;232 if (param.Value is IDataAnalysisProblemData) validDragOperation = true; 202 233 } 203 234 } 204 235 205 236 protected override void itemsListView_DragDrop(object sender, DragEventArgs e) { 206 if (e.Effect != DragDropEffects.None) { 207 var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 208 if (dropData is DataAnalysisProblemData) { 209 DataAnalysisProblemData problemData = (DataAnalysisProblemData)dropData; 210 Content.ProblemData = (DataAnalysisProblemData)problemData.Clone(); 211 } else if (dropData is IValueParameter) { 212 var param = (IValueParameter)dropData; 213 DataAnalysisProblemData problemData = param.Value as DataAnalysisProblemData; 214 if (problemData != null) 215 Content.ProblemData = (DataAnalysisProblemData)problemData.Clone(); 216 } 217 } 237 if (e.Effect == DragDropEffects.None) return; 238 239 IDataAnalysisProblemData problemData = null; 240 var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 241 if (dropData is IDataAnalysisProblemData) 242 problemData = (IDataAnalysisProblemData)dropData; 243 else if (dropData is IDataAnalysisProblem) 244 problemData = ((IDataAnalysisProblem)dropData).ProblemData; 245 else if (dropData is IValueParameter) { 246 var param = (IValueParameter)dropData; 247 problemData = param.Value as DataAnalysisProblemData; 248 } 249 if (problemData == null) return; 250 CheckCompatibilityOfProblemData(problemData); 251 Content.ProblemData = (IDataAnalysisProblemData)problemData.Clone(); 252 } 253 #endregion 254 255 #region load problem data 256 protected virtual bool CheckCompatibilityOfProblemData(IDataAnalysisProblemData problemData) { 257 StringBuilder message = new StringBuilder(); 258 List<string> variables = problemData.InputVariables.Select(x => x.Value).ToList(); 259 foreach (var item in Content.ProblemData.InputVariables.CheckedItems) { 260 if (!variables.Contains(item.Value.Value)) 261 message.AppendLine("Input variable '" + item.Value.Value + "' is not in the new problem data."); 262 } 263 264 if (message.Length != 0) { 265 ErrorHandling.ShowErrorDialog(this, new InvalidOperationException(message.ToString())); 266 return false; 267 } 268 return true; 218 269 } 219 270 #endregion -
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionEnsembleSolutionView.cs
r9456 r10538 32 32 } 33 33 34 protected override void SetEnabledStateOfControls() { 35 base.SetEnabledStateOfControls(); 36 //loading of problemdata is currently not support for ensemble solutions 37 loadProblemDataButton.Enabled = false; 38 loadProblemDataButton.Visible = false; 39 } 40 34 41 public new RegressionEnsembleSolution Content { 35 42 get { return (RegressionEnsembleSolution)base.Content; } … … 47 54 var droppedData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 48 55 if (droppedData is IValueParameter) droppedData = ((IValueParameter)droppedData).Value; 56 if (droppedData is IRegressionProblem) droppedData = ((IRegressionProblem)droppedData).ProblemData; 49 57 50 58 RegressionEnsembleProblemData ensembleProblemData = droppedData as RegressionEnsembleProblemData; 51 RegressionProblemData problemData = droppedData asRegressionProblemData;59 IRegressionProblemData problemData = droppedData as IRegressionProblemData; 52 60 if (ensembleProblemData != null) { 53 61 Content.ProblemData = (RegressionEnsembleProblemData)ensembleProblemData.Clone(); -
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/RegressionSolutionView.cs
r9456 r10538 20 20 #endregion 21 21 22 using System; 22 23 using System.Windows.Forms; 24 using HeuristicLab.Common; 23 25 using HeuristicLab.Core; 24 26 using HeuristicLab.MainForm; 27 using HeuristicLab.PluginInfrastructure; 25 28 26 29 namespace HeuristicLab.Problems.DataAnalysis.Views { … … 43 46 44 47 var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 45 if (dropData is RegressionProblemData) validDragOperation = true; 48 if (dropData is IRegressionProblemData) validDragOperation = true; 49 else if (dropData is IRegressionProblem) validDragOperation = true; 46 50 else if (dropData is IValueParameter) { 47 51 var param = (IValueParameter)dropData; … … 50 54 } 51 55 #endregion 56 57 protected override bool CheckCompatibilityOfProblemData(IDataAnalysisProblemData problemData) { 58 IRegressionProblemData regressionProblemData = problemData as IRegressionProblemData; 59 if (regressionProblemData == null) { 60 ErrorHandling.ShowErrorDialog(this, new ArgumentException("The problem data is no regression problem data. Instead a " + problemData.GetType().GetPrettyName() + " was provided.")); 61 return false; 62 } 63 64 if (!regressionProblemData.TargetVariable.Equals(Content.ProblemData.TargetVariable)) { 65 string message = "The target variables are not matching. Old target variable: '" 66 + Content.ProblemData.TargetVariable 67 + "'. New targetvariable: '" + regressionProblemData.TargetVariable + "'"; 68 ErrorHandling.ShowErrorDialog(this, new InvalidOperationException(message)); 69 return false; 70 } 71 72 return base.CheckCompatibilityOfProblemData(problemData); 73 } 52 74 } 53 75 } -
branches/DataPreprocessing/HeuristicLab.Problems.DataAnalysis.Views/3.4/Solution Views/TimeSeriesPrognosisSolutionView.cs
r9456 r10538 44 44 var dropData = e.Data.GetData(HeuristicLab.Common.Constants.DragDropDataFormat); 45 45 if (dropData is ITimeSeriesPrognosisProblemData) validDragOperation = true; 46 else if (dropData is ITimeSeriesPrognosisProblem) validDragOperation = true; 46 47 else if (dropData is IValueParameter) { 47 48 var param = (IValueParameter)dropData;
Note: See TracChangeset
for help on using the changeset viewer.