GEF v2.0

org.eclipse.gef
Interface EditPart

All Superinterfaces:
IAdaptable
All Known Subinterfaces:
ConnectionEditPart, GraphicalEditPart, NodeEditPart, RootEditPart, TreeEditPart
All Known Implementing Classes:
AbstractEditPart

public interface EditPart
extends IAdaptable

EditParts are the conceptual objects that populate an EditPartViewer. An EditPart ties together the application's model, a visual representation of some type, and all editing behavior. It can be composed of or have references to other EditParts.

The creator of an EditPart should call only setModel(Object). The remaining API is used mostly by Tools, EditPolicies, and other EditParts. CHANGES are made to the model, not the EditPart. Most interaction with EditParts is acheived using Requests. A Request specifies the type of interaction, and is used in targeting, filtering, graphical feedback, and most importantly, obtaining commands. Only Commands should change the model.


Field Summary
static int SELECTED
          Used to indicate non-primary selection
static int SELECTED_NONE
          Used to indicate no selection
static int SELECTED_PRIMARY
          Used to indicate primary selection, or "Anchor" selection.
 
Method Summary
 void activate()
          Indicates that editing has begun and the model may start changing.
 void addEditPartListener(EditPartListener listener)
          Adds a listener to the EditPart.
 void deactivate()
          Called by the managing EditPart(s).
 void dispose()
          Called when the EditPart will no longer be used.
 void eraseSourceFeedback(Request request)
          Erases feedback for which this EditPart is the source.
 void eraseTargetFeedback(Request request)
          Erase feedback for which this Editpart is the target.
 List getChildren()
          Returns the children for this EditPart.
 Command getCommand(Request request)
          Returns the command to perform the given Request or null.
 DragTracker getDragTracker(Request request)
          Return a drag tracker for dragging this EditPart.
 EditPolicy getEditPolicy(Object key)
          Returns null or the EditPolicy installed with the given key.
 KeyHandler getKeyHandler()
          Returns the KeyHandler for this EditPart or null.
 Object getModel()
          Return the primary model object that this EditPart represents.
 EditPart getParent()
          Returns the parent of this editpart.
 RootEditPart getRoot()
          Returns the root EditPart.
 int getSelected()
          Returns the selected state of this EditPart.
 EditPart getTargetEditPart(Request request)
          Return the editpart that should be used as the target for the Request.
 boolean hasFocus()
          Returns true if this EditPart has focus.
 void installEditPolicy(Object role, EditPolicy ep)
          installs an EditPolicy for a certain editing role.
 void performRequest(Request request)
          Performs the specified Request.
 void refresh()
          Called to force a refresh of all properties displayed by this EditPart.
 void removeEditPartListener(EditPartListener listener)
          Removes the first entry for that listener in the list of listeners.
 void removeEditPolicy(Object role)
          Removes the EditPolicy for the given role, if found.
 void setFocus(boolean hasFocus)
          Tells the EditPart whether it is the focus owner.
 void setModel(Object model)
          Sets the model.
 void setParent(EditPart parent)
           Sets the parent.
 void setSelected(int value)
           Sets the selected state.
 void showSourceFeedback(Request request)
          Shows or updates source feedback for the given request.
 void showTargetFeedback(Request request)
          Shows or updates target feedback for the given request.
 boolean understandsRequest(Request request)
          Returns true if editpart understands the given Request.
 
Methods inherited from interface org.eclipse.core.runtime.IAdaptable
getAdapter
 

Field Detail

SELECTED_NONE

public static final int SELECTED_NONE
Used to indicate no selection

SELECTED

public static final int SELECTED
Used to indicate non-primary selection

SELECTED_PRIMARY

public static final int SELECTED_PRIMARY
Used to indicate primary selection, or "Anchor" selection. Primary selection is defined as the last object selected.
Method Detail

activate

public void activate()
Indicates that editing has begun and the model may start changing. Called by the managing EditPart. The managing edit part may call activate() and then deactivate() multiple times on the receiver.

Activiation should initiate several things. First, the EditPart should begin to observe its model if appropriate, and should continue the observation until deactivate() is called. The EditPart should create and activate all of its EditPolicies. EditPolicies may also observe the model, and should also stop observing when deactivated. Any EditParts managed by this EditPart should also be activated.


addEditPartListener

public void addEditPartListener(EditPartListener listener)
Adds a listener to the EditPart. Duplicate calls result in duplicate notification.

deactivate

