Class MultiSelectionProvider

java.lang.Object
com.iizigo.editor.MultiSelectionProvider
All Implemented Interfaces:
EventListener, ISelectionChangedListener, ISelectionProvider, CaretListener, DisposeListener, FocusListener, KeyListener, ModifyListener, MouseListener, SelectionListener, SWTEventListener

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 Details Link icon

    • MultiSelectionProvider Link icon

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

      public MultiSelectionProvider(ISelectionProvider defaultProvider)
      Creates the instance with a default provider.
  • Method Details Link icon

    • registerViewer Link icon

      public static void registerViewer(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 Link icon

      public static TextViewer getTextViewer(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 Link icon

      public void setDefaultProvider(ISelectionProvider defaultProvider)
      Sets the default provider when no provider is found for a control.
    • dispose Link icon

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

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

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

      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 Link icon

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

      public void addComposite(Composite composite, 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 Link icon

      public void addControl(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 Link icon

      public void addControl(Control control, 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 Link icon

      public void widgetDisposed(DisposeEvent e)
      Called when a widget is disposed of.
      Specified by:
      widgetDisposed in interface DisposeListener
    • removeControl Link icon

      public void removeControl(Control control, boolean fireEventIfFocusLost)
      Removes a control that was part of the selection process.
      Parameters:
      control - The control.
    • addSelectionChangedListener Link icon

      public void addSelectionChangedListener(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 ISelectionProvider
      Parameters:
      listener - A selection changed listener.
    • removeSelectionChangedListener Link icon

      public void removeSelectionChangedListener(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 ISelectionProvider
      Parameters:
      listener - A selection changed listener.
    • selectionChanged Link icon

      public void selectionChanged(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 ISelectionChangedListener
      Parameters:
      event - Event object describing the change.
    • fireCurrentSelection Link icon

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

      public void fireSelection(ISelection selection)
      Fires the selection to the listeners.
    • getSelection Link icon

      public ISelection getSelection()
      Returns the current selection for this provider.
      Specified by:
      getSelection in interface ISelectionProvider
      Returns:
      The current selection.
    • setSelection Link icon

      public void setSelection(ISelection selection)
      Sets the current selection for this selection provider.
      Specified by:
      setSelection in interface ISelectionProvider
      Parameters:
      selection - the new selection
    • focusGained Link icon

      public void focusGained(FocusEvent e)
      Focus gained.
      Specified by:
      focusGained in interface FocusListener
    • focusLost Link icon

      public void focusLost(FocusEvent e)
      Focus lost.
      Specified by:
      focusLost in interface FocusListener
    • getClipboardSelectionProvider Link icon

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

      public Control getCurrentControl()
      Gets the current control.
      Returns:
      The control in focus, or null for none.
    • modifyText Link icon

      public void modifyText(ModifyEvent e)
      Entry field control modification.
      Specified by:
      modifyText in interface ModifyListener
    • widgetSelected Link icon

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

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

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

      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 Link icon

      public void mouseDoubleClick(MouseEvent e)
      Specified by:
      mouseDoubleClick in interface MouseListener
    • mouseDown Link icon

      public void mouseDown(MouseEvent e)
      Specified by:
      mouseDown in interface MouseListener
    • mouseUp Link icon

      public void mouseUp(MouseEvent e)
      Specified by:
      mouseUp in interface MouseListener
    • keyPressed Link icon

      public void keyPressed(KeyEvent e)
      Specified by:
      keyPressed in interface KeyListener
    • keyReleased Link icon

      public void keyReleased(KeyEvent e)
      Specified by:
      keyReleased in interface KeyListener