@BeanSettings(useXdevCustomizer=true) public class XdevComboBox extends JComboBox implements ExtendedList<XdevComboBox>, XdevFocusCycleComponent
JComboBox
.JComboBox
,
FormularComponent
,
ItemListOwner
,
XdevFocusCycleComponent
,
MasterDetailComponent
,
Serialized FormModifier and Type | Class and Description |
---|---|
static class |
XdevComboBox.ItemListModelWrapper |
protected class |
XdevComboBox.XdevComboBoxListCellRenderer |
JComboBox.AccessibleJComboBox, JComboBox.KeySelectionManager
JComponent.AccessibleJComponent
Container.AccessibleAWTContainer
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy
MasterDetailComponent.DetailHandler
FormularComponent.ValueChangeListener
actionCommand, dataModel, editor, isEditable, keySelectionManager, lightWeightPopupEnabled, maximumRowCount, renderer, selectedItemReminder
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOW
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
DATA_FIELD_SEPARATOR
TAB_INDEX_PROPERTY
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
Constructor and Description |
---|
XdevComboBox()
Constructs a new
XdevComboBox . |
XdevComboBox(ComboBoxModel model)
Constructs a
XdevComboBox that is initialized with
ComboBoxModel as the data model. |
XdevComboBox(ItemList il)
Constructs a
XdevComboBox that is initialized with
ItemList as the data model. |
Modifier and Type | Method and Description |
---|---|
void |
addValidator(Validator validator)
Adds a validator to this component
|
void |
addValueChangeListener(FormularComponent.ValueChangeListener l)
Registers a
FormularComponent.ValueChangeListener . |
void |
clearModel()
Clears the underlying data model, mostly a
VirtualTable , and the
view. |
protected ListCellRenderer |
createListCellRenderer() |
void |
doLayout() |
String |
getDataField()
Returns the name of the bound data field of this formular component.
|
Color |
getEvenBackground()
Returns the background
Color of even rows. |
Operator |
getFilterOperator()
Returns the operator used in
Formular.createCondition(String) |
String |
getFormularName()
Returns the name of the component in the formular context.
|
Object |
getFormularValue()
Returns the value of the component.
|
ItemList |
getItemList()
|
Color |
getOddBackground()
Returns the background
Color of odd rows. |
Dimension |
getPreferredSize() |
String |
getPreSelectionValue()
Returns the string which is displayed before the user selects a value.
|
Object |
getSelectedData()
Returns the selected data.
|
ItemList.Entry |
getSelectedEntry()
Returns the selected
ItemList -ItemList.Entry . |
int |
getSelectedModelIndex()
Returns the modelindex of the selected item.
|
VirtualTable.VirtualTableRow |
getSelectedVirtualTableRow()
Returns the selected
VirtualTable.VirtualTableRow of this component, or
null if nothing is selected. |
Dimension |
getSize() |
int |
getTabIndex()
Returns the tabindex assigned to this component.
|
Validator[] |
getValidators()
Returns all validators of this component.
|
VirtualTable |
getVirtualTable()
Returns the associated
VirtualTable of this object. |
boolean |
hasStateChanged()
Checks if the component's state since the last call of
FormularComponent.saveState() has changed. |
protected boolean |
isElementSelectable(Object item) |
boolean |
isMultiSelect()
Returns whether the component supports multi selection or not.
|
boolean |
isReadOnly()
Determines whether this component is only used to display values.
|
boolean |
isSomethingSelected()
Verify if a item is selected.
|
ItemList |
modelToItemList(ComboBoxModel model)
Create a new
ItemList based on the provided ComboBoxModel
. |
void |
refresh()
Reloads the data from the underlying data source with the last executed
resp.
|
void |
removeValidator(Validator validator)
Removes a validator from this component
|
void |
restoreState()
Restores the internally saved state of the component.
|
void |
saveState()
Saves the state of the component internally.
|
void |
setDataField(String dataField)
Sets the name of the bound data field of this formular component.
|
void |
setDetailHandler(MasterDetailComponent.DetailHandler detailHandler)
Sets the handler which controls the corporation of two
MasterDetailComponent s. |
void |
setEvenBackground(Color evenBackground)
Sets the background
Color of even rows. |
void |
setFilterOperator(Operator filterOperator)
Sets the filter operator used in
Formular.createCondition(String) |
void |
setFormularValue(VirtualTable vt,
int col,
Object value)
Deprecated.
|
void |
setFormularValue(VirtualTable vt,
Map<String,Object> record)
Sets the value of the component, taking the value(s) of the record
according to
FormularComponent.getDataField() . |
void |
setItemList(ItemList itemList)
Sets the
ItemList that represents the contents or "value" of the
ExtendedList and then clears the list's selection. |
void |
setMasterValue(VirtualTable vt,
Map<String,Object> record)
Sets the value of this component (master), taking the value(s) of the
record.
|
void |
setModel(VirtualTable vt,
String itemCol,
String dataCol)
Updates the underlying model with data from the
VirtualTable vt. |
void |
setModel(VirtualTable vt,
String itemCol,
String dataCol,
boolean queryData)
Updates the underlying model with data from the
VirtualTable vt. |
void |
setModel(VirtualTable vt,
String itemCol,
String dataCol,
boolean queryData,
boolean selectiveQuery)
Updates the underlying model with data from the
VirtualTable vt. |
void |
setOddBackground(Color oddBackground)
Sets the background
Color of odd rows. |
void |
setPreSelectionValue(String s)
Sets the value which is displayed before the user selects a value, e.g.
|
void |
setReadOnly(boolean readOnly)
Sets if this form component is only used to display values.
|
void |
setSelectedData(Object o)
Select the index of the first occurrence of the specified
o
in this list. |
void |
setSelectedItem(Object anObject) |
void |
setSelectedModelIndex(int anIndex)
Selects the item at modelindex
anIndex . |
void |
setSelectedVirtualTableRow(VirtualTable.VirtualTableRow row)
Selects the row in the combo box if present.
|
void |
setTabIndex(int tabIndex)
Sets the tabindex of this component.
|
void |
setVirtualTable(VirtualTable vt)
Sets the
VirtualTable containing the valid values for this
component. |
String |
toString() |
void |
updateModel(Condition condition,
Object... params)
Reloads the data form the underlying data source.
|
void |
validateState()
Calls
Validator.validate(Object) of all registered
Validator s. |
void |
validateState(Validation validation)
Calls
Validator.validate(Object) of all registered
Validator s. |
boolean |
verify()
Returns whether the component's value adheres all set constraints.
|
actionPerformed, actionPropertyChanged, addActionListener, addItem, addItemListener, addPopupMenuListener, configureEditor, configurePropertiesFromAction, contentsChanged, createActionPropertyChangeListener, createDefaultKeySelectionManager, fireActionEvent, fireItemStateChanged, firePopupMenuCanceled, firePopupMenuWillBecomeInvisible, firePopupMenuWillBecomeVisible, getAccessibleContext, getAction, getActionCommand, getActionListeners, getEditor, getItemAt, getItemCount, getItemListeners, getKeySelectionManager, getMaximumRowCount, getModel, getPopupMenuListeners, getPrototypeDisplayValue, getRenderer, getSelectedIndex, getSelectedItem, getSelectedObjects, getUI, getUIClassID, hidePopup, insertItemAt, installAncestorListener, intervalAdded, intervalRemoved, isEditable, isLightWeightPopupEnabled, isPopupVisible, paramString, processKeyBinding, processKeyEvent, removeActionListener, removeAllItems, removeItem, removeItemAt, removeItemListener, removePopupMenuListener, selectedItemChanged, selectWithKeyChar, setAction, setActionCommand, setEditable, setEditor, setEnabled, setKeySelectionManager, setLightWeightPopupEnabled, setMaximumRowCount, setModel, setPopupVisible, setPrototypeDisplayValue, setRenderer, setSelectedIndex, setUI, showPopup, updateUI
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, update
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTree
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, transferFocus, transferFocusBackward, transferFocusUpCycle
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
getClientProperty, isEnabled, isVisible, putClientProperty
public XdevComboBox()
XdevComboBox
.XdevComboBox(ItemList)
public XdevComboBox(ItemList il)
XdevComboBox
that is initialized with
ItemList
as the data model.il
- the ItemList
that provides the displayed and data
itemssetItemList(ItemList)
,
JComboBox.setRenderer(javax.swing.ListCellRenderer)
public XdevComboBox(ComboBoxModel model)
XdevComboBox
that is initialized with
ComboBoxModel
as the data model.model
- the ComboBoxModel
with dataJComboBox.setModel(ComboBoxModel)
,
JComboBox.setRenderer(javax.swing.ListCellRenderer)
protected boolean isElementSelectable(Object item)
protected ListCellRenderer createListCellRenderer()
public ItemList getItemList()
getItemList
in interface ExtendedList<XdevComboBox>
ItemList
of this ExtendedList
public void setItemList(ItemList itemList)
ItemList
that represents the contents or "value" of the
ExtendedList
and then clears the list's selection.setItemList
in interface ExtendedList<XdevComboBox>
itemList
- ItemList
include the item
and
data
public ItemList modelToItemList(ComboBoxModel model)
ItemList
based on the provided ComboBoxModel
.public void setModel(VirtualTable vt, String itemCol, String dataCol)
VirtualTable
vt.
This is a shortcut for setModel(vt,itemCol,dataCol,false)
setModel
in interface ExtendedList<XdevComboBox>
vt
- the VirtualTable
containing the data for the modelitemCol
- columnname to fill item
from or string with
variables like "{%SURNAME} {%NAME} - {%AGE}"
dataCol
- column name to fill data
from, or multiple
columns names, comma-separatedItemList.setModel(VirtualTable, String, String)
,
StringUtils.format(String, xdev.util.StringUtils.ParameterProvider)
public void setModel(VirtualTable vt, String itemCol, String dataCol, boolean queryData)
VirtualTable
vt.setModel
in interface ExtendedList<XdevComboBox>
vt
- the VirtualTable
containing the data for the modelitemCol
- columnname to fill item
from or string with
variables like "{%SURNAME} {%NAME} - {%AGE}"
dataCol
- column name to fill data
from, or multiple
columns names, comma-separatedqueryData
- if true
, the best fitting select for this vt
is usedItemList.setModel(VirtualTable, String, String, boolean)
,
StringUtils.format(String, xdev.util.StringUtils.ParameterProvider)
public void setModel(VirtualTable vt, String itemCol, String dataCol, boolean queryData, boolean selectiveQuery)
VirtualTable
vt.setModel
in interface ExtendedList<XdevComboBox>
vt
- the VirtualTable
containing the data for the modelitemCol
- columnname to fill item
from or string with
variables like "{%SURNAME} {%NAME} - {%AGE}"
dataCol
- column name to fill data
from, or multiple
columns names, comma-separatedqueryData
- if true
, the best fitting select for this vt
is usedselectiveQuery
- if true
, only the used columns
are
queriedItemList.setModel(VirtualTable, String, String, boolean, boolean)
,
StringUtils.format(String, xdev.util.StringUtils.ParameterProvider)
public void refresh()
refresh
in interface MasterDetailComponent<XdevComboBox>
public void updateModel(Condition condition, Object... params)
The last executed query is extended with condition
.
updateModel
in interface VirtualTableOwner
condition
- The additional filter for the queryparams
- param objects used in condition
public void clearModel()
VirtualTable
, and the
view.clearModel
in interface MasterDetailComponent<XdevComboBox>
public void setPreSelectionValue(String s)
s
- the String
to display in this XdevComboBox
public String getPreSelectionValue()
public void setEvenBackground(Color evenBackground)
Color
of even rows.evenBackground
- the background of even rows as Color
.public Color getEvenBackground()
Color
of even rows.Color
.public void setOddBackground(Color oddBackground)
Color
of odd rows.oddBackground
- the background of odd rows as Color
.public Color getOddBackground()
Color
of odd rows.Color
.public boolean isSomethingSelected()
true
if a item is selected, otherwise
false
.public Object getSelectedData()
null
public int getSelectedModelIndex()
For example the index of the selected item in it is VirtualTable
.
public void setSelectedData(Object o)
o
in this list. If the ItemList
of this XdevComboBox
does
not contain the o
, the selection is canceled.o
- the Object
to selectpublic void setSelectedItem(Object anObject)
setSelectedItem
in class JComboBox
public void setSelectedModelIndex(int anIndex)
anIndex
.
For example the given index of an item in it is model VirtualTable
.
anIndex
- an integer specifying the list item to select, where 0
specifies the first item in the list and -1 indicates no
selectionpublic ItemList.Entry getSelectedEntry()
ItemList
-ItemList.Entry
.ItemList
-ItemList.Entry
public String getFormularName()
getFormularName
in interface FormularComponent<XdevComboBox>
public void setDataField(String dataField)
setDataField
in interface FormularComponent<XdevComboBox>
dataField
- the new bound data fieldpublic String getDataField()
getDataField
in interface FormularComponent<XdevComboBox>
@Deprecated public void setFormularValue(VirtualTable vt, int col, Object value)
value
. The value is formatted using the column format of the
provided VirtualTable
and columnIndex
.setFormularValue
in interface FormularComponent<XdevComboBox>
vt
- VirtualTable
to use the format fromcol
- of the column to use the format fromvalue
- value to setpublic void setFormularValue(VirtualTable vt, Map<String,Object> record)
FormularComponent.getDataField()
.setFormularValue
in interface FormularComponent<XdevComboBox>
vt
- the underlying virtual tablerecord
- the data <column,value>public void setMasterValue(VirtualTable vt, Map<String,Object> record)
Called by the MasterDetailHandler
if the client's value has
changed.
setMasterValue
in interface MasterDetailComponent<XdevComboBox>
vt
- the underlying virtual tablerecord
- the data <column,value>public Object getFormularValue()
getFormularValue
in interface FormularComponent<XdevComboBox>
public void saveState()
A saved state can be restored using FormularComponent.restoreState()
.
saveState
in interface FormularComponent<XdevComboBox>
public void restoreState() throws IllegalArgumentException
The state of the component can be saved using FormularComponent.saveState()
.
restoreState
in interface FormularComponent<XdevComboBox>
IllegalArgumentException
public boolean hasStateChanged()
FormularComponent.saveState()
has changed.hasStateChanged
in interface FormularComponent<XdevComboBox>
true
if the component's state has changed,
false
otherwisepublic boolean isMultiSelect()
A component that supports multi selection can have more than one selected item / value.
isMultiSelect
in interface FormularComponent<XdevComboBox>
true
if the component supports multi
selection, false
otherwise.public boolean verify()
This is a alternative method for FormularComponent.validateState()
, but this
method returns a boolean depending on the validation's result and doesn't
throw an ValidationException
.
verify
in interface FormularComponent<XdevComboBox>
true
if the value of the component adheres all set
constraints; otherwise false
.public void addValidator(Validator validator)
addValidator
in interface FormularComponent<XdevComboBox>
validator
- the validator to addFormularComponent.validateState()
public void removeValidator(Validator validator)
removeValidator
in interface FormularComponent<XdevComboBox>
validator
- the validator to removeFormularComponent.validateState()
public Validator[] getValidators()
If no validator is present an empty array is returned.
getValidators
in interface FormularComponent<XdevComboBox>
public void validateState() throws ValidationException
Validator.validate(Object)
of all registered
Validator
s.validateState
in interface FormularComponent<XdevComboBox>
ValidationException
FormularComponent.verify()
public void validateState(Validation validation) throws ValidationException
Validator.validate(Object)
of all registered
Validator
s.
Every ValidationException
is recorded in the
validation
object, and if
Validation.continueValidation(ValidationException)
returns
false
this exception is re-thrown by this method.
validateState
in interface FormularComponent<XdevComboBox>
validation
- the validation process objectValidationException
FormularComponent.verify()
public void setFilterOperator(Operator filterOperator)
Formular.createCondition(String)
setFilterOperator
in interface FormularComponent<XdevComboBox>
filterOperator
- the new filter operatorpublic Operator getFilterOperator()
Formular.createCondition(String)
getFilterOperator
in interface FormularComponent<XdevComboBox>
public void setReadOnly(boolean readOnly)
setReadOnly
in interface FormularComponent<XdevComboBox>
readOnly
- true
to only display valuespublic boolean isReadOnly()
isReadOnly
in interface FormularComponent<XdevComboBox>
true
if this component is only used to display
values.public void setVirtualTable(VirtualTable vt)
VirtualTable
containing the valid values for this
component.setVirtualTable
in interface VirtualTableOwner
public VirtualTable getVirtualTable()
VirtualTable
of this object.getVirtualTable
in interface VirtualTableOwner
VirtualTable
of this object.public VirtualTable.VirtualTableRow getSelectedVirtualTableRow()
VirtualTable.VirtualTableRow
of this component, or
null
if nothing is selected.getSelectedVirtualTableRow
in interface MasterDetailComponent<XdevComboBox>
VirtualTable.VirtualTableRow
of this componentpublic void setSelectedVirtualTableRow(VirtualTable.VirtualTableRow row)
row
- the row to selectpublic void addValueChangeListener(FormularComponent.ValueChangeListener l)
FormularComponent.ValueChangeListener
.addValueChangeListener
in interface FormularComponent<XdevComboBox>
l
- the listener to registerpublic void setDetailHandler(MasterDetailComponent.DetailHandler detailHandler)
MasterDetailComponent
s.setDetailHandler
in interface MasterDetailComponent<XdevComboBox>
detailHandler
- the new MasterDetailComponent.DetailHandler
public Dimension getPreferredSize()
getPreferredSize
in class JComponent
public int getTabIndex()
getTabIndex
in interface XdevFocusCycleComponent
public void setTabIndex(int tabIndex)
To exclude this component from the focus cycle set tabindex to -1.
setTabIndex
in interface XdevFocusCycleComponent
tabIndex
- to be setCopyright © 2003–2021 XDEV Software. All rights reserved.