public class EncodingComboBoxModel
extends java.lang.Object
implements javax.swing.ComboBoxModel
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
AVAILABLE_ENCODINGS
The property that defines which encodings are available in the export dialogs.
|
static java.lang.String |
AVAILABLE_ENCODINGS_ALL
The encodings available properties value for all properties.
|
static java.lang.String |
AVAILABLE_ENCODINGS_FILE
The encodings available properties value for properties defined in the properties
file.
|
static java.lang.String |
AVAILABLE_ENCODINGS_NONE
The encodings available properties value for no properties defined.
|
static java.lang.String |
BUNDLE_NAME |
static java.lang.String |
ENCODINGS_DEFINITION_FILE
The name of the properties file used to define the available encodings.
|
static java.lang.String |
ENCODINGS_DEFINITION_FILE_DEFAULT
The default name for the encoding properties file.
|
Constructor and Description |
---|
EncodingComboBoxModel(java.util.Locale locale)
Creates a new model.
|
Modifier and Type | Method and Description |
---|---|
boolean |
addEncoding(java.lang.String name,
java.lang.String description)
Adds an encoding.
|
void |
addEncodingUnchecked(java.lang.String name,
java.lang.String description)
Adds an encoding to the model without checking its validity.
|
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.
|
static EncodingComboBoxModel |
createDefaultModel(java.util.Locale locale)
Creates a default model containing a selection of encodings.
|
void |
ensureEncodingAvailable(java.lang.String encoding)
Make sure, that this encoding is defined and selectable in the combobox model.
|
protected void |
fireContentsChanged()
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 java.lang.String |
getAvailableEncodings()
Defines the loader settings for the available encodings shown to the user.
|
java.lang.String |
getDescription(int index)
Returns a description.
|
java.lang.Object |
getElementAt(int index)
Returns the value at the specified index.
|
java.lang.String |
getEncoding(int index)
Returns an encoding.
|
protected java.lang.String |
getEncodingDescription(java.lang.String encoding) |
static java.lang.String |
getEncodingsDefinitionFile()
Defines the loader settings for the available encodings shown to the user.
|
java.lang.String |
getSelectedEncoding()
Returns the selected encoding.
|
int |
getSelectedIndex()
Returns the selected index.
|
java.lang.Object |
getSelectedItem()
Returns the selected item.
|
int |
getSize()
Returns the length of the list.
|
int |
indexOf(java.lang.String encoding)
Returns the index of an encoding.
|
void |
removeEncoding(java.lang.String name) |
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.
|
void |
setSelectedEncoding(java.lang.String encoding) |
void |
setSelectedIndex(int index)
Defines the selected index for this encoding model.
|
void |
setSelectedItem(java.lang.Object anItem)
Set the selected item.
|
void |
sort()
Sorts the encodings.
|
public static final java.lang.String AVAILABLE_ENCODINGS
public static final java.lang.String AVAILABLE_ENCODINGS_ALL
public static final java.lang.String AVAILABLE_ENCODINGS_FILE
public static final java.lang.String AVAILABLE_ENCODINGS_NONE
public static final java.lang.String ENCODINGS_DEFINITION_FILE
public static final java.lang.String ENCODINGS_DEFINITION_FILE_DEFAULT
public static final java.lang.String BUNDLE_NAME
public EncodingComboBoxModel(java.util.Locale locale)
locale
- public boolean addEncoding(java.lang.String name, java.lang.String description)
name
- the name.description
- the description.true
if the encoding is valid and added to the model,
false
otherwise.public void addEncodingUnchecked(java.lang.String name, java.lang.String description)
name
- the name.description
- the description.public void removeEncoding(java.lang.String name)
public void ensureEncodingAvailable(java.lang.String encoding)
encoding
- the encoding that should be verified.protected java.lang.String getEncodingDescription(java.lang.String encoding)
public void sort()
protected void fireContentsChanged()
protected void fireContentsChanged(int start, int length)
public void setSelectedItem(java.lang.Object anItem)
ListDataListener
s that the contents have changed.setSelectedItem
in interface javax.swing.ComboBoxModel
anItem
- the list object to select or null
to clear the selectionpublic int getSelectedIndex()
public void setSelectedIndex(int index)
index
- the selected index or -1 to clear the selection.java.lang.IllegalArgumentException
- if the given index is invalid.public java.lang.String getSelectedEncoding()
public java.lang.Object getSelectedItem()
getSelectedItem
in interface javax.swing.ComboBoxModel
null
if there is no selectionpublic int getSize()
getSize
in interface javax.swing.ListModel
public java.lang.Object getElementAt(int index)
getElementAt
in interface javax.swing.ListModel
index
- the requested indexindex
public void addListDataListener(javax.swing.event.ListDataListener l)
addListDataListener
in interface javax.swing.ListModel
l
- the ListDataListener
to be addedpublic void removeListDataListener(javax.swing.event.ListDataListener l)
removeListDataListener
in interface javax.swing.ListModel
l
- the ListDataListener
to be removedpublic static EncodingComboBoxModel createDefaultModel(java.util.Locale locale)
public int indexOf(java.lang.String encoding)
encoding
- the encoding (name).public java.lang.String getEncoding(int index)
index
- the index.public java.lang.String getDescription(int index)
index
- the index.public static java.lang.String getEncodingsDefinitionFile()
public static java.lang.String getAvailableEncodings()
public void setSelectedEncoding(java.lang.String encoding)