Top Description Constructors Methods
com.dlsc.workbenchfx.util

public final Class WorkbenchUtils

extends Object
Class Inheritance
Imports
com.google.common.base.CharMatcher, java.util.function.Consumer, javafx.collections.ListChangeListener, .ObservableList, javafx.scene.Node

Provides utility methods to do general transformations between different model objects of WorkbenchFX and or lists and maps of them.
Authors
François Martin, Marco Sanfratello

Constructor Summary

AccessConstructor and Description
private
WorkbenchUtils()

Utility class should not be possible to be instantiated.

Method Summary

Modifier and TypeMethod and Description
public static <
type of the ObservableList
T
>
void
addListListener(ObservableList<T>
to add a listener to
list
,
Consumer<T>
action to be performed when an object was added to the ObservableList
addAction
,
Consumer<T>
action to be performed when an object was removed from the ObservableList
removeAction
)

Adds a ListChangeListener to an ObservableList.

public static void
assertNodeNotSame(Node
first node to check
node1
,
Node
second node to check
node2
)

Makes sure the addresses of two nodes aren't the same.

public static int

Returns:

the amount of columns per row
calculateColumnsPerRow
(int
how many modules are shown in a page, a maximum of 9 is recommended
modulesPerPage
)

Calculates from the amount of modules per page how many columns of modules there should be in a row.

public static String

Returns:

the converted String with only the allowed characters, characters in lowercase and whitespaces replaced by '-'
convertToId
(String
the String to be converted into an css id
name
)

Converts a given String into one that can be used in css.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

WorkbenchUtilsback to summary
private WorkbenchUtils()

Utility class should not be possible to be instantiated.

Method Detail

addListListenerback to summary
public static <T> void addListListener(ObservableList<T> list, Consumer<T> addAction, Consumer<T> removeAction)

Adds a ListChangeListener to an ObservableList.

Parameters
<T>
type of the ObservableList
list:ObservableList<T>

to add a listener to

addAction:Consumer<T>

action to be performed when an object was added to the ObservableList

removeAction:Consumer<T>

action to be performed when an object was removed from the ObservableList

assertNodeNotSameback to summary
public static void assertNodeNotSame(Node node1, Node node2)

Makes sure the addresses of two nodes aren't the same. Is used to check Nodes passed in by an API user. Since every Node can only be associated with one parent, if two Nodes are being passed in, there is a certain risk the API user may pass in the same node twice, which will result in the node only being rendered in the GUI once.

Parameters
node1:Node

first node to check

node2:Node

second node to check

Exceptions
IllegalArgumentException:
if node1 == node2
calculateColumnsPerRowback to summary
public static int calculateColumnsPerRow(int modulesPerPage)

Calculates from the amount of modules per page how many columns of modules there should be in a row.

Parameters
modulesPerPage:int

how many modules are shown in a page, a maximum of 9 is recommended

Returns:int

the amount of columns per row

convertToIdback to summary
public static String convertToId(String name)

Converts a given String into one that can be used in css. Accepts only characters that match 'a' to 'z', 'A' to 'Z', '0' to '9', ' ' and '-'. All uppercase letters are converted into a lowercase and spaces are replaced by '-'.

Parameters
name:String

the String to be converted into an css id

Returns:String

the converted String with only the allowed characters, characters in lowercase and whitespaces replaced by '-'