org.jfree.report.modules.gui.swing.common

Class EncodingComboBoxModel

public class EncodingComboBoxModel extends Object implements ComboBoxModel

A model for the 'encoding' combo box. This combobox model presents a selection for all available string encodings.

Author: Thomas Morgner.

Field Summary
static StringAVAILABLE_ENCODINGS
The property that defines which encodings are available in the export dialogs.
static StringAVAILABLE_ENCODINGS_ALL
The encodings available properties value for all properties.
static StringAVAILABLE_ENCODINGS_FILE
The encodings available properties value for properties defined in the properties file.
static StringAVAILABLE_ENCODINGS_NONE
The encodings available properties value for no properties defined.
static StringBUNDLE_NAME
static StringENCODINGS_DEFINITION_FILE
The name of the properties file used to define the available encodings.
static StringENCODINGS_DEFINITION_FILE_DEFAULT
The default name for the encoding properties file.
Constructor Summary
EncodingComboBoxModel(Locale locale)
Creates a new model.
Method Summary
booleanaddEncoding(String name, String description)
Adds an encoding.
voidaddEncodingUnchecked(String name, String description)
Adds an encoding to the model without checking its validity.
voidaddListDataListener(ListDataListener l)
Adds a listener to the list that's notified each time a change to the data model occurs.
static EncodingComboBoxModelcreateDefaultModel(Locale locale)
Creates a default model containing a selection of encodings.
voidensureEncodingAvailable(String encoding)
Make sure, that this encoding is defined and selectable in the combobox model.
protected voidfireContentsChanged()
Notifies all registered listeners that the content of the model has changed.
protected voidfireContentsChanged(int start, int length)
Notifies all registered listeners that the content of the model has changed.
static StringgetAvailableEncodings()
Defines the loader settings for the available encodings shown to the user.
StringgetDescription(int index)
Returns a description.
ObjectgetElementAt(int index)
Returns the value at the specified index.
StringgetEncoding(int index)
Returns an encoding.
protected StringgetEncodingDescription(String encoding)
static StringgetEncodingsDefinitionFile()
Defines the loader settings for the available encodings shown to the user.
StringgetSelectedEncoding()
Returns the selected encoding.
intgetSelectedIndex()
Returns the selected index.
ObjectgetSelectedItem()
Returns the selected item.
intgetSize()
Returns the length of the list.
intindexOf(String encoding)
Returns the index of an encoding.
voidremoveEncoding(String name)
voidremoveListDataListener(ListDataListener l)
Removes a listener from the list that's notified each time a change to the data model occurs.
voidsetSelectedEncoding(String encoding)
voidsetSelectedIndex(int index)
Defines the selected index for this encoding model.
voidsetSelectedItem(Object anItem)
Set the selected item.
voidsort()
Sorts the encodings.

Field Detail

AVAILABLE_ENCODINGS

public static final String AVAILABLE_ENCODINGS
The property that defines which encodings are available in the export dialogs.

AVAILABLE_ENCODINGS_ALL

public static final String AVAILABLE_ENCODINGS_ALL
The encodings available properties value for all properties.

AVAILABLE_ENCODINGS_FILE

public static final String AVAILABLE_ENCODINGS_FILE
The encodings available properties value for properties defined in the properties file.

AVAILABLE_ENCODINGS_NONE

public static final String AVAILABLE_ENCODINGS_NONE
The encodings available properties value for no properties defined. The encoding selection will be disabled.

BUNDLE_NAME

public static final String BUNDLE_NAME

ENCODINGS_DEFINITION_FILE

public static final String 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!

ENCODINGS_DEFINITION_FILE_DEFAULT

public static final String ENCODINGS_DEFINITION_FILE_DEFAULT
The default name for the encoding properties file. This property defaults to "/org/jfree/report/jfreereport-encodings.properties".

Constructor Detail

EncodingComboBoxModel

public EncodingComboBoxModel(Locale locale)
Creates a new model.

Parameters: locale

Method Detail

addEncoding

public boolean addEncoding(String name, String description)
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

public void addEncodingUnchecked(String name, String description)
Adds an encoding to the model without checking its validity.

Parameters: name the name. description the description.

addListDataListener

public void addListDataListener(ListDataListener l)
Adds a listener to the list that's notified each time a change to the data model occurs.

Parameters: l the ListDataListener to be added

createDefaultModel

public static EncodingComboBoxModel createDefaultModel(Locale locale)
Creates a default model containing a selection of encodings.

Returns: The default model.

ensureEncodingAvailable

public void ensureEncodingAvailable(String encoding)
Make sure, that this encoding is defined and selectable in the combobox model.

Parameters: encoding the encoding that should be verified.

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.

getAvailableEncodings

public static String 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.

getDescription

public String getDescription(int index)
Returns a description.

Parameters: index the index.

Returns: The description.

getElementAt

public Object getElementAt(int index)
Returns the value at the specified index.

Parameters: index the requested index

Returns: the value at index

getEncoding

public String getEncoding(int index)
Returns an encoding.

Parameters: index the index.

Returns: The index.

getEncodingDescription

protected String getEncodingDescription(String encoding)

getEncodingsDefinitionFile

public static String 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.

getSelectedEncoding

public String getSelectedEncoding()
Returns the selected encoding.

Returns: The encoding (name).

getSelectedIndex

public int getSelectedIndex()
Returns the selected index.

Returns: The index.

getSelectedItem

public Object getSelectedItem()
Returns the selected item.

Returns: The selected item or null if there is no selection

getSize

public int getSize()
Returns the length of the list.

Returns: the length of the list

indexOf

public int indexOf(String encoding)
Returns the index of an encoding.

Parameters: encoding the encoding (name).

Returns: The index.

removeEncoding

public void removeEncoding(String name)

removeListDataListener

public void removeListDataListener(ListDataListener l)
Removes a listener from the list that's notified each time a change to the data model occurs.

Parameters: l the ListDataListener to be removed

setSelectedEncoding

public void setSelectedEncoding(String encoding)

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: java.lang.IllegalArgumentException if the given index is invalid.

setSelectedItem

public void setSelectedItem(Object anItem)
Set the selected item. The implementation of this method should notify all registered ListDataListeners that the contents have changed.

Parameters: anItem the list object to select or null to clear the selection

sort

public void sort()
Sorts the encodings. Keep the selected object ...