Venice 0.751beta

nz.org.venice.prefs
Class PreferencesManager

java.lang.Object
  extended bynz.org.venice.prefs.PreferencesManager

public class PreferencesManager
extends java.lang.Object

The Preferences Manager contains a set of routines for loading and saving all preferences data for the application. Consolidating these routines in a single place allows us to maintain preferences namespace convention and also allows us to easily change the method of storage at a later date if desired.

If a save method first clears all preferences data from a node, it is imperative that both the save and the equivalent load methods are synchronized. Otherwise there is the possibility the load call is called just after the delete call which would nuke all the values. Perhaps all the methods should be synchronized.

Author:
Daniel Makovec

Nested Class Summary
 class PreferencesManager.DatabasePreferences
          Database preferences fields.
 class PreferencesManager.DisplayPreferences
          Display preferences fields.
 class PreferencesManager.IDQuoteSyncPreferences
          Intra-day Quote Sync preferences fields.
 class PreferencesManager.ProxyPreferences
          Web proxy preferences fields.
 
Field Summary
static int DATABASE
          Indicates the quote source is accessing quotes in a database.
static int FILES
          Deprecated. Indicates the quote source is accessing quotes in files.
static int INTERNAL
          Indicates the quote source is accessing the internal database.
static int SAMPLES
          Indicates the quote source is using the inbuilt sample quotes.
 
Method Summary
static void deletePortfolio(java.lang.String name)
          Delete the portfolio.
static void deleteWatchScreen(java.lang.String name)
          Delete the watch screen.
static void flush()
          Forces the preferences data to be saved to the backend store (e.g. disk).
static java.lang.String getAlertDestination()
          Retrieve where the users is storing alerts
static java.util.HashMap getAnalyserPageSettings(java.lang.String key)
          Load all saved user input in an Analyser Page.
static boolean getCacheExpiryEnabled()
          Load the users preference for whether the quotes in the cache expire.
static int getCacheExpiryTime()
          Load the users preference for when the quotes in the cache expire.
static boolean getConfirmExitSetting()
          Return true if Venice should confirm exit.
static PreferencesManager.DatabasePreferences getDatabaseSettings()
          Load database settings.
static java.lang.String getDefaultChart()
          Load default chart setting.
static java.awt.Color getDefaultChartBackgroundColour()
          Load default chart setting.
static boolean getDefaultChartScrollToEnd()
          Load default chart scroll bar position.
static boolean getDefaultTableScrollToEnd()
          Load default table scroll bar position.
static java.lang.String getDirectoryLocation(java.lang.String dirtype)
          Load the last directory used when importing quote files.
static PreferencesManager.DisplayPreferences getDisplaySettings()
          Load display settings.
static int getEditTabSize()
          Load user interface setting.
static boolean getHasGPLAcceptance()
          Return whether we require the user to explicitly accept the GPL license.
static PreferencesManager.IDQuoteSyncPreferences getIDQuoteSyncPreferences()
          Load intra-day quote sync module preferences.
static java.lang.String getInternalFileName()
          Load the file name to store the internal database.
static java.lang.String getLanguageCode()
          Load language setting.
static int getLastPreferencesPage()
          Load the last preferences page visited.
static java.io.File getMacroHome()
          Return the directroy which contains Venice's macros.
static int getMaxDecimalDigits()
          Load user interface setting.
static int getMaximumCachedQuotes()
          Load the cache's maximum number of quotes.
static int getMinDecimalDigits()
          Load user interface setting.
static Portfolio getPortfolio(java.lang.String portfolioName)
          Load the portfolio with the given name.
static java.util.List getPortfolioNames()
          Return a list of the names of all the portfolios.
static PreferencesManager.ProxyPreferences getProxySettings()
          Load proxy settings.
static int getQuoteSource()
          Get quote source setting.
static boolean getRestoreSavedWindowsSetting()
          Return wether to restore windows on restart
static java.util.Vector getSavedFrames()
          Return a list of frames saved on the filesystem.
static java.util.List getStoredExpressions()
          Load the list of all stored expressions.
static java.util.List getStoredMacros()
          Load the list of all registered macros.
