Eclipse GEF
2.1

org.eclipse.gef.ui.parts
Class AbstractEditPartViewer

java.lang.Object
  |
  +--org.eclipse.gef.ui.parts.AbstractEditPartViewer
All Implemented Interfaces:
EditPartViewer, ISelectionProvider
Direct Known Subclasses:
GraphicalViewerImpl, TreeViewer

public abstract class AbstractEditPartViewer
extends Object
implements EditPartViewer


Nested Class Summary
 
Nested classes inherited from class org.eclipse.gef.EditPartViewer
EditPartViewer.Conditional
 
Field Summary
protected  List constantSelection
           
protected  List selection
           
protected  List selectionListeners
           
 
Constructor Summary
AbstractEditPartViewer()
           
 
Method Summary
 void addDragSourceListener(TransferDragSourceListener listener)
          Adds a TransferDragSourceListener to this viewer.
 void addDropTargetListener(TransferDropTargetListener listener)
          Adds a TransferDropTargetListener to this viewer.
 void addSelectionChangedListener(ISelectionChangedListener listener)
           
 void appendSelection(EditPart editpart)
          Appends the specified EditPart to the Viewer's selection.
abstract  Control createControl(Composite parent)
          This assumes that the subclass has created the control and simply returns the current control.
 void deselect(EditPart editpart)
          Removes the specified EditPart from the current selection.
 void deselectAll()
          Deselects all EditParts.
 EditPart findObjectAt(org.eclipse.draw2d.geometry.Point pt)
          Returns null or the EditPart associated with the specified location.
 EditPart findObjectAtExcluding(org.eclipse.draw2d.geometry.Point pt, Collection exclude)
          Returns null or the EditPart at the specified location, excluding the specified set.
protected  void fireSelectionChanged()
          Fires selection changed to the registered listeners at the time called.
 void flush()
          Flushes all pending updates to the Viewer.
 EditPart getContents()
          Returns the contents of this Viewer.
 MenuManager getContextMenu()
          Returns the MenuManager for this viewer or null if no provider exists.
 Control getControl()
          Returns the SWT Control for this viewer.
protected  DelegatingDragAdapter getDelegatingDragAdapter()
           
protected  DelegatingDropAdapter getDelegatingDropAdapter()
           
protected  DragSource getDragSource()
           
protected  DropTarget getDropTarget()
           
 EditDomain getEditDomain()
          Returns the EditDomain to which this viewer belongs
 EditPartFactory getEditPartFactory()
          Returns the EditPartFactory for this viewer.
 Map getEditPartRegistry()
          Returns the Map for registering EditParts by Keys.
 EditPart getFocusEditPart()
          Returns the focus EditPart.
 KeyHandler getKeyHandler()
          Returns the KeyHandler for this viewer.
 RootEditPart getRootEditPart()
          Returns the RootEditPart.
 List getSelectedEditParts()
          Returns an unmodifiable List containing the selected editparts.
 ISelection getSelection()
           
 Map getVisualPartMap()
          Returns the Map for associating visual parts with their EditParts.
protected  void handleDispose(DisposeEvent e)
          Called if and when the Control is disposed.
protected  void hookControl()
           
protected  void hookDragSource()
           
protected  void hookDropTarget()
           
protected  void init()
           
protected  List primGetSelectedEditParts()
           
protected  void refreshDragSourceAdapter()
           
protected  void refreshDropTargetAdapter()
           
 void registerAccessibleEditPart(AccessibleEditPart acc)
          Used for accessibility purposes.
 void removeDragSourceListener(TransferDragSourceListener listener)
           
 void removeDropTargetListener(TransferDropTargetListener listener)
           
 void removeSelectionChangedListener(ISelectionChangedListener l)
           
 void reveal(EditPart part)
          Shows the given EditPart if it is not visible.
 void select(EditPart editpart)
          Replaces the current selection with the specified EditPart.
 void setContents(EditPart editpart)
          Sets the for this Viewer.
 void setContents(Object contents)
          Creates an EditPart for the specified contents using this viewer's EditPartFactory.
 void setContextMenu(MenuManager manager)
          Sets the MenuManager for this viewer's context menu.
 void setControl(Control control)
          Optionally sets the Control for this viewer.
 void setCursor(Cursor cursor)
          Sets the cursor for the viewer's Control.
protected  void setDragSource(DragSource source)
           
protected  void setDropTarget(DropTarget target)
          Sets the dropTarget.
 void setEditDomain(EditDomain editdomain)
          Sets the EditDomain for this viewer.
 void setEditPartFactory(EditPartFactory factory)
          Sets the EditPartFactory.
 void setFocus(EditPart part)
          Sets the focus EditPart.
 void setKeyHandler(KeyHandler handler)
          Sets the KeyHandler.
 void setRootEditPart(RootEditPart editpart)
          Sets the root of this viewer.
 void setRouteEventsToEditDomain(boolean value)
          Turns on/off the routing of events directly to the Editor.
 void setSelection(ISelection newSelection)
          This method will clear the current selection, and set the given ISelection as the current selection.
