Interface EditPartViewer
- All Superinterfaces:
- ISelectionProvider
- All Known Subinterfaces:
- GraphicalViewer
- All Known Implementing Classes:
- AbstractEditPartViewer,- GraphicalViewerImpl,- PaletteViewer,- ScrollingGraphicalViewer,- TreeViewer
Control that manages the
 EditParts. The viewer is responsible for the
 editpart lifecycle. Editparts have visuals, such as
 TreeItems or Figures, which are hosted by the
 viewer and its control. The viewer provides targeting of editparts via their
 visuals.
 
 A viewer is a ISelectionProvider. It
 maintains a list of selected editparts. The last member of this list is the
 primary member of the selection. The list should never be empty; when
 no editparts are selected, the viewer's contents editpart is used.
 
 A viewer is populated by setting its contents. This can be done by
 passing the model corresponding to the contents. The viewer's
 EditPartFactory is then used to
 create the contents editpart, and add it to the root editpart.
 Alternatively, the contents editpart itself can be provided. Once the
 contents editpart is parented, it will populate the rest of the viewer by
 calling its EditPart.refresh() method.
 
 The Root editpart does not correspond to anything in the model, it is used to
 bootstrap the viewer, and to parent the contents. Depending on the type of
 viewer being used, it may be common to replace the root editpart. See
 implementations of RootEditPart.
 
 An editpart's lifecycle is managed by the viewer. When the Viewer is
 realized, meaning it has an SWT Control, it activates its root,
 which in turn activates all editparts. Editparts are deactivated when they
 are removed from the viewer. When the viewer's control is disposed, all
 editparts are similarly deactivated by decativating the root.
 
 A Viewer has an arbitrary collection of keyed properties that can be set and
 queried. A value of null is used to remove a key from the
 property map. A viewer will fire property change notification whenever these
 values are updated.
 
 WARNING: This interface is not intended to be implemented. Clients should
 extend AbstractEditPartViewer.
- 
Nested Class SummaryNested ClassesModifier and TypeInterfaceDescriptionstatic interfaceAn object which evaluates an EditPart for an arbitrary property.
- 
Method SummaryModifier and TypeMethodDescriptionvoidDeprecated, for removal: This API element is subject to removal in a future version.voidAdds aTransferDragSourceListenerto this viewer.voidDeprecated, for removal: This API element is subject to removal in a future version.UseaddDragSourceListener(TransferDragSourceListener)instead.voidAdds aTransferDropTargetListenerto this viewer.voidAdds a listener to be notified of viewer property changes.voidappendSelection(EditPart editpart) Appends the specifiedEditPartto the viewer's selection.createControl(Composite composite) Optionally creates the defaultControlusing the default style.voidRemoves the specifiedEditPartfrom the current selection.voidDeselects all EditParts.findObjectAt(Point location) Returnsnullor theEditPartassociated with the specified location.findObjectAtExcluding(Point location, Collection<IFigure> exclusionSet) Returnsnullor theEditPartat the specified location, excluding the specified set.findObjectAtExcluding(Point location, Collection<IFigure> exclusionSet, EditPartViewer.Conditional conditional) Returnsnullor theEditPartat the specified location, using the given exclusion set and conditional.voidflush()Flushes all pending updates to the Viewer.Returns the contents of this Viewer.Returnsnullor the MenuManager for this viewer.Returnsnullor the SWTControlfor this viewer.Returns theEditDomainto which this viewer belongs.Returns theEditPartFactoryfor this viewer.getEditPartForModel(Object model) Convenience method to look up an edit part for a given model element in the EditPart registry.Returns theMapfor registeringEditPartsby Keys.Returns the focusEditPart.Returns theKeyHandlerfor this viewer.getProperty(String key) Returns the value of the given property.Returnsnull, or the ResourceManager for this Viewer.Returns theRootEditPart.Returns an unmodifiableListcontaining zero or more selected editparts.This method is inherited fromISelectionProvider.Returns the viewer's selection manager.Returns theMapfor associating visual parts with theirEditParts.voidUsed for accessibility purposes.voidDeprecated, for removal: This API element is subject to removal in a future version.UseremoveDragSourceListener(TransferDragSourceListener)instead.voidRemoves the specified drag source listener.voidDeprecated, for removal: This API element is subject to removal in a future version.UseremoveDropTargetListener(TransferDropTargetListener)instead.voidRemoves the specified drop target listener.voidremoves the first instance of the specified property listener.voidReveals the given EditPart if it is not visible.voidReplaces the current selection with the specifiedEditPart.voidsetContents(Object contents) Creates anEditPartfor the provided model object using theEditPartFactory.voidsetContents(EditPart editpart) Sets the contents for this Viewer.voidsetContextMenu(MenuManager contextMenu) Sets the contextMenuManagerfor this viewer.voidsetControl(Control control) Sets theControlfor this viewer.voidSets the cursor for the viewer'sControl.voidsetEditDomain(EditDomain domain) Sets theEditDomainfor this viewer.voidsetEditPartFactory(EditPartFactory factory) Sets the EditPartFactory.voidSets the focus EditPart.voidsetKeyHandler(KeyHandler keyHandler) Sets theKeyHandler.voidsetProperty(String propertyName, Object value) Sets a property on this viewer.voidsetRootEditPart(RootEditPart root) Sets the root of this viewer.voidsetRouteEventsToEditDomain(boolean value) Turns on/off the routing of events directly to the Editor.voidsetSelectionManager(SelectionManager manager) Sets the selection manager for this viewer.voidUsed for accessibility purposes.Methods inherited from interface org.eclipse.jface.viewers.ISelectionProvideraddSelectionChangedListener, removeSelectionChangedListener, setSelection
- 
Method Details- 
addDragSourceListener@Deprecated(since="3.21", forRemoval=true) void addDragSourceListener(TransferDragSourceListener listener) Deprecated, for removal: This API element is subject to removal in a future version.UseaddDragSourceListener(TransferDragSourceListener)instead. This method will be removed after the 2027-03 release.Provided for compatibility with existing code.- Parameters:
- listener- a drag source listener
- See Also:
 
