Java Doc for SelectionInList.java in  » Swing-Library » jgoodies-data-binding » com » jgoodies » binding » list » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Swing Library » jgoodies data binding » com.jgoodies.binding.list 
Source Cross Reference  Class Diagram Java Document (Java Doc) 


com.jgoodies.binding.list.SelectionInList

SelectionInList
final public class SelectionInList extends IndirectListModel implements ValueModel(Code)
Represents a selection in a list of objects. Provides bound bean properties for the list, the selection, the selection index, and the selection empty state. The SelectionInList implements ValueModel with the selection as value. Selection changes fire an event only if the old and new value are not equal. If you need to compare the identity you can use and observe the selection index instead of the selection or value.

The SelectionInList uses three ValueModels to hold the list, the selection and selection index and provides bound bean properties for these models. You can access, observe and replace these ValueModels. This is useful to connect a SelectionInList with other ValueModels; for example you can use the SelectionInList's selection holder as bean channel for a PresentationModel. Since the SelectionInList is a ValueModel, it is often used as bean channel. See the Binding tutorial classes for examples on how to connect a SelectionInList with a PresentationModel.

This class also implements the ListModel interface that allows API users to observe fine grained changes in the structure and contents of the list. Hence instances of this class can be used directly as model of a JList. If you want to use a SelectionInList with a JComboBox or JTable, you can convert the SelectionInList to the associated component model interfaces using the adapter classes com.jgoodies.binding.adapter.ComboBoxAdapter and com.jgoodies.binding.adapter.AbstractTableAdapter respectively. These classes are part of the Binding library too.

The SelectionInList supports two list types as content of its list holder: List and ListModel. The two modes differ in how precise this class can fire events about changes to the content and structure of the list. If you use a List, this class can only report that the list changes completely; this is done by firing a PropertyChangeEvent for the list property. Also, a ListDataEvent is fired that reports a complete change. In contrast, if you use a ListModel it will report the same PropertyChangeEvent. But fine grained changes in the list model will be fired by this class to notify observes about changes in the content, added and removed elements.

If the list content doesn't change at all, or if it always changes completely, you can work well with both List content and ListModel content. But if the list structure or content changes, the ListModel reports more fine grained events to registered ListDataListeners, which in turn allows list views to chooser better user interface gestures: for example, a table with scroll pane may retain the current selection and scroll offset.

An example for using a ListModel in a SelectionInList is the asynchronous transport of list elements from a server to a client. Let's say you transport the list elements in portions of 10 elements to improve the application's responsiveness. The user can then select and work with the SelectionInList as soon as the ListModel gets populated. If at a later time more elements are added to the list model, the SelectionInList can retain the selection index (and selection) and will just report a ListDataEvent about the interval added. JList, JTable and JComboBox will then just add the new elements at the end of the list presentation.

If you want to combine List operations and the ListModel change reports, you may consider using an implementation that combines these two interfaces, for example ArrayListModel or LinkedListModel .

Important Note: If you change the ListModel instance, either by calling #setListModel(ListModel) or by setting a new value to the underlying list holder, you must ensure that the list holder throws a PropertyChangeEvent whenever the instance changes. This event is used to remove a ListDataListener from the old ListModel instance and is later used to add it to the new ListModel instance. It is easy to violate this constraint, just because Java's standard PropertyChangeSupport helper class that is used by many beans, checks a changed property value via #equals, not ==. For example, if you change the SelectionInList's list model from an empty list L1 to another empty list instance L2, the PropertyChangeSupport won't generate a PropertyChangeEvent, and so, the SelectionInList won't know about the change, which may lead to unexpected behavior.