protected  void unhookControl()
           
 void unregisterAccessibleEditPart(AccessibleEditPart acc)
          Used for accessibility purposes
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.eclipse.gef.EditPartViewer
findObjectAtExcluding
 

Field Detail

selection

protected final List selection

constantSelection

protected final List constantSelection

selectionListeners

protected List selectionListeners
Constructor Detail

AbstractEditPartViewer

public AbstractEditPartViewer()
Method Detail

addSelectionChangedListener

public void addSelectionChangedListener(ISelectionChangedListener listener)
Specified by:
addSelectionChangedListener in interface ISelectionProvider

addDragSourceListener

public void addDragSourceListener(TransferDragSourceListener listener)
Description copied from interface: EditPartViewer
Adds a TransferDragSourceListener to this viewer. This has the side-effect of ensuring that a DragSource exists for the viewer's Control.

Specified by:
addDragSourceListener in interface EditPartViewer
Parameters:
listener - the listener

addDropTargetListener

public void addDropTargetListener(TransferDropTargetListener listener)
Description copied from interface: EditPartViewer
Adds a TransferDropTargetListener to this viewer. This has the side-effect of ensuring that a DropTarget exists for the viewer's Control.

Specified by:
addDropTargetListener in interface EditPartViewer
Parameters:
listener - the listener

appendSelection

public void appendSelection(EditPart editpart)
Description copied from interface: EditPartViewer
Appends the specified EditPart to the Viewer's selection. The EditPart becomes the new primary selection. Fires selection changed to allISelectionChangedListeners.

Specified by:
appendSelection in interface EditPartViewer
Parameters:
editpart - the EditPart to append

createControl

public abstract Control createControl(Composite parent)
This assumes that the subclass has created the control and simply returns the current control. When overriding this method, call setControl(Control) with the newly created control and then call super.createControl(Composite).

Specified by:
createControl in interface EditPartViewer
Parameters:
parent - the parent in which create the SWT Control
Returns:
the created Control for convenience
See Also:
EditPartViewer.setControl(Control)

deselect

public void deselect(EditPart editpart)
Description copied from interface: EditPartViewer
Removes the specified EditPart from the current selection. If the selection becomes empty, the viewer's contents becomes the current selected part. The last EditPart in the new selection is made primary.

Fires selection changed to ISelectionChangedListeners.

Specified by:
deselect in interface EditPartViewer
Parameters:
editpart - the EditPart to deselect

deselectAll

public void deselectAll()
Description copied from interface: EditPartViewer
Deselects all EditParts. The viewer's contents becomes the current selection. Fires selection changed to ISelectionChangedListeners.

Specified by:
deselectAll in interface EditPartViewer

handleDispose

protected void handleDispose(DisposeEvent e)
Called if and when the Control is disposed. Subclasses may extend this method to perform additional cleanup.

Parameters:
e - the disposeevent

findObjectAt

public final EditPart findObjectAt(org.eclipse.draw2d.geometry.Point pt)
Description copied from interface: EditPartViewer
Returns null or the EditPart associated with the specified location. The location is relative to the client area of the Viewer's Control. An EditPart is not directly visible. It is targeted using its visual part which it registered using the visual part map. What constitutes a visual part is viewer-specific. Examples include Figures and TreeItems.

Specified by:
findObjectAt in interface EditPartViewer
Parameters:
pt - The location
Returns:
null or an EditPart
See Also:
EditPartViewer.findObjectAt(Point)

findObjectAtExcluding

public final EditPart findObjectAtExcluding(org.eclipse.draw2d.geometry.Point pt,
                                            Collection exclude)
Description copied from interface: EditPartViewer
Returns null or the EditPart at the specified location, excluding the specified set. This method behaves similarly to EditPartViewer.findObjectAt(Point).

Specified by:
findObjectAtExcluding in interface EditPartViewer
Parameters:
pt - The mouse location
exclude - The set of EditParts to be excluded
Returns:
null or an EditPart
See Also:
EditPartViewer.findObjectAtExcluding(Point, Collection)

fireSelectionChanged

protected void fireSelectionChanged()
Fires selection changed to the registered listeners at the time called.


flush

public void flush()
Description copied from interface: EditPartViewer
Flushes all pending updates to the Viewer.

Specified by:
flush in interface EditPartViewer
See Also:
EditPartViewer.flush()

getContextMenu

public MenuManager getContextMenu()
Description copied from interface: EditPartViewer
Returns the MenuManager for this viewer or null if no provider exists.

