JIDE 3.5.15

com.jidesoft.list
Class AbstractDualListModel

java.lang.Object
  extended by javax.swing.AbstractListModel
      extended by com.jidesoft.list.AbstractDualListModel
All Implemented Interfaces:
DualListModel, Serializable, ListModel

public abstract class AbstractDualListModel
extends AbstractListModel
implements DualListModel

See Also:
Serialized Form

Field Summary
protected  PropertyChangeSupport changeSupport
           
 
Fields inherited from class javax.swing.AbstractListModel
listenerList
 
Fields inherited from interface com.jidesoft.list.DualListModel
DISABLE_SELECTION, KEEP_SELECTION, REMOVE_SELECTION
 
Constructor Summary
AbstractDualListModel()
           
 
Method Summary
 void addFreezeIndex(int index)
          Freezes the index.
 void addListSelectionListener(ListSelectionListener l)
          Add a listener to the list that's notified each time a change to the selection occurs.
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a PropertyChangeListener to the listener list.
 void addPropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Add a PropertyChangeListener for a specific property.
 void addSelectionInterval(int index0, int index1)
          Change the selection to be the set union of the current selection and the indices between index0 and index1 inclusive.
 void clearSelection()
          Change the selection to the empty set.
 void fireIndexedPropertyChange(String propertyName, int index, Object oldValue, Object newValue)
          Report a bound indexed property update to any registered listeners.
 void firePropertyChange(PropertyChangeEvent evt)
          Fire an existing PropertyChangeEvent to any registered listeners.
 void firePropertyChange(String propertyName, Object oldValue, Object newValue)
          Report a bound property update to any registered listeners.
protected  void fireValueChanged(int firstIndex, int lastIndex)
          Notifies ListSelectionListeners that the value of the selection, in the closed interval firstIndex, lastIndex, has changed.
protected  void fireValueChanged(int firstIndex, int lastIndex, boolean isAdjusting)
           
 int[] getFrozenIndices()
          Gets all frozen indices.
 ListSelectionListener[] getListSelectionListeners()
          Returns an array of all the list selection listeners registered on this DefaultListSelectionModel.
 PropertyChangeListener[] getPropertyChangeListeners()
          Returns an array of all the listeners that were added to the PropertyChangeSupport object with addPropertyChangeListener().
 PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
          Returns an array of all the listeners which have been associated with the named property.
 int[] getSelectedIndices()
          Returns all selected indices in order.
 int getSelectionMode()
          Returns the current selection mode.
 boolean getValueIsAdjusting()
          Returns true if the value is undergoing a series of changes.
 boolean hasListeners(String propertyName)
          Check if there are any listeners for a specific property, including those registered on all properties.
 int[] internalGetSelectedIndices()
           
 boolean isFreezeIndex(int index)
          Gets if the index is froze.
 boolean isSelectedIndex(int index)
          Returns true if the specified index is selected.
 boolean isSelectionEmpty()
          Returns true if no indices are selected.
 void moveSelection(int index0, int index1, int newIndex, boolean before)
          Moves all indices of an interval to a new index.
 void removeFreezeIndex(int index)
          Unfreezes the index.
 void removeListSelectionListener(ListSelectionListener l)
          Remove a listener from the list that's notified each time a change to the selection occurs.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a PropertyChangeListener from the listener list.
 void removePropertyChangeListener(String propertyName, PropertyChangeListener listener)
          Remove a PropertyChangeListener for a specific property.
 void removeSelectionInterval(int index0, int index1)
          Change the selection to be the set difference of the current selection and the indices between index0 and index1 inclusive.
 void selectAll()
          Select all elements that exist in original list.
 void setSelectionMode(int selectionMode)
          Set the selection mode.
 void setValueIsAdjusting(boolean valueIsAdjusting)
          This property is true if upcoming changes to the value of the model should be considered a single event.
 
Methods inherited from class javax.swing.AbstractListModel
addListDataListener, fireContentsChanged, fireIntervalAdded, fireIntervalRemoved, getListDataListeners, getListeners, removeListDataListener
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface javax.swing.ListModel
addListDataListener, getElementAt, getSize, removeListDataListener
 

Field Detail

changeSupport

protected PropertyChangeSupport changeSupport
Constructor Detail

AbstractDualListModel

public AbstractDualListModel()
Method Detail

isSelectedIndex

public boolean isSelectedIndex(int index)
Returns true if the specified index is selected.

Specified by:
isSelectedIndex in interface DualListModel
Parameters:
index - the specified index
Returns:
true if the specified index is selected.

getSelectedIndices

public int[] getSelectedIndices()
Returns all selected indices in order. Note that the return value may have duplicated indices

Specified by:
getSelectedIndices in interface DualListModel
Returns:
all selected indices in order

addSelectionInterval

public void addSelectionInterval(int index0,
                                 int index1)
