Class SearchBox

  • All Implemented Interfaces:
    org.eclipse.swt.graphics.Drawable
    Direct Known Subclasses:
    EventHandlersSearchBox

    public class SearchBox
    extends org.eclipse.swt.custom.StyledText
    Search box widget with plugable history support. Features:
    • History drop-down list, activated by drop-down button or down array key.
    • Quick history browsing, activated by up arrow key.
    See Also:
    SearchBox.ISearchListener, ISearchHistory
    • Nested Class Summary

      Nested Classes 
      Modifier and Type Class Description
      static interface  SearchBox.ISearchListener
      Search event listener.
    • Constructor Summary

      Constructors 
      Constructor Description
      SearchBox​(org.eclipse.swt.widgets.Composite parent)
      Instantiates a new search box.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void addControlListener()
      Adds control listener
      protected void addFocusListener()
      Adds focus listener
      protected void addKeyListener()
      Adds key listener
      protected void addListeners()
      Adds all listeners
      protected void addNotifyListener()
      Adds NotifyListener
      protected void addPaintListener()
      Adds paint listener
      protected void addTraverseListener()
      Adds traverse listener
      org.eclipse.swt.graphics.Point computeSize​(int wHint, int hHint, boolean changed)  
      void dispose()
      int getKeyBinding​(int key)  
      String getText()
      void notifyListeners​(int eventType, org.eclipse.swt.widgets.Event event)
      void setCursor​(org.eclipse.swt.graphics.Cursor cursor)
      void setForeground​(org.eclipse.swt.graphics.Color color)  
      void setHistory​(ISearchHistory history)
      Sets the history provider.
      void setJobScheduleDelay​(int scheduleDelay)
      Sets the search job schedule delay, default value is 100 ms.
      void setMessage​(String message)
      Sets message prompt.
      void setMinimumSearchTextLength​(int minimumSearchTextLength)
      Sets minimum search text length, which will trigger search event, default value is 3 characters.
      void setSearchDelay​(int searchDelay)
      Sets the search delay, default value is 100 ms.
      void setSearchListener​(SearchBox.ISearchListener searchListener)
      Sets search listener, which will be called on search events.
      void setText​(String text)
      • Methods inherited from class org.eclipse.swt.custom.StyledText

        addBidiSegmentListener, addCaretListener, addExtendedModifyListener, addLineBackgroundListener, addLineStyleListener, addModifyListener, addPaintObjectListener, addSelectionListener, addVerifyKeyListener, addVerifyListener, addWordMovementListener, append, copy, copy, cut, getAlignment, getAlwaysShowScrollBars, getBackground, getBaseline, getBaseline, getBidiColoring, getBlockSelection, getBlockSelectionBounds, getBottomMargin, getCaretOffset, getCharCount, getContent, getDoubleClickEnabled, getDragDetect, getEditable, getForeground, getHorizontalIndex, getHorizontalPixel, getIndent, getJustify, getLeftMargin, getLine, getLineAlignment, getLineAtOffset, getLineBackground, getLineBullet, getLineCount, getLineDelimiter, getLineHeight, getLineHeight, getLineIndent, getLineIndex, getLineJustify, getLinePixel, getLineSpacing, getLineTabStops, getLineVerticalIndent, getLineWrapIndent, getLocationAtOffset, getMarginColor, getMouseNavigatorEnabled, getOffsetAtLine, getOffsetAtLocation, getOffsetAtPoint, getOrientation, getRanges, getRanges, getRightMargin, getSelection, getSelectionBackground, getSelectionCount, getSelectionForeground, getSelectionRange, getSelectionRanges, getSelectionText, getStyleRangeAtOffset, getStyleRanges, getStyleRanges, getStyleRanges, getStyleRanges, getTabs, getTabStops, getText, getTextBounds, getTextLimit, getTextRange, getTopIndex, getTopMargin, getTopPixel, getWordWrap, getWrapIndent, insert, invokeAction, isTextSelected, paste, print, print, print, redraw, redraw, redrawRange, removeBidiSegmentListener, removeCaretListener, removeExtendedModifyListener, removeLineBackgroundListener, removeLineStyleListener, removeModifyListener, removePaintObjectListener, removeSelectionListener, removeVerifyKeyListener, removeVerifyListener, removeWordMovementListener, replaceStyleRanges, replaceTextRange, scroll, selectAll, setAlignment, setAlwaysShowScrollBars, setBackground, setBidiColoring, setBlockSelection, setBlockSelectionBounds, setBlockSelectionBounds, setBottomMargin, setCaret, setCaretOffset, setContent, setDoubleClickEnabled, setDragDetect, setEditable, setFont, setHorizontalIndex, setHorizontalPixel, setIndent, setJustify, setKeyBinding, setLeftMargin, setLineAlignment, setLineBackground, setLineBullet, setLineIndent, setLineJustify, setLineSpacing, setLineSpacingProvider, setLineTabStops, setLineVerticalIndent, setLineWrapIndent, setMarginColor, setMargins, setMouseNavigatorEnabled, setOrientation, setRightMargin, setSelection, setSelection, setSelection, setSelectionBackground, setSelectionForeground, setSelectionRange, setStyleRange, setStyleRanges, setStyleRanges, setStyleRanges, setTabs, setTabStops, setTextDirection, setTextLimit, setTopIndex, setTopMargin, setTopPixel, setWordWrap, setWrapIndent, showSelection
      • Methods inherited from class org.eclipse.swt.widgets.Canvas

        drawBackground, getCaret, getIME, setIME
      • Methods inherited from class org.eclipse.swt.widgets.Composite

        changed, checkSubclass, drawBackground, getBackgroundMode, getChildren, getLayout, getLayoutDeferred, getTabList, isLayoutDeferred, layout, layout, layout, layout, layout, setBackgroundMode, setFocus, setLayout, setLayoutDeferred, setTabList
      • Methods inherited from class org.eclipse.swt.widgets.Scrollable

        computeTrim, getClientArea, getHorizontalBar, getScrollbarsMode, getVerticalBar
      • Methods inherited from class org.eclipse.swt.widgets.Control

        addControlListener, addDragDetectListener, addFocusListener, addGestureListener, addHelpListener, addKeyListener, addMenuDetectListener, addMouseListener, addMouseMoveListener, addMouseTrackListener, addMouseWheelListener, addPaintListener, addTouchListener, addTraverseListener, computeSize, dragDetect, dragDetect, forceFocus, getAccessible, getBackgroundImage, getBorderWidth, getBounds, getCursor, getEnabled, getFont, getLayoutData, getLocation, getMenu, getMonitor, getParent, getRegion, getShell, getSize, getTextDirection, getToolTipText, getTouchEnabled, getVisible, internal_dispose_GC, internal_new_GC, isEnabled, isFocusControl, isReparentable, isVisible, moveAbove, moveBelow, pack, pack, print, removeControlListener, removeDragDetectListener, removeFocusListener, removeGestureListener, removeHelpListener, removeKeyListener, removeMenuDetectListener, removeMouseListener, removeMouseMoveListener, removeMouseTrackListener, removeMouseWheelListener, removePaintListener, removeTouchListener, removeTraverseListener, requestLayout, setBackgroundImage, setBounds, setBounds, setCapture, setEnabled, setLayoutData, setLocation, setLocation, setMenu, setParent, setRedraw, setRegion, setSize, setSize, setToolTipText, setTouchEnabled, setVisible, toControl, toControl, toDisplay, toDisplay, traverse, traverse, traverse, update
      • Methods inherited from class org.eclipse.swt.widgets.Widget

        addDisposeListener, addListener, checkWidget, getData, getData, getDisplay, getListeners, getStyle, isAutoDirection, isDisposed, isListening, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
      • Methods inherited from interface org.eclipse.swt.graphics.Drawable

        isAutoScalable
    • Field Detail

      • DEFAULT_MIN_SEARCH_TEXT_LENGTH

        public static final int DEFAULT_MIN_SEARCH_TEXT_LENGTH
        See Also:
        Constant Field Values
      • settingText

        protected boolean settingText
      • displayingPopup

        protected boolean displayingPopup
      • popup

        protected org.eclipse.swt.widgets.Shell popup
      • selectedPopupItem

        protected int selectedPopupItem
      • displayingQuickBrowse

        protected boolean displayingQuickBrowse
      • quickBrowseItem

        protected int quickBrowseItem
    • Constructor Detail

      • SearchBox

        public SearchBox​(org.eclipse.swt.widgets.Composite parent)
        Instantiates a new search box.
        Parameters:
        parent - container widget.
    • Method Detail

      • setHistory

        public void setHistory​(ISearchHistory history)
        Sets the history provider.
        Parameters:
        history - history to use.
        See Also:
        ISearchHistory
      • setSearchDelay

        public void setSearchDelay​(int searchDelay)
        Sets the search delay, default value is 100 ms. It's a time to wait after a user stops typing a search string to avoid scheduling a search job on each entered character. This delay is used in SearchBox.addNotifyListener.
        Parameters:
        searchDelay - new search delay.
      • setJobScheduleDelay

        public void setJobScheduleDelay​(int scheduleDelay)
        Sets the search job schedule delay, default value is 100 ms. It's a delay before scheduling a new serch job to give a chance to complete or cancel a previous one.
        Parameters:
        scheduleDelay - new search job schedule delay.
      • setMinimumSearchTextLength

        public void setMinimumSearchTextLength​(int minimumSearchTextLength)
        Sets minimum search text length, which will trigger search event, default value is 3 characters.
        Parameters:
        minimumSearchTextLength - new value.
        See Also:
        SearchBox.ISearchListener
      • setMessage

        public void setMessage​(String message)
        Sets message prompt.
        Parameters:
        message - new message.
      • getText

        public String getText()
        Overrides:
        getText in class org.eclipse.swt.custom.StyledText
      • setText

        public void setText​(String text)
        Overrides:
        setText in class org.eclipse.swt.custom.StyledText
      • notifyListeners

        public void notifyListeners​(int eventType,
                                    org.eclipse.swt.widgets.Event event)
        Overrides:
        notifyListeners in class org.eclipse.swt.widgets.Widget
      • dispose

        public void dispose()
        Overrides:
        dispose in class org.eclipse.swt.custom.StyledText
      • setCursor

        public void setCursor​(org.eclipse.swt.graphics.Cursor cursor)
        Overrides:
        setCursor in class org.eclipse.swt.custom.StyledText
      • setForeground

        public void setForeground​(org.eclipse.swt.graphics.Color color)
        Overrides:
        setForeground in class org.eclipse.swt.custom.StyledText
      • computeSize

        public org.eclipse.swt.graphics.Point computeSize​(int wHint,
                                                          int hHint,
                                                          boolean changed)
        Overrides:
        computeSize in class org.eclipse.swt.custom.StyledText
      • getKeyBinding

        public int getKeyBinding​(int key)
        Overrides:
        getKeyBinding in class org.eclipse.swt.custom.StyledText
      • addListeners

        protected void addListeners()
        Adds all listeners
      • addKeyListener

        protected void addKeyListener()
        Adds key listener
      • addTraverseListener

        protected void addTraverseListener()
        Adds traverse listener
      • addNotifyListener

        protected void addNotifyListener()
        Adds NotifyListener
      • addFocusListener

        protected void addFocusListener()
        Adds focus listener
      • addControlListener

        protected void addControlListener()
        Adds control listener
      • addPaintListener

        protected void addPaintListener()
        Adds paint listener