Top Description Fields Constructors Methods
com.dlsc.gemsfx.util

public Class SessionManager

extends Object
Class Inheritance
Imports
java.util.ArrayList, .HashMap, .Map, .Objects, javafx.beans.property.*, java.util.logging.Logger, java.util.prefs.Preferences, javafx.beans.value.ChangeListener, javafx.scene.paint.Color

A manager for storing observable values in the user preferences.

Field Summary

Modifier and TypeField and Description
private static final Logger
private final Preferences
private final HashMap<Property<T>, ArrayList<ChangeListener<T>>>

Constructor Summary

AccessConstructor and Description
public
SessionManager(Preferences
the preferences used for persisting the property value
preferences
)

Constructs a new session manager that will use the passed in preferences.

Method Summary

Modifier and TypeMethod and Description
private void
addListener(Property<T> property, ChangeListener<T> listener)

private String
public final Preferences

Returns:

the preferences
getPreferences
()

Returns the preferences object used for persisting the property values.

private void
public void
register(String
the path to use for the property (e.g. "divider.location"). Paths must be unique for all persisted properties.
path
,
DoubleProperty
the property to persist and restore across user sessions
property
)

Registers a double property so that any changes made to that property will be persisted in the user's preferences and restored for the next client session.

public void
register(String
the path to use for the property (e.g. "divider.location"). Paths must be unique for all persisted properties.
path
,
IntegerProperty
the property to persist and restore across user sessions
property
)

Registers an integer property so that any changes made to that property will be persisted in the user's preferences and restored for the next client session.

public void
register(String
the path to use for the property (e.g. "divider.location"). Paths must be unique for all persisted properties.
path
,
FloatProperty
the property to persist and restore across user sessions
property
)

Registers a float property so that any changes made to that property will be persisted in the user's preferences and restored for the next client session.

public void
register(String
the path to use for the property (e.g. "divider.location"). Paths must be unique for all persisted properties.
path
,
LongProperty
the property to persist and restore across user sessions
property
)

Registers a long property so that any changes made to that property will be persisted in the user's preferences and restored for the next client session.

public void
register(String
the path to use for the property (e.g. "divider.location"). Paths must be unique for all persisted properties.
path
,
BooleanProperty
the property to persist and restore across user sessions
property
)

Registers a boolean property so that any changes made to that property will be persisted in the user's preferences and restored for the next client session.

public void
register(String
the path to use for the property (e.g. "divider.location"). Paths must be unique for all persisted properties.
path
,
StringProperty
the property to persist and restore across user sessions
property
)

Registers a string property so that any changes made to that property will be persisted in the user's preferences and restored for the next client session.

public void
register(String
the path to use for the property (e.g. "divider.location"). Paths must be unique for all persisted properties.
path
,
ObjectProperty<Color>
the property to persist and restore across user sessions
property
)

Registers a color property so that any changes made to that property will be persisted in the user's preferences and restored for the next client session.

public void
unregister(Property<T>
the property to unregister
property
)

Unregisters all listeners created by SessionManager for the specified property.

public void
unregisterAll()

Unregisters all listeners created by SessionManager.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

LOGback to summary
private static final Logger LOG
preferencesback to summary
private final Preferences preferences
propertyToListenersback to summary
private final HashMap<Property<T>, ArrayList<ChangeListener<T>>> propertyToListeners

Constructor Detail

SessionManagerback to summary
public SessionManager(Preferences preferences)

Constructs a new session manager that will use the passed in preferences.

Parameters
preferences:Preferences

the preferences used for persisting the property value

Method Detail

addListenerback to summary
private void addListener(Property<T> property, ChangeListener<T> listener)
colorToHexRGBAback to summary
private String colorToHexRGBA(Color color)
getPreferencesback to summary
public final Preferences getPreferences()

Returns the preferences object used for persisting the property values.

Returns:Preferences

the preferences

putPropertyValueIntoPreferencesback to summary
private void putPropertyValueIntoPreferences(String path, Property<T> property)
registerback to summary
public void register(String path, DoubleProperty property)

Registers a double property so that any changes made to that property will be persisted in the user's preferences and restored for the next client session.

Parameters
path:String

the path to use for the property (e.g. "divider.location"). Paths must be unique for all persisted properties.

property:DoubleProperty

the property to persist and restore across user sessions

registerback to summary
public void register(String path, IntegerProperty property)

Registers an integer property so that any changes made to that property will be persisted in the user's preferences and restored for the next client session.

Parameters
path:String

the path to use for the property (e.g. "divider.location"). Paths must be unique for all persisted properties.

property:IntegerProperty

the property to persist and restore across user sessions

registerback to summary
public void register(String path, FloatProperty property)

Registers a float property so that any changes made to that property will be persisted in the user's preferences and restored for the next client session.

Parameters
path:String

the path to use for the property (e.g. "divider.location"). Paths must be unique for all persisted properties.

property:FloatProperty

the property to persist and restore across user sessions

registerback to summary
public void register(String path, LongProperty property)

Registers a long property so that any changes made to that property will be persisted in the user's preferences and restored for the next client session.

Parameters
path:String

the path to use for the property (e.g. "divider.location"). Paths must be unique for all persisted properties.

property:LongProperty

the property to persist and restore across user sessions

registerback to summary
public void register(String path, BooleanProperty property)

Registers a boolean property so that any changes made to that property will be persisted in the user's preferences and restored for the next client session.

Parameters
path:String

the path to use for the property (e.g. "divider.location"). Paths must be unique for all persisted properties.

property:BooleanProperty

the property to persist and restore across user sessions

registerback to summary
public void register(String path, StringProperty property)

Registers a string property so that any changes made to that property will be persisted in the user's preferences and restored for the next client session.

Parameters
path:String

the path to use for the property (e.g. "divider.location"). Paths must be unique for all persisted properties.

property:StringProperty

the property to persist and restore across user sessions

registerback to summary
public void register(String path, ObjectProperty<Color> property)

Registers a color property so that any changes made to that property will be persisted in the user's preferences and restored for the next client session.

Parameters
path:String

the path to use for the property (e.g. "divider.location"). Paths must be unique for all persisted properties.

property:ObjectProperty<Color>

the property to persist and restore across user sessions

unregisterback to summary
public void unregister(Property<T> property)

Unregisters all listeners created by SessionManager for the specified property.

Parameters
property:Property<T>

the property to unregister

unregisterAllback to summary
public void unregisterAll()

Unregisters all listeners created by SessionManager.