Class EncodingComboBoxModel
- java.lang.Object
-
- org.jfree.report.modules.gui.swing.common.EncodingComboBoxModel
-
- All Implemented Interfaces:
javax.swing.ComboBoxModel,javax.swing.ListModel
public class EncodingComboBoxModel extends java.lang.Object implements javax.swing.ComboBoxModelA model for the 'encoding' combo box. This combobox model presents a selection for all available string encodings.- Author:
- Thomas Morgner.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.StringAVAILABLE_ENCODINGSThe property that defines which encodings are available in the export dialogs.static java.lang.StringAVAILABLE_ENCODINGS_ALLThe encodings available properties value for all properties.static java.lang.StringAVAILABLE_ENCODINGS_FILEThe encodings available properties value for properties defined in the properties file.static java.lang.StringAVAILABLE_ENCODINGS_NONEThe encodings available properties value for no properties defined.static java.lang.StringBUNDLE_NAMEstatic java.lang.StringENCODINGS_DEFINITION_FILEThe name of the properties file used to define the available encodings.static java.lang.StringENCODINGS_DEFINITION_FILE_DEFAULTThe default name for the encoding properties file.
-
Constructor Summary
Constructors Constructor Description EncodingComboBoxModel(java.util.Locale locale)Creates a new model.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanaddEncoding(java.lang.String name, java.lang.String description)Adds an encoding.voidaddEncodingUnchecked(java.lang.String name, java.lang.String description)Adds an encoding to the model without checking its validity.voidaddListDataListener(javax.swing.event.ListDataListener l)Adds a listener to the list that's notified each time a change to the data model occurs.static EncodingComboBoxModelcreateDefaultModel(java.util.Locale locale)Creates a default model containing a selection of encodings.voidensureEncodingAvailable(java.lang.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 java.lang.StringgetAvailableEncodings()Defines the loader settings for the available encodings shown to the user.java.lang.StringgetDescription(int index)Returns a description.java.lang.ObjectgetElementAt(int index)Returns the value at the specified index.java.lang.StringgetEncoding(int index)Returns an encoding.protected java.lang.StringgetEncodingDescription(java.lang.String encoding)static java.lang.StringgetEncodingsDefinitionFile()Defines the loader settings for the available encodings shown to the user.java.lang.StringgetSelectedEncoding()Returns the selected encoding.intgetSelectedIndex()Returns the selected index.java.lang.ObjectgetSelectedItem()Returns the selected item.intgetSize()Returns the length of the list.intindexOf(java.lang.String encoding)Returns the index of an encoding.voidremoveEncoding(java.lang.String name)voidremoveListDataListener(javax.swing.event.ListDataListener l)Removes a listener from the list that's notified each time a change to the data model occurs.voidsetSelectedEncoding(java.lang.String encoding)voidsetSelectedIndex(int index)Defines the selected index for this encoding model.voidsetSelectedItem(java.lang.Object anItem)Set the selected item.voidsort()Sorts the encodings.
-
-
-
Field Detail
-
AVAILABLE_ENCODINGS
public static final java.lang.String AVAILABLE_ENCODINGS
The property that defines which encodings are available in the export dialogs.- See Also:
- Constant Field Values
-
AVAILABLE_ENCODINGS_ALL
public static final java.lang.String AVAILABLE_ENCODINGS_ALL
The encodings available properties value for all properties.- See Also:
- Constant Field Values
-
AVAILABLE_ENCODINGS_FILE
public static final java.lang.String AVAILABLE_ENCODINGS_FILE
The encodings available properties value for properties defined in the properties file.- See Also:
- Constant Field Values
-
AVAILABLE_ENCODINGS_NONE
public static final java.lang.String AVAILABLE_ENCODINGS_NONE
The encodings available properties value for no properties defined. The encoding selection will be disabled.- See Also:
- Constant Field Values
-
ENCODINGS_DEFINITION_FILE
public static final java.lang.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!- See Also:
- Constant Field Values
-
ENCODINGS_DEFINITION_FILE_DEFAULT
public static final java.lang.String ENCODINGS_DEFINITION_FILE_DEFAULT
The default name for the encoding properties file. This property defaults to "/org/jfree/report/jfreereport-encodings.properties".- See Also:
- Constant Field Values
-
BUNDLE_NAME
public static final java.lang.String BUNDLE_NAME
- See Also:
- Constant Field Values
-
-
Method Detail
-
addEncoding
public boolean addEncoding(java.lang.String name, java.lang.String description)Adds an encoding.- Parameters:
name- the name.description- the description.- Returns:
trueif the encoding is valid and added to the model,falseotherwise.
-
addEncodingUnchecked
public void addEncodingUnchecked(java.lang.String name, java.lang.String description)Adds an encoding to the model without checking its validity.- Parameters:
name- the name.description- the description.
-
removeEncoding
public void removeEncoding(java.lang.String name)
-
ensureEncodingAvailable
public void ensureEncodingAvailable(java.lang.String encoding)
Make sure, that this encoding is defined and selectable in the combobox model.- Parameters:
encoding- the encoding that should be verified.
-
getEncodingDescription
protected java.lang.String getEncodingDescription(java.lang.String encoding)
-
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
public void setSelectedItem(java.lang.Object anItem)
Set the selected item. The implementation of this method should notify all registeredListDataListeners that the contents have changed.- Specified by:
setSelectedItemin interfacejavax.swing.ComboBoxModel- Parameters:
anItem- the list object to select ornullto 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:
java.lang.IllegalArgumentException- if the given index is invalid.
-
getSelectedEncoding
public java.lang.String getSelectedEncoding()
Returns the selected encoding.- Returns:
- The encoding (name).
-
getSelectedItem
public java.lang.Object getSelectedItem()
Returns the selected item.- Specified by:
getSelectedItemin interfacejavax.swing.ComboBoxModel- Returns:
- The selected item or
nullif there is no selection
-
getSize
public int getSize()
Returns the length of the list.- Specified by:
getSizein interfacejavax.swing.ListModel- Returns:
- the length of the list
-
getElementAt
public java.lang.Object getElementAt(int index)
Returns the value at the specified index.- Specified by:
getElementAtin interfacejavax.swing.ListModel- Parameters:
index- the requested index- Returns:
- the value at
index
-
addListDataListener
public void addListDataListener(javax.swing.event.ListDataListener l)
Adds a listener to the list that's notified each time a change to the data model occurs.- Specified by:
addListDataListenerin interfacejavax.swing.ListModel- Parameters:
l- theListDataListenerto be added
-
removeListDataListener
public void removeListDataListener(javax.swing.event.ListDataListener l)
Removes a listener from the list that's notified each time a change to the data model occurs.- Specified by:
removeListDataListenerin interfacejavax.swing.ListModel- Parameters:
l- theListDataListenerto be removed
-
createDefaultModel
public static EncodingComboBoxModel createDefaultModel(java.util.Locale locale)
Creates a default model containing a selection of encodings.- Returns:
- The default model.
-
indexOf
public int indexOf(java.lang.String encoding)
Returns the index of an encoding.- Parameters:
encoding- the encoding (name).- Returns:
- The index.
-
getEncoding
public java.lang.String getEncoding(int index)
Returns an encoding.- Parameters:
index- the index.- Returns:
- The index.
-
getDescription
public java.lang.String getDescription(int index)
Returns a description.- Parameters:
index- the index.- Returns:
- The description.
-
getEncodingsDefinitionFile
public static java.lang.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.
-
getAvailableEncodings
public static java.lang.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.
-
setSelectedEncoding
public void setSelectedEncoding(java.lang.String encoding)
-
-