diff options
author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2019-03-22 19:35:30 -0400 |
---|---|---|
committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2019-03-22 19:35:30 -0400 |
commit | bfe1f266922bffd3c0c8d8906535be7621217e7a (patch) | |
tree | 3e85bac0398208db251f7365aa479528409f04f3 /src/org/unitConverter/converterGUI | |
parent | 943496888d18b031be19ba8e7348ec188dc8eb6b (diff) |
Unit Expressions are now parsed with the expression parser.
Addition and subtraction are now possible.
Diffstat (limited to 'src/org/unitConverter/converterGUI')
-rwxr-xr-x | src/org/unitConverter/converterGUI/UnitConverterGUI.java | 7 |
1 files changed, 6 insertions, 1 deletions
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; |