public interface BaseTokenSubstitution
String
.
To use this interface, you must create four strings for each token that will be replaced by text:
String
that is displayed in the
insert drop down list, such as "Date". Store all of these in an
array. The UI will ask for the array.String
, such as "&Date", that appears in
the JTextField
when a user has selected a
ListItem.String
that is actually stored in the unparsed
String
; this String
must not be
localized, because it needs to be same String
in all
languages. String
that is displayed in the view
itself, such as "24 March 2001".
In addition, you must provide conversion between these strings, which are used as follows:
JTextField
. JTextField
.String
from the JTextField
,
including the token, and asks you for a String
that has
the key instead of the token.String
with the key, to ask you for the
parsed String
to display in the graph.
When a graph is persisted, the String
with key is stored in
the XML, and this String
is given to your implementation
of this interface to restore the parsed String
in the
graph.
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getKey(java.lang.String listItem)
Retrieves a keyword for a list item.
|
java.lang.String |
getKeyString(java.lang.String tokenString)
Retrieves a
String that includes unlocalizable keywords
instead of localizable tokens. |
java.lang.String[] |
getListItems()
Retrieves an array of items for the "Insert" drop-down list box.
|
java.lang.String |
getParsedString(java.lang.String keyString)
Retrieves a parsed
String that is displayed in the view. |
java.lang.String |
getToken(java.lang.String listItem)
Retrieves a token that corresponds to a list item.
|
java.lang.String |
getTokenString(java.lang.String keyString)
Retrieves a
String that includes localizable tokens
instead of unlocalizable keywords. |
void |
setLocale(java.util.Locale locale)
Specifies the
Locale for this BaseTokenSubstitution . |
java.lang.String[] getListItems()
java.lang.String getToken(java.lang.String listItem)
JTextField
.
The token usually includes an indicator that it will be replaced
in the actual view.
For example, if the list item is "Date", the token might be "&Date".
The UI places this token in the text field with any other text.
For example, the text field might then display "Sales Report for &Date".listItem
- The list item that the user selected from the drop-down
list.JTextField
.java.lang.String getKeyString(java.lang.String tokenString)
String
that includes unlocalizable keywords
instead of localizable tokens.
When the view saves itself in XML, it uses this string to identify
the text that it represents.
Currently, this key string is also passed to setText
methods in graph components.
If you present your own UI that allows token substitution, and
you call setText
methods, you should call this method
in your implementation of this interface to get the String
to pass to setText
.tokenString
- The String
that the
JTextField
displays. This is the
String
that the user has entered
into the text field, including any tokens for
replaceable text.
tokenString
does not have to contain
tokens. It might have plain text only.String
that has unlocalizable keys instead of
any localizable tokens.java.lang.String getTokenString(java.lang.String keyString)
String
that includes localizable tokens
instead of unlocalizable keywords.
The String
that this method returns is displayed in the
JTextField
.
The view calls this method when it applies XML that includes a setting
for the Text
property.
The view uses the key string as the Text
value in XML.keyString
- The String
that can include unlocalizable
keys. keyString
does not have to
include keys. It might have plain text only.String
that contains localizable tokens instead
of any keys in keyString
.java.lang.String getParsedString(java.lang.String keyString)
String
that is displayed in the view.
The String
that this method returns has replacement
text in place of the keys in keyString
.
The setText
methods in a graph call this method to
retrieve the text to display in the graph text component.
If you call setText
, be sure to pass a key string
and not a token string.keyString
- The string
that the view stores as the
setting of the Text
property.String
that contains localized text
instead of any keys in keyString
.getKeyString(java.lang.String)
java.lang.String getKey(java.lang.String listItem)
listItem
- A String
that represents a list item
from the drop-down "Insert" list.listItem
.void setLocale(java.util.Locale locale)
Locale
for this BaseTokenSubstitution
.
The setLocale
method of the view that uses this
BaseTokenSubstitution
calls this method.locale
- The Locale
for this BaseTokenSubstitution
.