Module is.codion.swing.framework.ui
Class EntitySearchField
java.lang.Object
java.awt.Component
java.awt.Container
javax.swing.JComponent
javax.swing.text.JTextComponent
javax.swing.JTextField
is.codion.swing.common.ui.component.text.HintTextField
is.codion.swing.framework.ui.component.EntitySearchField
- All Implemented Interfaces:
ImageObserver,MenuContainer,Serializable,Accessible,Scrollable,SwingConstants
public final class EntitySearchField
extends is.codion.swing.common.ui.component.text.HintTextField
A UI component based on the EntitySearchModel.
The search is triggered by the ENTER key and behaves in the following way:
If the search result is empty a message is shown, if a single entity fits the
condition then that entity is selected, otherwise a component displaying the entities
fitting the condition is shown in a dialog allowing either a single or multiple
selection based on the search model settings.
EntitySearchField.ListSelector is the default EntitySearchField.Selector.
Use builder(EntitySearchModel) or builder(EntityType, EntityConnectionProvider) for a builder instance.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceBuilds a entity search field.static interfaceAEntitySearchField.Selectorbased on aJList.static enumThe ways which a search field can indicate that a search is in progress.static interfaceProvides a way for the user to select one or more of a given set of entitiesstatic interfaceAEntitySearchField.Selectorbased on aFilteredTable.Nested classes/interfaces inherited from class javax.swing.JTextField
JTextField.AccessibleJTextFieldNested classes/interfaces inherited from class javax.swing.text.JTextComponent
JTextComponent.AccessibleJTextComponent, JTextComponent.DropLocation, JTextComponent.KeyBindingNested classes/interfaces inherited from class javax.swing.JComponent
JComponent.AccessibleJComponentNested classes/interfaces inherited from class java.awt.Container
Container.AccessibleAWTContainerNested classes/interfaces inherited from class java.awt.Component
Component.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final is.codion.common.property.PropertyValue<EntitySearchField.SearchIndicator>Specifies the way aEntitySearchFieldindicates that a search is in progress.Fields inherited from class javax.swing.JTextField
notifyActionFields inherited from class javax.swing.text.JTextComponent
DEFAULT_KEYMAP, FOCUS_ACCELERATOR_KEYFields inherited from class javax.swing.JComponent
listenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWFields inherited from class java.awt.Component
accessibleContext, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTFields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTHFields inherited from interface javax.swing.SwingConstants
BOTTOM, CENTER, EAST, HORIZONTAL, LEADING, LEFT, NEXT, NORTH, NORTH_EAST, NORTH_WEST, PREVIOUS, RIGHT, SOUTH, SOUTH_EAST, SOUTH_WEST, TOP, TRAILING, VERTICAL, WEST -
Method Summary
Modifier and TypeMethodDescriptionstatic EntitySearchField.Builderbuilder(is.codion.framework.domain.entity.EntityType entityType, is.codion.framework.db.EntityConnectionProvider connectionProvider) Instantiates a newEntitySearchField.Builderstatic EntitySearchField.Builderbuilder(is.codion.framework.model.EntitySearchModel searchModel) Instantiates a newEntitySearchField.BuilderlistSelector(is.codion.framework.model.EntitySearchModel searchModel) is.codion.framework.model.EntitySearchModelmodel()is.codion.swing.common.ui.component.value.ComponentValue<Collection<is.codion.framework.domain.entity.Entity>,EntitySearchField> is.codion.common.state.StatevoidsetSearchIndicator(EntitySearchField.SearchIndicator searchIndicator) voidsetSelectorFactory(Function<is.codion.framework.model.EntitySearchModel, EntitySearchField.Selector> selectorFactory) Sets the factory for theEntitySearchField.Selectorresponsible for selecting items from the search result.voidsetTransferFocusOnEnter(boolean transferFocusOnEnter) is.codion.swing.common.ui.component.value.ComponentValue<is.codion.framework.domain.entity.Entity,EntitySearchField> tableSelector(is.codion.framework.model.EntitySearchModel searchModel) voidupdateUI()Methods inherited from class is.codion.swing.common.ui.component.text.HintTextField
addFocusListener, addPropertyChangeListener, hintText, paintMethods inherited from class javax.swing.JTextField
actionPropertyChanged, addActionListener, configurePropertiesFromAction, createActionPropertyChangeListener, createDefaultModel, fireActionPerformed, getAccessibleContext, getAction, getActionListeners, getActions, getColumns, getColumnWidth, getHorizontalAlignment, getHorizontalVisibility, getPreferredSize, getScrollOffset, getUIClassID, isValidateRoot, paramString, postActionEvent, removeActionListener, scrollRectToVisible, setAction, setActionCommand, setColumns, setDocument, setFont, setHorizontalAlignment, setScrollOffsetMethods inherited from class javax.swing.text.JTextComponent
addCaretListener, addInputMethodListener, addKeymap, copy, cut, fireCaretUpdate, getCaret, getCaretColor, getCaretListeners, getCaretPosition, getDisabledTextColor, getDocument, getDragEnabled, getDropLocation, getDropMode, getFocusAccelerator, getHighlighter, getInputMethodRequests, getKeymap, getKeymap, getMargin, getNavigationFilter, getPreferredScrollableViewportSize, getPrintable, getScrollableBlockIncrement, getScrollableTracksViewportHeight, getScrollableTracksViewportWidth, getScrollableUnitIncrement, getSelectedText, getSelectedTextColor, getSelectionColor, getSelectionEnd, getSelectionStart, getText, getText, getToolTipText, getUI, isEditable, loadKeymap, modelToView, modelToView2D, moveCaretPosition, paste, print, print, print, processInputMethodEvent, read, removeCaretListener, removeKeymap, removeNotify, replaceSelection, restoreComposedText, saveComposedText, select, selectAll, setCaret, setCaretColor, setCaretPosition, setComponentOrientation, setDisabledTextColor, setDragEnabled, setDropMode, setEditable, setFocusAccelerator, setHighlighter, setKeymap, setMargin, setNavigationFilter, setSelectedTextColor, setSelectionColor, setSelectionEnd, setSelectionStart, setText, setUI, viewToModel, viewToModel2D, writeMethods inherited from class javax.swing.JComponent
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, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateMethods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, 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, validateTreeMethods inherited from class java.awt.Component
action, add, addComponentListener, addHierarchyBoundsListener, addHierarchyListener, 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, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPropertyChangeListeners, getPropertyChangeListeners, getSize, 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, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, resize, resize, setBounds, setBounds, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setMixingCutoutShape, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle
-
Field Details
-
SEARCH_INDICATOR
public static final is.codion.common.property.PropertyValue<EntitySearchField.SearchIndicator> SEARCH_INDICATORSpecifies the way aEntitySearchFieldindicates that a search is in progress. Value type:EntitySearchField.SearchIndicator
Default value:EntitySearchField.SearchIndicator.WAIT_CURSOR
-
-
Method Details
-
updateUI
public void updateUI()- Overrides:
updateUIin classJTextComponent
-
model
public is.codion.framework.model.EntitySearchModel model()- Returns:
- the search model this search field is based on
-
setTransferFocusOnEnter
public void setTransferFocusOnEnter(boolean transferFocusOnEnter) - Parameters:
transferFocusOnEnter- true if this component should transfer focus on Enter
-
setSearchIndicator
- Parameters:
searchIndicator- the search indicator type- See Also:
-
setSelectorFactory
public void setSelectorFactory(Function<is.codion.framework.model.EntitySearchModel, EntitySearchField.Selector> selectorFactory) Sets the factory for theEntitySearchField.Selectorresponsible for selecting items from the search result.- Parameters:
selectorFactory- a factory for theEntitySearchField.Selectorimplementation to use when presenting a selection dialog to the user- Throws:
NullPointerException- in caseselectorFactoryis null
-
searchOnFocusLost
public is.codion.common.state.State searchOnFocusLost()- Returns:
- the State controlling whether this field should trigger a search when it loses focus
-
singleSelectionValue
public is.codion.swing.common.ui.component.value.ComponentValue<is.codion.framework.domain.entity.Entity,EntitySearchField> singleSelectionValue()- Returns:
- a
ComponentValuefor selecting a single entity
-
multiSelectionValue
public is.codion.swing.common.ui.component.value.ComponentValue<Collection<is.codion.framework.domain.entity.Entity>,EntitySearchField> multiSelectionValue()- Returns:
- a
ComponentValuefor selecting multiple entities
-
builder
public static EntitySearchField.Builder builder(is.codion.framework.domain.entity.EntityType entityType, is.codion.framework.db.EntityConnectionProvider connectionProvider) Instantiates a newEntitySearchField.Builder- Parameters:
entityType- the entity typeconnectionProvider- the connection provider- Returns:
- a new builder instance
-
builder
public static EntitySearchField.Builder builder(is.codion.framework.model.EntitySearchModel searchModel) Instantiates a newEntitySearchField.Builder- Parameters:
searchModel- the search model on which to base the search field- Returns:
- a new builder instance
-
listSelector
public static EntitySearchField.ListSelector listSelector(is.codion.framework.model.EntitySearchModel searchModel) - Parameters:
searchModel- the search model- Returns:
- a
EntitySearchField.Selectorbased on aJList.
-
tableSelector
public static EntitySearchField.TableSelector tableSelector(is.codion.framework.model.EntitySearchModel searchModel) - Parameters:
searchModel- the search model- Returns:
- a
EntitySearchField.Selectorbased on aFilteredTable.
-