Change the selection to be the set union of the current selection and the indices between index0 and index1 inclusive. If this represents a change to the current selection, then notify each ListSelectionListener. Note that index0 doesn't have to be less than or equal to index1.

Specified by:
addSelectionInterval in interface DualListModel
Parameters:
index0 - one end of the interval.
index1 - other end of the interval
See Also:
DualListModel.addListSelectionListener(javax.swing.event.ListSelectionListener)

removeSelectionInterval

public void removeSelectionInterval(int index0,
                                    int index1)
Change the selection to be the set difference of the current selection and the indices between index0 and index1 inclusive. If this represents a change to the current selection, then notify each ListSelectionListener. Note that index0 doesn't have to be less than or equal to index1.

Specified by:
removeSelectionInterval in interface DualListModel
Parameters:
index0 - one end of the interval.
index1 - other end of the interval
See Also:
DualListModel.addListSelectionListener(javax.swing.event.ListSelectionListener)

moveSelection

public void moveSelection(int index0,
                          int index1,
                          int newIndex,
                          boolean before)
Moves all indices of an interval to a new index. note this index is relative to the selected index, not in the original list model.

Specified by:
moveSelection in interface DualListModel
Parameters:
index0 - one end of the interval.
index1 - other end of the interval
newIndex - new index
before - true if moving the indices before the new index

clearSelection

public void clearSelection()
Change the selection to the empty set. If this represents a change to the current selection then notify each ListSelectionListener.

Specified by:
clearSelection in interface DualListModel
See Also:
DualListModel.addListSelectionListener(javax.swing.event.ListSelectionListener)

isSelectionEmpty

public boolean isSelectionEmpty()
Returns true if no indices are selected.

Specified by:
isSelectionEmpty in interface DualListModel
Returns:
true if no indices are selected.

selectAll

public void selectAll()
Select all elements that exist in original list.

Specified by:
selectAll in interface DualListModel

setValueIsAdjusting

public void setValueIsAdjusting(boolean valueIsAdjusting)
This property is true if upcoming changes to the value of the model should be considered a single event. For example if the model is being updated in response to a user drag, the value of the valueIsAdjusting property will be set to true when the drag is initiated and be set to false when the drag is finished. This property allows listeners to to update only when a change has been finalized, rather than always handling all of the intermediate values.

Specified by:
setValueIsAdjusting in interface DualListModel
Parameters:
valueIsAdjusting - The new value of the property.
See Also:
DualListModel.getValueIsAdjusting()

getValueIsAdjusting

public boolean getValueIsAdjusting()
Returns true if the value is undergoing a series of changes.

Specified by:
getValueIsAdjusting in interface DualListModel
Returns:
true if the value is currently adjusting
See Also:
DualListModel.setValueIsAdjusting(boolean)

setSelectionMode

public void setSelectionMode(int selectionMode)
Set the selection mode. The following selectionMode values are allowed:

Specified by:
setSelectionMode in interface DualListModel
Parameters:
selectionMode - the selection mode
See Also:
DualListModel.getSelectionMode()

getSelectionMode

public int getSelectionMode()
Returns the current selection mode.

Specified by:
getSelectionMode in interface DualListModel
Returns:
The value of the selectionMode property.
See Also:
DualListModel.setSelectionMode(int)

addFreezeIndex

public void addFreezeIndex(int index)
Description copied from interface: DualListModel
Freezes the index. No matter if the index is selected, the item would not be able to move left or right.

Specified by:
addFreezeIndex in interface DualListModel
Parameters:
index - the index

removeFreezeIndex

public void removeFreezeIndex(int index)
Description copied from interface: DualListModel
Unfreezes the index.

Specified by:
removeFreezeIndex in interface DualListModel
Parameters:
index - the index

getFrozenIndices

public int[] getFrozenIndices()
Description copied from interface: DualListModel
Gets all frozen indices.

Specified by:
getFrozenIndices in interface DualListModel
Returns:
the frozen index array

isFreezeIndex

public boolean isFreezeIndex(int index)
Description copied from interface: DualListModel
Gets if the index is froze.

Specified by:
isFreezeIndex in interface DualListModel
Parameters:
index - the index
Returns:
true if the index is froze. Otherwise false.

addListSelectionListener

public void addListSelectionListener(ListSelectionListener l)
Description copied from interface: DualListModel
Add a listener to the list that's notified each time a change to the selection occurs.

Specified by:
addListSelectionListener in interface DualListModel
Parameters:
l - the ListSelectionListener
See Also:
DualListModel.removeListSelectionListener(javax.swing.event.ListSelectionListener), DualListModel.addSelectionInterval(int, int), DualListModel.removeSelectionInterval(int, int), DualListModel.clearSelection()

removeListSelectionListener

