Class FXUiUtil


  • public final class FXUiUtil
    extends Object
    A factory class for UI related things.
    • Method Detail

      • selectValue

        public static <T> T selectValue​(List<T> values)
        Displays a dialog for selecting one of the given values
        Type Parameters:
        T - the type of values
        Parameters:
        values - the values from which to choose
        Returns:
        the selected value
        Throws:
        CancelException - in case the user cancels the operation
      • selectValues

        public static <T> List<T> selectValues​(List<T> values)
        Displays a dialog for selecting one or more of the given values
        Type Parameters:
        T - the type of values
        Parameters:
        values - the values from which to choose
        Returns:
        the selected values
        Throws:
        CancelException - in case the user cancels the operation
      • selectValues

        public static <T> List<T> selectValues​(List<T> values,
                                               FXUiUtil.SingleSelection singleSelection)
        Displays a dialog for selecting one or more of the given values
        Type Parameters:
        T - the type of values
        Parameters:
        values - the values from which to choose
        singleSelection - if yes then only a single value can be selected
        Returns:
        the selected values
        Throws:
        CancelException - in case the user cancels the operation
      • setClipboard

        public static void setClipboard​(String string)
        Sets the given string as the system clipboard value
        Parameters:
        string - the string to add to the clipboard
      • confirm

        public static boolean confirm​(String message)
        Displays a confirmation dialog
        Parameters:
        message - the message to display
        Returns:
        true if confirmed
      • confirm

        public static boolean confirm​(String headerText,
                                      String message)
        Displays a confirmation dialog
        Parameters:
        headerText - the dialog header text
        message - the message to display
        Returns:
        true if confirmed
      • confirm

        public static boolean confirm​(String title,
                                      String headerText,
                                      String message)
        Displays a confirmation dialog
        Parameters:
        title - the dialog title
        headerText - the dialog header text
        message - the message to display
        Returns:
        true if confirmed
      • createValue

        public static <T> Value<T> createValue​(Property<T> property,
                                               javafx.scene.control.Control control,
                                               T defaultValue)
        Instantiates a Value instance based on the given property, linked to the given control
        Type Parameters:
        T - the value type
        Parameters:
        property - the property
        control - the control
        defaultValue - the default to set after instantiation
        Returns:
        the Value instance
      • createEntityValue

        public static Value<Entity> createEntityValue​(javafx.scene.control.ComboBox<Entity> comboBox)
        Instantiates a Value instance based on the given ComboBox
        Parameters:
        comboBox - the combo box on which to base the value
        Returns:
        the Value instance
      • createToggleButton

        public static javafx.scene.control.ToggleButton createToggleButton​(State state)
        Instantiates a ToggleButton based on the given State instance
        Parameters:
        state - the state on which to base the toggle button
        Returns:
        a ToggleButton based on the given state
      • createCheckBox

        public static javafx.scene.control.CheckBox createCheckBox​(State state)
        Instantiates a CheckBox based on the given State instance
        Parameters:
        state - the state on which to base the check-box
        Returns:
        a CheckBox based on the given state
      • createControl

        public static <T> javafx.scene.control.Control createControl​(Property<T> property,
                                                                     EntityConnectionProvider connectionProvider)
        Instantiates a Control based on the given property.
        Type Parameters:
        T - the value type
        Parameters:
        property - the property
        connectionProvider - the EntityConnectionProvider instance to use
        Returns:
        a Control based on the given property
      • createCheckBox

        public static javafx.scene.control.CheckBox createCheckBox​(Property<Boolean> property,
                                                                   FXEntityEditModel editModel)
        Instantiates a CheckBox based on the given property, linked to the given edit model
        Parameters:
        property - the property
        editModel - the edit model
        Returns:
        a CheckBox based on the given property and edit model
      • createCheckBox

        public static javafx.scene.control.CheckBox createCheckBox​(Property<Boolean> property,
                                                                   FXEntityEditModel editModel,
                                                                   StateObserver enabledState)
        Instantiates a CheckBox based on the given property, linked to the given edit model
        Parameters:
        property - the property
        editModel - the edit model
        enabledState - the State instance controlling the enabled state of the check-box
        Returns:
        a CheckBox based on the given property and edit model
      • createBooleanValue

        public static Value<Boolean> createBooleanValue​(javafx.scene.control.CheckBox checkBox)
        Instantiates a Value instance based on the value of the given CheckBox
        Parameters:
        checkBox - the check-box on which to base the value
        Returns:
        a Value based on the given check-box
      • createTextField

        public static javafx.scene.control.TextField createTextField​(Property<String> property,
                                                                     FXEntityEditModel editModel)
        Instantiates a TextField based on the given property, linked to the given edit model
        Parameters:
        property - the property
        editModel - the edit model
        Returns:
        a TextField based on the given property
      • createTextField

        public static javafx.scene.control.TextField createTextField​(Property<String> property,
                                                                     FXEntityEditModel editModel,
                                                                     StateObserver enabledState)
        Instantiates a TextField based on the given property, linked to the given edit model
        Parameters:
        property - the property
        editModel - the edit model
        enabledState - the State instance controlling the enabled state of the text field
        Returns:
        a TextField based on the given property
      • createStringValue

        public static StringValue<String> createStringValue​(javafx.scene.control.TextField textField)
        Instantiates a StringValue based on the given text field
        Parameters:
        textField - the text field
        Returns:
        a StringValue based on the given text field
      • createLongField

        public static javafx.scene.control.TextField createLongField​(Property<Long> property,
                                                                     FXEntityEditModel editModel)
        Instantiates a TextField for Long values, based on the given property and linked to the given edit model
        Parameters:
        property - the property
        editModel - the edit model
        Returns:
        a TextField for Long values, based on the given property
      • createLongField

        public static javafx.scene.control.TextField createLongField​(Property<Long> property,
                                                                     FXEntityEditModel editModel,
                                                                     StateObserver enabledState)
        Instantiates a TextField for Long values, based on the given property and linked to the given edit model
        Parameters:
        property - the property
        editModel - the edit model
        enabledState - the State instance controlling the enabled state of the text field
        Returns:
        a TextField for Long values, based on the given property
      • createLongValue

        public static StringValue<Long> createLongValue​(Property<Long> property,
                                                        javafx.scene.control.TextField textField)
        Instantiates a StringValue for Long values, based on the given property and linked to the given text field
        Parameters:
        property - the property
        textField - the text field
        Returns:
        a StringValue for Long values, based on the given property
      • createIntegerField

        public static javafx.scene.control.TextField createIntegerField​(Property<Integer> property,
                                                                        FXEntityEditModel editModel)
        Instantiates a TextField for Integer values, based on the given property and linked to the given edit model
        Parameters:
        property - the property
        editModel - the edit model
        Returns:
        a TextField for Integer values, based on the given property
      • createIntegerField

        public static javafx.scene.control.TextField createIntegerField​(Property<Integer> property,
                                                                        FXEntityEditModel editModel,
                                                                        StateObserver enabledState)
        Instantiates a TextField for Integer values, based on the given property and linked to the given edit model
        Parameters:
        property - the property
        editModel - the edit model
        enabledState - the State instance controlling the enabled state of the text field
        Returns:
        a TextField for Integer values, based on the given property
      • createIntegerValue

        public static StringValue<Integer> createIntegerValue​(Property<Integer> property,
                                                              javafx.scene.control.TextField textField)
        Instantiates a StringValue for Integer values, based on the given property and linked to the given text field
        Parameters:
        property - the property
        textField - the text field
        Returns:
        a StringValue for Integer values, based on the given property
      • createDoubleField

        public static javafx.scene.control.TextField createDoubleField​(Property<Double> property,
                                                                       FXEntityEditModel editModel)
        Instantiates a TextField for Double values, based on the given property and linked to the given edit model
        Parameters:
        property - the property
        editModel - the edit model
        Returns:
        a TextField for Double values, based on the given property
      • createDoubleField

        public static javafx.scene.control.TextField createDoubleField​(Property<Double> property,
                                                                       FXEntityEditModel editModel,
                                                                       StateObserver enabledState)
        Instantiates a TextField for Double values, based on the given property and linked to the given edit model
        Parameters:
        property - the property
        editModel - the edit model
        enabledState - the State instance controlling the enabled state of the text field
        Returns:
        a TextField for Double values, based on the given property
      • createBigDecimalField

        public static javafx.scene.control.TextField createBigDecimalField​(Property<BigDecimal> property,
                                                                           FXEntityEditModel editModel)
        Instantiates a TextField for BigDecimal values, based on the given property and linked to the given edit model
        Parameters:
        property - the property
        editModel - the edit model
        Returns:
        a TextField for BigDecimal values, based on the given property
      • createBigDecimalField

        public static javafx.scene.control.TextField createBigDecimalField​(Property<BigDecimal> property,
                                                                           FXEntityEditModel editModel,
                                                                           StateObserver enabledState)
        Instantiates a TextField for BigDecimal values, based on the given property and linked to the given edit model
        Parameters:
        property - the property
        editModel - the edit model
        enabledState - the State instance controlling the enabled state of the text field
        Returns:
        a TextField for BigDecimal values, based on the given property
      • createDoubleValue

        public static StringValue<Double> createDoubleValue​(Property<Double> property,
                                                            javafx.scene.control.TextField textField)
        Instantiates a StringValue for Double values, based on the given property and linked to the given text field
        Parameters:
        property - the property
        textField - the text field
        Returns:
        a StringValue for Double values, based on the given property
      • createBigDecimalValue

        public static StringValue<BigDecimal> createBigDecimalValue​(Property<BigDecimal> property,
                                                                    javafx.scene.control.TextField textField)
        Instantiates a StringValue for BigDecimal values, based on the given property and linked to the given text field
        Parameters:
        property - the property
        textField - the text field
        Returns:
        a StringValue for BigDecimal values, based on the given property
      • createDatePicker

        public static javafx.scene.control.DatePicker createDatePicker​(Property<LocalDate> property,
                                                                       FXEntityEditModel editModel)
        Instantiates a DatePicker based on the given property and linked to the given edit model
        Parameters:
        property - the property
        editModel - the edit model
        Returns:
        a DatePicker based on the given property
      • createDatePicker

        public static javafx.scene.control.DatePicker createDatePicker​(Property<LocalDate> property,
                                                                       FXEntityEditModel editModel,
                                                                       StateObserver enabledState)
        Instantiates a DatePicker based on the given property and linked to the given edit model
        Parameters:
        property - the property
        editModel - the edit model
        enabledState - the State instance controlling the enabled state of the date picker
        Returns:
        a DatePicker based on the given property
      • createDateValue

        public static StringValue<LocalDate> createDateValue​(Property<LocalDate> property,
                                                             javafx.scene.control.DatePicker picker)
        Instantiates a StringValue for LocalDate values, based on the given property and linked to the given text field
        Parameters:
        property - the property
        picker - the date picker
        Returns:
        a StringValue for LocalDate values, based on the given property
      • createTimeValue

        public static StringValue<LocalTime> createTimeValue​(Property<LocalTime> property,
                                                             javafx.scene.control.TextField textField)
        Instantiates a StringValue for LocalTime values, based on the given property and linked to the given text field
        Parameters:
        property - the property
        textField - the text field
        Returns:
        a StringValue for LocalTime values, based on the given property
      • link

        public static void link​(javafx.beans.property.BooleanProperty property,
                                StateObserver stateObserver)
        Links the given boolean property to the given state observer, so that changes is one are reflected in the other
        Parameters:
        property - the boolean property
        stateObserver - the state observer
      • createForeignKeyComboBox

        public static javafx.scene.control.ComboBox<Entity> createForeignKeyComboBox​(ForeignKey foreignKey,
                                                                                     FXEntityEditModel editModel)
        Instantiates a ComboBox based on the given foreign key and linked to the given edit model
        Parameters:
        foreignKey - the foreign key
        editModel - the edit model
        Returns:
        a ComboBox based on the given property
      • createItemComboBox

        public static <T> javafx.scene.control.ComboBox<Item<T>> createItemComboBox​(ItemProperty<T> itemProperty,
                                                                                    FXEntityEditModel editModel)
        Instantiates a ComboBox based on the values of the given property and linked to the given edit model
        Type Parameters:
        T - the property type
        Parameters:
        itemProperty - the property
        editModel - the edit model
        Returns:
        a ComboBox based on the values of the given property
      • createCheckBox

        public static javafx.scene.control.CheckBox createCheckBox()
        Instantiates a new CheckBox instance
        Returns:
        the check-box
      • createCheckBox

        public static javafx.scene.control.CheckBox createCheckBox​(StateObserver enabledState)
        Instantiates a new CheckBox instance
        Parameters:
        enabledState - the State instance controlling the enabled state of the check-box
        Returns:
        the check-box
      • createItemComboBoxModel

        public static <T> javafx.collections.ObservableList<Item<T>> createItemComboBoxModel​(ItemProperty<T> property)
        Instantiates a ObservableList containing the Items associated with the given value list property
        Type Parameters:
        T - the value type
        Parameters:
        property - the property
        Returns:
        a ObservableList containing the Items associated with the given value list property
      • createTextField

        public static <T> javafx.scene.control.TextField createTextField​(Property<T> property)
        Instantiates a TextField based on the given property
        Type Parameters:
        T - the value type
        Parameters:
        property - the property
        Returns:
        a TextField based on the given property
      • createTextField

        public static <T> javafx.scene.control.TextField createTextField​(Property<T> property,
                                                                         StateObserver enabledState)
        Instantiates a TextField based on the given property
        Type Parameters:
        T - the value type
        Parameters:
        property - the property
        enabledState - the State instance controlling the enabled state of the text field
        Returns:
        a TextField based on the given property
      • createDatePicker

        public static javafx.scene.control.DatePicker createDatePicker()
        Returns:
        a DatePicker instance
      • createDatePicker

        public static javafx.scene.control.DatePicker createDatePicker​(StateObserver enabledState)
        Parameters:
        enabledState - the State instance controlling the enabled state of the date picker
        Returns:
        a DatePicker instance
      • showLoginDialog

        public static User showLoginDialog​(String applicationTitle,
                                           User defaultUser,
                                           javafx.scene.image.ImageView icon)
        Displays a login dialog
        Parameters:
        applicationTitle - the title to display
        defaultUser - the default user to display in the dialog
        icon - the icon, if any
        Returns:
        a User instance based on the values found in the dialog
        Throws:
        CancelException - in case the user cancels the operation
      • showExceptionDialog

        public static void showExceptionDialog​(Throwable exception)
        Displays an exception dialog for the given exception
        Parameters:
        exception - the exception to display
      • parentOfType

        public static <T> T parentOfType​(javafx.scene.Node node,
                                         Class<T> clazz)
        Finds and returns the first parent of node of the given type
        Type Parameters:
        T - the type of the parent
        Parameters:
        node - the child node
        clazz - the type to find
        Returns:
        the parent, or null if none is found