Class BaseController
- java.lang.Object
-
- com.palmer.billingstatementgenerator.views.controllers.BaseController
-
- Direct Known Subclasses:
GridTabController,InstructionsTabController,ServiceInformationController,SummaryTabController
public abstract class BaseController extends java.lang.ObjectAbstract base class for all FXML controllers in the billing statement generator. Provides shared UI building utilities, button lifecycle hooks, and common field binding helpers used across all tab controllers.
-
-
Field Summary
Fields Modifier and Type Field Description protected javafx.scene.control.ButtonclearButtonThe Clear Selections button, injected by the parent view.protected static java.text.NumberFormatDOLLAR_FORMATTERCurrency formatter for displaying monetary values.protected javafx.scene.control.ButtonnextButtonThe Next/Generate PDF button, injected by the parent view.
-
Constructor Summary
Constructors Constructor Description BaseController()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidbindIntegerTextField(javafx.scene.control.TextField field, javafx.beans.property.IntegerProperty prop)Binds aTextFieldbidirectionally to anIntegerProperty, displaying a blank field when the value is zero.protected javafx.scene.control.CheckBoxbuildCheckBox(java.lang.String label, int row, javafx.scene.layout.GridPane grid)Builds aCheckBoxand adds it to column 0 of the specified row in the grid.protected javafx.scene.control.TextFieldbuildPriceField(javafx.beans.property.ObjectProperty<java.math.BigDecimal> priceProperty, int row, javafx.scene.layout.GridPane grid)Builds an editable priceTextFieldbound to the givenBigDecimalproperty.protected voidbuildPriceLabel(java.math.BigDecimal cost, int row, javafx.scene.layout.GridPane grid)Builds a read-only priceLabeland adds it to column 2 of the specified row.protected javafx.scene.control.TextFieldbuildTextField(int columnCount, int column, int row, javafx.scene.layout.GridPane grid)Builds aTextFieldand adds it to the specified column and row in the grid.protected voidclearAll()Clears all selections and refreshes the tab total.protected voidconfigTextFieldForInts(javafx.scene.control.TextField... fields)Applies an integer-onlyTextFormatterto the given text fields, restricting input to digits and an optional leading minus sign.protected voidconfigureClearButton(java.util.List<javafx.scene.control.CheckBox> checkBoxes)Configures the clear button with a disabled binding and action.javafx.beans.binding.BooleanBindinghasInvalidSelections()Returns a binding that istruewhen any checked item is missing a required price.protected voidonClearButtonSet()Called after the clear button is injected.voidonHide()Called when this tab is deselected.protected voidonNextButtonSet()Called after the next button is injected.voidonShow()Called when this tab becomes selected.protected voidrefreshTotal()Refreshes the tab total label.voidreset()No-op in the base class.voidsetClearButton(javafx.scene.control.Button clearButton)Injects the clear button and triggersonClearButtonSet().voidsetNextButton(javafx.scene.control.Button nextButton)Injects the next button and triggersonNextButtonSet().protected voidwireTextFieldToCheckBox(javafx.scene.control.TextField tf, javafx.scene.control.CheckBox cb)Wires aTextFieldto aCheckBoxsuch that the checkbox is selected when the field has a non-empty value, and the tab total is refreshed on every change.
-
-
-
Field Detail
-
DOLLAR_FORMATTER
protected static final java.text.NumberFormat DOLLAR_FORMATTER
Currency formatter for displaying monetary values.
-
clearButton
protected javafx.scene.control.Button clearButton
The Clear Selections button, injected by the parent view.
-
nextButton
protected javafx.scene.control.Button nextButton
The Next/Generate PDF button, injected by the parent view.
-
-
Method Detail
-
setClearButton
public void setClearButton(javafx.scene.control.Button clearButton)
Injects the clear button and triggersonClearButtonSet().- Parameters:
clearButton- the button to use for clearing selections
-
setNextButton
public void setNextButton(javafx.scene.control.Button nextButton)
Injects the next button and triggersonNextButtonSet().- Parameters:
nextButton- the button to use for advancing to the next tab
-
onClearButtonSet
protected void onClearButtonSet()
Called after the clear button is injected. Override to wire clear button behavior specific to the controller.
-
onNextButtonSet
protected void onNextButtonSet()
Called after the next button is injected. Override to wire next button behavior specific to the controller.
-
reset
public void reset()
No-op in the base class. Override to reset the controller to its default state.
-
buildCheckBox
protected javafx.scene.control.CheckBox buildCheckBox(java.lang.String label, int row, javafx.scene.layout.GridPane grid)Builds aCheckBoxand adds it to column 0 of the specified row in the grid.- Parameters:
label- the display text for the checkboxrow- the grid row indexgrid- the targetGridPane- Returns:
- the constructed
CheckBox
-
buildPriceLabel
protected void buildPriceLabel(java.math.BigDecimal cost, int row, javafx.scene.layout.GridPane grid)Builds a read-only priceLabeland adds it to column 2 of the specified row. Displays a blank label if cost is null.- Parameters:
cost- the monetary value to display, or null for a blank labelrow- the grid row indexgrid- the targetGridPane
-
buildTextField
protected javafx.scene.control.TextField buildTextField(int columnCount, int column, int row, javafx.scene.layout.GridPane grid)Builds aTextFieldand adds it to the specified column and row in the grid.- Parameters:
columnCount- the preferred column count for sizingcolumn- the grid column indexrow- the grid row indexgrid- the targetGridPane- Returns:
- the constructed
TextField
-
wireTextFieldToCheckBox
protected void wireTextFieldToCheckBox(javafx.scene.control.TextField tf, javafx.scene.control.CheckBox cb)Wires aTextFieldto aCheckBoxsuch that the checkbox is selected when the field has a non-empty value, and the tab total is refreshed on every change.- Parameters:
tf- the text field to observecb- the checkbox to drive
-
configureClearButton
protected void configureClearButton(java.util.List<javafx.scene.control.CheckBox> checkBoxes)
Configures the clear button with a disabled binding and action. The button is disabled when no checkboxes are selected. Override in subclasses to add additional dependencies (e.g. a ComboBox).- Parameters:
checkBoxes- the list of checkboxes the button should observe and clear
-
clearAll
protected void clearAll()
Clears all selections and refreshes the tab total. Override in subclasses to add additional clearing behavior.
-
configTextFieldForInts
protected void configTextFieldForInts(javafx.scene.control.TextField... fields)
Applies an integer-onlyTextFormatterto the given text fields, restricting input to digits and an optional leading minus sign.- Parameters:
fields- one or more text fields to configure
-
bindIntegerTextField
protected void bindIntegerTextField(javafx.scene.control.TextField field, javafx.beans.property.IntegerProperty prop)Binds aTextFieldbidirectionally to anIntegerProperty, displaying a blank field when the value is zero.- Parameters:
field- the text field to bindprop- the integer property to bind to
-
buildPriceField
protected javafx.scene.control.TextField buildPriceField(javafx.beans.property.ObjectProperty<java.math.BigDecimal> priceProperty, int row, javafx.scene.layout.GridPane grid)Builds an editable priceTextFieldbound to the givenBigDecimalproperty. Input is restricted to valid currency format, and the value is formatted as currency viaBigDecimalCurrencyConverter.- Parameters:
priceProperty- the property to bind the field's value torow- the grid row indexgrid- the targetGridPane- Returns:
- the constructed price
TextField
-
hasInvalidSelections
public javafx.beans.binding.BooleanBinding hasInvalidSelections()
Returns a binding that istruewhen any checked item is missing a required price. Alwaysfalsein the base class; overridden inGridTabController.- Returns:
- a
BooleanBindingindicating whether any checked item is missing a required price
-
refreshTotal
protected void refreshTotal()
Refreshes the tab total label. No-op in the base class; overridden inGridTabControllerwhen a total supplier is set.
-
onShow
public void onShow()
Called when this tab becomes selected. Override to perform any refresh or update logic needed on tab activation.
-
onHide
public void onHide()
Called when this tab is deselected. Override to perform any cleanup logic needed on tab deactivation.
-
-