From bfe1f266922bffd3c0c8d8906535be7621217e7a Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Fri, 22 Mar 2019 19:35:30 -0400 Subject: Unit Expressions are now parsed with the expression parser. Addition and subtraction are now possible. --- src/org/unitConverter/converterGUI/UnitConverterGUI.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/org/unitConverter/converterGUI/UnitConverterGUI.java') diff --git a/src/org/unitConverter/converterGUI/UnitConverterGUI.java b/src/org/unitConverter/converterGUI/UnitConverterGUI.java index a70e971..867211c 100755 --- a/src/org/unitConverter/converterGUI/UnitConverterGUI.java +++ b/src/org/unitConverter/converterGUI/UnitConverterGUI.java @@ -175,7 +175,12 @@ final class UnitConverterGUI { // try to parse to final Unit to; try { - to = this.units.getUnitFromExpression(toUnitString); + // if it's a unit, convert to that + if (this.units.containsUnitName(toUnitString)) { + to = this.units.getUnit(toUnitString); + } else { + to = this.units.getUnitFromExpression(toUnitString); + } } catch (final IllegalArgumentException e) { this.view.showErrorDialog("Parse Error", "Could not recognize text in To entry: " + e.getMessage()); return; -- cgit v1.2.3