Package com.iizigo.editor
Class MultiSelectionProvider
java.lang.Object
com.iizigo.editor.MultiSelectionProvider
- All Implemented Interfaces:
EventListener,ISelectionChangedListener,ISelectionProvider,CaretListener,DisposeListener,FocusListener,KeyListener,ModifyListener,MouseListener,SelectionListener,SWTEventListener
public class MultiSelectionProvider extends Object implements ISelectionProvider, DisposeListener, FocusListener, ISelectionChangedListener, ModifyListener, KeyListener, MouseListener, SelectionListener, 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
ConstructorsConstructorDescriptionCreates the instance without a default provider.MultiSelectionProvider(ISelectionProvider defaultProvider) Creates the instance with a default provider.Method Summary
Modifier and TypeMethodDescriptionvoidaddComposite(Composite composite, ISelectionProvider selectionProvider) Adds a composite that is part of the selection process.voidaddControl(Control control) Adds a control that is part of the selection process.voidaddControl(Control control, ISelectionProvider selectionProvider) Adds a control that is part of the selection process.voidAdds a listener for selection changes in this selection provider.voidcaretMoved(CaretEvent event) This method is called after the caret offset is changed.voiddispose()Disposes of the selection provider.voidFires the current selection to the listeners.voidfireSelection(ISelection selection) Fires the selection to the listeners.voidFires the selection asynchronously.voidFocus gained.voidFocus lost.Gets the current IClipboardSelection interface for the current control.Gets the current control.Returns the current selection for this provider.static TextViewergetTextViewer(StyledText styledText) Gets the text viewer for a StyledText control.voidvoidvoidEntry field control modification.voidvoidvoidvoidDrag finished, called by the part when all drags complete.voidonPartActivated(boolean isActive) Clears the current focus control due to part inactivation.static voidregisterViewer(TextViewer viewer) Registers the TextViewer or similar (e.g.voidremoveControl(Control control, boolean fireEventIfFocusLost) Removes a control that was part of the selection process.voidRemoves the given selection change listener from this selection provider.voidNotifies that the selection has changed.voidsetDefaultProvider(ISelectionProvider defaultProvider) Sets the default provider when no provider is found for a control.voidsetDraggingFix(IDraggingFix dragFixer) Sets the dragging fix interface.voidMarks the selection provider as initialized on the owner side, i.e.voidsetSelection(ISelection selection) Sets the current selection for this selection provider.voidSent when default selection occurs in the control.voidCalled when a widget is disposed of.voidSent when selection occurs in the control.
Constructor Details
MultiSelectionProvider
public MultiSelectionProvider()Creates the instance without a default provider.MultiSelectionProvider
Creates the instance with a default provider.
Method Details
registerViewer
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
Gets the text viewer for a StyledText control.- Parameters:
styledText- The styled text control.- Returns:
- The text viewer, or null for none.
setDefaultProvider
Sets the default provider when no provider is found for a control.dispose
public void dispose()Disposes of the selection provider.setDraggingFix
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
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
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
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
selectionProviderimplements the interfaceIClipboardSelectionthis interface can be returned with the methodgetClipboardSelectionProvider().
widgetDisposed
Called when a widget is disposed of.- Specified by:
widgetDisposedin interfaceDisposeListener
removeControl
Removes a control that was part of the selection process.- Parameters:
control- The control.
addSelectionChangedListener
Adds a listener for selection changes in this selection provider. Has no effect if an identical listener is already registered.- Specified by:
addSelectionChangedListenerin interfaceISelectionProvider- Parameters:
listener- A selection changed listener.
removeSelectionChangedListener
Removes the given selection change listener from this selection provider. Has no effect if an identical listener is not registered.- Specified by:
removeSelectionChangedListenerin interfaceISelectionProvider- Parameters:
listener- A selection changed listener.
selectionChanged
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:
selectionChangedin interfaceISelectionChangedListener- Parameters:
event- Event object describing the change.
fireCurrentSelection
public void fireCurrentSelection()Fires the current selection to the listeners.fireSelection
Fires the selection to the listeners.getSelection
Returns the current selection for this provider.- Specified by:
getSelectionin interfaceISelectionProvider- Returns:
- The current selection.
setSelection
Sets the current selection for this selection provider.- Specified by:
setSelectionin interfaceISelectionProvider- Parameters:
selection- the new selection
focusGained
Focus gained.- Specified by:
focusGainedin interfaceFocusListener
focusLost
Focus lost.- Specified by:
focusLostin interfaceFocusListener
getClipboardSelectionProvider
Gets the current IClipboardSelection interface for the current control.- Returns:
- null If not available.
getCurrentControl
Gets the current control.- Returns:
- The control in focus, or null for none.
modifyText
Entry field control modification.- Specified by:
modifyTextin interfaceModifyListener
widgetSelected
Sent when selection occurs in the control.- Specified by:
widgetSelectedin interfaceSelectionListener- Parameters:
e- An event containing information about the selection.
widgetDefaultSelected
Sent when default selection occurs in the control.- Specified by:
widgetDefaultSelectedin interfaceSelectionListener- Parameters:
e- An event containing information about the default selection.
caretMoved
This method is called after the caret offset is changed.- Specified by:
caretMovedin interfaceCaretListener- Parameters:
event- The given event.- See Also:
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
- Specified by:
mouseDoubleClickin interfaceMouseListener
mouseDown
- Specified by:
mouseDownin interfaceMouseListener
mouseUp
- Specified by:
mouseUpin interfaceMouseListener
keyPressed
- Specified by:
keyPressedin interfaceKeyListener
keyReleased
- Specified by:
keyReleasedin interfaceKeyListener