This binding library provides some help for firing PropertyChangeEvents if the old ListModel and new ListModel are equal but not the same. Class com.jgoodies.binding.beans.ExtendedPropertyChangeSupport allows to permanently or individually check the identity (using ==) instead of checking the equity (using #equals). Class com.jgoodies.binding.beans.Model uses this extended property change support. And class ValueHolder uses it too and can be configured to always test the identity.

Since version 1.0.2 this class provides public convenience methods for firing ListDataEvents, see the methods #fireContentsChanged, #fireIntervalAdded, and #fireIntervalRemoved. These are automatically invoked if the list holder holds a ListModel that fires these events. If on the other hand the underlying List or ListModel does not fire a required ListDataEvent, you can use these methods to notify presentations about a change. It is recommended to avoid sending duplicate ListDataEvents; hence check if the underlying ListModel fires the necessary events or not. Typically an underlying ListModel will fire the add and remove events; but often it'll lack an event if the (selected) contents has changed. A convenient way to indicate that change is #fireSelectedContentsChanged. See the tutorial's AlbumManagerModel for an example how to use this feature.

The SelectionInList is partially defined for Lists and ListModels that contain null . Setting the selection to null on a SelectionInList that contains null won't set the selection index to the index of the first null element. For details see the SelectionInList.setSelection(Object) JavaDocs. This is because the current implementation interprets a null selection as unspecified, which maps better to a cleared selection than to a concrete selection index. Anyway, as long as you work with the selection index and selection index holder, such a SelectionInList will work fine. This is the case if you bind a SelectionInList to a JList or JTable. Binding such a SelectionInList to a JComboBox won't synchronize the selection index if null is selected.

Constraints: The list holder holds instances of List or ListModel , the selection holder values of type E and the selection index holder of type Integer . The selection index holder must hold non-null index values; however, when firing an index value change event, both the old and new value may be null. If the ListModel changes, the underlying ValueModel must fire a PropertyChangeEvent.
author:
   Karsten Lentzsch
version:
   $Revision: 1.36 $
See Also:   ValueModel
See Also:   List
See Also:   ListModel
See Also:   com.jgoodies.binding.adapter.ComboBoxAdapter
See Also:   com.jgoodies.binding.adapter.AbstractTableAdapter
See Also:   com.jgoodies.binding.beans.ExtendedPropertyChangeSupport
See Also:   com.jgoodies.binding.beans.Model
See Also:   com.jgoodies.binding.value.ValueHolder<
Parameters:
  E - > the type of the list elements and the selection



Field Summary
final public static  StringPROPERTYNAME_SELECTION
     The name of the bound read-write selection property.
final public static  StringPROPERTYNAME_SELECTION_EMPTY
     The name of the bound read-only selectionEmpty property.
final public static  StringPROPERTYNAME_SELECTION_HOLDER
     The name of the bound read-write selection holder property.
final public static  StringPROPERTYNAME_SELECTION_INDEX
     The name of the bound read-write selectionIndex property.
final public static  StringPROPERTYNAME_SELECTION_INDEX_HOLDER
     The name of the bound read-write selection index holder property.
final public static  StringPROPERTYNAME_VALUE
     The name of the bound read-write value property.

Constructor Summary
public  SelectionInList()
     Constructs a SelectionInList with an empty initial ArrayListModel using defaults for the selection holder and selection index holder.
public  SelectionInList(E[] listItems)
     Constructs a SelectionInList on the given item array using defaults for the selection holder and selection index holder.
public  SelectionInList(E[] listItems, ValueModel selectionHolder)
     Constructs a SelectionInList on the given item array and selection holder using a default selection index holder.
public  SelectionInList(E[] listItems, ValueModel selectionHolder, ValueModel selectionIndexHolder)
     Constructs a SelectionInList on the given item array and selection holder using a default selection index holder.
public  SelectionInList(List<E> list)
     Constructs a SelectionInList on the given list using defaults for the selection holder and selection index holder.

Note: Favor ListModel over List when working with the SelectionInList. Why? The SelectionInList can work with both types.

public  SelectionInList(List<E> list, ValueModel selectionHolder)
     Constructs a SelectionInList on the given list and selection holder using a default selection index holder.

Note: Favor ListModel over List when working with the SelectionInList. Why? The SelectionInList can work with both types.

public  SelectionInList(List<E> list, ValueModel selectionHolder, ValueModel selectionIndexHolder)
     Constructs a SelectionInList on the given list, selection holder, and selection index holder.

Note: Favor ListModel over List when working with the SelectionInList. Why? The SelectionInList can work with both types.

public  SelectionInList(ListModel listModel)
     Constructs a SelectionInList on the given list model using defaults for the selection holder and selection index holder.
public  SelectionInList(ListModel listModel, ValueModel selectionHolder)
     Constructs a SelectionInList on the given list model and selection holder using a default selection index holder.
public  SelectionInList(ListModel listModel, ValueModel selectionHolder, ValueModel selectionIndexHolder)
     Constructs a SelectionInList on the given list model, selection holder, and selection index holder.
public  SelectionInList(ValueModel listHolder)
     Constructs a SelectionInList on the given list holder using defaults for the selection holder and selection index holder.

Constraints: 1) The listHolder must hold instances of List or ListModel and 2) must report a value change whenever the value's identity changes. Note that many bean properties don't fire a PropertyChangeEvent if the old and new value are equal - and so would break this constraint. If you provide a ValueHolder, enable its identityCheck feature during construction.