Specified by:
getContextMenu in interface EditPartViewer
Returns:
the MenuManager
See Also:
EditPartViewer.getContextMenu()

getContents

public EditPart getContents()
Description copied from interface: EditPartViewer
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.

Specified by:
getContents in interface EditPartViewer
Returns:
the contents EditPart
See Also:
EditPartViewer.getContents()

getControl

public Control getControl()
Description copied from interface: EditPartViewer
Returns the SWT Control for this viewer.

Specified by:
getControl in interface EditPartViewer
Returns:
the SWT Control
See Also:
EditPartViewer.getControl()

getDelegatingDragAdapter

protected DelegatingDragAdapter getDelegatingDragAdapter()

getDelegatingDropAdapter

protected DelegatingDropAdapter getDelegatingDropAdapter()

getDragSource

protected DragSource getDragSource()

getDropTarget

protected DropTarget getDropTarget()

getEditDomain

public EditDomain getEditDomain()
Description copied from interface: EditPartViewer
Returns the EditDomain to which this viewer belongs

Specified by:
getEditDomain in interface EditPartViewer
Returns:
the EditDomain

getEditPartFactory

public EditPartFactory getEditPartFactory()
Description copied from interface: EditPartViewer
Returns the EditPartFactory for this viewer. The EditPartFactory is used to create the contents EditPart when EditPartViewer.setContents(Object) is called. It is then used by all EditParts that need to create additional EditParts, such as children.

Specified by:
getEditPartFactory in interface EditPartViewer
Returns:
EditPartFactory

getEditPartRegistry

public Map getEditPartRegistry()
Description copied from interface: EditPartViewer
Returns the Map for registering EditParts by Keys. EditParts may register themselves using any method, and may register themselved multiple times. The purpose of such registration is to allow an EditPart to be found by other EditParts.

Specified by:
getEditPartRegistry in interface EditPartViewer
Returns:
the registry map

getFocusEditPart

public EditPart getFocusEditPart()
Description copied from interface: EditPartViewer
Returns the focus EditPart. 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.

Specified by:
getFocusEditPart in interface EditPartViewer
Returns:
the focus EditPart

getKeyHandler

public KeyHandler getKeyHandler()
Description copied from interface: EditPartViewer
Returns the KeyHandler for this viewer. The KeyHandler is forwarded keys by the active Tool. 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 the SelectionTool forwards keysrokes. It does not do so during a drag.

Specified by:
getKeyHandler in interface EditPartViewer
Returns:
KeyHandler

getRootEditPart

public RootEditPart getRootEditPart()
Description copied from interface: EditPartViewer
Returns the RootEditPart. The RootEditPart is a special EditPart that bridges the connection to the viewer. 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.

Specified by:
getRootEditPart in interface EditPartViewer
Returns:
the RootEditPart
See Also:
EditPartViewer.getContents(), EditPartViewer.setRootEditPart(RootEditPart)

getSelectedEditParts

public List getSelectedEditParts()
Description copied from interface: EditPartViewer
Returns an unmodifiable List containing the selected editparts.

Specified by:
getSelectedEditParts in interface EditPartViewer
Returns:
the selected parts

getSelection

public ISelection getSelection()
Specified by:
getSelection in interface ISelectionProvider

getVisualPartMap

public Map getVisualPartMap()
Description copied from interface: EditPartViewer
Returns the Map for associating visual parts with their EditParts. 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 an EditPart. What consistutes a visual part is viewer-specific. Examples include Figures and TreeItems.

Specified by:
getVisualPartMap in interface EditPartViewer
Returns:
the visual part Map

hookControl

protected void hookControl()

hookDragSource

protected void hookDragSource()

hookDropTarget

protected void hookDropTarget()

init

protected void init()

primGetSelectedEditParts

protected List primGetSelectedEditParts()

refreshDragSourceAdapter

protected void refreshDragSourceAdapter()

refreshDropTargetAdapter

protected void refreshDropTargetAdapter()

registerAccessibleEditPart

public void registerAccessibleEditPart(AccessibleEditPart acc)
Description copied from interface: EditPartViewer
Used for accessibility purposes.

Specified by:
registerAccessibleEditPart in interface EditPartViewer
Parameters:
acc - the AccessibleEditPart

removeDragSourceListener

public void removeDragSourceListener(TransferDragSourceListener listener)

removeDropTargetListener

public void removeDropTargetListener(TransferDropTargetListener listener)

removeSelectionChangedListener

public void removeSelectionChangedListener(ISelectionChangedListener l)
Specified by:
removeSelectionChangedListener in interface ISelectionProvider

reveal

public void reveal(EditPart part)
Description copied from interface: EditPartViewer
Shows the given EditPart if it is not visible.

Specified by:
reveal in interface EditPartViewer
Parameters:
part - the EditPart to reveal
See Also:
EditPartViewer.reveal(EditPart)

