Alert
.- Author:
- Thomas Thrien (thomas.thrien@tquadrat.org)
- Version:
- $Id: AlertBuilder.java 1110 2024-03-04 15:26:06Z tquadrat $
- Since:
- 0.4.1
- UML Diagram
-
UML Diagram for "org.tquadrat.foundation.fx.util.AlertBuilder"
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAlertBuilder
(Alert.AlertType type) Creates a new instance ofAlertBuilder
.AlertBuilder
(Alert.AlertType type, Window owner) Creates a new instance ofAlertBuilder
. -
Method Summary
Modifier and TypeMethodDescriptionfinal <E extends Event>
AlertBuilderaddEventFilter
(EventType<E> eventType, EventHandler<? super E> eventFilter) Registers an event filter for the new alert.final <E extends Event>
AlertBuilderaddEventHandler
(EventType<E> eventType, EventHandler<? super E> eventHandler) Registers an even filter for the new alert.final Alert
build()
Returns the alert instance.private final void
final boolean
execute()
Builds the alert, callsshowAndWait()
on it and returns the result.final AlertBuilder
Sets the content text for the new alert.final AlertBuilder
setDialogPane
(DialogPane dialogPane) Sets theDialogPane
for the new alert.final AlertBuilder
setDimensions
(double width, double height) Sets the window dimensions for the new alert.final AlertBuilder
setGraphic
(Node node) Sets the graphics for the new alert.final AlertBuilder
Sets the header text for the new alert.final AlertBuilder
setHeight
(double height) Sets the window height for the new alert.final AlertBuilder
setModality
(Modality modality) Sets theModality
for the new alert.final AlertBuilder
setOnCloseRequest
(EventHandler<DialogEvent> eventHandler) Sets the 'OnCloseRequest' event handler for the new alert.final AlertBuilder
setOnHidden
(EventHandler<DialogEvent> eventHandler) Sets the 'OnHidden' event handler for the new alert.final AlertBuilder
setOnHiding
(EventHandler<DialogEvent> eventHandler) Sets the 'OnHiding' event handler for the new alert.final AlertBuilder
setOnShowing
(EventHandler<DialogEvent> eventHandler) Sets the 'OnShowing' event handler for the new alert.final AlertBuilder
setOnShown
(EventHandler<DialogEvent> eventHandler) Sets the 'OnShown' event handler for the new alert.final AlertBuilder
Sets the parent window for the new alert.final AlertBuilder
setPos
(double x, double y) Sets the position for the new alert.final AlertBuilder
setResizable
(boolean flag) Sets the flag that indicates whether the window for the new alert can be resized.final AlertBuilder
setResultConverter
(Callback<ButtonType, ButtonType> callback) Sets the result converter for the new alert.final AlertBuilder
setStyle
(StageStyle style) Sets the style for the new alert.final AlertBuilder
Sets the window title for the new alert.final AlertBuilder
setWidth
(double width) Sets the window width for the new alert.final AlertBuilder
setX
(double x) Sets the x position for the new alert.final AlertBuilder
setY
(double y) Sets the y position for the new alert.
-
Field Details
-
m_Alert
The alert instance to build. -
m_IsBuilt
Flag that prevents the re-use of the builder.
-
-
Constructor Details
-
AlertBuilder
Creates a new instance ofAlertBuilder
.- Parameters:
type
- The type of the new alert.
-
AlertBuilder
Creates a new instance ofAlertBuilder
.- Parameters:
type
- The type of the new alert.owner
- The parent window for the alert.
-
-
Method Details
-
addEventFilter
public final <E extends Event> AlertBuilder addEventFilter(EventType<E> eventType, EventHandler<? super E> eventFilter) throws IllegalStateException Registers an event filter for the new alert.
- Type Parameters:
E
- The event class of the filer.- Parameters:
eventType
- The type of the events received by the filter.eventFilter
- The event filter.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
addEventHandler
public final <E extends Event> AlertBuilder addEventHandler(EventType<E> eventType, EventHandler<? super E> eventHandler) throws IllegalStateException Registers an even filter for the new alert.
- Type Parameters:
E
- The event class of the filter.- Parameters:
eventType
- The type of the events received by the filter.eventHandler
- The event handler.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
build
Returns the alert instance.- Returns:
- The alert.
- Throws:
IllegalStateException
- The methodbuild()
was already called previously on this builder instance.
-
checkIsBuilt
- Throws:
IllegalStateException
-m_IsBuilt
istrue
.
-
execute
Builds the alert, callsshowAndWait()
on it and returns the result.- Returns:
true
if the alert was terminated with the Ok button,false
in any other case.- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- Since:
- 0.4.2
-
setContentText
Sets the content text for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
- Parameters:
s
- The content text; can benull
.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setDialogPane
Sets the
DialogPane
for the new alert.This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
- Parameters:
dialogPane
- The dialog pane; can benull
.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setDimensions
Sets the window dimensions for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the values set by the previous one.
- Parameters:
width
- The window width.height
- The window height.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setGraphic
Sets the graphics for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
- Parameters:
node
- The graphics; can benull
.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setHeaderText
Sets the header text for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
- Parameters:
s
- The text for the header; can benull
.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setHeight
Sets the window height for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
- Parameters:
height
- The window height.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setModality
Sets the
Modality
for the new alert.- Parameters:
modality
- The modality.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setOnCloseRequest
public final AlertBuilder setOnCloseRequest(EventHandler<DialogEvent> eventHandler) throws IllegalStateException Sets the 'OnCloseRequest' event handler for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
- Parameters:
eventHandler
- The event handler- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setOnHidden
public final AlertBuilder setOnHidden(EventHandler<DialogEvent> eventHandler) throws IllegalStateException Sets the 'OnHidden' event handler for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
- Parameters:
eventHandler
- The event handler- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setOnHiding
public final AlertBuilder setOnHiding(EventHandler<DialogEvent> eventHandler) throws IllegalStateException Sets the 'OnHiding' event handler for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
- Parameters:
eventHandler
- The event handler- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setOnShowing
public final AlertBuilder setOnShowing(EventHandler<DialogEvent> eventHandler) throws IllegalStateException Sets the 'OnShowing' event handler for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
- Parameters:
eventHandler
- The event handler- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setOnShown
public final AlertBuilder setOnShown(EventHandler<DialogEvent> eventHandler) throws IllegalStateException Sets the 'OnShown' event handler for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
- Parameters:
eventHandler
- The event handler- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setOwner
@API(status=STABLE, since="0.4.1") public final AlertBuilder setOwner(Window owner) throws IllegalStateException Sets the parent window for the new alert.- Parameters:
owner
- The parent window.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- Since:
- 0.4.2
- See Also:
-
setPos
Sets the position for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the values set by the previous one.
- Parameters:
x
- The x position for the alert window.y
- The y position for the alert window.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setResizable
Sets the flag that indicates whether the window for the new alert can be resized.
This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
- Parameters:
flag
-true
for a resizeable window, _false for a window with fixed sizes.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setResultConverter
public final AlertBuilder setResultConverter(Callback<ButtonType, ButtonType> callback) throws IllegalStateExceptionSets the result converter for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
Setting a result converter may have an impact on the behaviour of
execute()
.- Parameters:
callback
- The result converter; can benull
.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setStyle
Sets the style for the new alert.
- Parameters:
style
- The style.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setTitle
Sets the window title for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
- Parameters:
s
- The window title; can benull
.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setWidth
Sets the window width for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
- Parameters:
width
- The window width.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setX
Sets the x position for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
- Parameters:
x
- The x position.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-
setY
Sets the y position for the new alert.
This operation can be called repeatedly; each consecutive call will overwrite the value set by the previous one.
- Parameters:
y
- The y position.- Returns:
- The builder reference.
- Throws:
IllegalStateException
- The methodbuild()
was already called on this builder instance.- See Also:
-