Class BindingUtils

java.lang.Object
org.matwoess.jsourceprofiler.fxui.util.BindingUtils

public class BindingUtils extends Object
This class contains utility methods for creating bindings.
  • Field Details

    • pathStringConverter

      public static final StringConverter<Path> pathStringConverter
      This StringConverter is used to convert a Path to a String and vice versa.
  • Constructor Details

    • BindingUtils

      public BindingUtils()
  • Method Details

    • createBorderBinding

      public static ObjectBinding<Border> createBorderBinding(StringProperty stringProperty, BooleanBinding invalidityBinding)
      Specialized version of createBorderBinding(ObjectProperty, BooleanBinding) for StringProperties.

      The neutral border is returned if the property is empty (not null).

      Parameters:
      stringProperty - the property to create the binding for
      invalidityBinding - the binding that determines whether the property is invalid
      Returns:
      the created border binding
    • createBorderBinding

      public static <T> ObjectBinding<Border> createBorderBinding(ObjectProperty<T> property, BooleanBinding invalidityBinding)
      Creates a binding that returns a Border depending on the validity of the property.

      If the property is null, the neutral border is returned. If the invalidity-binding is true, the invalid border is returned. Otherwise, the valid border is returned.

      The binding is invalidated when the property or the invalidity-binding changes.

      Type Parameters:
      T - the generic type of the property
      Parameters:
      property - the property to check
      invalidityBinding - the binding that determines whether the property is invalid
      Returns:
      the created binding
    • creatRelativeIsJavaFileBinding

      public static BooleanBinding creatRelativeIsJavaFileBinding(ObjectProperty<Path> parentDirProperty, ObjectProperty<Path> fileProperty)
      Creates a binding for whether the file property is a valid java file, relative to the parent directory property.
      Parameters:
      parentDirProperty - the parent directory property
      fileProperty - the file property
      Returns:
      the created binding, telling us whether the file is a valid java file
    • createIsDirectoryBinding

      public static BooleanBinding createIsDirectoryBinding(ObjectProperty<Path> dirProperty)
      Creates a binding for whether the directory property is a valid directory, relative to the parent directory property.
      Parameters:
      dirProperty - the directory property
      Returns:
      the created binding, telling us whether the directory is a valid directory
    • createRelativeIsDirectoryBinding

      public static BooleanBinding createRelativeIsDirectoryBinding(ObjectProperty<Path> parentDirProperty, ObjectProperty<Path> dirProperty)
      Like createIsDirectoryBinding(ObjectProperty), but relative to the parent directory property.
      Parameters:
      parentDirProperty - the parent directory property
      dirProperty - the directory property
      Returns:
      the created binding, telling us whether the directory is a valid directory
    • creatRelativeFileExistsBinding

      public static BooleanBinding creatRelativeFileExistsBinding(ObjectProperty<Path> parentDirProperty, Path relFilePath)
      Creates a binding for whether the file path property exists, relative to the parent directory property.
      Parameters:
      parentDirProperty - the parent directory property
      relFilePath - the relative file path
      Returns:
      the created binding, telling us whether the file exists
    • createSelectedTreeItemBorderBinding

      public static ObjectBinding<Border> createSelectedTreeItemBorderBinding(BooleanBinding isOutDir, BooleanBinding isSelectedDir, BooleanBinding isSelectedMain)
      Create the border binding for a SelectableTreeCell.

      Returns a brown border for the output directory, a blue border for the sources directory and a green border for the main file.

      Parameters:
      isOutDir - whether the item is the output directory
      isSelectedDir - whether the item is the selected sources directory
      isSelectedMain - whether the item is the selected main file
      Returns:
      the border binding depending on the input parameters