Class AutoCompleteValueComboChooserViewer

All Implemented Interfaces:
EventListener, IInputProvider, IInputSelectionProvider, IPostSelectionProvider, ISelectionProvider, org.eclipse.swt.events.FocusListener, org.eclipse.swt.events.ModifyListener, org.eclipse.swt.internal.SWTEventListener, org.eclipse.swt.widgets.Listener

public class AutoCompleteValueComboChooserViewer extends ValueComboChooserViewer implements org.eclipse.swt.events.ModifyListener, org.eclipse.swt.events.FocusListener, org.eclipse.swt.widgets.Listener
ValueComboChooserViewer extension with auto complete support.

By default, eontent to proposal associations will be defined by ILabelProvider of this viewer. Clients may override with buildProposals(Iterable). Iterable input is expected for this viewer.

  • Field Details

  • Constructor Details

    • AutoCompleteValueComboChooserViewer

      public AutoCompleteValueComboChooserViewer(org.eclipse.swt.widgets.Composite parent, int style, org.eclipse.ui.forms.widgets.FormToolkit toolkit, int maxDecorationWidth)
      Parameters:
      parent - the parent control, cannot be null
      style - the SWT style bits
      toolkit - the reference to the toolkit context, cannot be null
      maxDecorationWidth - maximum width of the decoration shown in the content area.
  • Method Details

    • modifyText

      public void modifyText(org.eclipse.swt.events.ModifyEvent event)
      Specified by:
      modifyText in interface org.eclipse.swt.events.ModifyListener
    • handleEvent

      public void handleEvent(org.eclipse.swt.widgets.Event event)
      Specified by:
      handleEvent in interface org.eclipse.swt.widgets.Listener
    • focusGained

      public void focusGained(org.eclipse.swt.events.FocusEvent event)
      Specified by:
      focusGained in interface org.eclipse.swt.events.FocusListener
    • focusLost

      public void focusLost(org.eclipse.swt.events.FocusEvent event)
      Specified by:
      focusLost in interface org.eclipse.swt.events.FocusListener
    • getSelection

      public ISelection getSelection()
      Specified by:
      getSelection in interface ISelectionProvider
      Overrides:
      getSelection in class StructuredViewer
    • inputChanged

      protected void inputChanged(Object input, Object oldInput)
      Overrides:
      inputChanged in class AbstractListViewer
    • isAllowed

      protected boolean isAllowed(char character)
      Returns whether the given control character is allowed for auto complete popup providing.
      Parameters:
      character - the control character to check
      Returns:
      whether the given control character is allowed for auto complete popup providing
    • buildProposals

      protected com.google.common.collect.Multimap<String,Object> buildProposals(Iterable<Object> input)
      Build proposals for the viewer auto completion. Default implementation uses ILabelProvider to get proposal text. Allows non-unique input object text presentation. Returns multi map:
      • key - string representation for the target object
      • value - the target object
      Parameters:
      input - an iterable input of the viewer, cannot be null, can be empty
      Returns:
      proposals multi map for the viewer auto completion, never null
    • getLabelText

      protected String getLabelText(Object object)
      Returns label text for the given input object.
      Parameters:
      object - the input object to get label text for, cannot be null
      Returns:
      the label text for the given input object, never null
    • initializeAutoComplete

      protected void initializeAutoComplete()
      Initialize auto completion support for this viewer.
    • extractSelection

      protected IStructuredSelection extractSelection(String typedValue)
      Try to extract IStructuredSelection from given text input. Can return structured selection with item from current input of combo viewer or empty selection.
      Parameters:
      typedValue - text input to extract structured selection from, cannot be null
      Returns:
      extracted structured selection, never null, can be empty
    • ensureEnabled

      protected void ensureEnabled()
      Enable auto complete if it is not already enabled.
    • ensureDisabled

      protected void ensureDisabled()
      Disable auto complete if it is enabled.