static java.util.List getSymbolMetadata()
           
static java.util.prefs.Preferences getUserNode(java.lang.String node)
          Fetches the desired user node, based at the base branch.
static java.lang.String getUserNotes(java.lang.String symbol)
           
static WatchScreen getWatchScreen(java.lang.String watchScreenName)
          Load the watch screen with the given name.
static java.util.List getWatchScreenNames()
          Return a list of the names of all the watch screens.
static boolean isMarketIndex(Symbol symbol)
           
static void putAlertDestination(java.lang.String destination)
          Save alert destination
static void putAnalyserPageSettings(java.lang.String key, java.util.HashMap settings)
          Save all user input in an Analyser Page.
static void putCacheExpiryEnabled(boolean expiry)
          Save the users preferences for whether the quotes in the cache expire.
static void putCacheExpiryTime(int lifespan)
          Save the users preference for when the quotes in the cache expire.
static void putConfirmExitSetting(boolean state)
          Save whether Venice should confirm exit.
static void putDatabaseSettings(PreferencesManager.DatabasePreferences databasePreferences)
          Save database settings.
static void putDefaultChart(java.lang.String defaultChart)
          Save default chart setting.
static void putDefaultChartBackgroundColour(java.awt.Color backColour)
          Save default chart background colour.
static void putDefaultChartScrollToEnd(boolean isSelected)
          Save default chart scroll bar setting.
static void putDefaultTableScrollToEnd(boolean isSelected)
          Save default table scroll bar setting.
static void putDirectoryLocation(java.lang.String dirtype, java.lang.String directory)
          Save the directory used to import quote files.
static void putDisplaySettings(PreferencesManager.DisplayPreferences displayPreferences)
          Save display settings.
static void putEditTabSize(java.lang.String tabSize)
          Save user interface setting.
static void putHasGPLAcceptance()
          Set that the user has been shown the GPL and has accepted it.
static void putIDQuoteSyncPreferences(PreferencesManager.IDQuoteSyncPreferences idQuoteSyncPreferences)
          Save intra-day quote sync module preferences.
static void putLanguageCode(java.lang.String languageCode)
          Save language setting.
static void putLastPreferencesPage(int page)
          Save last preferences page visited.
static void putMaxDecimalDigits(java.lang.String maxDecimalDigits)
          Save user interface setting.
static void putMaximumCachedQuotes(int maximumCachedQuotes)
          Save the cache's maximum number of quotes.
static void putMinDecimalDigits(java.lang.String minDecimalDigits)
          Save user interface setting.
static void putModuleFrameSettings(ModuleFrame frame)
           
static void putPortfolio(Portfolio portfolio)
          Save the portfolio.
static void putProxySettings(PreferencesManager.ProxyPreferences proxyPreferences)
          Save proxy settings.
static void putQuoteSource(int quoteSource)
          Set quote source setting.
static void putRestoreSavedWindowsSetting(boolean state)
          Save wether to restore windows on restart.
static void putStoredExpressions(java.util.List storedExpressions)
          Save the list of all stored expressions.
static void putStoredMacros(java.util.List stored_macros)
          Save the list of all registered macros.
static void putSymbolMetadata(java.util.List indexSymbols)
           
static void putUserNotes(java.lang.String symbol, java.lang.String text)
           
static void putWatchScreen(WatchScreen watchScreen)
          Save the watch screen.
static void removeSavedFrames()
          Remove all the saved frames.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SAMPLES

public static int SAMPLES
Indicates the quote source is using the inbuilt sample quotes.


FILES

public static int FILES
Deprecated. Indicates the quote source is accessing quotes in files.


DATABASE

public static int DATABASE
Indicates the quote source is accessing quotes in a database.


INTERNAL

public static int INTERNAL
Indicates the quote source is accessing the internal database.

Method Detail

flush

public static void flush()
Forces the preferences data to be saved to the backend store (e.g. disk).


getUserNode

public static java.util.prefs.Preferences getUserNode(java.lang.String node)
Fetches the desired user node, based at the base branch.

Parameters:
node - the path to the node to be fetched.

