public class Preference extends Object implements ConfigurationKeys
Preference
class is a wrapper around a single configuration parameter. It
defines meta data needed to display and edit the parameter value in the GUI. This
meta data includes short name of the preference (called "label"), description,
value type (string, boolean, integer, float, color, enumerated type or a keystroke),
parameter key in the configuration file or a parameter set.T-Plan Robot Enterprise, (C) 2009-2022 T-Plan Limited. All rights reserved.
Modifier and Type | Field and Description |
---|---|
static int |
TYPE_BOOLEAN
A boolean value represented by a check box or a radio button.
|
static int |
TYPE_BUTTON
Standalone JButton which can be attached through the
PreferenceComponentManager . |
static int |
TYPE_COLLAPSED_FOLDER
"Collapsed container" preference type allowing to hide a group of
preferences and display just a check box (since 4.0)
|
static int |
TYPE_COLOR
A color value represented by a drop down with the default set of colors
and a button allowing to add custom ones.
|
static int |
TYPE_COLOR_FROM_IMAGE
Color from an image.
|
static int |
TYPE_COLOR_LIST
List of colors.
|
static int |
TYPE_COORDINATES
A coordinate panel where each of the two numbers supports custom input.
|
static int |
TYPE_DATE_FORMAT
A date format preference.
|
static int |
TYPE_DIMENSION
Dimension/size type (since 4.0)
|
static int |
TYPE_DIRECTORY
A directory preference value type.
|
static int |
TYPE_DUMMY
Dummy preference which represents no value.
|
static int |
TYPE_DYNAMIC_PANEL
Dynamic panel whose content depends on the value selected in another preference
|
static int |
TYPE_DYNAMIC_PARAM_LIST
A field specifying a dynamic parameter list
|
static int |
TYPE_FILE
A file preference value type.
|
static int |
TYPE_FILELIST
List of files.
|
static int |
TYPE_FLOAT
A floating point value represented by a number spinner.
|
static int |
TYPE_FLOAT_LIST
List of floats (since 4.0)
|
static int |
TYPE_HIDDEN
A hidden fixed value.
|
static int |
TYPE_INT
An integer value represented by a number spinner.
|
static int |
TYPE_INT_DISPLAYED_AS_BOOLEAN
Integer value which should be represented by a checkbox.
|
static int |
TYPE_INT_LIST
List of integers (since 4.0)
|
static int |
TYPE_KEYSTROKE
A key stroke such as "Ctrl+C".
|
static int |
TYPE_PASSWORD
Password type - a String whose value should be masked when displayed in the GUI.
|
static int |
TYPE_PINCH
Pinch/zoom parameters (since 3.5)
|
static int |
TYPE_POINT
A point value (a location consisting of the [x, y] coordinates).
|
static int |
TYPE_POINT_RELATIVE
Relative point (since 4.1)
|
static int |
TYPE_PREFERENCE_PANEL
A custom implementation of PreferencePanel.
|
static int |
TYPE_RECTANGLE
A rectangle field.
|
static int |
TYPE_REGEXP
A field specifying a regular expression
|
static int |
TYPE_STRING
A string preference type represented by a text field or a drop down.
|
static int |
TYPE_STRING_WITH_ACTION
A string value represented by a text field with a customizable button which can be attached through the
PreferenceComponentManager . |
static int |
TYPE_STRINGLIST
A list of semicolon separated string values where the supported value set
is fixed.
|
static int |
TYPE_TEXT
Multi line text, usually represented in the GUI by a text editor.
|
static int |
TYPE_TIME_INTERVAL
Time interval such as 2 seconds or 5 minutes
|
CAPTURE_USE_LEGACY_DIALOG, COMPARETO_MAX_LOADED_PIXEL_ROWS, COMPARETO_MAX_SEARCH_HITS, DEFAULT_MODULE_PARAM_NAME, EDITOR_BREAKPOINT_COLOR, EDITOR_EXECUTED_LINE_COLOR, EDITOR_SYNTAX_ERROR_COLOR, IO_ACTIVE_FILE, IO_OPEN_FILE_LIST, IO_RECENT_SCRIPTS, IO_RECENT_SERVERS, MAX_DYNAMIC_MENU_ITEMS, MODULE_LIST_PARAM_NAME, REFRESH_DAEMON_ENABLE, REFRESH_DAEMON_MAX_IDLE_TIME, REPEAT_COMPARISON_FOR_MOVED_MOUSE, SCRIPT_HANDLER_CHECK_SYNTAX_BEFORE_EXECUTION, SCRIPT_HANDLER_OPEN_INCLUDED_FILES, STATUS_BAR_MINIMUM_DISPLAYED_UPDATE_SIZE, TOOLBAR_LOCATION
Constructor and Description |
---|
Preference()
Default parameterless constructor for TYPE_STRING preferences.
|
Preference(int type,
String configurationKey,
String resourceKey,
String descriptionKey)
Constructor allowing to pass resource bundle keys for the preference
name and description rather than plain text.
|
Preference(com.tplan.robot.gui.preferences.PreferencePanel pnl) |
Preference(String configurationKey,
int type,
String label,
String description)
Generic constructor for any preference type.
|
Preference(String configurationKey,
String label,
String description,
int maxValue,
int minValue)
Constructor for numeric types (TYPE_INT, TYPE_FLOAT).
|
Modifier and Type | Method and Description |
---|---|
void |
addAcceptedFileFilter(FileFilter filter)
Add a file filter to be shown in the file chooser of a TYPE_FILE preference.
|
void |
checkValue(Object value)
Check if a value meets the rules defined in this instance and is
acceptable for this preference (parameter).
|
static String |
createMandatoryFieldLabel(String label)
Create an HTML label with a trailing red asterisk used to indicate a
mandatory field.
|
String[] |
getAcceptedFileExtensions()
Get the list of accepted file extensions for the TYPE_FILE and
TYPE_FILELIST preferences.
|
String |
getAcceptedFileExtensionsDesc()
Get description of the file extension based filter for the TYPE_FILE
preferences.
|
String[] |
getAcceptedFileExtensionsDescs()
Get description of the file extension based filter for the TYPE_FILE
preferences.
|
int |
getBottomInset()
Get the bottom inset (padding) in pixels.
|
String |
getButtonGroup()
Get the group name this button belongs to.
|
String |
getColorMapName()
Get the name of the color map to use with the
TYPE_COLOR option. |
int |
getColumns()
Get the default text field width in characters.
|
PreferenceComponentManager |
getComponentManager() |
String |
getComponentName()
Get the component internal name.
|
ConfigurableCreator |
getConfigurableCreator()
Set the object able to create a
Configurable object based on the
value it depends on. |
String |
getConfigurationKey()
Get the preference/parameter name (configuration key).
|
String |
getCurrentDirectory() |
File |
getCurrentFile() |
String[] |
getCustomInputTemplates()
Get the custom input templates.
|
com.tplan.robot.gui.preferences.PreferencePanel |
getCustomPanel() |
Object |
getDefaultValue()
Get the default value of this preference (parameter).
|
String |
getDependentOption()
Get the preference name (configuration key) that this preference depends
on.
|
String[] |
getDependentOptions()
Get the list of options that this one depends on.
|
String |
getDescription()
Get the preference/parameter description.
|
String |
getDescriptionOfAvailableValues()
Get description of available values.
|
String |
getDirDefaultSearchPath()
Get the default path for verification of value of a TYPE_DIRECTORY or TYPE_FILE
preference.
|
String |
getDirFileToSearchFor()
Get the file name to verify existence of in a TYPE_DIRECTORY or TYPE_FILE
preference.
|
List |
getDisplayValues()
Get the fixed set of values displayable in the GUI.
|
Map |
getDisplayValuesTable()
Get the map of descriptions and their values.
|
Map |
getDynamicPanels() |
JComponent |
getFileAccessory()
Get the file accessory component.
|
JFileChooser |
getFileChooser()
Get the custom file chooser for the
TYPE_FILE and TYPE_DIRECTORY
preference type. |
com.tplan.robot.gui.components.FileChooserManager |
getFileChooserManager()
Get the file chooser manager for the
TYPE_FILE and TYPE_DIRECTORY
preferences. |
String[] |
getFileExtensions()
Get the supported file extensions.
|
List<FileFilter> |
getFileFilters()
Get file filters for the file chooser employed by the TYPE_FILE preferences.
|
FileView |
getFileView() |
String |
getFooter()
Get the footer text to be displayed in a smaller font below the
component.
|
String |
getHintText() |
String |
getHintTitle() |
List<String> |
getIgnoreDynamicParamList()
Get the list of parameter names to be ignored by the
TYPE_DYNAMIC_PARAM_LIST
preference. |
ColorChooserImageProvider |
getImageProvider() |
Object |
getJoinWith()
|
String |
getLabel()
Get the preference/parameter label (short description).
|
String |
getLabelAfter() |
String[] |
getLabels() |
int |
getLeftInset()
Get the left inset (padding) in pixels.
|
int |
getMaxPointX()
Get the maximum acceptable X coordinate value of the
TYPE_POINT
and TYPE_POINT_RELATIVE preferences. |
int |
getMaxPointY()
Get the maximum acceptable Y coordinate value of the
TYPE_POINT
and TYPE_POINT_RELATIVE preferences. |
int |
getMaxValue()
Get the maximum value.
|
int |
getMinPointX()
Get the minimum acceptable X coordinate value of the
TYPE_POINT
and TYPE_POINT_RELATIVE preferences. |
int |
getMinPointY()
Get the minimum acceptable Y coordinate value of the
TYPE_POINT
and TYPE_POINT_RELATIVE preferences. |
int |
getMinValue()
Get the minimum value.
|
String |
getNamePrefix()
Get the parameter name prefix.
|
String |
getPreferredContainerName()
Get the preferred container name.
|
String |
getSummary()
Get a simple HTML summary with the preference details.
|
int |
getTextRowsToDisplay()
Get the number of visible text rows to be displayed if the parameter
is displayed in a text pane in the GUI.
|
int |
getType()
Get the preference type (numeric code).
|
String |
getTypeDesc()
Get description of a preference type (see
getType() ).. |
static Map<Integer,String> |
getTypeMap(boolean baseTypesOnly)
Get the map of preference type names and their integer codes.
|
List |
getValues()
Get the list of raw values to be mapped to descriptions returned by
getDisplayValues() . |
boolean |
isAcceptEmptyValue()
Indicates whether the empty value ("") should be accepted as a valid one
and saved or not.
|
boolean |
isAcceptFileAsUri()
Find out whether the
TYPE_FILE preference values may be provided
in form of URI. |
boolean |
isBottomButton()
Indicates whether the
TYPE_BUTTON preference wants to have the
button at the bottom of the window next to "OK". |
boolean |
isCustomInputEnabled() |
boolean |
isDirSearchForceValueToFound()
Indicates whether the preference value should be forced to the value of
the verification file search.
|
boolean |
isDirSearchIgnoreCase() |
boolean |
isDirSearchUseRegularExpressions() |
boolean |
isEnabled()
Indicate whether the component should be enabled.
|
boolean |
isHideBorder()
Defines whether to display border of a
TYPE_DYNAMIC_PANEL
preference. |
boolean |
isMandatory()
Find out if the preference is mandatory and must be specified.
|
boolean |
isMatchMode()
A flag used for the
TYPE_REGEXP preference types. |
boolean |
isNameCaseSensitive()
Indicates whether the preference key is case sensitive.
|
boolean |
isNumber()
Find out if the preference/parameter is a number type or not.
|
boolean |
isOpaque()
Defines whether to make the
TYPE_DYNAMIC_PANEL preference
component opaque or transparent. |
boolean |
isRemoveIfDisabled() |
boolean |
isRemoveProtocol()
Specifies whether the preference value should be checked on load (in the
PreferencePanel.loadPreferences(java.lang.Object) method) against
the URL/URI syntax. |
boolean |
isSaveDefaultValue()
|
boolean |
isScreenSelectionEnabled() |
boolean |
isSelectOnly()
Indicate whether the values of this parameter are enumerated.
|
boolean |
isUseCheckBox() |
boolean |
isWindowsKeyCompatMode()
Find out if the Windows compatibility mode of a key stroke preference
(type
TYPE_KEYSTROKE ) is on or off. |
void |
setAcceptedFileExtensions(String[] acceptedFileExtensions,
String descriptionKey)
Set the list of accepted file extensions for the TYPE_FILE and
TYPE_FILELIST preferences.
|
void |
setAcceptEmptyValue(boolean acceptEmptyValue)
Defines whether the empty value ("") should be accepted as a valid one
and saved or not.
|
void |
setAcceptFileAsUri(boolean reportFileAsURI)
Controls whether the
TYPE_FILE preference should accept files
in form of a URL or URI, for example "file://C:\test.png". |
void |
setBottomButton(boolean bottomButton)
Set the flag indicating whether the
TYPE_BUTTON preference wants
to have the button at the bottom of the window next to "OK". |
void |
setBottomInset(int bottomInset)
Set the left inset (padding) in pixels.
|
void |
setButtonGroup(String buttonGroup)
Set the group name this button belongs to.This applies only to the
TYPE_BOOLEAN , TYPE_INT_DISPLAYED_AS_BOOLEAN and
TYPE_COLLAPSED_FOLDER preference types. |
void |
setButtonGroup(String buttonGroup,
boolean useCheckBox)
Set the group name this button belongs to.This applies only to the
TYPE_BOOLEAN , TYPE_INT_DISPLAYED_AS_BOOLEAN and
TYPE_COLLAPSED_FOLDER preference types. |
void |
setColorMapName(String colorMapName)
Set the name of the color map to use with the
TYPE_COLOR option. |
void |
setColumns(int columns)
Set the default text field width in characters.
|
void |
setComponentManager(PreferenceComponentManager componentManager) |
void |
setComponentName(String componentName)
Set the component internal name for demo and automation purposes.
|
void |
setConfigurableCreator(ConfigurableCreator configurableCreator)
Set the
Configurable object creator for the TYPE_DYNAMIC_PANEL
preference. |
void |
setCurrentDirectory(String path) |
void |
setCurrentFile(File currentFile) |
void |
setCustomInputEnabled(boolean enabled,
String[] templates)
Enable/disable the custom input mode.
|
void |
setDefaultValue(Object defaultValue)
Set the default value of this parameter.
|
void |
setDefaultValue(Object defaultValue,
boolean forceSaving)
Set the default value of this parameter with optional forcing of saving
of the default value.
|
void |
setDependentOption(String dependentOption)
Set the option that this one depends on.This leads to behavior
modifications, for example a String field remains disabled unless the
check box representing a boolean value is not selected.
|
void |
setDependentOption(String dependentOption,
boolean removeIfDisabled)
Declare that this preference/parameter is only valid if the specified
parameter is TYPE_BOOLEAN and its value is true.This flag is used in GUI
to implement parameter pairs representing a parameter which can be set on
or off.
|
void |
setDependentOptions(String[] dependentOptions)
Set the list of options that this one depends on.This leads to behavior
modifications, for example a String field remains disabled unless the
check box representing a boolean value is not selected.
|
void |
setDescription(String desc) |
void |
setDescriptionKey(String descriptionKey)
Set the description resource bundle key.
|
void |
setDescriptionOfAvailableValues(String descriptionOfAvailableValues)
Set description of available values.
|
void |
setDirFileToSearchFor(String fileToSearchFor,
String defaultSearchPath,
boolean useRegularExpressions,
boolean ignoreCase,
boolean forceValueToFound)
This method allows to set verification options for TYPE_FILE and
TYPE_DIRECTORY preferences.
|
void |
setDisplayValues(List displayValues)
This method allows together with
setValues(java.util.List)
to define enumerated values for parameter of the TYPE_STRING type. |
void |
setDisplayValuesTable(Map displayValuesTable)
This method allows to define enumerated values for a TYPE_STRINGLIST parameter.
|
void |
setDynamicPanels(Map dynamicPanels,
String dependentOption)
Set the map of dynamic panels.The key is the value of the option which
drives it.
|
void |
setDynamicPanels(Map dynamicPanels,
String[] dependentOptions)
Set the map of dynamic panels.The key is the value of the option which
drives it.
|
void |
setEnabled(boolean enabled)
Enable or disable the component.
|
void |
setFileAccessory(JComponent fileAccessory)
Set the file accessory component.
|
void |
setFileChooser(JFileChooser fileChooser)
Set the custom file chooser to be used by the GUI component representing
the
TYPE_FILE and TYPE_DIRECTORY preferences. |
void |
setFileChooserManager(com.tplan.robot.gui.components.FileChooserManager fileChooserManager)
Set the manager for the file chooser provided by the GUI component representing
the
TYPE_FILE and TYPE_DIRECTORY preferences. |
void |
setFileChooserManager(Reference<com.tplan.robot.gui.components.FileChooserManager> fileChooserManager)
Set the manager for the file chooser provided by the GUI component representing
the
TYPE_FILE and TYPE_DIRECTORY preferences. |
void |
setFileExtensions(String[] fileExtensions)
Set the supported file extensions.
|
void |
setFileView(FileView fileView) |
void |
setFooter(String footer)
Set the footer text to be displayed in a smaller font below the
component.
|
void |
setHideBorder(boolean hideBorder)
Hide the container border of a
TYPE_DYNAMIC_PANEL preference. |
void |
setHint(String title,
String hint)
Set the hint (a pop up help message).
|
void |
setIgnoreDynamicParamList(List<String> ignoreDynamicParamList)
Set the list of parameter names to be ignored by the
TYPE_DYNAMIC_PARAM_LIST
preference. |
void |
setImageProvider(ColorChooserImageProvider imageProvider) |
void |
setImageProvider(Reference<ColorChooserImageProvider> imageProvider) |
void |
setJoinWith(Object joinWith)
Set the configuration key of another option that this BOOLEAN preference
should be visually joined with (put in one line).
|
void |
setLabel(String label)
Set the preference label.
|
void |
setLabelAfter(String labelAfter) |
void |
setLabels(String[] labels) |
void |
setLeftInset(int leftInset)
Set the left inset (padding) in pixels.
|
void |
setMandatory(boolean mandatory)
Set whether the preferece is mandatory and must be specified.
|
void |
setMatchMode(boolean matchMode)
See
isMatchMode() . |
void |
setMaxValue(int maxValue)
Set the maximum value.
|
void |
setMinValue(int minValue)
Set the minimum value.
|
void |
setNameCaseSensitive(boolean nameCaseSensitive)
Set the flag indicating whether the preference key is case sensitive or
not.
|
void |
setNamePrefix(String namePrefix)
Set the parameter name prefix.
|
void |
setOpaque(boolean opaque)
Set opacity of the
TYPE_DYNAMIC_PANEL preference component. |
void |
setPointBounds(int minX,
int minY,
int maxX,
int maxY)
Set the coordinate bounds applied to the
TYPE_POINT and
TYPE_POINT_RELATIVE preferences. |
void |
setPreferredContainerName(String preferredContainerName)
Set the preferred container name.
|
void |
setRemoveProtocol(boolean removeProtocol)
Set on/off the protocol removal mode.
|
void |
setScreenSelectionEnabled(boolean screenSelectionEnabled) |
void |
setSelectOnly(boolean selectOnly)
Indicate whether the values of this parameter are enumerated (select-only, one-of).
|
void |
setTextRowsToDisplay(int textRowsToDisplay)
Set the number of visible text rows to be displayed if the parameter
is displayed in a text pane in the GUI.
|
void |
setValues(List values)
Set the list of raw values to be mapped to descriptions defined through
setDisplayValues(java.util.List) . |
void |
setWindowsKeyCompatMode(boolean windowsKeyCompatMode)
Set the Windows compatibility mode on/off.
|
public static final int TYPE_STRING
public static final int TYPE_INT
public static final int TYPE_FLOAT
public static final int TYPE_BOOLEAN
public static final int TYPE_COLOR
public static final int TYPE_KEYSTROKE
public static final int TYPE_STRINGLIST
public static final int TYPE_INT_DISPLAYED_AS_BOOLEAN
public static final int TYPE_FILE
public static final int TYPE_DIRECTORY
public static final int TYPE_PASSWORD
public static final int TYPE_FILELIST
public static final int TYPE_TEXT
public static final int TYPE_COLOR_FROM_IMAGE
public static final int TYPE_DUMMY
public static final int TYPE_DYNAMIC_PANEL
public static final int TYPE_COLOR_LIST
public static final int TYPE_TIME_INTERVAL
public static final int TYPE_POINT
public static final int TYPE_PREFERENCE_PANEL
public static final int TYPE_RECTANGLE
public static final int TYPE_REGEXP
public static final int TYPE_DYNAMIC_PARAM_LIST
public static final int TYPE_STRING_WITH_ACTION
PreferenceComponentManager
.public static final int TYPE_HIDDEN
public static final int TYPE_PINCH
public static final int TYPE_DIMENSION
public static final int TYPE_COLLAPSED_FOLDER
public static final int TYPE_INT_LIST
public static final int TYPE_FLOAT_LIST
public static final int TYPE_POINT_RELATIVE
public static final int TYPE_BUTTON
PreferenceComponentManager
.public static final int TYPE_COORDINATES
public static final int TYPE_DATE_FORMAT
public Preference()
public Preference(com.tplan.robot.gui.preferences.PreferencePanel pnl)
public Preference(String configurationKey, String label, String description, int maxValue, int minValue)
configurationKey
- preference/parameter name.label
- label (short description). In GUI representation of this
preference the label is displayed next to the editable component. If the
preference is a boolean type (TYPE_BOOLEAN or TYPE_INT_DISPLAYED_AS_BOOLEAN),
the label will serve as the check box text.description
- optional preference description (may be null).
In GUI representation of this preference it is typically displayed in a text pane above the editable component.
The description may be plain text or HTML. In the latter case and it may also
contain enhanced application links supported by the CustomHyperlinkListener
class.maxValue
- maximum acceptable value. Use Integer.MAX_VALUE to indicate that
the limit should not be set.minValue
- minimum acceptable value. Use Integer.MIN_VALUE to indicate that
the limit should not be set.public Preference(String configurationKey, int type, String label, String description)
configurationKey
- preference/parameter name.type
- preference value type - one of the numeric codes defined by
the TYPE_
prefixed constants defined in this classlabel
- label (short description). In GUI representation of this
preference the label is displayed next to the editable component. If the
preference is a boolean type (TYPE_BOOLEAN or TYPE_INT_DISPLAYED_AS_BOOLEAN),
the label will serve as the check box text.description
- optional preference description (may be null).
In GUI representation of this preference it is typically displayed in a text pane above the editable component.
The description may be plain text or HTML. In the latter case and it may also
contain enhanced application links supported by the CustomHyperlinkListener
class.public Preference(int type, String configurationKey, String resourceKey, String descriptionKey)
Constructor allowing to pass resource bundle keys for the preference name and description rather than plain text. It should be used for preferences created by objects which may experience change of the underlying resource bundle, for example objects which exist at the time when user may select to change the display language.
A good example are desktop clients which should use exclusively this constructor. As their preferences are displayed as logon parameters in the Login Dialog which allows to change the language, they must allow the dialog to reload the texts from the new resource bundle.
type
- preference value type - one of the numeric codes defined by
the TYPE_
prefixed constants defined in this classconfigurationKey
- preference/parameter name.resourceKey
- message key of the preference name (label).descriptionKey
- message key of the preference description (may be null).public static Map<Integer,String> getTypeMap(boolean baseTypesOnly)
baseTypesOnly
- the value of true will return a reduced map
containing just primitive values such as strings, numbers, lists of
strings or numbers etc. Complex types such as for example
TYPE_DYNAMIC_PANEL
and pseudo types such as TYPE_DUMMY
and TYPE_HIDDEN
will be skipped.public int getType()
TYPE_
prefixed constants
defined in this class for possible return values.public List getDisplayValues()
setDisplayValues(java.util.List)
.public void setDisplayValues(List displayValues)
This method allows together with setValues(java.util.List)
to define enumerated values for parameter of the TYPE_STRING type. The GUI then typically doesn't allow to edit
the value in a generic editor and rather displays a fixed list (JComboBox)
allowing to select only one of the predefined values.
The absolute minimum to define a value set is to call this
setDisplayValues()
method with a list of acceptable values.
This is fine where we want to display the values as they are.
Though the list is a generic one and may contain any objects, the values
may be internally converted to String instances and the object consuming
the parameters should handle the stored parameter value with regard to this.
The setValues(java.util.List)
method is optional and allows
to define raw values to be assigned internally to the displayed descriptions.
As the values are matched to descriptions based on the index, the lists
must naturally have the same length. If the value list is defined, the component will
populate the parameter with the raw value rather than the
one displayed in the GUI.
displayValues
- a list of enumerated values good for displaying in the GUI.public List getValues()
getDisplayValues()
. Applies to enumerated string parameters only (TYPE_STRING).public void setValues(List values)
setDisplayValues(java.util.List)
. Applies to enumerated string parameters only (TYPE_STRING).values
- list of raw parameter values.public Map getDisplayValuesTable()
setDisplayValuesTable(java.util.Map)
.
Applies to enumerated string list parameters only (TYPE_STRINGLIST).public void setDisplayValuesTable(Map displayValuesTable)
This method allows to define enumerated values for a TYPE_STRINGLIST parameter. The GUI then typically doesn't allow to edit the value in a generic editor and rather displays a fixed list (JList) allowing to select only one or more of the predefined values in a particular order.
The principle is very similar to the one described in
setDisplayValues(java.util.List)
. As TYPE_STRINGLIST however
allows to change order of the displayed values, the mapping must be realized
through a Map instead of a pair of List instances. The map should contain
the [value, description] pairs where descriptions are displayed in the GUI
and the parameter is then populated with the corresponding raw value.
displayValuesTable
- map of descriptions and values where values
are the keys and descriptions are the map values. If you want to
make the GUI display and store the same value set, create a map where
description and value are the same for each acceptable value.public String getLabel()
public void setLabel(String label)
label
- the label text.public String getDescription()
CustomHyperlinkListener
class.public void setDescription(String desc)
public String getConfigurationKey()
public boolean isNumber()
public boolean isSelectOnly()
setSelectOnly(boolean)
.public void setSelectOnly(boolean selectOnly)
setDisplayValues(java.util.List)
method for description of how to define a set of enumerated values.selectOnly
- true if the parameter values are enumerated, false if not.public int getMaxValue()
public void setMaxValue(int maxValue)
maxValue
- maximum numeric value of the parameter or Integer.MAX_VALUE
to unset this limit.public int getMinValue()
public void setMinValue(int minValue)
minValue
- maximum numeric value of the parameter or Integer.MIN_VALUE
to unset this limit.public String getPreferredContainerName()
setPreferredContainerName(java.lang.String)
.public void setPreferredContainerName(String preferredContainerName)
preferredContainerName
- container name (title). If the name is null,
the GUI container this preference displays in will not be titled.public String getDependentOption()
setDependentOption(java.lang.String)
.setDependentOption(java.lang.String)
method.public String[] getDependentOptions()
public void setDependentOption(String dependentOption, boolean removeIfDisabled)
dependentOption
- name (configuration key) of the preference that
this one depends on.removeIfDisabled
- true forces the preference value to be removed
on save if the option it depends on is not set.public void setDependentOption(String dependentOption)
dependentOption
- the name of an option this one depends on.public void setDependentOptions(String[] dependentOptions)
dependentOptions
- the list of options this one depends on.public String[] getAcceptedFileExtensions()
setAcceptedFileExtensions(java.lang.String[], java.lang.String)
method.new String[] {"txt"}
.public void setAcceptedFileExtensions(String[] acceptedFileExtensions, String descriptionKey)
acceptedFileExtensions
- string array of accepted file extensions,
for example new String[] {"txt"}
.descriptionKey
- filter description or resource bundle key of
the description.public String getAcceptedFileExtensionsDesc()
setAcceptedFileExtensions(java.lang.String[], java.lang.String)
method. If it is not found, the method returns the key itself.public void addAcceptedFileFilter(FileFilter filter)
filter
- a filter.public List<FileFilter> getFileFilters()
addAcceptedFileFilter(javax.swing.filechooser.FileFilter)
.public String[] getAcceptedFileExtensionsDescs()
setAcceptedFileExtensions(java.lang.String[], java.lang.String)
method. If it is not found, the method returns the key itself.public String getSummary()
public String getTypeDesc()
getType()
)..public boolean isAcceptEmptyValue()
public void setAcceptEmptyValue(boolean acceptEmptyValue)
acceptEmptyValue
- the acceptEmptyValue to setpublic int getTextRowsToDisplay()
TYPE_TEXT
type and it is ignored by other types.public void setTextRowsToDisplay(int textRowsToDisplay)
TYPE_TEXT
type and it is ignored by other types.textRowsToDisplay
- number of text rows to display if the parameter
is displayed in GUI.public Object getDefaultValue()
public void setDefaultValue(Object defaultValue)
defaultValue
- default parameter value. It is not validated so make
sure it is of the declared type and meets the rules and relationships
declared in this parameter.public void setDefaultValue(Object defaultValue, boolean forceSaving)
defaultValue
- default parameter value. It is not validated so make
sure it is of the declared type and meets the rules and relationships
declared in this parameter.forceSaving
- the UI by default doesn't save the parameter to the
configuration container when its value is equal to the default one. Use
the value of true
to override this behavior and save the
default value anyway. This makes sense just for the parameters of
primitive types (TYPE_BOOLEAN, TYPE_INT, TYPE_FLOAT, TYPE_STRING) because
default values of all other ones are stored always.public boolean isAcceptFileAsUri()
TYPE_FILE
preference values may be provided
in form of URI.public void setAcceptFileAsUri(boolean reportFileAsURI)
TYPE_FILE
preference should accept files
in form of a URL or URI, for example "file://C:\test.png".reportFileAsURI
- true indicates that the parameter value might
be in URI/URL format.public void checkValue(Object value) throws IllegalArgumentException
TYPE_INT
type, the method checks whether the value is
a number or whether it may be converted to a number. If the minimum
and/or maximum values are set through the setMinValue(int)
and
setMaxValue(int)
methods, the value is also checked against
these limits.value
- a value to be checked.IllegalArgumentException
- if the value is not eligible
for this preference.public boolean isMandatory()
public void setMandatory(boolean mandatory)
mandatory
- true if the preference (parameter) is mandatory, false if not.public JComponent getFileAccessory()
TYPE_FILE
, TYPE_FILELIST
and TYPE_DIRECTORY
preferences. It is an optional component for the file chooser which may provide
a preview of the file (for example an image thumbnail).
See the JFileChooser.setAccessory(javax.swing.JComponent)
method for more information.public void setFileAccessory(JComponent fileAccessory)
TYPE_FILE
, TYPE_FILELIST
and TYPE_DIRECTORY
preferences. It is an optional component for the file chooser which may provide
a preview of the file (for example an image thumbnail).
See the JFileChooser.setAccessory(javax.swing.JComponent)
method for more information.fileAccessory
- the file chooser accessory component.public ColorChooserImageProvider getImageProvider()
public void setImageProvider(ColorChooserImageProvider imageProvider)
imageProvider
- the imageProvider to setpublic void setImageProvider(Reference<ColorChooserImageProvider> imageProvider)
imageProvider
- the imageProvider to setpublic void setDirFileToSearchFor(String fileToSearchFor, String defaultSearchPath, boolean useRegularExpressions, boolean ignoreCase, boolean forceValueToFound)
This method allows to set verification options for TYPE_FILE and TYPE_DIRECTORY preferences. As these preference types are often used to store install locations of integrated third party component, this is intended to provide a quick verification mechanism like "check if the path selected by user contains this specific file".
The fileToSearchFor
parameter may
specify the required file name or a regular expression (pattern) the selected
file must comply with. If the preference is of the TYPE_DIRECTORY type,
the underlying GUI component is expected to search the selected directory
recursively and verify whether it contains a file complying with the
specified name or pattern.
fileToSearchFor
- file name or a Pattern
compliant regular expression.defaultSearchPath
- default directory. It may be used for resolution
of relative paths. It may be null.useRegularExpressions
- true matches the specified file name using
regular expressions, false sets regular string comparison.ignoreCase
- whether the regular comparison should be done in a case
sensitive way or not. If the value is true, the file names will be
compared with the fileToSearchFor
parameter using String.equalsIgnoreCase(java.lang.String)
instead of standard String.equals(java.lang.Object)
. If regular
expressions are on (the useRegularExpressions
parameter is true),
this parameter is ignored.forceValueToFound
- Indicates whether the preference value should
be forced to the located file (TYPE_FILE) or its parent folder (TYPE_DIRECTORY).
The value of true forces the file search mechanism to set the value to the file found,
false leaves the value as it was selected by the user.public String getDirFileToSearchFor()
setDirFileToSearchFor(java.lang.String, java.lang.String, boolean, boolean, boolean)
.public String getCurrentDirectory()
public void setCurrentDirectory(String path)
public String getDirDefaultSearchPath()
setDirFileToSearchFor(java.lang.String, java.lang.String, boolean, boolean, boolean)
.public boolean isDirSearchUseRegularExpressions()
public boolean isDirSearchIgnoreCase()
public boolean isDirSearchForceValueToFound()
setDirFileToSearchFor(java.lang.String, java.lang.String, boolean, boolean, boolean)
.public String getDescriptionOfAvailableValues()
TYPE_STRINGLIST
preference type and it is displayed as a
description of the list of available (disabled) values on the right side
of the GUI component.public void setDescriptionOfAvailableValues(String descriptionOfAvailableValues)
TYPE_STRINGLIST
preference type and it is displayed as a
description of the list of available (disabled) values on the right side
of the GUI component.descriptionOfAvailableValues
- label text for available values.public String getButtonGroup()
TYPE_BOOLEAN
, TYPE_INT_DISPLAYED_AS_BOOLEAN
and
TYPE_COLLAPSED_FOLDER
preference types.public void setButtonGroup(String buttonGroup, boolean useCheckBox)
TYPE_BOOLEAN
, TYPE_INT_DISPLAYED_AS_BOOLEAN
and
TYPE_COLLAPSED_FOLDER
preference types.buttonGroup
- the button group.useCheckBox
- true to force the preference to use JCheckBox or false
to use JRadioButton.public void setButtonGroup(String buttonGroup)
TYPE_BOOLEAN
, TYPE_INT_DISPLAYED_AS_BOOLEAN
and
TYPE_COLLAPSED_FOLDER
preference types.buttonGroup
- the button group.public Object getJoinWith()
public void setJoinWith(Object joinWith)
setDependentOption(java.lang.String)
.joinWith
- key of the other preference to join this preference with.IllegalStateException
- when this preference is not of TYPE_BOOLEAN
or TYPE_INT_DISPLAYED_AS_BOOLEAN
.public Map getDynamicPanels()
public void setDynamicPanels(Map dynamicPanels, String[] dependentOptions)
Configurable
instance or a
list of Preference
instances.dynamicPanels
- the dynamicPanels to setdependentOptions
- dependent options.public void setDynamicPanels(Map dynamicPanels, String dependentOption)
Configurable
instance or a
list of Preference
instances.dynamicPanels
- the dynamicPanels to setdependentOption
- dependent option.public boolean isUseCheckBox()
public String getLabelAfter()
public void setLabelAfter(String labelAfter)
labelAfter
- the labelAfter to setpublic boolean isRemoveIfDisabled()
public com.tplan.robot.gui.preferences.PreferencePanel getCustomPanel()
public String getHintTitle()
public void setHint(String title, String hint)
title
- the hint title.hint
- the hint to set.public String getHintText()
public FileView getFileView()
public void setFileView(FileView fileView)
fileView
- the fileView to setpublic File getCurrentFile()
public void setCurrentFile(File currentFile)
currentFile
- the currentFile to setpublic int getColumns()
setColumns(int)
for more.public void setColumns(int columns)
Set the default text field width in characters. This can be used for preferences using a JTextField editor to force the field width to be able to hold a certain text length.
Be aware that as JTextField instances typically use a proportional font, the field width is typically calculated as the maximum character width times the number of columns. That's why the field may display wide enough to fit for example 50 characters even though the columns are set to 25 or 30.
columns
- number of character the text field should be able to display.public com.tplan.robot.gui.components.FileChooserManager getFileChooserManager()
TYPE_FILE
and TYPE_DIRECTORY
preferences. See setFileChooserManager(com.tplan.robot.gui.components.FileChooserManager)
for more.public void setFileChooserManager(com.tplan.robot.gui.components.FileChooserManager fileChooserManager)
Set the manager for the file chooser provided by the GUI component representing
the TYPE_FILE
and TYPE_DIRECTORY
preferences. The manager can
be used to customize the chooser view, accessory, file filters etc. It can also
register as a PropertyChangeListener
to the chooser to react on a
file selection.
Note that other supported ways of the file chooser customization are
the methods of setFileAccessory(javax.swing.JComponent)
,
setFileView(javax.swing.filechooser.FileView)
,
addAcceptedFileFilter(javax.swing.filechooser.FileFilter)
and
setAcceptedFileExtensions(java.lang.String[], java.lang.String)
.
It is also possible to replace the default file chooser with a custom one
through the setFileChooser(javax.swing.JFileChooser)
method.
fileChooserManager
- the fileChooserManager to setpublic void setFileChooserManager(Reference<com.tplan.robot.gui.components.FileChooserManager> fileChooserManager)
Set the manager for the file chooser provided by the GUI component representing
the TYPE_FILE
and TYPE_DIRECTORY
preferences. The manager can
be used to customize the chooser view, accessory, file filters etc. It can also
register as a PropertyChangeListener
to the chooser to react on a
file selection.
Note that other supported ways of the file chooser customization are
the methods of setFileAccessory(javax.swing.JComponent)
,
setFileView(javax.swing.filechooser.FileView)
,
addAcceptedFileFilter(javax.swing.filechooser.FileFilter)
and
setAcceptedFileExtensions(java.lang.String[], java.lang.String)
.
It is also possible to replace the default file chooser with a custom one
through the setFileChooser(javax.swing.JFileChooser)
method.
fileChooserManager
- the fileChooserManager to setpublic int getLeftInset()
setLeftInset(int)
for more.public void setLeftInset(int leftInset)
leftInset
- the left inset (padding) in pixels. The default value is
0 which ensures that all components in the same container are aligned
vertically to the left.public int getBottomInset()
setBottomInset(int)
for more.public void setBottomInset(int bottomInset)
bottomInset
- the bottom inset (padding) in pixels. The default
value is 0 which ensures that all components in the same container
maintain the same vertical distance from one another.public boolean isMatchMode()
TYPE_REGEXP
preference types. It indicates
whether the regular expression identified by the option is going to be
used for text matching (return value is true
) or for text splitting or
parsing (return value is false
).public void setMatchMode(boolean matchMode)
isMatchMode()
.matchMode
- true if the regexp is going to be used for text matching, false
if not.public JFileChooser getFileChooser()
TYPE_FILE
and TYPE_DIRECTORY
preference type.public void setFileChooser(JFileChooser fileChooser)
TYPE_FILE
and TYPE_DIRECTORY
preferences.fileChooser
- a custom file chooser to be used by the preference editor.public ConfigurableCreator getConfigurableCreator()
Set the object able to create a Configurable
object based on the
value it depends on. This value is used exclusively by the TYPE_DYNAMIC_PANEL
preference type to provide dynamic content based on a value provided in
another preference component. This dependency must be declared through a
call of the setDependentOption(java.lang.String)
method.
Note that another supported way of creating a TYPE_DYNAMIC_PANEL
is
to create a map of [value, params] pairs where the params
objects
are either preference lists (List<Preference>
or
Configurable
instances. The map must be then passed to the preference
through the setDynamicPanels(java.util.Map, java.lang.String)
method.
This way is however suitable when the list of driving values is fixed and
well known in advance.
ConfigurableCreator
interface.public void setConfigurableCreator(ConfigurableCreator configurableCreator)
Configurable
object creator for the TYPE_DYNAMIC_PANEL
preference. See getConfigurableCreator()
for details.configurableCreator
- a configuration parameter producer.public List<String> getIgnoreDynamicParamList()
TYPE_DYNAMIC_PARAM_LIST
preference. This allows the dynamic parameter list to skip other parameters which
are being used in the same form.TYPE_DYNAMIC_PARAM_LIST
preference.public void setIgnoreDynamicParamList(List<String> ignoreDynamicParamList)
TYPE_DYNAMIC_PARAM_LIST
preference. This allows the dynamic parameter list to skip other parameters which
are being used in the same form.ignoreDynamicParamList
- names of parameters to be ignored (not to be
recognized as dynamic ones) by a TYPE_DYNAMIC_PARAM_LIST
preference.public PreferenceComponentManager getComponentManager()
public void setComponentManager(PreferenceComponentManager componentManager)
componentManager
- the componentManager to setpublic boolean isSaveDefaultValue()
public void setCustomInputEnabled(boolean enabled, String[] templates)
enabled
- true enables the input mode, false disables. The mode is by
default enabled.templates
- optional array of code template code shortcuts allowed in the value.
If the argument is null the editor will offer all templates which are not
standalone and have compatible type.public boolean isCustomInputEnabled()
public String[] getCustomInputTemplates()
setCustomInputEnabled(boolean, java.lang.String[])
for details.public void setDescriptionKey(String descriptionKey)
setDescription(java.lang.String)
which sets the description directly, this method allows to load the text
from the resource bundle. If both the key and the description are set the
getDescription()
method will prefer the resource bundle text.descriptionKey
- the resource bundle key of the preference description.public String[] getLabels()
public void setLabels(String[] labels)
labels
- the labels to setpublic boolean isScreenSelectionEnabled()
public void setScreenSelectionEnabled(boolean screenSelectionEnabled)
screenSelectionEnabled
- the screenSelectionEnabled to setpublic boolean isRemoveProtocol()
Specifies whether the preference value should be checked on load (in the
PreferencePanel.loadPreferences(java.lang.Object)
method) against
the URL/URI syntax. If the string contains a protocol it will be removed.
For example, a string like "rfb://localhost:5901" will be stripped to
"localhos:5901".
This mode is applied only to the String preferences (TYPE_STRING
,
TYPE_STRING_WITH_ACTION
and TYPE_PASSWORD
). The flag is
ignored for other preference types. The default value is false.
public void setRemoveProtocol(boolean removeProtocol)
isRemoveProtocol()
for
details.removeProtocol
- the removeProtocol to setpublic void setPointBounds(int minX, int minY, int maxX, int maxY)
TYPE_POINT
and
TYPE_POINT_RELATIVE
preferences.minX
- minimum acceptable X coordinate value (defaults to 0).minY
- minimum acceptable Y coordinate value (defaults to 0).maxX
- maximum acceptable X coordinate value (defaults to 9999).maxY
- maximum acceptable Y coordinate value (defaults to 9999).public int getMinPointX()
TYPE_POINT
and TYPE_POINT_RELATIVE
preferences. The default value is 0
(zero).public int getMaxPointX()
TYPE_POINT
and TYPE_POINT_RELATIVE
preferences. The default value is 9999
which ensures that the coordinate editor is not too wide.public int getMinPointY()
TYPE_POINT
and TYPE_POINT_RELATIVE
preferences. The default value is 0
(zero).public int getMaxPointY()
TYPE_POINT
and TYPE_POINT_RELATIVE
preferences. The default value is 9999
which ensures that the coordinate editor is not too wide.public boolean isHideBorder()
TYPE_DYNAMIC_PANEL
preference. See setHideBorder(boolean)
.public void setHideBorder(boolean hideBorder)
TYPE_DYNAMIC_PANEL
preference.hideBorder
- true will hide the border, false will show it. The
default value is false (show the border).public boolean isOpaque()
TYPE_DYNAMIC_PANEL
preference
component opaque or transparent.public void setOpaque(boolean opaque)
TYPE_DYNAMIC_PANEL
preference component.opaque
- true for opaque and false for transparent.public boolean isWindowsKeyCompatMode()
TYPE_KEYSTROKE
) is on or off.public void setWindowsKeyCompatMode(boolean windowsKeyCompatMode)
TYPE_KEYSTROKE
). The main
difference is that when the mode is on the field records the 'Windows'
key instead of the 'Command' one on Mac OS.windowsKeyCompatMode
- true/false to set the Windows compat mode
on/off.public static String createMandatoryFieldLabel(String label)
label
- a plain text label.public String[] getFileExtensions()
TYPE_FILE
preferences.setFileExtensions(java.lang.String[])
.public void setFileExtensions(String[] fileExtensions)
TYPE_FILE
preferences.fileExtensions
- array of supported file extensions.public boolean isNameCaseSensitive()
true
.public void setNameCaseSensitive(boolean nameCaseSensitive)
true
(case sensitive). When the
key is not case sensitive the preference editor component is being looked
up in a different way.nameCaseSensitive
- true for case sensitive (default) or false
otherwise.public boolean isEnabled()
true
.public void setEnabled(boolean enabled)
enabled
- true/false to enable/disable.public String getFooter()
public void setFooter(String footer)
footer
- the footer text.public String getComponentName()
public void setComponentName(String componentName)
componentName
- the component internal name.public String getColorMapName()
TYPE_COLOR
option.public void setColorMapName(String colorMapName)
TYPE_COLOR
option.colorMapName
- name of a color map that was previously registered
through the
ColorSetMap.create(java.lang.String, java.util.Map)
method.public boolean isBottomButton()
TYPE_BUTTON
preference wants to have the
button at the bottom of the window next to "OK".public void setBottomButton(boolean bottomButton)
TYPE_BUTTON
preference wants
to have the button at the bottom of the window next to "OK".bottomButton
- true to put the button into the bottom or false
to put it next to other preference components.public String getNamePrefix()
TYPE_DYNAMIC_PARAM_LIST
components.public void setNamePrefix(String namePrefix)
TYPE_DYNAMIC_PARAM_LIST
components.namePrefix
- the parameter name prefix.