Class EncodingComboBoxModel
java.lang.Object
org.jfree.report.modules.gui.swing.common.EncodingComboBoxModel
- All Implemented Interfaces:
ComboBoxModel
,ListModel
A model for the 'encoding' combo box. This combobox model presents a selection for all
available string encodings.
- Author:
- Thomas Morgner.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final String
The property that defines which encodings are available in the export dialogs.static final String
The encodings available properties value for all properties.static final String
The encodings available properties value for properties defined in the properties file.static final String
The encodings available properties value for no properties defined.static final String
static final String
The name of the properties file used to define the available encodings.static final String
The default name for the encoding properties file. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionboolean
addEncoding
(String name, String description) Adds an encoding.void
addEncodingUnchecked
(String name, String description) Adds an encoding to the model without checking its validity.void
Adds a listener to the list that's notified each time a change to the data model occurs.static EncodingComboBoxModel
createDefaultModel
(Locale locale) Creates a default model containing a selection of encodings.void
ensureEncodingAvailable
(String encoding) Make sure, that this encoding is defined and selectable in the combobox model.protected void
Notifies all registered listeners that the content of the model has changed.protected void
fireContentsChanged
(int start, int length) Notifies all registered listeners that the content of the model has changed.static String
Defines the loader settings for the available encodings shown to the user.getDescription
(int index) Returns a description.getElementAt
(int index) Returns the value at the specified index.getEncoding
(int index) Returns an encoding.protected String
getEncodingDescription
(String encoding) static String
Defines the loader settings for the available encodings shown to the user.Returns the selected encoding.int
Returns the selected index.Returns the selected item.int
getSize()
Returns the length of the list.int
Returns the index of an encoding.void
removeEncoding
(String name) void
Removes a listener from the list that's notified each time a change to the data model occurs.void
setSelectedEncoding
(String encoding) void
setSelectedIndex
(int index) Defines the selected index for this encoding model.void
setSelectedItem
(Object anItem) Set the selected item.void
sort()
Sorts the encodings.
-
Field Details
-
AVAILABLE_ENCODINGS
The property that defines which encodings are available in the export dialogs.- See Also:
-
AVAILABLE_ENCODINGS_ALL
The encodings available properties value for all properties.- See Also:
-
AVAILABLE_ENCODINGS_FILE
The encodings available properties value for properties defined in the properties file.- See Also:
-
AVAILABLE_ENCODINGS_NONE
The encodings available properties value for no properties defined. The encoding selection will be disabled.- See Also:
-
ENCODINGS_DEFINITION_FILE
The name of the properties file used to define the available encodings. The property points to a resources in the classpath, not to a real file!- See Also:
-
ENCODINGS_DEFINITION_FILE_DEFAULT
The default name for the encoding properties file. This property defaults to "/org/jfree/report/jfreereport-encodings.properties".- See Also:
-
BUNDLE_NAME
- See Also:
-
-
Constructor Details
-
EncodingComboBoxModel
Creates a new model.- Parameters:
locale
-
-
-
Method Details
-
addEncoding
Adds an encoding.- Parameters:
name
- the name.description
- the description.- Returns:
true
if the encoding is valid and added to the model,false
otherwise.
-
addEncodingUnchecked
Adds an encoding to the model without checking its validity.- Parameters:
name
- the name.description
- the description.
-
removeEncoding
-
ensureEncodingAvailable
Make sure, that this encoding is defined and selectable in the combobox model.- Parameters:
encoding
- the encoding that should be verified.
-
getEncodingDescription
-
sort
public void sort()Sorts the encodings. Keep the selected object ... -
fireContentsChanged
protected void fireContentsChanged()Notifies all registered listeners that the content of the model has changed. -
fireContentsChanged
protected void fireContentsChanged(int start, int length) Notifies all registered listeners that the content of the model has changed. -
setSelectedItem
Set the selected item. The implementation of this method should notify all registeredListDataListener
s that the contents have changed.- Specified by:
setSelectedItem
in interfaceComboBoxModel
- Parameters:
anItem
- the list object to select ornull
to clear the selection
-
getSelectedIndex
public int getSelectedIndex()Returns the selected index.- Returns:
- The index.
-
setSelectedIndex
public void setSelectedIndex(int index) Defines the selected index for this encoding model.- Parameters:
index
- the selected index or -1 to clear the selection.- Throws:
IllegalArgumentException
- if the given index is invalid.
-
getSelectedEncoding
Returns the selected encoding.- Returns:
- The encoding (name).
-
getSelectedItem
Returns the selected item.- Specified by:
getSelectedItem
in interfaceComboBoxModel
- Returns:
- The selected item or
null
if there is no selection
-
getSize
public int getSize()Returns the length of the list. -
getElementAt
Returns the value at the specified index.- Specified by:
getElementAt
in interfaceListModel
- Parameters:
index
- the requested index- Returns:
- the value at
index
-
addListDataListener
Adds a listener to the list that's notified each time a change to the data model occurs.- Specified by:
addListDataListener
in interfaceListModel
- Parameters:
l
- theListDataListener
to be added
-
removeListDataListener
Removes a listener from the list that's notified each time a change to the data model occurs.- Specified by:
removeListDataListener
in interfaceListModel
- Parameters:
l
- theListDataListener
to be removed
-
createDefaultModel
Creates a default model containing a selection of encodings.- Returns:
- The default model.
-
indexOf
Returns the index of an encoding.- Parameters:
encoding
- the encoding (name).- Returns:
- The index.
-
getEncoding
Returns an encoding.- Parameters:
index
- the index.- Returns:
- The index.
-
getDescription
Returns a description.- Parameters:
index
- the index.- Returns:
- The description.
-
getEncodingsDefinitionFile
Defines the loader settings for the available encodings shown to the user. The property defaults to AVAILABLE_ENCODINGS_ALL.- Returns:
- either AVAILABLE_ENCODINGS_ALL, AVAILABLE_ENCODINGS_FILE or AVAILABLE_ENCODINGS_NONE.
-
getAvailableEncodings
Defines the loader settings for the available encodings shown to the user. The property defaults to AVAILABLE_ENCODINGS_ALL.- Returns:
- either AVAILABLE_ENCODINGS_ALL, AVAILABLE_ENCODINGS_FILE or AVAILABLE_ENCODINGS_NONE.
-
setSelectedEncoding
-