getHasGPLAcceptance

public static boolean getHasGPLAcceptance()
Return whether we require the user to explicitly accept the GPL license. Currently the license must be explicilty accepted by the user for each version.

Returns:
true if the user needs to explicitly accept the GPL.

putHasGPLAcceptance

public static void putHasGPLAcceptance()
Set that the user has been shown the GPL and has accepted it. The user will not be bothered again until the next version.


getDirectoryLocation

public static java.lang.String getDirectoryLocation(java.lang.String dirtype)
Load the last directory used when importing quote files.

Parameters:
dirtype - the directory type (e.g. macros, importer, etc).
Returns:
the directory.

putDirectoryLocation

public static void putDirectoryLocation(java.lang.String dirtype,
                                        java.lang.String directory)
Save the directory used to import quote files.

Parameters:
dirtype - the directory type (e.g. macros, importer, etc)
directory - the directory.

getStoredExpressions

public static java.util.List getStoredExpressions()
Load the list of all stored expressions.

Returns:
the list of stored expressions.
See Also:
StoredExpression

putStoredExpressions

public static void putStoredExpressions(java.util.List storedExpressions)
Save the list of all stored expressions.

Parameters:
storedExpressions - the stored expressions.
See Also:
StoredExpression

getStoredMacros

public static java.util.List getStoredMacros()
Load the list of all registered macros.

Returns:
the list of registered macros.
See Also:
StoredMacro

putStoredMacros

public static void putStoredMacros(java.util.List stored_macros)
Save the list of all registered macros.

Parameters:
stored_macros - the registered macros.
See Also:
StoredMacro

getSymbolMetadata

public static java.util.List getSymbolMetadata()
                                        throws PreferencesException
Throws:
PreferencesException

putSymbolMetadata

public static void putSymbolMetadata(java.util.List indexSymbols)
                              throws PreferencesException
Throws:
PreferencesException

isMarketIndex

public static boolean isMarketIndex(Symbol symbol)

putUserNotes

public static void putUserNotes(java.lang.String symbol,
                                java.lang.String text)

getUserNotes

public static java.lang.String getUserNotes(java.lang.String symbol)

getAnalyserPageSettings

public static java.util.HashMap getAnalyserPageSettings(java.lang.String key)
Load all saved user input in an Analyser Page.

Parameters:
key - a key which identifies which page settings to load.
Returns:
mapping of settings.
See Also:
AnalyserPage

putAnalyserPageSettings

public static void putAnalyserPageSettings(java.lang.String key,
                                           java.util.HashMap settings)
Save all user input in an Analyser Page.

Parameters:
key - a key which identifies which page settings to save.
settings - the settings to save.
See Also:
AnalyserPage

getLastPreferencesPage

public static int getLastPreferencesPage()
Load the last preferences page visited.

Returns:
index of the last preferences page visited.

putLastPreferencesPage

public static void putLastPreferencesPage(int page)
Save last preferences page visited.

Parameters:
page - index of the last preferences page visited.

getMaximumCachedQuotes

public static int getMaximumCachedQuotes()
Load the cache's maximum number of quotes.

Returns:
the maximum number of quotes.

putMaximumCachedQuotes

public static void putMaximumCachedQuotes(int maximumCachedQuotes)
Save the cache's maximum number of quotes.

Parameters:
maximumCachedQuotes - the maximum number of quotes.

getCacheExpiryEnabled

public static boolean getCacheExpiryEnabled()
Load the users preference for whether the quotes in the cache expire.

Returns:
True if cacheExpiry is enabled.

putCacheExpiryEnabled

public static void putCacheExpiryEnabled(boolean expiry)
Save the users preferences for whether the quotes in the cache expire.

Parameters:
expiry - If true, the quotes in the cache will expire.

putCacheExpiryTime

public static void putCacheExpiryTime(int lifespan)
Save the users preference for when the quotes in the cache expire.

Parameters:
lifespan - the number of minutes that must elapse before refreshing the cache.

getCacheExpiryTime

public static int getCacheExpiryTime()
Load the users preference for when the quotes in the cache expire.