- 
addDragSourceListenerAdds aTransferDragSourceListenerto this viewer. This has the side-effect of creating aDragSourceon the viewer's Control. A Control can only have a single DragSource. Clients must not create their own DragSource when using this method.- Parameters:
- listener- the listener
 
- 
addDropTargetListener@Deprecated(since="3.21", forRemoval=true) void addDropTargetListener(TransferDropTargetListener listener) Deprecated, for removal: This API element is subject to removal in a future version.UseaddDragSourceListener(TransferDragSourceListener)instead. This method will be removed after the 2027-03 release.Provided for compatibility with existing code.- Parameters:
- listener- the listener
- See Also:
 
- 
addDropTargetListenerAdds aTransferDropTargetListenerto this viewer. This has the side-effect of creating aDropTargeton the viewer's Control. A Control can only have a single DropTarget. Clients must not create their own DropTarget when using this method.- Parameters:
- listener- the listener
 
- 
addPropertyChangeListenerAdds a listener to be notified of viewer property changes.- Parameters:
- listener- the listener
 
- 
appendSelectionAppends the specifiedEditPartto the viewer's selection. The EditPart becomes the new primary selection. Fires selection changed to allISelectionChangedListeners.- Parameters:
- editpart- the EditPart to append
 
- 
createControlOptionally creates the defaultControlusing the default style. The Control can also be created externally and then set into the Viewer.- Parameters:
- composite- the parent in which create the SWT- Control
- Returns:
- the created Control for convenience
- See Also:
 
- 
deselectRemoves the specifiedEditPartfrom the current selection. If the selection becomes empty, the viewer'scontentsbecomes the current selected part. The last EditPart in the new selection is madeprimary.Fires selection changed to ISelectionChangedListeners.- Parameters:
- editpart- the- EditPartto deselect
 
- 
deselectAllvoid deselectAll()Deselects all EditParts. The viewer'scontentsbecomes the current selection. Fires selection changed toISelectionChangedListeners.
- 
findObjectAtReturnsnullor theEditPartassociated with the specified location. The location is relative to the client area of the Viewer'sControl. An EditPart is not directly visible. It is targeted using its visual part which it registered using thevisual part map. What constitutes a visual part is viewer-specific. Examples include Figures and TreeItems.- Parameters:
- location- The location
- Returns:
- nullor an EditPart
 
- 
findObjectAtExcludingReturnsnullor theEditPartat the specified location, excluding the specified set. This method behaves similarly tofindObjectAt(Point).- Parameters:
- location- The mouse location
- exclusionSet- The set of IFigures to be excluded
- Returns:
- nullor an EditPart
 
- 
findObjectAtExcludingEditPart findObjectAtExcluding(Point location, Collection<IFigure> exclusionSet, EditPartViewer.Conditional conditional) Returnsnullor theEditPartat the specified location, using the given exclusion set and conditional. This method behaves similarly tofindObjectAt(Point).- Parameters:
- location- The mouse location
- exclusionSet- The set of IFigures to be excluded
- conditional- the Conditional used to evaluate a potential hit
- Returns:
- nullor an EditPart
 
- 
flushvoid flush()Flushes all pending updates to the Viewer.
- 
getContentsEditPart getContents()Returns the contents of this Viewer. The contents is the EditPart associated with the top-level model object. It is considered to be "The Diagram". If the user has nothing selected, the contents is implicitly the selected object.The Root of the Viewer is different. By constrast, the root is never selected or targeted, and does not correspond to something in the model. - Returns:
- the contents EditPart
- See Also:
 
