Package org.eclipse.gef.ui.parts
Class SelectionSynchronizer
java.lang.Object
org.eclipse.gef.ui.parts.SelectionSynchronizer
- All Implemented Interfaces:
- ISelectionChangedListener
A utility for synchronizing the selection of multiple EditPartViewers. This
 class performs selection synchronization by taking the selection from one
 viewer, and mapping it to the selection in another viewer. The mapping is
 performed by matching the models of the selected EditParts from one viewer to
 the EditParts with the same models in another. It can be customized by
 overriding the 
convert(EditPartViewer, EditPart) method.- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionvoidaddViewer(EditPartViewer viewer) Adds a viewer to the set of synchronized viewersprotected voidapplySelection(EditPartViewer viewer, ISelection selection) Applies the given EditPart selection from another viewer to the given viewer.protected EditPartconvert(EditPartViewer viewer, EditPart part) Maps the given editpart from one viewer to an editpart in another viewer.voidremoveViewer(EditPartViewer viewer) Removes the viewer from the set of synchronized viewersvoidReceives notification from one viewer, and maps selection to all other members.voidsetEnabled(boolean value) Enables or disabled synchronization between viewers.protected voidsyncSelection(EditPartViewer selectionSource, ISelection selection) Synchronizes the given selection to all registered viewers except the one serving as selectionSource, by delegating toapplySelection(EditPartViewer, ISelection).
- 
Constructor Details- 
SelectionSynchronizerpublic SelectionSynchronizer()
 
- 
- 
Method Details- 
addViewerAdds a viewer to the set of synchronized viewers- Parameters:
- viewer- the viewer
 
- 
convertMaps the given editpart from one viewer to an editpart in another viewer. It returnsnullif there is no corresponding part. This method can be overridden to provide custom mapping.- Parameters:
- viewer- the viewer being mapped to
- part- a part from another viewer
- Returns:
- nullor a corresponding editpart
 
- 
removeViewerRemoves the viewer from the set of synchronized viewers- Parameters:
- viewer- the viewer to remove
 
- 
selectionChangedReceives notification from one viewer, and maps selection to all other members.- Specified by:
- selectionChangedin interface- ISelectionChangedListener
- Parameters:
- event- the selection event
 
- 
syncSelectionSynchronizes the given selection to all registered viewers except the one serving as selectionSource, by delegating toapplySelection(EditPartViewer, ISelection).- Parameters:
- selectionSource- The viewer from which the selection originated.
- selection- The selection to apply to the other viewers.
- Since:
- 3.10
 
- 
setEnabledpublic void setEnabled(boolean value) Enables or disabled synchronization between viewers.- Parameters:
- value-- trueif synchronization should occur
- Since:
- 3.1
 
- 
applySelectionApplies the given EditPart selection from another viewer to the given viewer. It will first compute a new selection ofEditParts for the given viewer by searching those that control the same model elements as theEditParts in the given selection (viaconvert(EditPartViewer, EditPart)), apply this new selection to the given viewer, and reveal the last part in the new selection.- Parameters:
- viewer- The viewer to apply the given selection to.
- selection- The selection to apply, which has to be an- IStructuredSelectionof- EditParts of another viewer.
- Since:
- 3.10
 
 
-