public void removeListSelectionListener(ListSelectionListener l)
Description copied from interface: DualListModel
Remove a listener from the list that's notified each time a change to the selection occurs.

Specified by:
removeListSelectionListener in interface DualListModel
Parameters:
l - the ListSelectionListener
See Also:
DualListModel.addListSelectionListener(javax.swing.event.ListSelectionListener)

getListSelectionListeners

public ListSelectionListener[] getListSelectionListeners()
Returns an array of all the list selection listeners registered on this DefaultListSelectionModel.

Returns:
all of this model's ListSelectionListeners or an empty array if no list selection listeners are currently registered
Since:
1.4
See Also:
addListSelectionListener(javax.swing.event.ListSelectionListener), removeListSelectionListener(javax.swing.event.ListSelectionListener)

fireValueChanged

protected void fireValueChanged(int firstIndex,
                                int lastIndex)
Notifies ListSelectionListeners that the value of the selection, in the closed interval firstIndex, lastIndex, has changed.

Parameters:
firstIndex - the first index in the interval
lastIndex - the last index in the interval

fireValueChanged

protected void fireValueChanged(int firstIndex,
                                int lastIndex,
                                boolean isAdjusting)
Parameters:
firstIndex - the first index in the interval
lastIndex - the last index in the interval
isAdjusting - true if this is the final change in a series of adjustments
See Also:
DualListModelSupport

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. The listener is registered for all properties. The same listener object may be added more than once, and will be called as many times as it is added. If listener is null, no exception is thrown and no action is taken.

Specified by:
addPropertyChangeListener in interface DualListModel
Parameters:
listener - The PropertyChangeListener to be added

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list. This removes a PropertyChangeListener that was registered for all properties. If listener was added more than once to the same event source, it will be notified one less time after being removed. If listener is null, or was never added, no exception is thrown and no action is taken.

Specified by:
removePropertyChangeListener in interface DualListModel
Parameters:
listener - The PropertyChangeListener to be removed

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners()
Returns an array of all the listeners that were added to the PropertyChangeSupport object with addPropertyChangeListener().

Returns:
all of the PropertyChangeListeners added or an empty array if no listeners have been added

addPropertyChangeListener

public void addPropertyChangeListener(String propertyName,
                                      PropertyChangeListener listener)
Add a PropertyChangeListener for a specific property. The listener will be invoked only when a call on firePropertyChange names that specific property. The same listener object may be added more than once. For each property, the listener will be invoked the number of times it was added for that property. If propertyName or listener is null, no exception is thrown and no action is taken.

Parameters:
propertyName - The name of the property to listen on.
listener - The PropertyChangeListener to be added

removePropertyChangeListener

public void removePropertyChangeListener(String propertyName,
                                         PropertyChangeListener listener)
Remove a PropertyChangeListener for a specific property. If listener was added more than once to the same event source for the specified property, it will be notified one less time after being removed. If propertyName is null, no exception is thrown and no action is taken. If listener is null, or was never added for the specified property, no exception is thrown and no action is taken.

Parameters:
propertyName - The name of the property that was listened on.
listener - The PropertyChangeListener to be removed

getPropertyChangeListeners

public PropertyChangeListener[] getPropertyChangeListeners(String propertyName)
Returns an array of all the listeners which have been associated with the named property.

Parameters:
propertyName - The name of the property being listened to
Returns:
all of the PropertyChangeListeners associated with the named property. If no such listeners have been added, or if propertyName is null, an empty array is returned.

firePropertyChange

public void firePropertyChange(String propertyName,
                               Object oldValue,
                               Object newValue)
Report a bound property update to any registered listeners. No event is fired if old and new are equal and non-null.

Parameters:
propertyName - The programmatic name of the property that was changed.
oldValue - The old value of the property.
newValue - The new value of the property.

firePropertyChange

public void firePropertyChange(PropertyChangeEvent evt)
Fire an existing PropertyChangeEvent to any registered listeners. No event is fired if the given event's old and new values are equal and non-null.

Parameters:
evt - The PropertyChangeEvent object.

fireIndexedPropertyChange

public void fireIndexedPropertyChange(String propertyName,
                                      int index,
                                      Object oldValue,
                                      Object newValue)
Report a bound indexed property update to any registered listeners.

No event is fired if old and new values are equal and non-null.

Parameters:
propertyName - The programmatic name of the property that was changed.
index - index of the property element that was changed.
oldValue - The old value of the property.
newValue - The new value of the property.
Since:
1.5

hasListeners

public boolean hasListeners(String propertyName)
Check if there are any listeners for a specific property, including those registered on all properties. If propertyName is null, only check for listeners registered on all properties.

Parameters:
propertyName - the property name.
Returns:
true if there are one or more listeners for the given property

internalGetSelectedIndices

public int[] internalGetSelectedIndices()

JIDE 3.5.15