Returns:
The number of minutes that must elapse before refreshing the cache.

getWatchScreenNames

public static java.util.List getWatchScreenNames()
Return a list of the names of all the watch screens.

Returns:
the list of watch screen names.

getWatchScreen

public static WatchScreen getWatchScreen(java.lang.String watchScreenName)
                                  throws PreferencesException
Load the watch screen with the given name.

Parameters:
watchScreenName - the name of the watch screen to load.
Returns:
the watch screen.
Throws:
PreferencesException - if there was an error loading the watch screen.

putWatchScreen

public static void putWatchScreen(WatchScreen watchScreen)
                           throws PreferencesException
Save the watch screen.

Parameters:
watchScreen - the watch screen.
Throws:
PreferencesException - if there was an error saving the watch screen.

deleteWatchScreen

public static void deleteWatchScreen(java.lang.String name)
Delete the watch screen.

Parameters:
name - the watch screen name.

getPortfolioNames

public static java.util.List getPortfolioNames()
Return a list of the names of all the portfolios.

Returns:
the list of portfolio names.

deletePortfolio

public static void deletePortfolio(java.lang.String name)
Delete the portfolio.

Parameters:
name - the portfolio name.

getPortfolio

public static Portfolio getPortfolio(java.lang.String portfolioName)
                              throws PreferencesException
Load the portfolio with the given name.

Parameters:
portfolioName - the name of the portfolio to load.
Returns:
the portfolio.
Throws:
PreferencesException - if there was an error loading the portfolio.

getMacroHome

public static java.io.File getMacroHome()
Return the directroy which contains Venice's macros.

Returns:
Macro directroy.

putPortfolio

public static void putPortfolio(Portfolio portfolio)
                         throws PreferencesException
Save the portfolio.

Parameters:
portfolio - the portfolio.
Throws:
PreferencesException - if there was an error saving the portfolio.

getProxySettings

public static PreferencesManager.ProxyPreferences getProxySettings()
Load proxy settings.

Returns:
proxy preferences.

putProxySettings

public static void putProxySettings(PreferencesManager.ProxyPreferences proxyPreferences)
Save proxy settings.

Parameters:
proxyPreferences - the new proxy preferences.

getLanguageCode

public static java.lang.String getLanguageCode()
Load language setting. Returns null if there is no language setting saved in preferences.

Returns:
ISO Language Code

putLanguageCode

public static void putLanguageCode(java.lang.String languageCode)
Save language setting.

Parameters:
languageCode - ISO Language Code.

getMinDecimalDigits

public static int getMinDecimalDigits()
Load user interface setting.

Returns:
the minimum decimal digits to be displayed.

putMinDecimalDigits

public static void putMinDecimalDigits(java.lang.String minDecimalDigits)
Save user interface setting.

Parameters:
minDecimalDigits - the minimum decimal digits to be displayed.

getMaxDecimalDigits

public static int getMaxDecimalDigits()
Load user interface setting.

Returns:
the maximum decimal digits to be displayed.

putMaxDecimalDigits

public static void putMaxDecimalDigits(java.lang.String maxDecimalDigits)
Save user interface setting.

Parameters:
maxDecimalDigits - the maximum decimal digits to be displayed.

getEditTabSize

public static int getEditTabSize()
Load user interface setting.

Returns:
the tab size to enter in a text dialog.

putEditTabSize

public static void putEditTabSize(java.lang.String tabSize)
Save user interface setting.

Parameters:
tabSize - the number of characters to insert when the tab key is pressed.

getDefaultChart

public static java.lang.String getDefaultChart()
Load default chart setting.

Returns:
the default chart to be displayed.

getDefaultChartBackgroundColour

public static java.awt.Color getDefaultChartBackgroundColour()
Load default chart setting.

Returns:
the default chart background colour.

getDefaultChartScrollToEnd

public static boolean getDefaultChartScrollToEnd()
Load default chart scroll bar position.

Returns:
whether to move the scroll bar to the end of the pane when creating a new chart.

getDefaultTableScrollToEnd

public static boolean getDefaultTableScrollToEnd()
Load default table scroll bar position.