public  SelectionInList(ValueModel listHolder, ValueModel selectionHolder)
     Constructs a SelectionInList on the given list holder, selection holder and selection index holder.

Constraints: 1) The listHolder must hold instances of List or ListModel and 2) must report a value change whenever the value's identity changes. Note that many bean properties don't fire a PropertyChangeEvent if the old and new value are equal - and so would break this constraint. If you provide a ValueHolder, enable its identityCheck feature during construction.

public  SelectionInList(ValueModel listHolder, ValueModel selectionHolder, ValueModel selectionIndexHolder)
     Constructs a SelectionInList on the given list holder, selection holder and selection index holder.

Constraints: 1) The listHolder must hold instances of List or ListModel and 2) must report a value change whenever the value's identity changes. Note that many bean properties don't fire a PropertyChangeEvent if the old and new value are equal - and so would break this constraint. If you provide a ValueHolder, enable its identityCheck feature during construction.


Method Summary
public  voidaddValueChangeListener(PropertyChangeListener l)
     Registers the given PropertyChangeListener with this model. The listener will be notified if the value has changed.

The PropertyChangeEvents delivered to the listener have the name set to "value".

public  voidclearSelection()
     Clears the selection of this SelectionInList - if any.
protected  ListDataListenercreateListDataChangeHandler()
     Creates and returns the ListDataListener used to observe changes in the underlying ListModel.
public  voidfireSelectedContentsChanged()
     Notifies all registered ListDataListeners that the contents of the selected list item - if any - has changed. Useful to update a presentation after editing the selection. See the tutorial's AlbumManagerModel for an example how to use this feature.

If the list holder holds a ListModel, this SelectionInList listens to ListDataEvents fired by that ListModel, and forwards these events by invoking the associated #fireXXX method, which in turn notifies all registered ListDataListeners.

 voidfireValueChange(Object oldValue, Object newValue)
     Notifies all listeners that have registered interest for notification on this event type.
public  EgetSelection()
     Looks up and returns the current selection using the current selection index.
public  ValueModelgetSelectionHolder()
     Returns the selection holder.
public  intgetSelectionIndex()
     Returns the selection index.
public  ValueModelgetSelectionIndexHolder()
     Returns the selection index holder.
public  EgetValue()
     Returns the current selection, null if the selection index does not represent a selection in the list.
public  booleanhasSelection()
     Checks and answers if an element is selected.
public  booleanisSelectionEmpty()
     Checks and answers whether the selection is empty or not. Unlike #hasSelection, the underlying property #selectionEmpty for this method is bound.
public  voidrelease()
     Removes the internal listeners from the list holder, selection holder, selection index holder.
public  voidremoveValueChangeListener(PropertyChangeListener l)
     Removes the given PropertyChangeListener from the model.
public  voidsetSelection(E newSelection)
     Sets the selection index to the index of the first list element that equals newSelection .
