at.spardat.xma.mdl
Interface ISelectable

All Known Subinterfaces:
IListDomWM, IListDomWMClient, IListWM, IListWMClient, ITableWM, ITableWMClient, ITreeWM, ITreeWMClient
All Known Implementing Classes:
ListDomWM, ListDomWMClient, ListWM, ListWMClient, TableWM, TableWMClient, TreeWM, TreeWMClient

public interface ISelectable

This interface is implemented by widget models that support the selection of entries in a keyed set (lists, tables, trees). Each entry in the underlying value domain has a key of type String which uniquely identifies the entry within the value domain. There may exist at most one entry with a particular key. This interface allows either to query the selection or to modify it.

This interface supports two variants. The first behaviour is called strict. With strict behaviour, the currently selected entries are always drawn from the underlying value domain. With !isStrict() (which is only allowed in models having !isMultiSelect()), the selected value needs not to be contained in the domain.


Method Summary
 void deselect(java.lang.String key)
          Deselects a particular entry.
 void deselectAll()
          All selected entries get deselected.
 java.lang.String getSelected()
          Returns the id of the selected element.
 java.lang.String[] getSelection()
          Returns a newly created array containing the ids of the selected entries or an empty array, if nothing is selected.
 int getSelectionCount()
          Returns the number of selected elements.
 boolean isMultiSelect()
          Returns true if more than one entry may be selected.
 boolean isSelected(java.lang.String key)
          Returns true if the entry with the provided key is selected, false otherwise.
 boolean isStrict()
          Returns if this Selectable has strict behaviour, that is, the selected keys must always be in the underlying domain of this.
 void select(java.lang.String key)
          Sets the entry with a provided key as selected.
 

Method Detail

select

public void select(java.lang.String key)
Sets the entry with a provided key as selected. If this model does not allow multiselection, a previous selected element is deselected before.

If isStrict() and the provided key is not contained in the underlying domain, this method does nothing.

Parameters:
key - the entry to select
Throws:
java.lang.IllegalArgumentException - if key is null.

deselect

public void deselect(java.lang.String key)
Deselects a particular entry. If the entry for the provided key is not selected, this method does nothing.

Parameters:
key - identifies the entry to deselect. If the entry with the provided key is not selected, this method does nothing.
Throws:
java.lang.IllegalArgumentException - if key is null.

deselectAll

public void deselectAll()
All selected entries get deselected. After calling this method, the condition getSelectionCount() == 0 holds.


isMultiSelect

public boolean isMultiSelect()
Returns true if more than one entry may be selected.

Returns:
boolean true if the widget model realizing this interface allows multiselection.

getSelected

public java.lang.String getSelected()
Returns the id of the selected element. If nothing is selected, null is returned. If more than one entry is selected, some of them is returned. Note that the selected id need not have to be in the underlying domain of this if !isStrict().

Usually, this method is the preferred way of querying the selection state if !isMultiSelect().

Returns:
key of selected entry or null if nothing is selected

getSelection

public java.lang.String[] getSelection()
Returns a newly created array containing the ids of the selected entries or an empty array, if nothing is selected.

Returns:
array of the selected keys. The length of the array equals getSelectionCount().

getSelectionCount

public int getSelectionCount()
Returns the number of selected elements.

Returns:
number of selected elements

isSelected

public boolean isSelected(java.lang.String key)
Returns true if the entry with the provided key is selected, false otherwise.


isStrict

public boolean isStrict()
Returns if this Selectable has strict behaviour, that is, the selected keys must always be in the underlying domain of this. In the case of !isStrict(), the selected key may be freely choosen and need not be drawn from the domain.

Strict behaviour is only supported if !isMultiSelect(). That means, isMultiSelect() always implies isStrict().

Returns:
true if the widget model implementing this interface supports strict behaviour, false otherwise.