Class GridTabController<T>
- java.lang.Object
-
- com.palmer.billingstatementgenerator.views.controllers.BaseController
-
- com.palmer.billingstatementgenerator.views.controllers.GridTabController<T>
-
- Type Parameters:
T- the line item type displayed in this tab
- Direct Known Subclasses:
CashAdvanceController,MerchandiseController,ServicesController,SpecialChargesController
public abstract class GridTabController<T> extends BaseController
Abstract base controller for tabs that display a grid of selectable line items. Handles building the item grid, managing checkboxes, wiring the clear button, clearing selections, and displaying a running total at the bottom of the tab.
-
-
Field Summary
Fields Modifier and Type Field Description protected javafx.scene.layout.GridPaneitemsGridThe grid pane containing the line item rows.-
Fields inherited from class com.palmer.billingstatementgenerator.views.controllers.BaseController
clearButton, DOLLAR_FORMATTER, nextButton
-
-
Constructor Summary
Constructors Constructor Description GridTabController()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract javafx.scene.control.CheckBoxaddItemRow(T item, int row)Builds and adds a single row to the items grid for the given line item.protected voidaddValidationPair(javafx.scene.control.CheckBox cb, javafx.beans.value.ObservableValue<java.math.BigDecimal> priceProperty)Registers a checkbox/price pair for validation.javafx.scene.layout.GridPanebuildView()Builds the full tab view including the items grid, separator, and total label.protected voidclearAll()Clears all checkbox selections, clears all text fields, and refreshes the total.protected abstract java.util.List<T>getItems()Returns the list of line items to display in this tab.javafx.beans.binding.BooleanBindinghasInvalidSelections()Returns a binding that istruewhen any checked item is missing a required price.protected voidonClearButtonSet()Called when the clear button is injected.protected voidrefreshTotal()Refreshes the total label using the configuredtotalSupplier.voidreset()Resets the tab by clearing all selections.voidsetTotalSupplier(java.util.function.Supplier<java.math.BigDecimal> totalSupplier)Sets the supplier used to calculate the tab total.-
Methods inherited from class com.palmer.billingstatementgenerator.views.controllers.BaseController
bindIntegerTextField, buildCheckBox, buildPriceField, buildPriceLabel, buildTextField, configTextFieldForInts, configureClearButton, onHide, onNextButtonSet, onShow, setClearButton, setNextButton, wireTextFieldToCheckBox
-
-
-
-
Method Detail
-
buildView
public javafx.scene.layout.GridPane buildView()
Builds the full tab view including the items grid, separator, and total label.- Returns:
- a
GridPanewrapper containing the complete tab content
-
onClearButtonSet
protected void onClearButtonSet()
Called when the clear button is injected. Wires the button to the current checkboxes if the grid has already been built.- Overrides:
onClearButtonSetin classBaseController
-
clearAll
protected void clearAll()
Clears all checkbox selections, clears all text fields, and refreshes the total.- Overrides:
clearAllin classBaseController
-
reset
public void reset()
Resets the tab by clearing all selections. Delegates toclearAll().- Overrides:
resetin classBaseController
-
setTotalSupplier
public void setTotalSupplier(java.util.function.Supplier<java.math.BigDecimal> totalSupplier)
Sets the supplier used to calculate the tab total. The supplier is called whenever the total label needs to be refreshed.- Parameters:
totalSupplier- aSupplierreturning the current tab total
-
refreshTotal
protected void refreshTotal()
Refreshes the total label using the configuredtotalSupplier. Does nothing if either the supplier or the label has not been initialized.- Overrides:
refreshTotalin classBaseController
-
addValidationPair
protected void addValidationPair(javafx.scene.control.CheckBox cb, javafx.beans.value.ObservableValue<java.math.BigDecimal> priceProperty)Registers a checkbox/price pair for validation. The nav buttons are disabled while the checkbox is selected but the price is null or zero.- Parameters:
cb- the checkbox to observepriceProperty- the price property that must be greater than zero when checked
-
hasInvalidSelections
public javafx.beans.binding.BooleanBinding hasInvalidSelections()
Returns a binding that istruewhen any checked item is missing a required price.- Overrides:
hasInvalidSelectionsin classBaseController- Returns:
- a
BooleanBindingindicating whether any checked item is missing a required price
-
getItems
protected abstract java.util.List<T> getItems()
Returns the list of line items to display in this tab.- Returns:
- the list of items of type
T
-
addItemRow
protected abstract javafx.scene.control.CheckBox addItemRow(T item, int row)
Builds and adds a single row to the items grid for the given line item.- Parameters:
item- the line item to renderrow- the grid row index- Returns:
- the
CheckBoxcreated for this row
-
-