public class UserConfiguration extends AbstractUserConfiguration implements PropertyChangeListener
A container for user preferences. Defines variables which affect the behavior of T-Plan Robot Enterprise and can be set by user.
Apart from get- and set- methods inherited from the base class, the
configuration allows to save a Color instance or even an array of colors.
Each color is converted to a vector of numbers where there are three integer
numbers representing Red, Green and Blue portions as provided by the Color's
RGB model. The vector of numbers is then saved using the setListOfNumbers()
method which converts the vector of numbers into a String.
If a component depends on any option value in this class, it should register
itself using the method addConfigurationListener()
and it will be notified about any changes in the
configuration.
T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
Modifier and Type | Field and Description |
---|---|
static String |
WATCH_DOG_LIST_KEY |
Modifier and Type | Method and Description |
---|---|
Boolean |
checkSecurity() |
static UserConfiguration |
getCopy()
Get a shared instance of this configuration.
|
static UserConfiguration |
getDefaultConfiguration()
Get a copy of the default configuration.
|
String |
getDefaultValue(String key)
Get default value for the given parameter
|
Color[] |
getDefaultValueAsArrayOfColors(String key)
Get default value of a parameter as an array of Color instances.
|
Color |
getDefaultValueAsColor(String key)
Get default value of a parameter as a Color instance.
|
Double |
getDefaultValueAsDouble(String key)
Get default value of a parameter as an Integer.
|
List |
getDefaultValueAsListOfNumbers(String key)
Get default value of a parameter as a vector of numbers.
|
static UserConfiguration |
getInstance()
Get a shared instance of this configuration.
|
KeyStroke |
getKeyStroke(String parameterName,
boolean fixForMacIfNeeded)
Get the value as a key stroke.
|
Map<String,String> |
getOverrideTable() |
List<String> |
getPreferenceNames() |
Object |
getRawValue(String key)
Get the raw value stored in the internal map for the given key.
|
static void |
load(InputStream inStream)
Load the configuration from an input stream.
|
static void |
loadDefaults(InputStream inStream)
Load the default configuration from an input stream.
|
void |
propertyChange(PropertyChangeEvent evt) |
void |
putRawValues(Map values) |
void |
remove(String configKey) |
static void |
resetToDefaults() |
static void |
save(OutputStream outStream)
Save the configuration into an output stream.
|
static void |
saveConfiguration() |
void |
setColors(String parameterName,
Color[] colors)
Save an array of colors to the configuration.
|
void |
setOverrideTable(Map overrideTable) |
void |
startWatchDog() |
void |
updateListOfRecents(String newItem,
String configKey,
int sizeLimit) |
void |
updateListOfRecents(String newItem,
String configKey,
int sizeLimit,
boolean caseSensitive)
This method will try to load a vector of strings using the given key.If
the vector already contains the new item, it gets moved to the first
position.
|
addConfigurationListener, addConfigurationListener, convertToListOfNumbers, fireConfigurationChanged, getArrayOfBytes, getArrayOfInts, getBoolean, getBooleanStrict, getColor, getColors, getDouble, getDoubleStrict, getInteger, getIntegerStrict, getListOfNumbers, getListOfStrings, getString, isModified, removeConfigurationListener, setBoolean, setDouble, setHTMLColor, setHTMLColorArray, setInteger, setListOfNumbers, setListOfObjects, setString
public static final String WATCH_DOG_LIST_KEY
public void startWatchDog()
public static UserConfiguration getInstance()
public static UserConfiguration getCopy()
public static UserConfiguration getDefaultConfiguration()
public static void resetToDefaults()
public static void load(InputStream inStream) throws IOException
inStream
- an input stream to load from.IOException
- when in I/O error occurs, e.g. cannot read from file
etc.public static void loadDefaults(InputStream inStream) throws IOException
inStream
- an input stream to load from.IOException
- when in I/O error occurs, e.g. cannot read from file
etc.public static void save(OutputStream outStream) throws IOException
outStream
- an output stream to save to.IOException
- when in I/O error occurs, e.g. cannot write to a file
etc.public static void saveConfiguration()
public final Boolean checkSecurity()
public String getDefaultValue(String key)
key
- parameter namepublic Double getDefaultValueAsDouble(String key)
key
- parameter namepublic List getDefaultValueAsListOfNumbers(String key)
key
- parameter namepublic Color[] getDefaultValueAsArrayOfColors(String key)
key
- parameter namepublic Color getDefaultValueAsColor(String key)
key
- parameter namepublic void setColors(String parameterName, Color[] colors)
setListOfNumbers()
method which converts the vector of numbers into a String.parameterName
- parameter name.colors
- an array of Color instances.public void updateListOfRecents(String newItem, String configKey, int sizeLimit, boolean caseSensitive)
This method will try to load a vector of strings using the given key.If the vector already contains the new item, it gets moved to the first position. Otherwise it is inserted into the first position.
If you need to keep the vector up to a certain size long, you may use the third argument to specify max vector size. A negative number disables this feature.
This method is used by dynamic menus that list e.g. recently open documents. Whenever a document is opened, it needs to be placed into the first position in the list. Such a list is usually of limited size, it e.g. lists just five most recently opened documents.
newItem
- a new item. If it already exists in the vector, it will be
just moved.configKey
- a key identifying the configuration vector.sizeLimit
- maximum size of the vector. If the vector exceeds this
size, it will be trimmed to the required size. Any negative number
disables this feature.caseSensitive
- true to apply case sensitive approach when checking
if the item is already in the list.public void updateListOfRecents(String newItem, String configKey, int sizeLimit)
public void setOverrideTable(Map overrideTable)
public void putRawValues(Map values)
public void remove(String configKey)
public final void propertyChange(PropertyChangeEvent evt)
propertyChange
in interface PropertyChangeListener
public Object getRawValue(String key)
String
instances it
always returns a string. Subclasses such as
SimplePreferenceContainer
may
return something else.key
- a key.public KeyStroke getKeyStroke(String parameterName, boolean fixForMacIfNeeded)
parameterName
- the parameter name.fixForMacIfNeeded
- if the value is the default one and the local OS
is Mac the method will fix the key stroke to meet the Mac guidelines
(Ctrl is converted to Command, Alt to Ctrl).