Class MultiSelectionProvider

  • All Implemented Interfaces:
    java.util.EventListener, org.eclipse.jface.viewers.ISelectionChangedListener, org.eclipse.jface.viewers.ISelectionProvider, org.eclipse.swt.custom.CaretListener, org.eclipse.swt.events.DisposeListener, org.eclipse.swt.events.FocusListener, org.eclipse.swt.events.KeyListener, org.eclipse.swt.events.ModifyListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.SelectionListener, org.eclipse.swt.internal.SWTEventListener

    public class MultiSelectionProvider
    extends java.lang.Object
    implements org.eclipse.jface.viewers.ISelectionProvider, org.eclipse.swt.events.DisposeListener, org.eclipse.swt.events.FocusListener, org.eclipse.jface.viewers.ISelectionChangedListener, org.eclipse.swt.events.ModifyListener, org.eclipse.swt.events.KeyListener, org.eclipse.swt.events.MouseListener, org.eclipse.swt.events.SelectionListener, org.eclipse.swt.custom.CaretListener
    Class used as selection provider for a part consisting of multiple types of components that would support the selection interface.

    Supported components:

    • Text capable widgets: Text, Combo, CCombo, Tree, Table, etc...
    • Other selection providers such as viewers.
    • Constructor Summary

      Constructors 
      ConstructorDescription
      MultiSelectionProvider()
      Creates the instance without a default provider.
      MultiSelectionProvider​(org.eclipse.jface.viewers.ISelectionProvider defaultProvider)
      Creates the instance with a default provider.
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and TypeMethodDescription
      voidaddComposite​(org.eclipse.swt.widgets.Composite composite, org.eclipse.jface.viewers.ISelectionProvider selectionProvider)
      Adds a composite that is part of the selection process.
      voidaddControl​(org.eclipse.swt.widgets.Control control)
      Adds a control that is part of the selection process.
      voidaddControl​(org.eclipse.swt.widgets.Control control, org.eclipse.jface.viewers.ISelectionProvider selectionProvider)
      Adds a control that is part of the selection process.
      voidaddSelectionChangedListener​(org.eclipse.jface.viewers.ISelectionChangedListener listener)
      Adds a listener for selection changes in this selection provider.
      voidcaretMoved​(org.eclipse.swt.custom.CaretEvent event)
      This method is called after the caret offset is changed.
      voiddispose()
      Disposes of the selection provider.
      voidfireCurrentSelection()
      Fires the current selection to the listeners.
      voidfireSelection​(org.eclipse.jface.viewers.ISelection selection)
      Fires the selection to the listeners.
      voidfireSelectionAsync()
      Fires the selection asynchronously.
      voidfocusGained​(org.eclipse.swt.events.FocusEvent e)
      Focus gained.
      voidfocusLost​(org.eclipse.swt.events.FocusEvent e)
      Focus lost.
      IClipboardSelectiongetClipboardSelectionProvider()
      Gets the current IClipboardSelection interface for the current control.
      org.eclipse.swt.widgets.ControlgetCurrentControl()
      Gets the current control.
      org.eclipse.jface.viewers.ISelectiongetSelection()
      Returns the current selection for this provider.
      static org.eclipse.jface.text.TextViewergetTextViewer​(org.eclipse.swt.custom.StyledText styledText)
      Gets the text viewer for a StyledText control.
      voidkeyPressed​(org.eclipse.swt.events.KeyEvent e) 
      voidkeyReleased​(org.eclipse.swt.events.KeyEvent e) 
      voidmodifyText​(org.eclipse.swt.events.ModifyEvent e)
      Entry field control modification.
      voidmouseDoubleClick​(org.eclipse.swt.events.MouseEvent e) 
      voidmouseDown​(org.eclipse.swt.events.MouseEvent e) 
      voidmouseUp​(org.eclipse.swt.events.MouseEvent e) 
      voidonDragEnd()
      Drag finished, called by the part when all drags complete.
      voidonPartActivated​(boolean isActive)
      Clears the current focus control due to part inactivation.
      static voidregisterViewer​(org.eclipse.jface.text.TextViewer viewer)
      Registers the TextViewer or similar (e.g.
      voidremoveControl​(org.eclipse.swt.widgets.Control control, boolean fireEventIfFocusLost)
      Removes a control that was part of the selection process.
      voidremoveSelectionChangedListener​(org.eclipse.jface.viewers.ISelectionChangedListener listener)
      Removes the given selection change listener from this selection provider.
      voidselectionChanged​(org.eclipse.jface.viewers.SelectionChangedEvent event)
      Notifies that the selection has changed.
      voidsetDefaultProvider​(org.eclipse.jface.viewers.ISelectionProvider defaultProvider)
      Sets the default provider when no provider is found for a control.
      voidsetDraggingFix​(IDraggingFix dragFixer)
      Sets the dragging fix interface.
      voidsetInitialized()
      Marks the selection provider as initialized on the owner side, i.e.
      voidsetSelection​(org.eclipse.jface.viewers.ISelection selection)
      Sets the current selection for this selection provider.
      voidwidgetDefaultSelected​(org.eclipse.swt.events.SelectionEvent e)
      Sent when default selection occurs in the control.
      voidwidgetDisposed​(org.eclipse.swt.events.DisposeEvent e)
      Called when a widget is disposed of.
      voidwidgetSelected​(org.eclipse.swt.events.SelectionEvent e)
      Sent when selection occurs in the control.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • MultiSelectionProvider

        public MultiSelectionProvider()
        Creates the instance without a default provider.
      • MultiSelectionProvider

        public MultiSelectionProvider​(org.eclipse.jface.viewers.ISelectionProvider defaultProvider)
        Creates the instance with a default provider.
    • Method Detail

      • registerViewer

        public static void registerViewer​(org.eclipse.jface.text.TextViewer viewer)
        Registers the TextViewer or similar (e.g. SourceViewer) as the controller class for it's StyledText. This is used to be able to extract the viewer for the MultiSelectionProvider and the IIZI actions for undo/redo, clipboard, etc...
      • getTextViewer

        public static org.eclipse.jface.text.TextViewer getTextViewer​(org.eclipse.swt.custom.StyledText styledText)
        Gets the text viewer for a StyledText control.
        Parameters:
        styledText - The styled text control.
        Returns:
        The text viewer, or null for none.
      • setDefaultProvider

        public void setDefaultProvider​(org.eclipse.jface.viewers.ISelectionProvider defaultProvider)
        Sets the default provider when no provider is found for a control.
      • dispose

        public void dispose()
        Disposes of the selection provider.
      • setDraggingFix

        public void setDraggingFix​(IDraggingFix dragFixer)
        Sets the dragging fix interface.
      • onDragEnd

        public void onDragEnd()
        Drag finished, called by the part when all drags complete.
      • setInitialized

        public void setInitialized()
        Marks the selection provider as initialized on the owner side, i.e. that all controls, etc, are created and that selection events should be sent.
      • onPartActivated

        public void onPartActivated​(boolean isActive)
        Clears the current focus control due to part inactivation.
      • addComposite

        public void addComposite​(org.eclipse.swt.widgets.Composite composite,
                                 org.eclipse.jface.viewers.ISelectionProvider selectionProvider)
        Adds a composite that is part of the selection process.

        Recursion will be done to find all Text, Combo, CCombo, StyledText, Spinner, then special clipboard routines also applies.

        Parameters:
        composite - The composite.
        selectionProvider - The selection provider to use.
      • addControl

        public void addControl​(org.eclipse.swt.widgets.Control control)
        Adds a control that is part of the selection process.

        If the control is Text, Combo, CCombo, StyledText, Spinner, then special clipboard routines also applies.

        Parameters:
        control - The control.
      • addControl

        public void addControl​(org.eclipse.swt.widgets.Control control,
                               org.eclipse.jface.viewers.ISelectionProvider selectionProvider)
        Adds a control that is part of the selection process.
        Parameters:
        control - The control.
        selectionProvider - Potential selection provider (e.g. the Viewer for Tree or Table).

        If the selectionProvider implements the interface IClipboardSelection this interface can be returned with the method getClipboardSelectionProvider().

      • widgetDisposed

        public void widgetDisposed​(org.eclipse.swt.events.DisposeEvent e)
        Called when a widget is disposed of.
        Specified by:
        widgetDisposed in interface org.eclipse.swt.events.DisposeListener
      • removeControl

        public void removeControl​(org.eclipse.swt.widgets.Control control,
                                  boolean fireEventIfFocusLost)
        Removes a control that was part of the selection process.
        Parameters:
        control - The control.
      • addSelectionChangedListener

        public void addSelectionChangedListener​(org.eclipse.jface.viewers.ISelectionChangedListener listener)
        Adds a listener for selection changes in this selection provider. Has no effect if an identical listener is already registered.
        Specified by:
        addSelectionChangedListener in interface org.eclipse.jface.viewers.ISelectionProvider
        Parameters:
        listener - A selection changed listener.
      • removeSelectionChangedListener

        public void removeSelectionChangedListener​(org.eclipse.jface.viewers.ISelectionChangedListener listener)
        Removes the given selection change listener from this selection provider. Has no effect if an identical listener is not registered.
        Specified by:
        removeSelectionChangedListener in interface org.eclipse.jface.viewers.ISelectionProvider
        Parameters:
        listener - A selection changed listener.
      • selectionChanged

        public void selectionChanged​(org.eclipse.jface.viewers.SelectionChangedEvent event)
        Notifies that the selection has changed. Called by Structured Viewers due to added controls. This will fire a selection change to all listeners, when potential dragging is completed.
        Specified by:
        selectionChanged in interface org.eclipse.jface.viewers.ISelectionChangedListener
        Parameters:
        event - Event object describing the change.
      • fireCurrentSelection

        public void fireCurrentSelection()
        Fires the current selection to the listeners.
      • fireSelection

        public void fireSelection​(org.eclipse.jface.viewers.ISelection selection)
        Fires the selection to the listeners.
      • getSelection

        public org.eclipse.jface.viewers.ISelection getSelection()
        Returns the current selection for this provider.
        Specified by:
        getSelection in interface org.eclipse.jface.viewers.ISelectionProvider
        Returns:
        The current selection.
      • setSelection

        public void setSelection​(org.eclipse.jface.viewers.ISelection selection)
        Sets the current selection for this selection provider.
        Specified by:
        setSelection in interface org.eclipse.jface.viewers.ISelectionProvider
        Parameters:
        selection - the new selection
      • focusGained

        public void focusGained​(org.eclipse.swt.events.FocusEvent e)
        Focus gained.
        Specified by:
        focusGained in interface org.eclipse.swt.events.FocusListener
      • focusLost

        public void focusLost​(org.eclipse.swt.events.FocusEvent e)
        Focus lost.
        Specified by:
        focusLost in interface org.eclipse.swt.events.FocusListener
      • getClipboardSelectionProvider

        public IClipboardSelection getClipboardSelectionProvider()
        Gets the current IClipboardSelection interface for the current control.
        Returns:
        null If not available.
      • getCurrentControl

        public org.eclipse.swt.widgets.Control getCurrentControl()
        Gets the current control.
        Returns:
        The control in focus, or null for none.
      • modifyText

        public void modifyText​(org.eclipse.swt.events.ModifyEvent e)
        Entry field control modification.
        Specified by:
        modifyText in interface org.eclipse.swt.events.ModifyListener
      • widgetSelected

        public void widgetSelected​(org.eclipse.swt.events.SelectionEvent e)
        Sent when selection occurs in the control.
        Specified by:
        widgetSelected in interface org.eclipse.swt.events.SelectionListener
        Parameters:
        e - An event containing information about the selection.
      • widgetDefaultSelected

        public void widgetDefaultSelected​(org.eclipse.swt.events.SelectionEvent e)
        Sent when default selection occurs in the control.
        Specified by:
        widgetDefaultSelected in interface org.eclipse.swt.events.SelectionListener
        Parameters:
        e - An event containing information about the default selection.
      • caretMoved

        public void caretMoved​(org.eclipse.swt.custom.CaretEvent event)
        This method is called after the caret offset is changed.
        Specified by:
        caretMoved in interface org.eclipse.swt.custom.CaretListener
        Parameters:
        event - The given event.
        See Also:
        CaretEvent
      • fireSelectionAsync

        public void fireSelectionAsync()
        Fires the selection asynchronously. The selection is fired only once, even if called multiple times within the same "sync" call (if from called from the SWT thread).
      • mouseDoubleClick

        public void mouseDoubleClick​(org.eclipse.swt.events.MouseEvent e)
        Specified by:
        mouseDoubleClick in interface org.eclipse.swt.events.MouseListener
      • mouseDown

        public void mouseDown​(org.eclipse.swt.events.MouseEvent e)
        Specified by:
        mouseDown in interface org.eclipse.swt.events.MouseListener
      • mouseUp

        public void mouseUp​(org.eclipse.swt.events.MouseEvent e)
        Specified by:
        mouseUp in interface org.eclipse.swt.events.MouseListener
      • keyPressed

        public void keyPressed​(org.eclipse.swt.events.KeyEvent e)
        Specified by:
        keyPressed in interface org.eclipse.swt.events.KeyListener
      • keyReleased

        public void keyReleased​(org.eclipse.swt.events.KeyEvent e)
        Specified by:
        keyReleased in interface org.eclipse.swt.events.KeyListener