com.jrefinery.report.preview
Class EncodingComboBoxModel

java.lang.Object
  extended bycom.jrefinery.report.preview.EncodingComboBoxModel
All Implemented Interfaces:
javax.swing.ComboBoxModel, javax.swing.ListModel

public class EncodingComboBoxModel
extends java.lang.Object
implements javax.swing.ComboBoxModel

A model for the 'encoding' combo box.

This model is used in the CSVExportDialog class (and possibly others).

Author:
Thomas Morgner.

Constructor Summary
EncodingComboBoxModel()
          Creates a new model.
 
Method Summary
 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()
          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.
 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.
 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 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 setSelectedItem(java.lang.Object anItem)
          Set the selected item.
 void sort()
          Sorts the encodings.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EncodingComboBoxModel

public EncodingComboBoxModel()
Creates a new model.

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:
true if the encoding is valid and added to the model, false otherwise.

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.

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.

sort

public void sort()
Sorts the encodings.


fireContentsChanged

protected void fireContentsChanged()
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 registered ListDataListeners that the contents have changed.

Specified by:
setSelectedItem in interface javax.swing.ComboBoxModel
Parameters:
anItem - the list object to select or null to clear the selection

getSelectedIndex

public int getSelectedIndex()
Returns the selected index.

Returns:
The index.

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:
getSelectedItem in interface javax.swing.ComboBoxModel
Returns:
The selected item or null if there is no selection

getSize

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

Specified by:
getSize in interface javax.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:
getElementAt in interface javax.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:
addListDataListener in interface javax.swing.ListModel
Parameters:
l - the ListDataListener to 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:
removeListDataListener in interface javax.swing.ListModel
Parameters:
l - the ListDataListener to be removed

createDefaultModel

public static EncodingComboBoxModel createDefaultModel()
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.