Class SearchPanel

    • Field Detail

      • m_RegExpEnabled

        protected boolean m_RegExpEnabled
        whether regular expressions are enabled.
      • m_Incremental

        protected boolean m_Incremental
        whether incremental search is enabled.
      • m_Prefix

        protected String m_Prefix
        the prefix (caption + optional mnemonic indicator).
      • m_ButtonCaption

        protected String m_ButtonCaption
        the caption (+ optional mnemonic indicator) for the search button.
      • m_LabelPrefix

        protected JLabel m_LabelPrefix
        the label for the text field.
      • m_PanelSearchText

        protected JPanel m_PanelSearchText
        the panel for the search text and clear button.
      • m_TextSearch

        protected BaseTextField m_TextSearch
        the text field for entering the search text.
      • m_CheckboxRegExp

        protected BaseCheckBox m_CheckboxRegExp
        whether to use regular expressions for searching or plain string comparison.
      • m_ButtonClear

        protected JLabel m_ButtonClear
        the button for clearing the search.
      • m_ButtonSearch

        protected JLabel m_ButtonSearch
        the button for performing the search.
      • m_PanelButtons

        protected JPanel m_PanelButtons
        the button panel.
      • m_PanelWidgets

        protected JPanel m_PanelWidgets
        the panel with the buttons and search box.
      • m_SearchListeners

        protected Set<SearchListener> m_SearchListeners
        the listeners for a search being initiated.
      • m_MinimumChars

        protected int m_MinimumChars
        the minimum number of characters before triggering search events.
      • m_LastSearch

        protected String m_LastSearch
        the last search term.
    • Constructor Detail

      • SearchPanel

        public SearchPanel​(SearchPanel.LayoutType layout,
                           boolean regExp)
        Initializes the panel.
        Parameters:
        layout - the layout of the panel
        regExp - whether to display regular expressions
      • SearchPanel

        public SearchPanel​(SearchPanel.LayoutType layout,
                           boolean regExp,
                           String prefix,
                           String button)
        Initializes the panel.
        Parameters:
        layout - the layout of the panel
        regExp - whether to display regular expressions
        prefix - the prefix label to use, use null to ignore. Mnemonics can be indicated by a preceding underscore "_".
        button - the caption for the button. Mnemonics can be indicated by a preceding underscore "_".
      • SearchPanel

        public SearchPanel​(SearchPanel.LayoutType layout,
                           boolean regExp,
                           String prefix,
                           boolean incremental,
                           String button)
        Initializes the panel with optional incremental search (and no search button if incremental search turned on).
        Parameters:
        layout - the layout of the panel
        regExp - whether to display regular expressions
        prefix - the prefix label to use, use null to ignore. Mnemonics can be indicated by a preceding underscore "_".
        incremental - if true then no search button will be displayed
        button - the caption for the button. Mnemonics can be indicated by a preceding underscore "_".
    • Method Detail

      • initialize

        protected void initialize()
        Initializes the members.
        Overrides:
        initialize in class BasePanel
      • initGUI

        protected void initGUI()
        Initializes the widgets.
        Overrides:
        initGUI in class BasePanel
      • updateLayout

        protected void updateLayout()
        Updates the layout.
      • createPopup

        protected BasePopupMenu createPopup​(MouseEvent e)
        Generates a popup for the search field.
        Parameters:
        e - the mouse event
      • setEnabled

        public void setEnabled​(boolean value)
        Sets the enabled state of the components.
        Overrides:
        setEnabled in class JComponent
        Parameters:
        value - if true then the components are enabled otherwise not
      • isEnabled

        public boolean isEnabled()
        Returns whether the panel is enabled or not.
        Overrides:
        isEnabled in class Component
        Returns:
        true if the search components are enabled.
      • getLayoutType

        public SearchPanel.LayoutType getLayoutType()
        Returns the type of layout.
        Returns:
        the layout
      • hasPrefix

        protected boolean hasPrefix()
        Checks whether a prefix string was provided.
        Returns:
        true if a prefix string was supplied
      • setRegularExpressionEnabled

        public void setRegularExpressionEnabled​(boolean value)
        Sets whether to use regexp search or plain substring matching.
        Parameters:
        value - true if regular expression search is to be used
      • isRegularExpressionEnabled

        public boolean isRegularExpressionEnabled()
        Returns whether regular expressions are turned on.
        Returns:
        true if regular expressions are enabled
      • setSearchText

        public void setSearchText​(String value)
        Sets the search text.
        Parameters:
        value - the new search text
      • getSearchText

        public String getSearchText()
        Returns the text in the search box.
        Returns:
        the current search text
      • setRegularExpression

        public void setRegularExpression​(boolean value)
        Sets whether the search text is a regular expression one or not.
        Parameters:
        value - if true then regular expression search will be enabled
      • isRegularExpression

        public boolean isRegularExpression()
        Returns whether the search text is a regular expression one or not.
        Returns:
        true if a regular expression search
      • setIncremental

        public void setIncremental​(boolean value)
        Sets whether to enabled incremental search.
        Parameters:
        value - true if incremental search enabled
      • isIncremental

        public boolean isIncremental()
        Returns whether incremental search is enabled.
        Returns:
        true if incremental search enabled
      • setMinimumChars

        public void setMinimumChars​(int value)
        Sets the minimum number of characters that the user needs to enter before triggering a search event.
        Parameters:
        value - the minimum number of characters (>= 1)
      • getMinimumChars

        public int getMinimumChars()
        Returns the minimum number of characters that the user needs to enter before triggering a search event.
        Returns:
        the minimum number of characters (>= 1)
      • setTextColumns

        public void setTextColumns​(int value)
        Sets the number of columns for the text field.
        Parameters:
        value - the number of columns (>0)
      • getTextColumns

        public int getTextColumns()
        Returns the number of columns of the text field.
        Returns:
        the number of columns (>0)
      • setButtonCaption

        public void setButtonCaption​(String value)
        The caption for the search button (incl. mnemonic). Ignored if button is not being displayed.
        Parameters:
        value - the caption
      • getButtonCaption

        public String getButtonCaption()
        Returns the current caption of the search button (incl. mnemonic).
        Returns:
        the caption or null if button not displayed
      • clearWidgetsPanel

        public void clearWidgetsPanel()
        Removes all components from the panel holding the Widgets.
      • addToWidgetsPanel

        public void addToWidgetsPanel​(Component comp,
                                      int index)
        Adds the component to the panel with the Widgets.
        Parameters:
        comp - the component to add
        index - the index where to add the component, -1 adds the component at the end
      • addToWidgetsPanel

        public void addToWidgetsPanel​(Component comp)
        Adds the component to the panel with the Widgets.
        Parameters:
        comp - the component to add
      • removeFromWidgetsPanel

        public void removeFromWidgetsPanel​(Component comp)
        Removes the component from the panel with the Widgets.
        Parameters:
        comp - the component to remove
      • updateWidgets

        protected void updateWidgets()
        Lays out the widgets according to the layout.
      • addSearchListener

        public void addSearchListener​(SearchListener l)
        Adds the specified listener to the internal list of listeners.
        Parameters:
        l - the listener to add
      • removeSearchListener

        public void removeSearchListener​(SearchListener l)
        Removes the specified listener from the internal list of listeners.
        Parameters:
        l - the listener to remove
      • notifySearchListeners

        protected void notifySearchListeners​(SearchEvent e)
        Sends out the event to all listeners.
        Parameters:
        e - the event to send
      • performSearch

        protected void performSearch()
        Initiates a search.
      • clearSearch

        protected void clearSearch()
        Clears a previous search if the last search term had a non-zero length.
      • isValidSearch

        protected boolean isValidSearch()
        Checks whether the search is valid.
        Returns:
        true if the search is valid
      • search

        public void search()
        Imitates a click on the search button to initiate a search.
      • grabFocus

        public void grabFocus()
        The text field for the search tries to grab the focus.
        Overrides:
        grabFocus in class JComponent
      • updateWidth

        public void updateWidth​(int width)
        In case of vertical display, the size of the panel can be adjusted to the specified width.
        Parameters:
        width - the new width