public  voidsetSelectionHolder(ValueModel newSelectionHolder)
     Sets a new selection holder. Does nothing if the new is the same as before. The selection remains unchanged and is still driven by the selection index holder.
public  voidsetSelectionIndex(int newSelectionIndex)
     Sets a new selection index.
public  voidsetSelectionIndexHolder(ValueModel newSelectionIndexHolder)
     Sets a new selection index holder.
public  voidsetValue(Object newValue)
     Sets the selection index to the index of the first list element that equals newValue .
protected  voidupdateList(Object oldList, int oldSize, Object newList)
     Removes the list data change handler from the old list in case it is a ListModel and adds it to new one in case it is a ListModel. It then fires a property change for the list and a contents change event for the list content.

Field Detail
PROPERTYNAME_SELECTION
final public static String PROPERTYNAME_SELECTION(Code)
The name of the bound read-write selection property.



PROPERTYNAME_SELECTION_EMPTY
final public static String PROPERTYNAME_SELECTION_EMPTY(Code)
The name of the bound read-only selectionEmpty property.



PROPERTYNAME_SELECTION_HOLDER
final public static String PROPERTYNAME_SELECTION_HOLDER(Code)
The name of the bound read-write selection holder property.



PROPERTYNAME_SELECTION_INDEX
final public static String PROPERTYNAME_SELECTION_INDEX(Code)
The name of the bound read-write selectionIndex property.



PROPERTYNAME_SELECTION_INDEX_HOLDER
final public static String PROPERTYNAME_SELECTION_INDEX_HOLDER(Code)
The name of the bound read-write selection index holder property.



PROPERTYNAME_VALUE
final public static String PROPERTYNAME_VALUE(Code)
The name of the bound read-write value property.




Constructor Detail
SelectionInList
public SelectionInList()(Code)
Constructs a SelectionInList with an empty initial ArrayListModel using defaults for the selection holder and selection index holder.



SelectionInList
public SelectionInList(E[] listItems)(Code)
Constructs a SelectionInList on the given item array using defaults for the selection holder and selection index holder. The specified array will be converted to a List.

Changes to the list "write through" to the array, and changes to the array contents will be reflected in the list.
Parameters:
  listItems - the array of initial items
throws:
  NullPointerException - if listItems is null




SelectionInList
public SelectionInList(E[] listItems, ValueModel selectionHolder)(Code)
Constructs a SelectionInList on the given item array and selection holder using a default selection index holder. The specified array will be converted to a List.

Changes to the list "write through" to the array, and changes to the array contents will be reflected in the list.
Parameters:
  listItems - the array of initial items
Parameters:
  selectionHolder - holds the selection
throws:
  NullPointerException - if listItems orselectionHolder is null




SelectionInList
public SelectionInList(E[] listItems, ValueModel selectionHolder, ValueModel selectionIndexHolder)(Code)
Constructs a SelectionInList on the given item array and selection holder using a default selection index holder. The specified array will be converted to a List.

Changes to the list "write through" to the array, and changes to the array contents will be reflected in the list.
Parameters:
  listItems - the array of initial items
Parameters:
  selectionHolder - holds the selection
Parameters:
  selectionIndexHolder - holds the selection index
throws:
  NullPointerException - if listItems,selectionHolder, or selectionIndexHolderis null




SelectionInList
public SelectionInList(List<E> list)(Code)
Constructs a SelectionInList on the given list using defaults for the selection holder and selection index holder.

Note: Favor ListModel over List when working with the SelectionInList. Why? The SelectionInList can work with both types. What's the difference? ListModel provides all list access features required by the SelectionInList's. In addition it reports more fine grained change events, instances of ListDataEvents. In contrast developer often create Lists and operate on them and the ListModel may be inconvenient for these operations.

A convenient solution for this situation is to use the ArrayListModel and LinkedListModel classes. These implement both List and ListModel, offer the standard List operations and report the fine grained ListDataEvents.
Parameters:
  list - the initial list




SelectionInList
public SelectionInList(List<E> list, ValueModel selectionHolder)(Code)
Constructs a SelectionInList on the given list and selection holder using a default selection index holder.