public void deactivate()
Called by the managing EditPart(s). The managing EditPart(s) may call activate() and then deactivate() multiple times on the receiver. The EditPart should unhook all listeners to the model, and should deactivate its EditPolicies. It may be reactivated later. The EditPart should deactivate all EditParts that it manages.

dispose

public void dispose()
Called when the EditPart will no longer be used. The EditPart should perform cleanup that cannot be performed in deactivate(), such as unregistering itself from the Viewer.

eraseSourceFeedback

public void eraseSourceFeedback(Request request)
Erases feedback for which this EditPart is the source. This method may be called several times due to some lazy code in the provided tools.

eraseTargetFeedback

public void eraseTargetFeedback(Request request)
Erase feedback for which this Editpart is the target. This method may be called several times due to some lazy code in the provided tools.

getChildren

public List getChildren()
Returns the children for this EditPart. This method should rarely be called, and is only made public so that helper objects of this EditPart, such as EditPolicies, can obtain the children.

getCommand

public Command getCommand(Request request)
Returns the command to perform the given Request or null.

getDragTracker

public DragTracker getDragTracker(Request request)
Return a drag tracker for dragging this EditPart. The SelectionTool makes such requests, but other Tools may also do so.

getEditPolicy

public EditPolicy getEditPolicy(Object key)
Returns null or the EditPolicy installed with the given key.

getKeyHandler

public KeyHandler getKeyHandler()
Returns the KeyHandler for this EditPart or null.

getModel

public Object getModel()
Return the primary model object that this EditPart represents. EditParts may correspond to more than one model object, or even no mode object. In practice, the Object returned is simply used to identify this EditPart. In addition, EditPolicies can call this method to set parameters for Commands being returned.

getParent

public EditPart getParent()
Returns the parent of this editpart. This method should only be called internally or by helpers such as edit policies.

getRoot

public RootEditPart getRoot()
Returns the root EditPart. This method should only be called internally or by helpers such as edit policies.

getSelected

public int getSelected()
Returns the selected state of this EditPart. This method should only be called internally or by helpers such as edit policies.

getTargetEditPart

public EditPart getTargetEditPart(Request request)
Return the editpart that should be used as the target for the Request. Tools will generally call this method will the mouse location so that the receiver can implement drop targeting. Typically, if this EditPart is not the requested target (for example, this EditPart is not a composite), it will forward the call to its parent.

hasFocus

public boolean hasFocus()
Returns true if this EditPart has focus.

installEditPolicy

public void installEditPolicy(Object role,
                              EditPolicy ep)
installs an EditPolicy for a certain editing role. An example role might be a connection node. A node editpolicy would be responsible for understanding requests to manipulate and create connections. null is a valid value for reserving

performRequest

public void performRequest(Request request)
Performs the specified Request. This method can be used to send a generic message to an EditPart. It is bad practice to use the API as a way to make changes to the model. Commands should be used to modify the model.

refresh

public void refresh()
Called to force a refresh of all properties displayed by this EditPart.

removeEditPartListener

public void removeEditPartListener(EditPartListener listener)
Removes the first entry for that listener in the list of listeners. Does nothing if the listener was not present.

removeEditPolicy

public void removeEditPolicy(Object role)
Removes the EditPolicy for the given role, if found. If the EditPolicy is not null, it is deactivated. The slot for that role is maintained with null in the place of the old policy.

setFocus

public void setFocus(boolean hasFocus)
Tells the EditPart whether it is the focus owner. Changes in focus are notified using EditPartListener.selectedStateChanged(EditPart).

setModel

public void setModel(Object model)
Sets the model. This method is made public to facilitate the use of EditPart factories. It should only be called by the creator of this EditPart.

setParent

public void setParent(EditPart parent)
Sets the parent. This should only be called by the managing EditPart.

setSelected

public void setSelected(int value)
Sets the selected state. This should only be called by the EditPartViewer. Fires selectedStateChanged(EditPart) to any EditPartListeners.

showSourceFeedback

public void showSourceFeedback(Request request)
Shows or updates source feedback for the given request. This method can be called multiple times so that the feedback can be updated for changes in the request, such as the mouse location changing.

showTargetFeedback

public void showTargetFeedback(Request request)
Shows or updates target feedback for the given request. This method can be called multiple times so that the feedback can be updated for changes in the request, such as the mouse location changing.

understandsRequest

public boolean understandsRequest(Request request)
Returns true if editpart understands the given Request. EditParts should ignore requests that they don't understand, but this can be used to filter out non-participating EditParts from operations that act on a set.

GEF v2.0