Package jmri.beans
Class PreferencesBean
- java.lang.Object
-
- jmri.beans.UnboundBean
-
- jmri.beans.Bean
-
- jmri.beans.PreferencesBean
-
- All Implemented Interfaces:
BeanInterface,PropertyChangeFirer,PropertyChangeProvider
- Direct Known Subclasses:
CbusPreferences,DefaultLogixNGPreferences,HelpUtilPreferences,LnTcpPreferences,LoadAndStorePreferences,ShutdownPreferences,WebServerPreferences,ZeroConfPreferences
public abstract class PreferencesBean extends Bean
Bean that implements some common code for preferences objects.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDIRTYProperty indicating preferences item do/do not need to be saved.static java.lang.StringRESTART_REQUIREDProperty indicating preferences item requires restart to be applied.-
Fields inherited from class jmri.beans.Bean
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description PreferencesBean(Profile profile)Create the PreferencesBean.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidfirePropertyChange(java.beans.PropertyChangeEvent evt)Fire a property change.voidfirePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)Fire a property change.voidfirePropertyChange(java.lang.String propertyName, int oldValue, int newValue)Fire a property change.voidfirePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)Fire a property change.ProfilegetProfile()Get the profile associated with this PreferencesBean.booleanisDirty()Check if this preferences bean has a state that needs to be saved.booleanisRestartRequired()Check if this preferences bean requires the application to be restarted to take effect.protected voidsetIsDirty(boolean value)Set if preferences need to be saved.protected voidsetRestartRequired()Set if restart needs to be required for some preferences to take effect.-
Methods inherited from class jmri.beans.Bean
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, isNotifyOnEDT, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class jmri.beans.UnboundBean
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty, setIndexedProperty, setProperty
-
-
-
-
Field Detail
-
DIRTY
public static final java.lang.String DIRTY
Property indicating preferences item do/do not need to be saved. "dirty"- See Also:
- Constant Field Values
-
RESTART_REQUIRED
public static final java.lang.String RESTART_REQUIRED
Property indicating preferences item requires restart to be applied. "restartRequired"- See Also:
- Constant Field Values
-
-
Constructor Detail
-
PreferencesBean
public PreferencesBean(Profile profile)
Create the PreferencesBean.- Parameters:
profile- the Profile this PreferencesBean is associated with; if null is not associated with a Profile, but applies application wide
-
-
Method Detail
-
getProfile
@Nonnull public Profile getProfile()
Get the profile associated with this PreferencesBean.- Returns:
- the profile
-
isDirty
public boolean isDirty()
Check if this preferences bean has a state that needs to be saved.- Returns:
- true if unsaved; false otherwise
-
isRestartRequired
public boolean isRestartRequired()
Check if this preferences bean requires the application to be restarted to take effect.- Returns:
- true if a restart is required; false otherwise
-
setRestartRequired
protected void setRestartRequired()
Set if restart needs to be required for some preferences to take effect.
-
setIsDirty
protected void setIsDirty(boolean value)
Set if preferences need to be saved.- Parameters:
value- true to indicate need to save; false otherwise
-
firePropertyChange
public void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
Fire a property change.As a side effect, calls to
isDirtywill returntrueif oldValue and newValue differ or are null.- Specified by:
firePropertyChangein interfacePropertyChangeFirer- Overrides:
firePropertyChangein classBean- Parameters:
propertyName- the programmatic name of the property that was changedoldValue- the old value of the propertynewValue- the new value of the property
-
firePropertyChange
public void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
Fire a property change.As a side effect, calls to
isDirtywill returntrueif oldValue and newValue differ and propertyName is not "dirty".- Specified by:
firePropertyChangein interfacePropertyChangeFirer- Overrides:
firePropertyChangein classBean- Parameters:
propertyName- the programmatic name of the property that was changedoldValue- the old value of the propertynewValue- the new value of the property
-
firePropertyChange
public void firePropertyChange(java.lang.String propertyName, int oldValue, int newValue)
Fire a property change.As a side effect, calls to
isDirtywill returntrueif oldValue and newValue differ.- Specified by:
firePropertyChangein interfacePropertyChangeFirer- Overrides:
firePropertyChangein classBean- Parameters:
propertyName- the programmatic name of the property that was changedoldValue- the old value of the propertynewValue- the new value of the property
-
firePropertyChange
public void firePropertyChange(java.beans.PropertyChangeEvent evt)
Fire a property change.As a side effect, calls to
isDirtywill returntrue. To avoid that side effect, callPropertyChangeSupport.firePropertyChange(java.beans.PropertyChangeEvent)onBean.propertyChangeSupportdirectly.- Specified by:
firePropertyChangein interfacePropertyChangeFirer- Overrides:
firePropertyChangein classBean- Parameters:
evt- the PropertyChangeEvent to be fired
-
-