Note: Favor ListModel over List when working with the SelectionInList. Why? The SelectionInList can work with both types. What's the difference? ListModel provides all list access features required by the SelectionInList's. In addition it reports more fine grained change events, instances of ListDataEvents. In contrast developer often create Lists and operate on them and the ListModel may be inconvenient for these operations.

A convenient solution for this situation is to use the ArrayListModel and LinkedListModel classes. These implement both List and ListModel, offer the standard List operations and report the fine grained ListDataEvents.
Parameters:
  list - the initial list
Parameters:
  selectionHolder - holds the selection
throws:
  NullPointerException - if selectionHolder is null




SelectionInList
public SelectionInList(List<E> list, ValueModel selectionHolder, ValueModel selectionIndexHolder)(Code)
Constructs a SelectionInList on the given list, selection holder, and selection index holder.

Note: Favor ListModel over List when working with the SelectionInList. Why? The SelectionInList can work with both types. What's the difference? ListModel provides all list access features required by the SelectionInList's. In addition it reports more fine grained change events, instances of ListDataEvents. In contrast developer often create Lists and operate on them and the ListModel may be inconvenient for these operations.

A convenient solution for this situation is to use the ArrayListModel and LinkedListModel classes. These implement both List and ListModel, offer the standard List operations and report the fine grained ListDataEvents.
Parameters:
  list - the initial list
Parameters:
  selectionHolder - holds the selection
Parameters:
  selectionIndexHolder - holds the selection index
throws:
  NullPointerException - if selectionHolder,or selectionIndexHolder is null




SelectionInList
public SelectionInList(ListModel listModel)(Code)
Constructs a SelectionInList on the given list model using defaults for the selection holder and selection index holder.
Parameters:
  listModel - the initial list model



SelectionInList
public SelectionInList(ListModel listModel, ValueModel selectionHolder)(Code)
Constructs a SelectionInList on the given list model and selection holder using a default selection index holder.
Parameters:
  listModel - the initial list model
Parameters:
  selectionHolder - holds the selection
throws:
  NullPointerException - if selectionHolder is null



SelectionInList
public SelectionInList(ListModel listModel, ValueModel selectionHolder, ValueModel selectionIndexHolder)(Code)
Constructs a SelectionInList on the given list model, selection holder, and selection index holder.
Parameters:
  listModel - the initial list model
Parameters:
  selectionHolder - holds the selection
Parameters:
  selectionIndexHolder - holds the selection index
throws:
  NullPointerException - if selectionHolder,or selectionIndexHolder is null



SelectionInList
public SelectionInList(ValueModel listHolder)(Code)
Constructs a SelectionInList on the given list holder using defaults for the selection holder and selection index holder.

Constraints: 1) The listHolder must hold instances of List or ListModel and 2) must report a value change whenever the value's identity changes. Note that many bean properties don't fire a PropertyChangeEvent if the old and new value are equal - and so would break this constraint. If you provide a ValueHolder, enable its identityCheck feature during construction. If you provide an adapted bean property from a bean that extends the JGoodies Model class, you can enable the identity check feature in the methods #firePropertyChange by setting the trailing boolean parameter to true.
Parameters:
  listHolder - holds the list or list model
throws:
  NullPointerException - if listHolder is null




SelectionInList
public SelectionInList(ValueModel listHolder, ValueModel selectionHolder)(Code)
Constructs a SelectionInList on the given list holder, selection holder and selection index holder.

Constraints: 1) The listHolder must hold instances of List or ListModel and 2) must report a value change whenever the value's identity changes. Note that many bean properties don't fire a PropertyChangeEvent if the old and new value are equal - and so would break this constraint. If you provide a ValueHolder, enable its identityCheck feature during construction. If you provide an adapted bean property from a bean that extends the JGoodies Model class, you can enable the identity check feature in the methods #firePropertyChange by setting the trailing boolean parameter to true.
Parameters:
  listHolder - holds the list or list model
Parameters:
  selectionHolder - holds the selection
