public class GChoice extends GContainer implements GDisplay, GReadWrite, GListener, GClear
GRadioButton
objects. Each option has an associated integer value. By default, the associated value
corresponds to the rank number in the list, but it is possible to associate arbitrary values. At any time,
the list of choice can be modified dynamically by the application maker and the display is updated. The
class allows also to save or to load to the configuration file.Index | Class | Item | Constraint |
0 | GLabelWithIndicator | label | 0, 0 => "newline , split 2" 0, 1 => (null) |
1 | GRadioButton | radioButton0 | "split" |
2 | GRadioButton | radioButton1 | (null) |
... | ... | ... | ... |
i+1 | GRadioButton | radioButtoni | (null) |
GComponent.CopyPasteOperation, GComponent.DisplayIndicatorStatus, GComponent.ItemType, GComponent.Operation
NAME_ATTRIBUTE
Constructor and Description |
---|
GChoice()
Constructor by default.
|
GChoice(String label,
int value,
int[] valueList,
String... labels)
Constructor when values are identical to the index of the choices.
|
GChoice(String label,
int value,
String... labels)
Constructor when values are identical to the index of the choices.
|
GChoice(String widgetId,
String label,
Enum<?> enumItem)
Constructor from an enum.
|
GChoice(String widgetId,
String label,
int value,
int[] valueList,
String... labels)
Constructor when values are identical to the index of the choices.
|
GChoice(String widgetId,
String label,
int value,
int[] valueList,
String[] labels,
String[] tooltips)
Constructor when values are identical to the index of the choices.
|
GChoice(String widgetId,
String label,
int value,
String... labels)
Constructor when values are identical to the index of the choices.
|
Modifier and Type | Method and Description |
---|---|
void |
after(GEvent e)
Called after the event is processed.
|
void |
attachCopyPasteMenu(String label,
GComponent.CopyPasteOperation... operationList)
Attach the copy and paste menu to this component.
|
void |
before(GEvent e)
Called before the event is processed.
|
void |
clear()
Called when the element is to be cleared, so it can perform the actions required to return to the last
saved/loaded values.
|
void |
display()
Called when the element is to be displayed, so it can perform the actions required for its display, and
the display of its inmmediate descendants.
|
void |
generic()
The prototype of the generic function that shall exist in all the descendants.
|
GLabelWithIndicator |
getGLabel()
Get the GLabel associated with the component.
|
ArrayList<GRadioButton> |
getGRadioButtonList()
Get the array of GRadioButtons associated with the component.
|
static int[] |
getIndexesArray(Enum<?> enumItem)
Gets an ordered array of integers with the indexes of each item contained in the enumerate.
|
static String |
getLabelForValue(String[] labelsList,
int[] valuesList,
int value)
Return the label associated to the value.
|
static String[] |
getNamesArray(Enum<?> enumItem)
Gets an ordered array of strings with the names of each item contained in the enumerate.
|
String[] |
getSavedLabels()
Get the last saved labels.
|
int |
getSavedSelectedValue()
Get the last saved selected value.
|
int[] |
getSavedValueList()
Get the array of last saved value list.
|
GComponent |
getSubComponent(int position)
Gets the subcomponent occupying the position defined by position.
|
int |
getValue()
Get the value of the component.
|
Enum<?> |
getValueEnum()
Return the value of the selected item.
|
GComponent.CopyPasteOperation |
isCopyPasteEvent(GEvent event)
Checks if the event corresponds to one of the copy and paste menu operations.
|
boolean |
isEnabled()
Return the enable/disable status of the component.
|
boolean |
isEnumCompat(Enum<?> value)
Check compatibility of an enum item with the widget.
|
boolean |
isModified()
Gets the modification status of the component against the last set of values loaded or saved.
|
void |
read()
Implementaion of the routines that allow the component to be loaded from a configuration file.
|
void |
setDefaultValue(Enum<?> value)
Change the default value of the list.
|
void |
setDefaultValue(int value)
Change the default value.
|
void |
setDefaultValueList(Enum<?> enumItem,
Enum<?>[] enumItemList)
Change the default list of values by means of an enumerate.
|
void |
setDefaultValueList(int value,
int[] valueList,
String... labels)
Change the default list of values, the value and labels of the choices.
|
void |
setDefaultValueList(int value,
int[] valueList,
String[] labels,
String[] tooltips)
Change the default list of values, the value and labels of the choices.
|
void |
setEnabled(boolean b)
Set the enable/disable status of the component.
|
void |
setSavedValue(Enum<?> value)
Change the saved value.
|
void |
setSavedValue(int value)
Change the saved value.
|
void |
setSavedValueList(int value,
int[] valueList,
String... labels)
Change the saved list of values, the value and labels of the choices.
|
void |
setShortcut(int... shorcutKeyList)
Set the shortcut keys for selecting the corresponding value.
|
void |
setStringConstraint(String constraints)
Set the constraint in string format for the component.
|
void |
setTooltipsList(String[] tooltipsList)
Set the list of tooltips associated to each item in the GChoice.
|
void |
setToolTipText(String text)
Set the tooltip text for the entry's label.
|
void |
setValue(Enum<?> value)
Set the selected item by value.
|
void |
setValue(int newValue)
Set the value of the component.
|
void |
setValueList(Enum<?> enumItem,
Enum<?>[] enumItemList)
Change the list of values, the selected value and the labels of the choices by means of an enumerate.
|
void |
setValueList(int value,
int[] valueList,
String... labels)
Change the list of values, the selected value and the labels of the choices.
|
void |
setValueList(int value,
int[] valueList,
String[] labels,
String[] tooltips)
Change the list of values, the selected value and the labels of the choices.
|
void |
setValueList(int value,
String... labels)
Change the list of choices labels and set the selected value.
|
protected void |
updateIsModifiedIndicator()
Updates the is modified indicator.
|
void |
write()
Implementaion of the routines that allow the component to be saved to a configuration file.
|
put
activateConstraintsByType, attachCopyPasteMenu, beginOfElement, beginOfElement, beginOfElement, beginOfElement, clearAllInnerDescendantConstraint, clearConstraint, clearInnerDescendantContraint, composeWidgetId, doDisplay, endOfElement, getCommentInConfigFile, getComponent, getConstraint, getCurrentOperation, getDisplayIndicatorStatus, getDisplayIsModifiedIndicator, getElement, getGClassName, getGPanel, getGParent, getGUnitInConfigFile, getInnerDescendantConstraint, getName, getNameInConfigFile, getOperationSaveValue, getPathInConfigFile, getSimpleWidgetId, getStatus, getStringConstraint, getWidgetId, handleCopyPasteEvent, handleCopyPasteEvent, handleProcessEventException, isForcedStatus, launchInvalidPositionException, mouseWheelMoved, parseSimpleConstraint, processGEvent, processMouseWheelEvent, setBusyCursor, setCommentInConfigFile, setConstraint, setCopyPasteMenuEnabled, setCurrentOperation, setDataForConstraintsByType, setDefaultConstraints, setDisplayIsModifiedIndicator, setElement, setForcedStatus, setGPanel, setGParent, setGUnitInConfigFile, setInnerDescendantConstraint, setName, setNameAndCommentInConfigFile, setNameInConfigFile, setPathInConfigFile, setStatus, setWidgetId, setWidth, setWindowBusyCursor, writeCollection, writeCollection, writeCollection, writeCollection, writeConfigItem, writeConfigItem, writeConfigItem, writeConfigItem, writeConfigItem
public GChoice(String widgetId, String label, Enum<?> enumItem)
widgetId
- identifier of the widget.label
- to display for the list of choices.enumItem
- initially selected item of the enumerate of itemspublic GChoice()
public GChoice(String widgetId, String label, int value, String... labels)
widgetId
- Widget identifier.label
- to display for the list of choices.value
- to be selected at construction.labels
- text of the different choices.public GChoice(String label, int value, String... labels)
label
- to display for the list of choices.value
- to be selected at construction.labels
- text of the different choices.public GChoice(String label, int value, int[] valueList, String... labels)
label
- to display for the list of choices.value
- to be selected at construction.valueList
- list of values to associate to the different choices.labels
- text of the different choices.public GChoice(String widgetId, String label, int value, int[] valueList, String... labels)
widgetId
- Widget identifier.label
- to display for the list of choices.value
- to be selected at construction.valueList
- list of values to associate to the different choices.labels
- text of the different choices.public GChoice(String widgetId, String label, int value, int[] valueList, String[] labels, String[] tooltips)
widgetId
- Widget identifier.label
- to display for the list of choices.value
- to be selected at construction.valueList
- list of values to associate to the different choices.labels
- text of the different choices.tooltips
- for the different choices.public static int[] getIndexesArray(Enum<?> enumItem)
enumItem
- enumerate single item.Enum.ordinal()
method)public static String[] getNamesArray(Enum<?> enumItem)
enumItem
- enumerate single item.Enum.toString()
method)public GComponent getSubComponent(int position) throws GComponentException
getSubComponent
in class GComponent
position
- position of the requested component.GComponentException
- in case the position argument is invalid.public void attachCopyPasteMenu(String label, GComponent.CopyPasteOperation... operationList)
attachCopyPasteMenu
in class GComponent
label
- of the copy&paste menu, if null no label is displayed.operationList
- list of operations to set in the menu. Valid values are Copy if the
"Copy" menu is available, Paste if the "Paste" menu is available, Import if the
"Import" menu is available, and Export if the "Export" menu is available.public GComponent.CopyPasteOperation isCopyPasteEvent(GEvent event)
isCopyPasteEvent
in class GComponent
event
- to check.public void generic() throws GException
generic
in class GContainer
GException
- In case of problem.public void display() throws GException
display
in interface GDisplay
GException
- in case of problem while reading the value from file.public boolean isEnabled()
isEnabled
in class GComponent
public void setEnabled(boolean b)
setEnabled
in class GComponent
b
- if true the component is enabled, otherwise is disabled.public int getValue()
public Enum<?> getValueEnum()
public void setValue(int newValue)
newValue
- to set.public final void setValue(Enum<?> value)
value
- of the item to select.public void setValueList(int value, int[] valueList, String[] labels, String[] tooltips)
value
- new value to select.valueList
- new value list, it can be null if the values are the indexes of the elements in the
combobox.labels
- text of the different choices.tooltips
- for the different choices.public void setValueList(Enum<?> enumItem, Enum<?>[] enumItemList)
enumItem
- new enumerate item to select.enumItemList
- new enumerate items list.public void setValueList(int value, int[] valueList, String... labels)
value
- new value to select.valueList
- new value list, it can be null if the values are the indexes of the elements in the
combobox.labels
- text of the different choices.public void setValueList(int value, String... labels)
value
- new value to select.labels
- text of the different choices.public GLabelWithIndicator getGLabel()
public ArrayList<GRadioButton> getGRadioButtonList()
public static String getLabelForValue(String[] labelsList, int[] valuesList, int value) throws GException
labelsList
- list of labels.valuesList
- list of values.value
- value for which the corresponding label is searched.GException
- in case of empty list of labels, empty list of values, different length for the lists or
value not found in the list of values.public void before(GEvent e)
public void after(GEvent e) throws GFileManipulatorException
after
in interface GListener
e
- processed event.GFileManipulatorException
public void read() throws GException
read
in interface GReadWrite
GException
- in case the value in the file is not defined in the list of values of the component.public void write() throws GException
write
in interface GReadWrite
GException
- in case of problem while writing the value to file.public void clear() throws GException
GClear
clear
in interface GClear
GException
- in case of problem while clearing the values.public boolean isModified()
GComponent
isModified
in class GComponent
protected void updateIsModifiedIndicator()
updateIsModifiedIndicator
in class GComponent
public void setSavedValueList(int value, int[] valueList, String... labels)
value
- new saved value.valueList
- new saved value list.labels
- new saved labels.public void setDefaultValue(int value)
value
- default value to set.public void setDefaultValue(Enum<?> value)
value
- new default value.public void setDefaultValueList(int value, int[] valueList, String... labels)
value
- new default value.valueList
- new default value list.labels
- new default labels.public void setDefaultValueList(Enum<?> enumItem, Enum<?>[] enumItemList)
enumItem
- new enumerate item to be set as default one.enumItemList
- new enumerate items list to be set as default one.public void setDefaultValueList(int value, int[] valueList, String[] labels, String[] tooltips)
value
- new default value.valueList
- new default value list.labels
- new default labels.tooltips
- new default tooltips.public void setSavedValue(int value)
value
- new saved value.public void setSavedValue(Enum<?> value)
value
- new saved value.public int getSavedSelectedValue()
public int[] getSavedValueList()
public String[] getSavedLabels()
public void setToolTipText(String text)
setToolTipText
in class GComponent
text
- the tooltip text for the entry's label.public void setShortcut(int... shorcutKeyList) throws GException
shorcutKeyList
- the shortcut key list to be attached to the widget.GException
- in case of giving a list with wrong number of shortcut keys.public void setTooltipsList(String[] tooltipsList)
tooltipsList
- the list of tooltips for the choices.public void setStringConstraint(String constraints)
setStringConstraint
in class GComponent
constraints
- constraint in string format to set for the component.public boolean isEnumCompat(Enum<?> value)
value
- enum item to checkCopyright © 2024. All rights reserved.