Changeset 17250
- Timestamp:
- 09/13/19 10:02:57 (5 years ago)
- Location:
- branches/2971_named_intervals
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataConstraintView.cs
r17249 r17250 21 21 using System; 22 22 using System.Collections.Generic; 23 using System.Drawing; 23 24 using HeuristicLab.Collections; 24 25 using HeuristicLab.Core; … … 75 76 if (constraintsInput.Text != null) { 76 77 intervalConstraints.Clear(); 77 var parsedConstraints = ParseConstraints(constraintsInput.Text); 78 Content.Constraints = parsedConstraints; 79 Content.Input = constraintsInput.Text; 80 errorOutput.Text = ""; 78 try { 79 var parsedConstraints = ParseConstraints(constraintsInput.Text); 80 Content.Constraints = parsedConstraints; 81 Content.Input = constraintsInput.Text; 82 errorOutput.ForeColor = Color.DarkGreen; 83 errorOutput.Text = "Constraints successfully parsed."; 84 //Catch the exception from the constraints parser and show it in the error dialog 85 } catch(ArgumentException ex) { 86 Content.Constraints = new List<IntervalConstraint>(); 87 errorOutput.ForeColor = Color.DarkRed; 88 errorOutput.Text = ex.Message.Replace("Parameter name", "@Line"); 89 } 81 90 } else { 82 91 errorOutput.Text = "No constraints were found!"; … … 125 134 126 135 private void constraintsInput_TextChanged(object sender, EventArgs e) { 127 if (Content.Input != constraintsInput.Text) { 136 if (Content.Input != constraintsInput.Text) { 137 errorOutput.ForeColor = Color.DarkOrange; 128 138 errorOutput.Text = "Unparsed changes! Press parse button to save changes."; 129 139 Content.Input = constraintsInput.Text; -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis.Views/3.4/ProblemDataConstraintView.designer.cs
r17249 r17250 120 120 // errorOutput 121 121 // 122 this.errorOutput.MaximumSize = new Size(350, 0); 122 123 this.errorOutput.AutoSize = true; 123 124 this.errorOutput.ForeColor = Color.DarkRed; -
branches/2971_named_intervals/HeuristicLab.Problems.DataAnalysis/3.4/Implementation/Interval/IntervalConstraintsParser.cs
r17146 r17250 47 47 if (match.Success) { 48 48 if (match.Groups.Count != 10) { 49 throw new ArgumentException("The target-constraint is not complete." );49 throw new ArgumentException("The target-constraint is not complete.", line); 50 50 } else { 51 51 var targetVariable = match.Groups[1].Value.Trim(); … … 55 55 56 56 if (targetVariable != target) { 57 throw new ArgumentException($"The target variable {targetVariable} does not match the provided target {target}." );57 throw new ArgumentException($"The target variable {targetVariable} does not match the provided target {target}.", line); 58 58 } 59 59 … … 74 74 } 75 75 } else { 76 throw new ArgumentException("The inserted target constraint is not valid." );76 throw new ArgumentException("The inserted target constraint is not valid.", line); 77 77 } 78 78 //Check for derivation … … 83 83 if (match.Success) { 84 84 if (match.Groups.Count != 17) { 85 throw new ArgumentException("The given derivation-constraint is not complete." );85 throw new ArgumentException("The given derivation-constraint is not complete.", line); 86 86 } else { 87 87 var derivationTarget = match.Groups[3].Value.Trim(); … … 96 96 97 97 if (derivationTarget != target) { 98 throw new ArgumentException($"The target variable {derivationTarget} does not match the provided target {target}." );98 throw new ArgumentException($"The target variable {derivationTarget} does not match the provided target {target}.", line); 99 99 } 100 100 101 101 if (variables.All(v => v != derivationVariable)) { 102 throw new ArgumentException($"The given variable {derivationVariable} does not exist in the dataset." );102 throw new ArgumentException($"The given variable {derivationVariable} does not exist in the dataset.", line); 103 103 } 104 104 105 105 if (match.Groups[2].Value.Trim() != "" || match.Groups[11].Value.Trim() != "") { 106 106 if (match.Groups[2].Value.Trim() == "" || match.Groups[11].Value.Trim() == "") 107 throw new ArgumentException("Number of derivation has to be written on both sides." );107 throw new ArgumentException("Number of derivation has to be written on both sides.", line); 108 108 if (match.Groups[2].Value.Trim() != match.Groups[11].Value.Trim()) 109 throw new ArgumentException("Derivation number is not equal on both sides." );109 throw new ArgumentException("Derivation number is not equal on both sides.", line); 110 110 } 111 111 … … 126 126 } 127 127 } else { 128 throw new ArgumentException("The inserted derivation constraint is not valid." );128 throw new ArgumentException("The inserted derivation constraint is not valid.", line); 129 129 } 130 130 //Check for comment … … 133 133 continue; 134 134 } else { 135 throw new ArgumentException("Error at your constraints definition constraints have to start with (Target: | d | \u2202 | #)" );135 throw new ArgumentException("Error at your constraints definition constraints have to start with (Target: | d | \u2202 | #)", line); 136 136 } 137 137 }
Note: See TracChangeset
for help on using the changeset viewer.