public class CodedChoices extends OwnedObject implements CopyFrom
Modifier | Constructor and Description |
---|---|
protected |
CodedChoices() |
|
CodedChoices(CodeToDisplay cd) |
Modifier and Type | Method and Description |
---|---|
void |
addChoices(String[] choices) |
void |
addMenuItems(Collection items)
Use this to provide MenuItem objects (or simple Strings) for display on an on-screen choice.
|
void |
clearChoices() |
String |
codeToDisplay(String code) |
void |
copyFrom(Object other)
Copy all appropriate data from another object.
|
String |
displayToCode(String display) |
String[] |
getAllCodes()
Return all possible codes.
|
Control |
getChoice(String prompt,
String nonePrompt) |
protected Dimension |
getChoiceDisplaySize()
Return the preferred size of the choice displays.
|
String[] |
getChoices()
Get the choice codes.
|
protected CodeToDisplay |
getMapping()
If you do not override codeToDisplay() or displayToCode() or addMenuItems() then you must override this
to provide a Map from the code to the display string or the display string to the code.
|
protected String[] |
getMenuItemCodes()
This is called by addMenuItems() and should return an array of codes in the order that they
should be displayed in the menu.
|
SimpleItemSelect |
getSimpleItemSelect(boolean multiChoice) |
Control |
getSingleChoiceControl(String prompt,
String menuPrompt) |
ControlPopupForm |
getSingleChoicePopup(Control activator,
String menuPrompt) |
String[] |
getSortedCodes(String[] codes,
Comparer sortByCode,
Comparer sortByDisplay) |
String[] |
getSortedCodesByDisplay() |
boolean |
isChosen(String code) |
protected MenuItem |
menuItemForCode(String code)
Return a selectable MenuItem for the specified code, that will be selected or not depending on whether
it is selected in this CodedChoices.
|
Control |
setSingleChoiceActionControl(Control c,
String menuPrompt) |
void |
textDecode(String txt)
You can override this to decode a String representation of the Object as
encoded by textEncode, but it is easier to override decode(TextDecoder te).
|
String |
textEncode()
You can override this to encode the object as a String, but it is easier to override
encode(TextEncoder te).
|
void |
toSimpleItemSelect(SimpleItemSelect ss) |
getParentObject, getParentObject, setParentObject
decode, decoded, decoded, decodeFields, decodeFields, encode, encoded, encoded, encodeFields, encodeFields
_getFieldType, _getSetField, cache, compareTo, copied, equals, getCopy, getDeclaredField, getDeclaredFieldValue, getMyFieldList, getNew
protected CodedChoices()
public CodedChoices(CodeToDisplay cd)
public void copyFrom(Object other)
DataUnit
public String textEncode()
EncodableObject
textEncode
in interface TextEncodable
textEncode
in class EncodableObject
public void textDecode(String txt)
EncodableObject
textDecode
in interface TextEncodable
textDecode
in class EncodableObject
public void clearChoices()
public void addChoices(String[] choices)
public String[] getChoices()
public boolean isChosen(String code)
protected CodeToDisplay getMapping()
public String[] getAllCodes()
protected MenuItem menuItemForCode(String code)
code
- the code for the item.protected String[] getMenuItemCodes()
If the code returned starts and ends with a "*" character - then it is assumed that the code is actually a section header and is displayed as such.
public void addMenuItems(Collection items)
items
- a destination Collection to add the items to.public String[] getSortedCodesByDisplay()
public String[] getSortedCodes(String[] codes, Comparer sortByCode, Comparer sortByDisplay)
public void toSimpleItemSelect(SimpleItemSelect ss)
public Control setSingleChoiceActionControl(Control c, String menuPrompt)
protected Dimension getChoiceDisplaySize()
public SimpleItemSelect getSimpleItemSelect(boolean multiChoice)
public ControlPopupForm getSingleChoicePopup(Control activator, String menuPrompt)