Returns:
whether to move the scroll bar to the end of the pane when creating a new table.

putRestoreSavedWindowsSetting

public static void putRestoreSavedWindowsSetting(boolean state)
Save wether to restore windows on restart.

Parameters:
state - a boolean flag which when true causes Venice to reconstruct previously open windows.

getRestoreSavedWindowsSetting

public static boolean getRestoreSavedWindowsSetting()
Return wether to restore windows on restart

Returns:
wether Venice should to reconstruct previously open windows.

putConfirmExitSetting

public static void putConfirmExitSetting(boolean state)
Save whether Venice should confirm exit.

Parameters:
state - Flag when true causes venice to prompt the user to confirm their exit.

getConfirmExitSetting

public static boolean getConfirmExitSetting()
Return true if Venice should confirm exit.

Returns:
true if Venice should prompt the user to confirm their exit.

putDefaultChart

public static void putDefaultChart(java.lang.String defaultChart)
Save default chart setting.

Parameters:
defaultChart - the chart to be displayed.

putDefaultChartBackgroundColour

public static void putDefaultChartBackgroundColour(java.awt.Color backColour)
Save default chart background colour.

Parameters:
backColour - the default background colour.

putDefaultChartScrollToEnd

public static void putDefaultChartScrollToEnd(boolean isSelected)
Save default chart scroll bar setting.

Parameters:
isSelected - if the scroll bar on a chart should be moved to the end.

putDefaultTableScrollToEnd

public static void putDefaultTableScrollToEnd(boolean isSelected)
Save default table scroll bar setting.

Parameters:
isSelected - if the scroll bar on a table should be moved to the end.

getQuoteSource

public static int getQuoteSource()
Get quote source setting.

Returns:
quote source, one of DATABASE, FILES or SAMPLES.

putQuoteSource

public static void putQuoteSource(int quoteSource)
Set quote source setting.

Parameters:
quoteSource - the quote source, one of DATABASE, INTERNAL or SAMPLES.

getDatabaseSettings

public static PreferencesManager.DatabasePreferences getDatabaseSettings()
Load database settings.

Returns:
database preferences.

putDatabaseSettings

public static void putDatabaseSettings(PreferencesManager.DatabasePreferences databasePreferences)
Save database settings.

Parameters:
databasePreferences - the new database preferences.

getInternalFileName

public static java.lang.String getInternalFileName()
Load the file name to store the internal database.

Returns:
internal database file name

getDisplaySettings

public static PreferencesManager.DisplayPreferences getDisplaySettings()
Load display settings.

Returns:
display preferences.

putDisplaySettings

public static void putDisplaySettings(PreferencesManager.DisplayPreferences displayPreferences)
Save display settings.

Parameters:
displayPreferences - the new display preferences.

getIDQuoteSyncPreferences

public static PreferencesManager.IDQuoteSyncPreferences getIDQuoteSyncPreferences()
Load intra-day quote sync module preferences.

Returns:
the preferences.
See Also:
IDQuoteSyncModule

putIDQuoteSyncPreferences

public static void putIDQuoteSyncPreferences(PreferencesManager.IDQuoteSyncPreferences idQuoteSyncPreferences)
Save intra-day quote sync module preferences.

Parameters:
idQuoteSyncPreferences - the preferences.
See Also:
IDQuoteSyncModule

getSavedFrames

public static java.util.Vector getSavedFrames()
Return a list of frames saved on the filesystem.

Returns:
A vector where the elements are File objects containing saved ModuleFrame data. The location of the saved frames is ~/Venice/SavedWindows. As the restore saved windows feature is new, there is no old preferences mechanism.

putModuleFrameSettings

public static void putModuleFrameSettings(ModuleFrame frame)
                                   throws PreferencesException
Throws:
PreferencesException

removeSavedFrames

public static void removeSavedFrames()
Remove all the saved frames.


getAlertDestination

public static java.lang.String getAlertDestination()
Retrieve where the users is storing alerts


putAlertDestination

public static void putAlertDestination(java.lang.String destination)
Save alert destination

Parameters:
destination - Where the alerts should be stored

Venice 0.751beta