- 
getContextMenuMenuManager getContextMenu()Returnsnullor the MenuManager for this viewer. The menu manager is set usingsetContextMenu(MenuManager).- Returns:
- nullor a MenuManager
 
- 
getControlControl getControl()Returnsnullor the SWTControlfor this viewer. The control is either set explicitly or can be created by the viewer.- Returns:
- the SWT Control
- See Also:
 
- 
getEditDomainEditDomain getEditDomain()Returns theEditDomainto which this viewer belongs.- Returns:
- the viewer's EditDomain
 
- 
getEditPartFactoryEditPartFactory getEditPartFactory()Returns theEditPartFactoryfor this viewer. The EditPartFactory is used to create the contents EditPart whensetContents(Object)is called. It is made available so that other EditParts can use it to create their children or connection editparts.- Returns:
- EditPartFactory
 
- 
getEditPartRegistryReturns theMapfor registeringEditPartsby Keys. EditParts may register themselves using any method, and may register themselves with multiple keys. The purpose of such registration is to allow an EditPart to be found by other EditParts, or by listeners of domain notifiers. By default, EditParts are registered by their model.Some models use a "domain" notification system, in which all changes are dispatched to a single listener. Such a listener might use this map to lookup editparts for a given model, and then ask the editpart to update. - Returns:
- the registry map
 
- 
getEditPartForModelConvenience method to look up an edit part for a given model element in the EditPart registry. See alsogetEditPartRegistry()for details on the EditPart registry.- Parameters:
- model- the model object for which an EditPart is looked up
- Returns:
- the edit part or null if for the given model no EditPart is registered
- Since:
- 3.19
 
- 
getFocusEditPartEditPart getFocusEditPart()Returns the focusEditPart. Focus refers to keyboard focus. This is the same concept as focus in a native Tree or Table. The User can change focus using the keyboard without affecting the currently selected objects. Never returnsnull.- Returns:
- the focus EditPart
 
- 
getKeyHandlerKeyHandler getKeyHandler()Returns theKeyHandlerfor this viewer. The KeyHandler is sent KeyEvents by the currently activeTool. This is important, because only the current tool knows if it is in a state in which keys should be ignored, such as during a drag. By default, only theSelectionToolforwards keysrokes. It does not do so during a drag.- Returns:
- nullor a KeyHandler
 
- 
getPropertyReturns the value of the given property. Returnsnullif the property has not been set, or has been set to null.- Parameters:
- key- the property's key
- Returns:
- the given properties value or null.
 
- 
getResourceManagerResourceManager getResourceManager()Returnsnull, or the ResourceManager for this Viewer. Once a viewer has a Control, clients may access the viewer's resource manager. Any resources constructed using this manager, but not freed, will be freed when the viewer's control is disposed. This does not mean that clients should be lazy about deallocating resources. If a resource is no longer needed but the viewer is still in use, the client must deallocate the resource.Typical usage is by EditParts contained inside the viewer. EditParts which are removed from the viewer should free their resources during EditPart.removeNotify(). When the viewer is disposed,removeNotify()is not called, but the viewer's resource manager will be disposed anyway.The viewer's default resource manager is linked to JFace's global shared resources.- Returns:
- the ResourceManager associated with this viewer
- Since:
- 3.3
 
- 
getRootEditPartRootEditPart getRootEditPart()Returns theRootEditPart. The RootEditPart is a special EditPart that serves as the parent to the contents editpart. The root is never selected. The root does not correspond to anything in the model. The User does not interact with the root.The RootEditPart has a single child: the contents.By defining the concept of "root", GEF allows the application's "real" EditParts to be more homogeneous. For example, all non-root EditParts have a parent. Also, it allows applications to change the type of root being used without affecting their own editpart implementation hierarchy. - Returns:
- the RootEditPart
- See Also:
 
- 
getSelectedEditPartsReturns an unmodifiableListcontaining zero or more selected editparts. This list may be empty. In contrast, the inherited methodISelectionProvider.getSelection()should not return an empty selection. When no editparts are selected, generally the contents editpart is considered to be selected. This list can be modified indirectly by calling other methods on the viewer.- Returns:
- a list containing zero or more editparts
 
- 
getSelectionISelection getSelection()This method is inherited fromISelectionProvider. This method should return aStructuredSelectioncontaining one or more of the viewer's EditParts. If no editparts are selected, thecontentseditpart is returned.- Specified by:
- getSelectionin interface- ISelectionProvider
- See Also:
 
- 
getSelectionManagerSelectionManager getSelectionManager()Returns the viewer's selection manager. The selection manager has complete control over the viewer's representation of selection. It provides theISelectionfor the viewer, and manages all changes to the current selection.- Returns:
- the selection manager
- Since:
- 3.2
 
