V - the kind of values this choice managespublic class DefaultChoice<V> extends Object implements Choice
Choice, provides text, id and objects
for every possible choice.| Modifier and Type | Class and Description |
|---|---|
static interface |
DefaultChoice.Entry<V> |
| Constructor and Description |
|---|
DefaultChoice(DockController controller)
Creates a new choice, adding additional entries if there are any
extensions.
|
| Modifier and Type | Method and Description |
|---|---|
DefaultChoice.Entry<V> |
add(String id,
String text,
boolean textIsKey,
V value)
Adds an entry to this
Choice. |
DefaultChoice.Entry<V> |
add(String id,
String text,
V value)
|
void |
addChoiceListener(ChoiceListener listener)
Adds a listener to this choice.
|
DefaultChoice.Entry<V> |
addLinked(String id,
String text,
V value)
|
protected boolean |
equals(V a,
V b)
Checks the equality of
a and b. |
protected void |
fireInserted(int start,
int end)
Calls
ChoiceListener.inserted(Choice, int, int) on all listeners
that are currently known. |
protected void |
fireRemoved(int start,
int end)
Calls
ChoiceListener.removed(Choice, int, int) on all listeners
that are currently known. |
protected void |
fireUpdated(int start,
int end)
Calls
ChoiceListener.updated(Choice, int, int) on all listeners
that are currently known. |
String |
getDefaultChoice()
Gets the standard choice.
|
DefaultChoice.Entry<V> |
getEntry(int index)
Gets all the data that is stored at
index. |
String |
getId(int index)
Gets a unique identifier for the
index'th choice. |
String |
getText(int index)
Gets a name for the
index'th choice. |
V |
getValue(int index)
Gets the value associated with the
index'th entry. |
V |
identifierToValue(String id)
Search the value for the entry width identifier
id. |
int |
indexOfIdentifier(String id)
Searches the entry with the identifier
id. |
int |
indexOfValue(V value)
Searches the index of the entry that contains
value. |
boolean |
isNullEntryAllowed()
Tells whether the user choose nothing.
|
void |
remove(int index)
Removes the index'th entry of this choice.
|
void |
removeChoiceListener(ChoiceListener listener)
Removes the listener
listener from this choice. |
void |
setController(DockController controller)
Informs this
Choice that it is now used for displaying items for
controller. |
void |
setDefaultChoice(String defaultChoice)
Sets the default choice for this choice.
|
void |
setNullEntryAllowed(boolean nullEntryAllowed)
Sets whether the
null-entry is allowed, the null-entry
describes the non existing selection. |
int |
size()
Gets the number of available choices.
|
String |
valueToIdentifier(V value)
Searches the identifier for an entry which contains
value,
this method uses equals(Object, Object) to decide whether two
values are equal. |
public DefaultChoice(DockController controller)
controller - the realm in which this choice is used, can be nullpublic void addChoiceListener(ChoiceListener listener)
ChoiceaddChoiceListener in interface Choicelistener - the new listener, not nullpublic void removeChoiceListener(ChoiceListener listener)
Choicelistener from this choice.removeChoiceListener in interface Choicelistener - the listener to removeprotected void fireInserted(int start,
int end)
ChoiceListener.inserted(Choice, int, int) on all listeners
that are currently known.start - the index of the first entryend - the index of the last entryprotected void fireRemoved(int start,
int end)
ChoiceListener.removed(Choice, int, int) on all listeners
that are currently known.start - the index of the first entryend - the index of the last entryprotected void fireUpdated(int start,
int end)
ChoiceListener.updated(Choice, int, int) on all listeners
that are currently known.start - the index of the first entryend - the index of the last entrypublic void setController(DockController controller)
ChoiceChoice that it is now used for displaying items for
controller.setController in interface Choicecontroller - the controller in whose realm this Choice is currently
used, can be nullpublic void remove(int index)
index - the index of the entry to removepublic DefaultChoice.Entry<V> add(String id, String text, V value)
id - the id of the new entrytext - the text of the new entryvalue - the optional valuepublic DefaultChoice.Entry<V> addLinked(String id, String text, V value)
id - the id of the new entrytext - the text of the new entryvalue - the optional valuepublic DefaultChoice.Entry<V> add(String id, String text, boolean textIsKey, V value)
Choice.id - the id of the new entrytext - the text of the new entrytextIsKey - if true, then text is interpreted as a key for a TextManager,
otherwise it is just textvalue - the optional valuepublic String getId(int index)
Choiceindex'th choice.public String getText(int index)
Choiceindex'th choice.public V getValue(int index)
index'th entry.index - the index of the entrypublic DefaultChoice.Entry<V> getEntry(int index)
index.index - the index of some entrypublic int indexOfIdentifier(String id)
id.id - some id, might be nullpublic int indexOfValue(V value)
value. This
method uses equals(Object, Object) to compare two objects.value - the value to searchvalue can't be found or
is nullprotected boolean equals(V a, V b)
a and b.a - some value, might be nullb - some value, might be nulltrue if a and b are equalpublic String valueToIdentifier(V value)
value,
this method uses equals(Object, Object) to decide whether two
values are equal.value - the value to searchnull if value is nullpublic V identifierToValue(String id)
id.id - the id to searchidpublic int size()
Choicepublic void setNullEntryAllowed(boolean nullEntryAllowed)
null-entry is allowed, the null-entry
describes the non existing selection.nullEntryAllowed - true if no selection is allowedpublic boolean isNullEntryAllowed()
ChoiceisNullEntryAllowed in interface Choicenull identifierpublic void setDefaultChoice(String defaultChoice)
defaultChoice - the default valuepublic String getDefaultChoice()
ChoicegetDefaultChoice in interface Choicenull is only
allowed if Choice.isNullEntryAllowed() returns trueCopyright © 2017 Docking Frames. All rights reserved.