throws:
  NullPointerException - if listHolderor selectionHolder is null




SelectionInList
public SelectionInList(ValueModel listHolder, ValueModel selectionHolder, ValueModel selectionIndexHolder)(Code)
Constructs a SelectionInList on the given list holder, selection holder and selection index holder.

Constraints: 1) The listHolder must hold instances of List or ListModel and 2) must report a value change whenever the value's identity changes. Note that many bean properties don't fire a PropertyChangeEvent if the old and new value are equal - and so would break this constraint. If you provide a ValueHolder, enable its identityCheck feature during construction. If you provide an adapted bean property from a bean that extends the JGoodies Model class, you can enable the identity check feature in the methods #firePropertyChange by setting the trailing boolean parameter to true.
Parameters:
  listHolder - holds the list or list model
Parameters:
  selectionHolder - holds the selection
Parameters:
  selectionIndexHolder - holds the selection index
throws:
  NullPointerException - if the listModelHolder,selectionHolder, or selectionIndexHolderis null
throws:
  IllegalArgumentException - if the listHolder is a ValueHolderthat doesn't check the identity when changing its value
throws:
  ClassCastException - if the listModelHolder contentsis neither a List nor a ListModel





Method Detail
addValueChangeListener
public void addValueChangeListener(PropertyChangeListener l)(Code)
Registers the given PropertyChangeListener with this model. The listener will be notified if the value has changed.

The PropertyChangeEvents delivered to the listener have the name set to "value". In other words, the listeners won't get notified when a PropertyChangeEvent is fired that has a null object as the name to indicate an arbitrary set of the event source's properties have changed.

In the rare case, where you want to notify a PropertyChangeListener even with PropertyChangeEvents that have no property name set, you can register the listener with #addPropertyChangeListener, not #addValueChangeListener.
Parameters:
  l - the listener to add
See Also:   ValueModel




clearSelection
public void clearSelection()(Code)
Clears the selection of this SelectionInList - if any.



createListDataChangeHandler
protected ListDataListener createListDataChangeHandler()(Code)
Creates and returns the ListDataListener used to observe changes in the underlying ListModel. It is re-registered in #updateListModel. the ListDataListener that handles changesin the underlying ListModel



fireSelectedContentsChanged
public void fireSelectedContentsChanged()(Code)
Notifies all registered ListDataListeners that the contents of the selected list item - if any - has changed. Useful to update a presentation after editing the selection. See the tutorial's AlbumManagerModel for an example how to use this feature.

If the list holder holds a ListModel, this SelectionInList listens to ListDataEvents fired by that ListModel, and forwards these events by invoking the associated #fireXXX method, which in turn notifies all registered ListDataListeners. Therefore if you fire ListDataEvents in an underlying ListModel, you don't need this method and should not use it to avoid sending duplicate ListDataEvents.
See Also:   ListModel
See Also:   ListDataListener
See Also:   ListDataEvent
since:
   1.0.2




fireValueChange
void fireValueChange(Object oldValue, Object newValue)(Code)
Notifies all listeners that have registered interest for notification on this event type. The event instance is lazily created using the parameters passed into the fire method.
Parameters:
  oldValue - the value before the change
Parameters:
  newValue - the value after the change
See Also:   java.beans.PropertyChangeSupport



getSelection
public E getSelection()(Code)
Looks up and returns the current selection using the current selection index. Returns null if no object is selected or if the list has no elements. the current selection, null if none is selected



getSelectionHolder
public ValueModel getSelectionHolder()(Code)
Returns the selection holder. the selection holder



getSelectionIndex
public int getSelectionIndex()(Code)
Returns the selection index. the selection index
throws:
  NullPointerException - if the selection index holderhas a null Object set



getSelectionIndexHolder
public ValueModel getSelectionIndexHolder()(Code)
Returns the selection index holder. the selection index holder



getValue
public E getValue()(Code)
Returns the current selection, null if the selection index does not represent a selection in the list. the selected element - if any



