Class SearchField

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible
Direct Known Subclasses:
IpaMapSearchField, TableSearchField

public class SearchField extends JPanel
A search field with optional context button. The field displays a prompt when the text field text is empty.
See Also:
  • Field Details

    • ctxButton

      protected ca.phon.ui.text.SearchField.SearchFieldButton ctxButton
      Search context button
    • endButton

      protected ca.phon.ui.text.SearchField.SearchFieldButton endButton
    • queryField

      protected final PromptedTextField queryField
  • Constructor Details

    • SearchField

      public SearchField()
      Search icon
    • SearchField

      public SearchField(String prompt)
    • SearchField

      public SearchField(String historyProperty, int maxHistory, String prompt)
  • Method Details

    • createClearIcon

      public BufferedImage createClearIcon()
    • createSearchIcon

      public BufferedImage createSearchIcon()
    • setFocusable

      public void setFocusable(boolean b)
      Overrides:
      setFocusable in class Component
    • getQuery

      public String getQuery()
      Get the query text
      Returns:
      query text
    • getAction

      public Action getAction()
    • setAction

      public void setAction(Action action)
    • onShowContextMenu

      public void onShowContextMenu(PhonActionEvent<Void> pae)
      Displays the context menu for the component. By default, this displays a single option for clearing the text field. Subclasses should override to define custom options.
      Parameters:
      pae -
    • getContextButton

      public JButton getContextButton()
    • getEndButton

      public JButton getEndButton()
    • getPrompt

      public String getPrompt()
    • setPrompt

      public void setPrompt(String prompt)
    • getColumns

      public int getColumns()
    • setColumns

      public void setColumns(int columns)
    • getDocument

      public Document getDocument()
    • getTextField

      public PromptedTextField getTextField()
    • setupPopupMenu

      protected void setupPopupMenu(JPopupMenu menu)
      Setup popup menu. Override this method to completely customize the context menu for the search field. Most implementations will only need to add custom options to the menu and should use the SearchField.SearchFieldMenuHandler interface to do so.
      Parameters:
      menu - popup menu to setup
    • setMenuHandler

      public void setMenuHandler(SearchField.SearchFieldMenuHandler menuHandler)
      Set a custom menu handler for the search field. May be used to add custom options to the context menu.
      Parameters:
      menuHandler - custom menu handler or null to remove
    • getMenuHandler

      public SearchField.SearchFieldMenuHandler getMenuHandler()
      Get the custom menu handler for the search field.
      Returns:
      custom menu handler or null if none is set
    • setState

      public void setState(String state)
    • getState

      public PromptedTextField.FieldState getState()
    • getText

      public String getText()
    • setText

      public void setText(String s)
    • onClearText

      public void onClearText(PhonActionEvent<Void> pae)
    • addToSearchHistory

      public void addToSearchHistory(SearchHistoryEntry entry)
      Add given entry to search history, requires that a history property was specified at construction time.
      Parameters:
      entry - the entry to add
    • setSearchHistorySelectionCallback

      public void setSearchHistorySelectionCallback(Consumer<SearchHistoryEntry> callback)