From 0aacba9fc8a9140fdf331172ad66afe280d09b5e Mon Sep 17 00:00:00 2001 From: Adrien Hopkins Date: Tue, 19 Apr 2022 16:10:44 -0500 Subject: Implemented prefix settings, saving & loading of settings Also fixed some bugs: - Presenter now has default values for its settings in case they don't load properly - UnitDatabase ensures its units, prefixes and dimensions have all of the names you give it --- src/main/java/sevenUnitsGUI/ViewBot.java | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'src/main/java/sevenUnitsGUI/ViewBot.java') diff --git a/src/main/java/sevenUnitsGUI/ViewBot.java b/src/main/java/sevenUnitsGUI/ViewBot.java index dd9869d..9253ae5 100644 --- a/src/main/java/sevenUnitsGUI/ViewBot.java +++ b/src/main/java/sevenUnitsGUI/ViewBot.java @@ -196,30 +196,30 @@ final class ViewBot implements UnitConversionView, ExpressionConversionView { private final Presenter presenter; /** The dimensions available to select from */ - private Set dimensionNames; + private Set dimensionNames = Set.of(); /** The expression in the From field */ - private String fromExpression; + private String fromExpression = ""; /** The expression in the To field */ - private String toExpression; + private String toExpression = ""; /** * The user-provided string representing the value in {@code fromSelection} */ - private String inputValue; + private String inputValue = ""; /** The unit selected in the From selection */ - private Optional fromSelection; + private Optional fromSelection = Optional.empty(); /** The unit selected in the To selection */ - private Optional toSelection; + private Optional toSelection = Optional.empty(); /** The currently selected dimension */ - private Optional selectedDimensionName; + private Optional selectedDimensionName = Optional.empty(); /** The units available in the From selection */ - private Set fromUnits; + private Set fromUnits = Set.of(); /** The units available in the To selection */ - private Set toUnits; + private Set toUnits = Set.of(); /** The selected unit in the unit viewer */ - private Optional unitViewerSelection; + private Optional unitViewerSelection = Optional.empty(); /** The selected unit in the prefix viewer */ - private Optional prefixViewerSelection; + private Optional prefixViewerSelection = Optional.empty(); /** Saved outputs of all unit conversions */ private final List unitConversions; @@ -289,6 +289,7 @@ final class ViewBot implements UnitConversionView, ExpressionConversionView { * @return the presenter associated with tihs view * @since 2022-01-29 */ + @Override public Presenter getPresenter() { return this.presenter; } -- cgit v1.2.3