Package org.xtce.apps.editor.ui
Class XTCEViewerPreferences
- java.lang.Object
-
- org.xtce.apps.editor.ui.XTCEViewerPreferences
-
public class XTCEViewerPreferences extends Object
This singleton class provides a convenient accessor for user preferences related to using the XTCEViewer application. The preferences are stored using the Java Preferences API, so the manner and location of storage is dependent on the platform being used and is not managed within the application directly. The design pattern for this singleton resembles the recommendation by "Bill Pugh", of the Java community.- Author:
- David Overeem
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFindContainerSearch(String searchItem)Adds another Find Container Search Text item to the history with a limit of 25 non-duplicate items, with the most recent being the first on the list.voidaddFindParameterSearch(String searchItem)Adds another Find Parameter Search Text item to the history with a limit of 25 non-duplicate items, with the most recent being the first on the list.voidaddFindTelecommandSearch(String searchItem)Adds another Find Telecommand Search Text item to the history with a limit of 25 non-duplicate items, with the most recent being the first on the list.voidaddSavedXPathQuerySearch(String searchItem)Adds another XPath Query item to the saved cache with a limit of 25 non-duplicate items, with the most recent being the first on the list.voidclearRecentFilesList(JMenu recentItemsMenu)Method to erase the recent files list.StringgetContainerOrientationOption()Retrieve the user preference for drawing containers and telecommands as to their orientation on the drawing.StringgetCurrentWorkingDirectory()Retrieve the last working directory that was used for a load or save operation, considering that this is not retained in the Preferences.static XTCEViewerPreferencesgetInstance()The instance accessor to retrieve the singleton reference to the preferences object.LocalegetLanguagePreference()Retrieve the user last selected language and country preference or the default of English/US if it has not been explicitly set.StringgetPreferredAliasNamespaceOption()Retrieve the user preference for which namespace to show Aliases for on XTCEViewer displays.intgetRecentFilesMaxCountOption()Retrieve the user preference for the number of files to store in the recently loaded list for quicker access.List<String>getRecentFindContainerSearches()Retrieve the list of recent Find Container Search Text items to display in the combo box for user convenience.List<String>getRecentFindParameterSearches()Retrieve the list of recent Find Parameter Search Text items to display in the combo box for user convenience.List<String>getRecentFindTelecommandSearches()Retrieve the list of recent Find Telecommand Search Text items to display in the combo box for user convenience.List<String>getSavedXPathQueries()Retrieve the list of stored XPath Query items to display in the combo box for user convenience.booleangetShowAliasNamespacesOption()Retrieve the user preference for showing the alias namespace on the XTCEViewer displays in the form of NS::ALIAS, which is generally recommended if more than one namespace is to be shown.booleangetShowAllAliasNamespacesOption()Retrieve the user preference for showing all available Aliases on the XTCEViewer displays.booleangetShowAllContainerConditionalsOption()Retrieve the user preference for showing all available conditions and their children on containers within the XTCEViewer displays.booleangetUseXIncludeOption()Retrieve the user preference for using the XInclude XML feature when loading a database document.booleangetValidateOnLoadOption()Retrieves the user preference for exercising XSD validation on any XTCE XML document at time of load.voidremoveSavedXPathQuerySearch(String searchItem)Removes an XPath Query item from the saved cache.voidsetContainerOrientationOption(String orientDrawingAs)Sets the user preference for drawing containers and telecommands as to their orientation on the drawing.voidsetCurrentWorkingDirectory(String dirName)Sets the last working directory that was used for a load or save operation, considering that this is not retained in the Preferences.voidsetLanguagePreference(Locale locale)Sets the user preferred language and country preference.voidsetParentWindow(XTCEViewer viewerTool)This permits the XTCEViewer application to set a reference to itself for displaying the warning dialog in the event that the preferences cannot be saved.voidsetPreferredAliasNamespaceOption(String ns)Sets the user preference for which namespace to show Aliases for on XTCEViewer displays.voidsetRecentFilesMaxCountOption(int maxNum)Sets the user preference for the number of files to store in the recently loaded list for quicker access.voidsetShowAliasNamespacesOption(boolean flag)Sets the user preference for showing the alias namespace on the XTCEViewer displays in the form of NS::ALIAS, which is generally recommended if more than one namespace is to be shown.voidsetShowAllAliasNamespacesOption(boolean flag)Sets the user preference for showing all available Aliases on the XTCEViewer displays.voidsetShowAllContainerConditionalsOption(boolean flag)Sets the user preference for showing all available conditions and their children on containers within the XTCEViewer displays.voidsetUseXIncludeOption(boolean flag)Sets the user preference for using the XInclude XML feature when loading a database document.voidsetValidateOnLoadOption(boolean flag)Sets the user preference for exercising the XSD validation on any XTCE XML document at time of load.voidupdateExampleFilesList(JMenu exampleItemsMenu)Method to initialize/update the example databases list from the internal database package directory included with the toolkit.voidupdateRecentFilesList(JMenu recentItemsMenu, File dbFile)Method to add the most recently loaded file to the recent items menu list, store it in the preferences, and re-sort the menu items.
-
-
-
Method Detail
-
getInstance
public static XTCEViewerPreferences getInstance()
The instance accessor to retrieve the singleton reference to the preferences object.- Returns:
- XTCEViewerPreferences object, which can never be null.
-
getValidateOnLoadOption
public boolean getValidateOnLoadOption()
Retrieves the user preference for exercising XSD validation on any XTCE XML document at time of load. Having this option be false improves load performance but risks a de-stablization of the application in the event that the XML document is not valid against the XTCE data model.- Returns:
- boolean indicating if schema validation will be enabled on load.
-
setValidateOnLoadOption
public void setValidateOnLoadOption(boolean flag)
Sets the user preference for exercising the XSD validation on any XTCE XML document at time of load. Having this option be false improves load performance but risks a de-stablization of the application in the event that the XML document is not valid against the XTCE data model.- Parameters:
flag- Boolean indicating if the XSD validation should be enabled on the next document load and for any other document load events until otherwise changed again by the user.
-
getShowAliasNamespacesOption
public boolean getShowAliasNamespacesOption()
Retrieve the user preference for showing the alias namespace on the XTCEViewer displays in the form of NS::ALIAS, which is generally recommended if more than one namespace is to be shown.- Returns:
- boolean indicating if the user interface should show the Alias namespaces in the form NS::ALIAS or just the ALIAS name.
-
setShowAliasNamespacesOption
public void setShowAliasNamespacesOption(boolean flag)
Sets the user preference for showing the alias namespace on the XTCEViewer displays in the form of NS::ALIAS, which is generally recommended if more than one namespace is to be shown.- Parameters:
flag- Boolean indicating if the user interface should show the alias namespaces in the form NS::ALIAS or just the ALIAS name.
-
getShowAllAliasNamespacesOption
public boolean getShowAllAliasNamespacesOption()
Retrieve the user preference for showing all available Aliases on the XTCEViewer displays. This preference is independent of the getShowAliasNamespacesOption(). That options controls whether or not the namespaces for each alias are displayed. It is generally recommended that the other option be true when this option is also true, but it is not required. The drawback is that the user will not be able to differentiate between the aliases. When a preferred namespace is set with setPreferredAliasNamespace(), then this flag will automatically become false. When setting this flag true, the setPreferredAliasNamespace() will automatically be set to an empty string, meaning no preferred namespace.- Returns:
- boolean indicating if all aliases of all namespaces will be displayed on the user interface.
-
setShowAllAliasNamespacesOption
public void setShowAllAliasNamespacesOption(boolean flag)
Sets the user preference for showing all available Aliases on the XTCEViewer displays. This preference is independent of the setShowAliasNamespacesOption(). That options controls whether or not the namespaces for each alias are displayed. It is generally recommended that the other option be true when this option is also true, but it is not required. The drawback is that the user will not be able to differentiate between the aliases. When a preferred namespace is set with setPreferredAliasNamespace(), then this flag will automatically become false. When setting this flag true, the setPreferredAliasNamespace() will automatically be set to an empty string, meaning no preferred namespace.- Parameters:
flag- Boolean indicating if all aliases of all namespaces will be displayed on the user interface.
-
getUseXIncludeOption
public boolean getUseXIncludeOption()
Retrieve the user preference for using the XInclude XML feature when loading a database document.- Returns:
- boolean indicating if new documents loaded will have XInclude applied when it exists in the document.
-
setUseXIncludeOption
public void setUseXIncludeOption(boolean flag)
Sets the user preference for using the XInclude XML feature when loading a database document.- Parameters:
flag- boolean indicating if future documents should have the XML XInclude feature observed.
-
getPreferredAliasNamespaceOption
public String getPreferredAliasNamespaceOption()
Retrieve the user preference for which namespace to show Aliases for on XTCEViewer displays. This option is coupled with the getShowAllAliasNamespacesOption() method. A non-empty string return here will imply that the other option will return false. If this option returns an empty string, then the other option will return true.- Returns:
- String containing the preferred namespace to show the user on the user interface.
-
setPreferredAliasNamespaceOption
public void setPreferredAliasNamespaceOption(String ns)
Sets the user preference for which namespace to show Aliases for on XTCEViewer displays. This option is coupled with the setShowAllAliasNamespacesOption() method. A non-empty string setting here will set that the other option will return false.- Parameters:
ns- String containing the preferred namespace to show the user on the user interface.
-
getRecentFilesMaxCountOption
public int getRecentFilesMaxCountOption()
Retrieve the user preference for the number of files to store in the recently loaded list for quicker access.- Returns:
- Integer count of the number of files to keep on the list. The oldest files are dropped first when the count reaches the maximum size.
-
setRecentFilesMaxCountOption
public void setRecentFilesMaxCountOption(int maxNum)
Sets the user preference for the number of files to store in the recently loaded list for quicker access.- Parameters:
maxNum- Integer value containing the maximum number of files to store on the recent files loaded list, with the oldest ones being dropped when the count is exceeded.
-
getShowAllContainerConditionalsOption
public boolean getShowAllContainerConditionalsOption()
Retrieve the user preference for showing all available conditions and their children on containers within the XTCEViewer displays.- Returns:
- boolean indicating if all aliases of all conditions will be displayed on the user interface.
-
setShowAllContainerConditionalsOption
public void setShowAllContainerConditionalsOption(boolean flag)
Sets the user preference for showing all available conditions and their children on containers within the XTCEViewer displays.- Parameters:
flag- Boolean indicating if all conditionals for containers will be displayed on the user interface.
-
getContainerOrientationOption
public String getContainerOrientationOption()
Retrieve the user preference for drawing containers and telecommands as to their orientation on the drawing.- Returns:
- String containing "LEFT_TO_RIGHT" or "TOP_TO_BOTTOM".
-
setContainerOrientationOption
public void setContainerOrientationOption(String orientDrawingAs)
Sets the user preference for drawing containers and telecommands as to their orientation on the drawing.- Parameters:
orientDrawingAs- String containing either "LEFT_TO_RIGHT" or "TOP_TO_BOTTOM". Anything else will be no change.
-
updateRecentFilesList
public void updateRecentFilesList(JMenu recentItemsMenu, File dbFile)
Method to add the most recently loaded file to the recent items menu list, store it in the preferences, and re-sort the menu items.- Parameters:
recentItemsMenu- The JMenu object to update the list with the latest loaded file.dbFile- The File object of the just loaded XTCE database or null if the list need not be updated, rather just the menu (such as startup).
-
updateExampleFilesList
public void updateExampleFilesList(JMenu exampleItemsMenu)
Method to initialize/update the example databases list from the internal database package directory included with the toolkit. Note that these files are loaded using the system resource classpath, which may be inside the distributed jar file and not directly visible on the filesystem. Also, this method presently only selects the files in the org.xtce.toolkit.database.examples package/folder with names of "*.xml".- Parameters:
exampleItemsMenu- JMenu item on the File Menu that contains the list of example databases.
-
clearRecentFilesList
public void clearRecentFilesList(JMenu recentItemsMenu)
Method to erase the recent files list.- Parameters:
recentItemsMenu- The JMenu object to clear the items from.
-
getSavedXPathQueries
public List<String> getSavedXPathQueries()
Retrieve the list of stored XPath Query items to display in the combo box for user convenience.- Returns:
- List of Strings in order from most recent to least recent with a limit of up to 25 previous searches.
-
addSavedXPathQuerySearch
public void addSavedXPathQuerySearch(String searchItem)
Adds another XPath Query item to the saved cache with a limit of 25 non-duplicate items, with the most recent being the first on the list.- Parameters:
searchItem- String containing the user text string to add.
-
removeSavedXPathQuerySearch
public void removeSavedXPathQuerySearch(String searchItem)
Removes an XPath Query item from the saved cache.- Parameters:
searchItem- String containing the user text string to remove.
-
getRecentFindParameterSearches
public List<String> getRecentFindParameterSearches()
Retrieve the list of recent Find Parameter Search Text items to display in the combo box for user convenience.- Returns:
- List of Strings in order from most recent to least recent with a limit of up to 25 previous searches.
-
addFindParameterSearch
public void addFindParameterSearch(String searchItem)
Adds another Find Parameter Search Text item to the history with a limit of 25 non-duplicate items, with the most recent being the first on the list.- Parameters:
searchItem- String containing the user text string to add.
-
getRecentFindContainerSearches
public List<String> getRecentFindContainerSearches()
Retrieve the list of recent Find Container Search Text items to display in the combo box for user convenience.- Returns:
- List of Strings in order from most recent to least recent with a limit of up to 25 previous searches.
-
addFindContainerSearch
public void addFindContainerSearch(String searchItem)
Adds another Find Container Search Text item to the history with a limit of 25 non-duplicate items, with the most recent being the first on the list.- Parameters:
searchItem- String containing the user text string to add.
-
getRecentFindTelecommandSearches
public List<String> getRecentFindTelecommandSearches()
Retrieve the list of recent Find Telecommand Search Text items to display in the combo box for user convenience.- Returns:
- List of Strings in order from most recent to least recent with a limit of up to 25 previous searches.
-
addFindTelecommandSearch
public void addFindTelecommandSearch(String searchItem)
Adds another Find Telecommand Search Text item to the history with a limit of 25 non-duplicate items, with the most recent being the first on the list.- Parameters:
searchItem- String containing the user text string to add.
-
getCurrentWorkingDirectory
public String getCurrentWorkingDirectory()
Retrieve the last working directory that was used for a load or save operation, considering that this is not retained in the Preferences.- Returns:
- String containing the last current working directory or an empty string if none has yet been used.
-
setCurrentWorkingDirectory
public void setCurrentWorkingDirectory(String dirName)
Sets the last working directory that was used for a load or save operation, considering that this is not retained in the Preferences.- Parameters:
dirName- String containing the last working directory that was used for a load or save operation.
-
getLanguagePreference
public Locale getLanguagePreference()
Retrieve the user last selected language and country preference or the default of English/US if it has not been explicitly set.- Returns:
- Locale containing the I18N and L10N preferences.
-
setLanguagePreference
public void setLanguagePreference(Locale locale)
Sets the user preferred language and country preference.- Parameters:
locale- containing the language and country preference.
-
setParentWindow
public void setParentWindow(XTCEViewer viewerTool)
This permits the XTCEViewer application to set a reference to itself for displaying the warning dialog in the event that the preferences cannot be saved. If this is not set, then the warning will be displayed to STDOUT.- Parameters:
viewerTool- The XTCEViewer application that instantiated this preferences object.
-
-