- 
getVisualPartMapReturns theMapfor associating visual parts with theirEditParts. This map is used for hit-testing. Hit testing is performed by first determining which visual part is hit, and then mapping that part to anEditPart. What constitutes a visual part is viewer-specific. Examples includeFiguresandTreeItems.- Returns:
- the visual part map
 
- 
registerAccessibleEditPartUsed for accessibility purposes.- Parameters:
- acc- the AccessibleEditPart
 
- 
removeDragSourceListener@Deprecated(since="3.0", forRemoval=true) void removeDragSourceListener(TransferDragSourceListener listener) Deprecated, for removal: This API element is subject to removal in a future version.UseremoveDragSourceListener(TransferDragSourceListener)instead. This method will be removed after the 2027-03 release.Removes the specified drag source listener. If all listeners are removed, the DragSource that was created will be disposed.- Parameters:
- listener- the listener
- See Also:
 
- 
removeDragSourceListenerRemoves the specified drag source listener. If all listeners are removed, the DragSource that was created will be disposed.- Parameters:
- listener- the listener
- See Also:
 
- 
removeDropTargetListener@Deprecated(since="3.0", forRemoval=true) void removeDropTargetListener(TransferDropTargetListener listener) Deprecated, for removal: This API element is subject to removal in a future version.UseremoveDropTargetListener(TransferDropTargetListener)instead. This method will be removed after the 2027-03 release.Removes the specified drop target listener. If all listeners are removed, the DropTarget that was created will be disposed.- Parameters:
- listener-
- See Also:
 
- 
removeDropTargetListenerRemoves the specified drop target listener. If all listeners are removed, the DropTarget that was created will be disposed.- Parameters:
- listener- the listener
- See Also:
 
- 
removePropertyChangeListenerremoves the first instance of the specified property listener.- Parameters:
- listener- the listener to remove
 
- 
revealReveals the given EditPart if it is not visible.- Parameters:
- editpart- the EditPart to reveal
 
- 
selectReplaces the current selection with the specifiedEditPart. That part becomes the primary selection. Fires selection changed toISelectionChangedListeners.- Parameters:
- editpart- the new selection
 
- 
setContentsSets the contents for this Viewer. The contents can also be set usingsetContents(Object).- Parameters:
- editpart- the contents
- See Also:
 
- 
setContentsCreates anEditPartfor the provided model object using theEditPartFactory. That EditPart is then added to theRootEditPart, and becomes the viewer's contents editpart.- Parameters:
- contents- the contents model object
 
- 
setContextMenuSets the contextMenuManagerfor this viewer. The MenuManager will be asked to create a Menu, which will be used as the context menu for this viewer's Control.- Parameters:
- contextMenu- the- ContextMenuProvider
 
- 
setControlSets theControlfor this viewer. The viewer's control is also set automatically ifcreateControl(Composite)is called.- Parameters:
- control- the Control
 
- 
setCursorSets the cursor for the viewer'sControl. This method should only be called byTools.nullcan be used to indicate that the default cursor should be restored.- Parameters:
- cursor-- nullor a Cursor
- See Also:
 
- 
setEditDomainSets theEditDomainfor this viewer. The Viewer will route all mouse and keyboard events to the EditDomain.- Parameters:
- domain- The EditDomain
 
- 
setEditPartFactorySets the EditPartFactory.- Parameters:
- factory- the factory
- See Also:
 
- 
setFocusSets the focus EditPart.- Parameters:
- focus- the FocusPart.
- See Also:
 
- 
setKeyHandlerSets theKeyHandler.- Parameters:
- keyHandler- the KeyHandler
- See Also:
 
- 
setPropertySets a property on this viewer. A viewer property is an arbitrary key-value pair that can be observed viaaddPropertyChangeListener(PropertyChangeListener). Anullvalue will remove the property from the viewer.- Parameters:
- propertyName- a unique string identifying the property
- value- the properties new value or- nullto remove
- Since:
- 3.0
 
- 
setRootEditPartSets the root of this viewer. The root should not be confused with the contents.- Parameters:
- root- the RootEditPart
- See Also:
 
- 
setRouteEventsToEditDomainvoid setRouteEventsToEditDomain(boolean value) Turns on/off the routing of events directly to the Editor. If supported by the viewer implementation, all Events should be routed to theEditDomainrather than handled in the default way.- Parameters:
- value- true if the viewer should route events to the EditDomain
 
- 
setSelectionManagerSets the selection manager for this viewer.- Parameters:
- manager- the new selection manager
- Since:
- 3.2
 
- 
unregisterAccessibleEditPartUsed for accessibility purposes.- Parameters:
- acc- the accessible part
 
 
- 
addDragSourceListener(TransferDragSourceListener)instead.