Top Description Fields Constructors Methods
com.dlsc.preferencesfx.model

public Class PreferencesFxModel

extends Object
Class Inheritance
Static Imports
com.dlsc.preferencesfx.util.Constants.DEFAULT_CATEGORY, .Constants.DEFAULT_DIVIDER_POSITION

Represents the model which holds all of the data and logic which is not limited to presenters.
Authors
François Martin, Marco Sanfratello

Field Summary

Modifier and TypeField and Description
private BooleanProperty
private List<Category>
private ObjectProperty<Category>
private DoubleProperty
private final Map<EventType<PreferencesFxEvent>, List<EventHandler<? super PreferencesFxEvent>>>
private List<Category>
private History
private boolean
private BooleanProperty
private static final Logger
private boolean
private boolean
private boolean
private SearchHandler
private StringProperty
private StorageHandler
private ObjectProperty<TranslationService>

Constructor Summary

AccessConstructor and Description
public
PreferencesFxModel(StorageHandler
the StorageHandler to use for saving and loading
storageHandler
,
SearchHandler
the SearchHandler to use for handling the searches
searchHandler
,
History
the History in which to save the changes and handle undo / redo
history
,
Category[]
the categories to be displayed, along with the groups and settings
categories
)

Initializes a new model.

Method Summary

Modifier and TypeMethod and Description
public void
addEventHandler(EventType<PreferencesFxEvent>
the type of the events to receive by the handler
eventType
,
EventHandler<? super PreferencesFxEvent>
the handler to register
eventHandler
)

Registers an event handler.

private void
public BooleanProperty
private void
public void
discardChanges()

Undos all changes made, clears the history and saves the settings.

private void
public ReadOnlyObjectProperty<Category>
public DoubleProperty
private void
public boolean
public List<Category>
public Category
public double
public List<Category>
public History
public boolean
public SearchHandler
public String
public StorageHandler
public TranslationService
private void
initializeCategoryTranslation()

Sets up a binding of the TranslationService on the model, so that the Category's title gets translated properly according to the TranslationService used.

public BooleanProperty
public boolean
public boolean
public boolean
public boolean
public Category

Returns:

last selected Category
loadSelectedCategory
()

Loads the last selected Category before exiting the Preferences window.

public void
loadSettingValues()

Load all of the values of the settings using a StorageHandler and attaches a listener for History, so that it will be notified of changes to the setting's values.

public void
removeEventHandler(EventType<PreferencesFxEvent>
the event type from which to unregister
eventType
,
EventHandler<? super PreferencesFxEvent>
the handler to unregister
eventHandler
)

Unregisters a previously registered event handler.

public void
saveSelectedCategory()

Saves the current selected Category.

public void
saveSettings()

Saves the settings, when isSaveSettings() returns true.

private void
saveSettingValues()

Saves all of the values of the settings using a StorageHandler.

public StringProperty
public void
setButtonsVisible(boolean buttonsVisible)

public void
setDisplayedCategory(Category displayedCategory)

public void
setDividerPosition(double dividerPosition)

public void
setHistoryDebugState(boolean historyDebugState)

public void
setInstantPersistent(boolean instantPersistent)

public void
setPersistWindowState(boolean persistWindowState)

public void
setSaveSettings(boolean saveSettings)

public void
setSearchText(String searchText)

public void
public ObjectProperty<TranslationService>
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

buttonsVisibleback to summary
private BooleanProperty buttonsVisible
categoriesback to summary
private List<Category> categories
displayedCategoryback to summary
private ObjectProperty<Category> displayedCategory
dividerPositionback to summary
private DoubleProperty dividerPosition
eventHandlersback to summary
private final Map<EventType<PreferencesFxEvent>, List<EventHandler<? super PreferencesFxEvent>>> eventHandlers
flatCategoriesLstback to summary
private List<Category> flatCategoriesLst
historyback to summary
private History history
historyDebugStateback to summary
private boolean historyDebugState
instantPersistentback to summary
private BooleanProperty instantPersistent
LOGGERback to summary
private static final Logger LOGGER
oneCategoryLayoutback to summary
private boolean oneCategoryLayout
persistWindowStateback to summary
private boolean persistWindowState
saveSettingsback to summary
private boolean saveSettings
searchHandlerback to summary
private SearchHandler searchHandler
searchTextback to summary
private StringProperty searchText
storageHandlerback to summary
private StorageHandler storageHandler
translationServiceback to summary
private ObjectProperty<TranslationService> translationService

Constructor Detail

PreferencesFxModelback to summary
public PreferencesFxModel(StorageHandler storageHandler, SearchHandler searchHandler, History history, Category[] categories)

Initializes a new model.

Parameters
storageHandler:StorageHandler

the StorageHandler to use for saving and loading

searchHandler:SearchHandler

the SearchHandler to use for handling the searches

history:History