select

public void select(EditPart editpart)
Description copied from interface: EditPartViewer
Replaces the current selection with the specified EditPart. That part becomes the primary selection.

Fires selection changed to ISelectionChangedListeners.

Specified by:
select in interface EditPartViewer
Parameters:
editpart - the new selection

setContextMenu

public void setContextMenu(MenuManager manager)
Description copied from interface: EditPartViewer
Sets the MenuManager for this viewer's context menu. This MenuManager creates the SWT Menu for this viewer's control.

Specified by:
setContextMenu in interface EditPartViewer
Parameters:
manager - the ContextMenuProvider
See Also:
EditPartViewer.getControl()

setContents

public void setContents(EditPart editpart)
Description copied from interface: EditPartViewer
Sets the for this Viewer.

Specified by:
setContents in interface EditPartViewer
See Also:
EditPartViewer.getRootEditPart()

setContents

public void setContents(Object contents)
Description copied from interface: EditPartViewer
Creates an EditPart for the specified contents using this viewer's EditPartFactory. That EditPart is then added to the RootEditPart.

Specified by:
setContents in interface EditPartViewer
Parameters:
contents - the Object representing the viewer's contents
See Also:
EditPartViewer.setEditPartFactory(EditPartFactory)

setControl

public void setControl(Control control)
Description copied from interface: EditPartViewer
Optionally sets the Control for this viewer. The viewer's control is also set automatically if EditPartViewer.createControl(Composite) is called.

Specified by:
setControl in interface EditPartViewer
Parameters:
control - the Control

setCursor

public void setCursor(Cursor cursor)
Description copied from interface: EditPartViewer
Sets the cursor for the viewer's Control. This method should only be called by Tools. null can be used to indicate that the default cursor should be restored.

Specified by:
setCursor in interface EditPartViewer
Parameters:
cursor - null or a Cursor
See Also:
EditPartViewer.getControl()

setDragSource

protected void setDragSource(DragSource source)

setDropTarget

protected void setDropTarget(DropTarget target)
Sets the dropTarget.


setEditDomain

public void setEditDomain(EditDomain editdomain)
Description copied from interface: EditPartViewer
Sets the EditDomain for this viewer. The Viewer will route all mouse and keyboard events to the EditDomain.

Specified by:
setEditDomain in interface EditPartViewer
Parameters:
editdomain - The EditDomain

setEditPartFactory

public void setEditPartFactory(EditPartFactory factory)
Description copied from interface: EditPartViewer
Sets the EditPartFactory.

Specified by:
setEditPartFactory in interface EditPartViewer
Parameters:
factory - the factory
See Also:
EditPartViewer.getEditPartFactory()

setFocus

public void setFocus(EditPart part)
Description copied from interface: EditPartViewer
Sets the focus EditPart.

Specified by:
setFocus in interface EditPartViewer
Parameters:
part - the FocusPart.
See Also:
EditPartViewer.getFocusEditPart()

setKeyHandler

public void setKeyHandler(KeyHandler handler)
Description copied from interface: EditPartViewer
Sets the KeyHandler.

Specified by:
setKeyHandler in interface EditPartViewer
Parameters:
handler - the KeyHandler
See Also:
EditPartViewer.getKeyHandler()

setRootEditPart

public void setRootEditPart(RootEditPart editpart)
Description copied from interface: EditPartViewer
Sets the root of this viewer. The root should not be confused with the contents.

Specified by:
setRootEditPart in interface EditPartViewer
Parameters:
editpart - the RootEditPart
See Also:
EditPartViewer.getRootEditPart(), EditPartViewer.getContents()

setRouteEventsToEditDomain

public void setRouteEventsToEditDomain(boolean value)
Description copied from interface: EditPartViewer
Turns on/off the routing of events directly to the Editor. If supported by the viewer implementation, all Events should be routed to the EditDomain rather than handled in the default way.

Specified by:
setRouteEventsToEditDomain in interface EditPartViewer
Parameters:
value - true if the viewer should route events to the EditDomain

setSelection

public void setSelection(ISelection newSelection)
This method will clear the current selection, and set the given ISelection as the current selection. It will do so without firing a selection-change event. NOTE: If the given argument is not an IStructuredSelection, this method will do nothing.

Specified by:
setSelection in interface ISelectionProvider

unhookControl

protected void unhookControl()

unregisterAccessibleEditPart

public void unregisterAccessibleEditPart(AccessibleEditPart acc)
Description copied from interface: EditPartViewer
Used for accessibility purposes

Specified by:
unregisterAccessibleEditPart in interface EditPartViewer
Parameters:
acc - the accessible part

Eclipse GEF
2.1

Copyright (c) IBM Corp. and others 2000, 2003. All Rights Reserved.