hasSelection
public boolean hasSelection()(Code)
Checks and answers if an element is selected. true if an element is selected, false otherwise



isSelectionEmpty
public boolean isSelectionEmpty()(Code)
Checks and answers whether the selection is empty or not. Unlike #hasSelection, the underlying property #selectionEmpty for this method is bound. I.e. you can observe this property using a PropertyChangeListener to update UI state. true if nothing is selected, false if there's a selection
See Also:   SelectionInList.clearSelection
See Also:   SelectionInList.hasSelection



release
public void release()(Code)
Removes the internal listeners from the list holder, selection holder, selection index holder. If the current list is a ListModel, the internal ListDataListener is removed from the list model. This SelectionInList must not be used after calling #release.

To avoid memory leaks it is recommended to invoke this method, if the list holder, selection holder, or selection index holder live much longer than this SelectionInList. Instead of releasing the SelectionInList, you typically make the list holder, selection holder, and selection index holder obsolete by releasing the PresentationModel or BeanAdapter that has created them before.

As an alternative you may use ValueModels that in turn use event listener lists implemented using WeakReference.

Basically this release method performs the reverse operation performed during the SelectionInList construction.
See Also:   PresentationModel.release
See Also:   BeanAdapter.release
See Also:   java.lang.ref.WeakReference
since:
   1.2




removeValueChangeListener
public void removeValueChangeListener(PropertyChangeListener l)(Code)
Removes the given PropertyChangeListener from the model.
Parameters:
  l - the listener to remove



setSelection
public void setSelection(E newSelection)(Code)
Sets the selection index to the index of the first list element that equals newSelection . If newSelection is null , it is interpreted as unspecified and the selection index is set to -1, and this SelectionInList has no selection. Does nothing if the list is empty or null .
Parameters:
  newSelection - the object to be set as new selection,or null to set the selection index to -1



setSelectionHolder
public void setSelectionHolder(ValueModel newSelectionHolder)(Code)
Sets a new selection holder. Does nothing if the new is the same as before. The selection remains unchanged and is still driven by the selection index holder. It's just that future index changes will update the new selection holder and that future selection holder changes affect the selection index.
Parameters:
  newSelectionHolder - the selection holder to set
throws:
  NullPointerException - if the new selection holder is null



setSelectionIndex
public void setSelectionIndex(int newSelectionIndex)(Code)
Sets a new selection index. Does nothing if it is the same as before.
Parameters:
  newSelectionIndex - the selection index to be set
throws:
  IndexOutOfBoundsException - if the new selection indexis outside the bounds of the list



setSelectionIndexHolder
public void setSelectionIndexHolder(ValueModel newSelectionIndexHolder)(Code)
Sets a new selection index holder. Does nothing if the new is the same as before.
Parameters:
  newSelectionIndexHolder - the selection index holder to set
throws:
  NullPointerException - if the new selection index holder is null
throws:
  IllegalArgumentException - if the value of the new selection indexholder is null



setValue
public void setValue(Object newValue)(Code)
Sets the selection index to the index of the first list element that equals newValue . If newValue is null , it is interpreted as unspecified and the selection index is set to -1, and this SelectionInList has no selection. Does nothing if the list is empty or null .
Parameters:
  newValue - the object to be set as new selection,or null to set the selection index to -1



updateList
protected void updateList(Object oldList, int oldSize, Object newList)(Code)
Removes the list data change handler from the old list in case it is a ListModel and adds it to new one in case it is a ListModel. It then fires a property change for the list and a contents change event for the list content. Finally it tries to restore the previous selection - if any.

Since version 1.1 the selection will be restored after the list content change has been indicated. This is because some listeners may clear the selection in a side-effect. For example a JTable that is bound to this SelectionInList via an AbstractTableAdapter and a SingleSelectionAdapter will clear the selection if the new list has a size other than the old list.
Parameters:
  oldList - the old list content
Parameters:
  oldSize - the size of the old List content
Parameters:
  newList - the new list content
See Also:   javax.swing.JTable.tableChanged(javax.swing.event.TableModelEvent)




www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.