the History in which to save the changes and handle undo / redo

categories:Category[]

the categories to be displayed, along with the groups and settings

Method Detail

addEventHandlerback to summary
public void addEventHandler(EventType<PreferencesFxEvent> eventType, EventHandler<? super PreferencesFxEvent> eventHandler)

Registers an event handler. The handler is called when a PreferencesFxEvent of the specified type is being fired.

Parameters
eventType:EventType<PreferencesFxEvent>

the type of the events to receive by the handler

eventHandler:EventHandler<? super PreferencesFxEvent>

the handler to register

Exceptions
NullPointerException:
if the event type or handler is null
applyFieldChangesback to summary
private void applyFieldChanges()
buttonsVisiblePropertyback to summary
public BooleanProperty buttonsVisibleProperty()
createBreadcrumbsback to summary
private void createBreadcrumbs(List<Category> categories)
discardChangesback to summary
public void discardChanges()

Undos all changes made, clears the history and saves the settings. Typically called when the cancel button of the PreferencesFxDialog is pressed. Can also be called explicity in case of using PreferencesFX as a node to undo all changes.

discardFieldChangesback to summary
private void discardFieldChanges()
displayedCategoryPropertyback to summary
public ReadOnlyObjectProperty<Category> displayedCategoryProperty()
dividerPositionPropertyback to summary
public DoubleProperty dividerPositionProperty()
fireEventback to summary
private void fireEvent(PreferencesFxEvent event)
getButtonsVisibleback to summary
public boolean getButtonsVisible()
getCategoriesback to summary
public List<Category> getCategories()
getDisplayedCategoryback to summary
public Category getDisplayedCategory()
getDividerPositionback to summary
public double getDividerPosition()
getFlatCategoriesLstback to summary
public List<Category> getFlatCategoriesLst()
getHistoryback to summary
public History getHistory()
getHistoryDebugStateback to summary
public boolean getHistoryDebugState()
getSearchHandlerback to summary
public SearchHandler getSearchHandler()
getSearchTextback to summary
public String getSearchText()
getStorageHandlerback to summary
public StorageHandler getStorageHandler()
getTranslationServiceback to summary
public TranslationService getTranslationService()
initializeCategoryTranslationback to summary
private void initializeCategoryTranslation()

Sets up a binding of the TranslationService on the model, so that the Category's title gets translated properly according to the TranslationService used.

instantPersistentPropertyback to summary
public BooleanProperty instantPersistentProperty()
isInstantPersistentback to summary
public boolean isInstantPersistent()
isOneCategoryLayoutback to summary
public boolean isOneCategoryLayout()
isPersistWindowStateback to summary
public boolean isPersistWindowState()
isSaveSettingsback to summary
public boolean isSaveSettings()
loadSelectedCategoryback to summary
public Category loadSelectedCategory()

Loads the last selected Category before exiting the Preferences window.

Returns:Category

last selected Category

loadSettingValuesback to summary
public void loadSettingValues()

Load all of the values of the settings using a StorageHandler and attaches a listener for History, so that it will be notified of changes to the setting's values.

removeEventHandlerback to summary
public void removeEventHandler(EventType<PreferencesFxEvent> eventType, EventHandler<? super PreferencesFxEvent> eventHandler)

Unregisters a previously registered event handler. One handler might have been registered for different event types, so the caller needs to specify the particular event type from which to unregister the handler.

Parameters
eventType:EventType<PreferencesFxEvent>

the event type from which to unregister

eventHandler:EventHandler<? super PreferencesFxEvent>

the handler to unregister

Exceptions
NullPointerException:
if the event type or handler is null
saveSelectedCategoryback to summary
public void saveSelectedCategory()

Saves the current selected Category.

saveSettingsback to summary
public void saveSettings()

Saves the settings, when isSaveSettings() returns true.

saveSettingValuesback to summary
private void saveSettingValues()

Saves all of the values of the settings using a StorageHandler.

searchTextPropertyback to summary
public StringProperty searchTextProperty()
setButtonsVisibleback to summary
public void setButtonsVisible(boolean buttonsVisible)
setDisplayedCategoryback to summary
public void setDisplayedCategory(Category displayedCategory)
setDividerPositionback to summary
public void setDividerPosition(double dividerPosition)
setHistoryDebugStateback to summary
public void setHistoryDebugState(boolean historyDebugState)
setInstantPersistentback to summary
public void setInstantPersistent(boolean instantPersistent)
setPersistWindowStateback to summary
public void setPersistWindowState(boolean persistWindowState)
setSaveSettingsback to summary
public void setSaveSettings(boolean saveSettings)
setSearchTextback to summary
public void setSearchText(String searchText)
setTranslationServiceback to summary
public void setTranslationService(TranslationService translationService)
translationServicePropertyback to summary
public ObjectProperty<TranslationService> translationServiceProperty()