Class GuiLafPreferencesManager
- java.lang.Object
-
- jmri.beans.UnboundBean
-
- jmri.beans.Bean
-
- jmri.util.gui.GuiLafPreferencesManager
-
- All Implemented Interfaces:
BeanInterface,PropertyChangeFirer,PropertyChangeProvider,InstanceManagerAutoDefault,JmriServiceProviderInterface,PreferencesManager
public class GuiLafPreferencesManager extends Bean implements PreferencesManager, InstanceManagerAutoDefault
Manage GUI Look and Feel (LAF) preferences.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_FONTstatic java.lang.StringEDITOR_USE_OLD_LOC_SIZEstatic java.lang.StringFONT_NAMEstatic java.lang.StringFONT_SIZEstatic java.lang.StringGRAPHIC_TABLE_STATEstatic java.lang.StringJFILECHOOSER_FORMATstatic java.lang.StringLOCALEstatic java.lang.StringLOOK_AND_FEELstatic java.lang.StringMAX_COMBO_ROWSstatic intMAX_FONT_SIZELargest font size a user can set the font size to (36).static intMIN_FONT_SIZESmallest font size a user can set the font size to other than zero (9).static java.lang.StringNONSTANDARD_MOUSE_EVENTstatic java.lang.StringOBLOCK_EDIT_TABBEDstatic java.lang.StringPROP_DIRTYstatic java.lang.StringPROP_RESTARTREQUIREDstatic java.lang.StringSHOW_TOOL_TIP_TIMEstatic java.lang.StringVERTICAL_TOOLBAR-
Fields inherited from class jmri.beans.Bean
propertyChangeSupport
-
-
Constructor Summary
Constructors Constructor Description GuiLafPreferencesManager()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidapplyLookAndFeel()Apply the existing look and feel.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.java.awt.FontgetDefaultFont()intgetDefaultFontSize()Get the default font size for the current Look and Feel.java.awt.FontgetFont()intgetFontSize()java.util.List<java.lang.Exception>getInitializationExceptions(Profile profile)Get the set of exceptions thrown during initialization for the provided Profile.intgetJFileChooserFormat()JFileChooser Typejava.util.LocalegetLocale()java.lang.StringgetLookAndFeel()Get the name of the class implementing the preferred look and feel.intgetMaxComboRows()java.lang.Iterable<java.lang.Class<?>>getProvides()Get the set of Classes that this PreferencesManager can be registered as a provider of in theInstanceManager.java.util.Collection<java.lang.Class<? extends PreferencesManager>>getRequires()Get the set of PreferencesManagers that must be initialized prior to initializing this PreferencesManager.intgetToolTipDismissDelay()Get the time a tooltip is displayed before being dismissed.voidinitialize(Profile profile)Initialize the PreferencesManager with preferences associated with the provided Profile.booleanisDirty()Check if preferences need to be saved.booleanisEditorUseOldLocSize()booleanisGraphicTableState()booleanisInitialized(Profile profile)Test if the PreferencesManager is initialized without errors for the provided Profile.booleanisInitializedWithExceptions(Profile profile)Test if the PreferencesManager is initialized, but threw anInitializationExceptionduring initialization, for the provided Profile.booleanisNonStandardMouseEvent()booleanisOblockEditTabbed()booleanisRestartRequired()Check if application needs to restart to apply preferences.voidsavePreferences(Profile profile)Save the preferences that this provider manages for the provided Profile.voidsetDefaultFont()Called to load the current Look and Feel default font, based on looking up the "List.font".voidsetDefaultFontSize()Get the default font size for the current Look and Feel, based on looking up the "List.font" size.voidsetEditorUseOldLocSize(boolean editorUseOldLocSize)voidsetFont(java.awt.Font newFont)Sets a new fontvoidsetFontByName(java.lang.String newFontName)Sets a new font by namevoidsetFontSize(int newFontSize)Set the new font size.voidsetGraphicTableState(boolean graphicTableState)voidsetJFileChooserFormat(int jFileChooserFormat)voidsetLocale(java.util.Locale locale)static voidsetLocaleMinimally(Profile profile)Stand-alone service routine to set the default Locale.voidsetLookAndFeel(java.lang.String lookAndFeel)Set the name of the class implementing the preferred look and feel.voidsetMaxComboRows(int maxRows)Set a new value for the number of combo box rows to be displayed.voidsetNonStandardMouseEvent(boolean nonStandardMouseEvent)voidsetOblockEditTabbed(boolean tabbed)voidsetToolTipDismissDelay(int time)Sets the time a tooltip is displayed before it goes away.-
Methods inherited from class jmri.beans.Bean
addPropertyChangeListener, addPropertyChangeListener, fireIndexedPropertyChange, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, getPropertyChangeListeners, getPropertyChangeListeners, isNotifyOnEDT, removePropertyChangeListener, removePropertyChangeListener
-
Methods inherited from class jmri.beans.UnboundBean
getIndexedProperty, getProperty, getPropertyNames, hasIndexedProperty, hasProperty, setIndexedProperty, setProperty
-
-
-
-
Field Detail
-
FONT_NAME
public static final java.lang.String FONT_NAME
- See Also:
- Constant Field Values
-
FONT_SIZE
public static final java.lang.String FONT_SIZE
- See Also:
- Constant Field Values
-
LOCALE
public static final java.lang.String LOCALE
- See Also:
- Constant Field Values
-
LOOK_AND_FEEL
public static final java.lang.String LOOK_AND_FEEL
- See Also:
- Constant Field Values
-
NONSTANDARD_MOUSE_EVENT
public static final java.lang.String NONSTANDARD_MOUSE_EVENT
- See Also:
- Constant Field Values
-
GRAPHIC_TABLE_STATE
public static final java.lang.String GRAPHIC_TABLE_STATE
- See Also:
- Constant Field Values
-
OBLOCK_EDIT_TABBED
public static final java.lang.String OBLOCK_EDIT_TABBED
- See Also:
- Constant Field Values
-
VERTICAL_TOOLBAR
public static final java.lang.String VERTICAL_TOOLBAR
- See Also:
- Constant Field Values
-
SHOW_TOOL_TIP_TIME
public static final java.lang.String SHOW_TOOL_TIP_TIME
- See Also:
- Constant Field Values
-
EDITOR_USE_OLD_LOC_SIZE
public static final java.lang.String EDITOR_USE_OLD_LOC_SIZE
- See Also:
- Constant Field Values
-
JFILECHOOSER_FORMAT
public static final java.lang.String JFILECHOOSER_FORMAT
- See Also:
- Constant Field Values
-
MAX_COMBO_ROWS
public static final java.lang.String MAX_COMBO_ROWS
- See Also:
- Constant Field Values
-
MIN_FONT_SIZE
public static final int MIN_FONT_SIZE
Smallest font size a user can set the font size to other than zero (9). A font size of 0 indicates that the system default font size will be used.
-
MAX_FONT_SIZE
public static final int MAX_FONT_SIZE
Largest font size a user can set the font size to (36).
-
PROP_DIRTY
public static final java.lang.String PROP_DIRTY
- See Also:
- Constant Field Values
-
PROP_RESTARTREQUIRED
public static final java.lang.String PROP_RESTARTREQUIRED
- See Also:
- Constant Field Values
-
DEFAULT_FONT
public static final java.lang.String DEFAULT_FONT
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
GuiLafPreferencesManager
public GuiLafPreferencesManager()
-
-
Method Detail
-
initialize
public void initialize(Profile profile) throws InitializationException
Description copied from interface:PreferencesManagerInitialize the PreferencesManager with preferences associated with the provided Profile.Implementing classes should throw an InitializationException with a user readable localized message, since it most likely be displayed to the user. Implementing classes will still want to ensure that
PreferencesManager.isInitialized(jmri.profile.Profile)orPreferencesManager.isInitializedWithExceptions(jmri.profile.Profile)return true if throwing an InitializationException to ensure that the provider is not repeatedly initialized.- Specified by:
initializein interfacePreferencesManager- Parameters:
profile- the configuration profile used for this initialization; may be null to initialize for this user regardless of profile- Throws:
InitializationException- if the user needs to be notified of an issue that prevents regular use of the application
-
isInitialized
public boolean isInitialized(Profile profile)
Description copied from interface:PreferencesManagerTest if the PreferencesManager is initialized without errors for the provided Profile. Note that although both this method andPreferencesManager.isInitializedWithExceptions(jmri.profile.Profile)can be false, if isInitializedWithExceptions(Profile) returns true, this method must return false.- Specified by:
isInitializedin interfacePreferencesManager- Parameters:
profile- the configuration profile to test against; may be null to test for exceptions thrown when initializing for this user regardless of profile- Returns:
- true if the provider is initialized without exceptions
-
getRequires
@Nonnull public java.util.Collection<java.lang.Class<? extends PreferencesManager>> getRequires()
Description copied from interface:PreferencesManagerGet the set of PreferencesManagers that must be initialized prior to initializing this PreferencesManager. It is generally preferable to require an Interface or an abstract Class instead of a concrete Class, since that allows all (or any) concrete implementations of the required class to be initialized to provide required services for the requiring PreferencesManager instance.Note that for any set of PreferencesManagers with the same requirements, or with a circular dependency between each other, the order in which the PreferencesManagers in that set are initialized should be considered non-deterministic.
- Specified by:
getRequiresin interfacePreferencesManager- Returns:
- A set or list of classes. If there are no dependencies, return an empty set instead of null.
-
getProvides
@Nonnull public java.lang.Iterable<java.lang.Class<?>> getProvides()
Description copied from interface:PreferencesManagerGet the set of Classes that this PreferencesManager can be registered as a provider of in theInstanceManager.- Specified by:
getProvidesin interfacePreferencesManager- Returns:
- A set or list of classes. If this PreferencesManager provides an instance of no other Interfaces or abstract Classes than PreferencesManager, return an empty set instead of null.
-
savePreferences
public void savePreferences(Profile profile)
Description copied from interface:PreferencesManagerSave the preferences that this provider manages for the provided Profile.- Specified by:
savePreferencesin interfacePreferencesManager- Parameters:
profile- the profile associated with the preferences to save; may be null to save preferences that apply to the current user regardless of profile
-
getLocale
public java.util.Locale getLocale()
- Returns:
- the locale
-
setLocale
public void setLocale(java.util.Locale locale)
- Parameters:
locale- the locale to set
-
getFont
public java.awt.Font getFont()
- Returns:
- the currently selected font
-
setFont
public void setFont(java.awt.Font newFont)
Sets a new font- Parameters:
newFont- the new font to set
-
setFontByName
public void setFontByName(java.lang.String newFontName)
Sets a new font by name- Parameters:
newFontName- the name of the new font to set
-
getDefaultFont
public java.awt.Font getDefaultFont()
- Returns:
- the current Look and Feel default font
-
setDefaultFont
public void setDefaultFont()
Called to load the current Look and Feel default font, based on looking up the "List.font".
-
getFontSize
public int getFontSize()
- Returns:
- the currently selected font size
-
setFontSize
public void setFontSize(int newFontSize)
Set the new font size. If newFontSize is non-zero and less than 9, the font size is set to 9 or if greater than 36, the font size is set to 36.- Parameters:
newFontSize- the new font size to set
-
getDefaultFontSize
public int getDefaultFontSize()
Get the default font size for the current Look and Feel.- Returns:
- the default font size
-
setDefaultFontSize
public void setDefaultFontSize()
Get the default font size for the current Look and Feel, based on looking up the "List.font" size.
-
setToolTipDismissDelay
public void setToolTipDismissDelay(int time)
Sets the time a tooltip is displayed before it goes away.Note that this preference takes effect immediately.
- Parameters:
time- the delay in seconds.
-
getToolTipDismissDelay
public int getToolTipDismissDelay()
Get the time a tooltip is displayed before being dismissed.- Returns:
- the delay in seconds
-
isNonStandardMouseEvent
public boolean isNonStandardMouseEvent()
- Returns:
- the nonStandardMouseEvent
-
setNonStandardMouseEvent
public void setNonStandardMouseEvent(boolean nonStandardMouseEvent)
- Parameters:
nonStandardMouseEvent- the nonStandardMouseEvent to set
-
isGraphicTableState
public boolean isGraphicTableState()
- Returns:
- the graphicTableState
-
setGraphicTableState
public void setGraphicTableState(boolean graphicTableState)
- Parameters:
graphicTableState- the graphicTableState to set
-
isOblockEditTabbed
public boolean isOblockEditTabbed()
- Returns:
- the graphicTableState
-
setOblockEditTabbed
public void setOblockEditTabbed(boolean tabbed)
- Parameters:
tabbed- the Editor interface to set (fasle = desktop)
-
getMaxComboRows
public int getMaxComboRows()
- Returns:
- the number of combo box rows to be displayed.
-
setMaxComboRows
public void setMaxComboRows(int maxRows)
Set a new value for the number of combo box rows to be displayed.- Parameters:
maxRows- The new value, zero for no limit
-
isEditorUseOldLocSize
public boolean isEditorUseOldLocSize()
- Returns:
- the editorUseOldLocSize value
-
setEditorUseOldLocSize
public void setEditorUseOldLocSize(boolean editorUseOldLocSize)
- Parameters:
editorUseOldLocSize- the editorUseOldLocSize value to set
-
getJFileChooserFormat
public int getJFileChooserFormat()
JFileChooser Type- Returns:
- 0 default, 1 List 2 Detail
-
setJFileChooserFormat
public void setJFileChooserFormat(int jFileChooserFormat)
- Parameters:
jFileChooserFormat- the JFileChooser 0 default, 1 list, 2 detail
-
getLookAndFeel
public java.lang.String getLookAndFeel()
Get the name of the class implementing the preferred look and feel. Note this may not be the in-use look and feel if the preferred look and feel is not available on the current platform; and will be overwritten if preferences are saved on a platform where the preferred look and feel is not available.- Returns:
- the look and feel class name
-
setLookAndFeel
public void setLookAndFeel(java.lang.String lookAndFeel)
Set the name of the class implementing the preferred look and feel. Note this change only takes effect after the application is restarted, because Java has some issues setting the look and feel correctly on already open windows.- Parameters:
lookAndFeel- the look and feel class name
-
applyLookAndFeel
public void applyLookAndFeel()
Apply the existing look and feel.
-
setLocaleMinimally
public static void setLocaleMinimally(Profile profile)
Stand-alone service routine to set the default Locale.Intended to be invoked early, as soon as a profile is available, to ensure the correct language is set as startup proceeds. Must be followed eventually by a complete
setLocale(java.util.Locale).- Parameters:
profile- The profile to get the locale from
-
isDirty
public boolean isDirty()
Check if preferences need to be saved.- Returns:
- true if preferences need to be saved
-
isRestartRequired
public boolean isRestartRequired()
Check if application needs to restart to apply preferences.- Returns:
- true if preferences are only applied on application start
-
firePropertyChange
public void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
Fire a property change.- 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.- 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, java.lang.Object oldValue, java.lang.Object newValue)
Fire a property change.- 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
-
isInitializedWithExceptions
public boolean isInitializedWithExceptions(Profile profile)
Description copied from interface:PreferencesManagerTest if the PreferencesManager is initialized, but threw anInitializationExceptionduring initialization, for the provided Profile. Note that although both this method andPreferencesManager.isInitialized(jmri.profile.Profile)can be false, if isInitialized(Profile) returns true, this method must return false.- Specified by:
isInitializedWithExceptionsin interfacePreferencesManager- Parameters:
profile- the configuration profile to test against; may be null to test for exceptions thrown when initializing for this user regardless of profile- Returns:
- true if the provide is initialized with exceptions
-
getInitializationExceptions
@Nonnull public java.util.List<java.lang.Exception> getInitializationExceptions(Profile profile)
Description copied from interface:PreferencesManagerGet the set of exceptions thrown during initialization for the provided Profile.- Specified by:
getInitializationExceptionsin interfacePreferencesManager- Parameters:
profile- the configuration profile to test against; may be null to test for exceptions thrown when initializing for this user regardless of profile- Returns:
- A list of exceptions. If there are no exceptions, return an empty set instead of null.
-
-