The Preference Settings Framework provides support for easy processing of preference settings from the .ini file. The framework identifies the valid values for each preference setting and supplies a default value if the preference setting is not included in the
.ini file. Preference settings are associated with applications and the most common way to code settings in the
.ini file is to put them in a stanza named the same as the application they apply to. However, settings in arbitrarily named stanzas and in multiple stanzas are also supported.
Some of the Application class methods are
delegated to subclasses, which mean that you must implement them to make use of the settings framework; some are
modifiable, which means you may implement them in your application class to change the default behavior; and some are provided for the application to use in processing the settings. Tto use the settings framework for an application, only the 3 modifiable and delegated methods need to be implemented.
|
•
|
an Atom (obtained by calling one of the xxxType methods on self)
|
|
•
|
a single-element Array containing either an Atom or an EmRange describing an unbounded array of values that are all of the same element type
|
|
•
|
a multiple-element Array containing Atoms and/or EmRanges describing a bounded (by the number of element types specified) array of values that correspond positionally with the specified element types
|
in their #startUp method so that the settings are initialized after an application has been loaded into a running image from the code repository and at image startup time.
Answer an Atom identifying the valid setting value as a
Boolean
Answer an Atom identifying the valid setting value as a
ScaledDecimal
Answer an Atom identifying the valid setting value as a
String representing a directory path name (with a trailing path separator character)
Answer an Atom identifying the valid setting value as a
String representing an absolute or relative filename
Answer an Atom identifying the valid setting value as a
Fraction
Answer an Atom identifying the valid setting value as an
Integer
Answer an Atom identifying the valid setting value as a
String which may contain line-end characters (
\)
Answer an Atom identifying the valid setting value as a
Fraction,
Integer, or
ScaledDecimal
Answer an Atom identifying the valid setting value as a
Point
Answer an Atom identifying the valid setting value as a positive
Integer
Answer an Atom identifying the valid setting value as a
String
Answer a new instance of EmRange that goes from
self to @last and includes @last in the range but does not include
self. Set the element type to @anAtom which specifies the legal types of values within the range. @anAtom can be one of
##decimalType,
##integerType,
##fractionType,
##pointType, or
##numberType (indicating that any of a decimal, fraction, or integer are valid setting elements).
Answer a new instance of EmRange that goes from
self to @last and excludes both
self and @last from the range. Set the element type to @anAtom which specifies the legal types of values within the range. @anAtom can be one of
##decimalType,
##integerType,
##fractionType,
##pointType, or
##numberType (indicating that any of a decimal, fraction, or integer are valid setting elements).
Answer a new instance of EmRange that goes from self to @last and includes
self in the range but does not include @last. Set the element type to @anAtom which specifies the legal types of values within the range. @anAtom can be one of
##decimalType,
##integerType,
##fractionType,
##pointType, or
##numberType (indicating that any of a decimal, fraction, or integer are valid setting elements).
Answer a new instance of EmRange that goes from
self to @last and includes both
self and @last in the range. Set the element type to @anAtom which specifies the legal types of values within the range. @anAtom can be one of
##decimalType,
##integerType,
##fractionType,
##pointType, or
##numberType (indicating that any of a decimal, fraction, or integer are valid setting elements).
A validSettings method specifying the value types for settings from 2 stanzas (showing the use of a simple specification and an
EmRange specification)
validSettings
^ LookupTable new
at: self symbol asString
put: (LookupTable with: 'fplevel' ->(0 inclusiveTo: 9 elementType: self integerType));
at: 'VAST 5.0 Compatibility'
put: (LookupTable with: 'installPath' -> self directoryType);
yourself
A validSettings method specifying the valueType for settings from one stanza showing the use of an
Array specification with a single elementType. This specifies that
bitmapPath will accept any number of directoryType values.
validSettings
^ LookupTable new
at: self symbol asString
put: (LookupTable with: 'bitmapPath' -> (Array with: self directoryType));
yourself
A validSettings method specifying the valueType for settings from one stanza showing the use of an
Array specification with multiple elementTypes. This specifies that
fooBar will accept exactly 3 values: 2 numberTypes and a stringType.
validSettings
^ LookupTable new
at: self symbol asString
put: (LookupTable with: 'fooBar' -> (Array with: self numberType with: self numberType with: self stringType));
yourself
A currentSettings method specifying information about settings from 2 stanzas
currentSettings
^ LookupTable new
at: self symbol asString
put: (LookupTable with: 'fplevel' -> (Array with: AbtFeatureLoader fixpackLevel with: 0));
at: 'VAST 5.0 Compatibility' put: (LookupTable with: 'installPath' -> (Array with: AbtFeatureLoader featureDirectory with: ('..%1feature%1' bindWith: CfsDirectoryDescriptor pathSeparatorString)));
yourself
A setCurrentSettings method showing how setting values are processed
setCurrentSettings
| addr |
addr := self settingFor: 'ServerAddress'.
addr isEmpty ifTrue: [ addr := nil ].
EmLibrary
defaultName: (self settingFor: 'DefaultName');
serverAddress: addr;
openReadOnly: (self settingFor: 'OpenReadOnly')
Copyright 2005, 2019 Instantiations, Inc. All rights reserved.