Follow Techotopia on Twitter

On-line Guides
All Guides
eBook Store
iOS / Android
Linux for Beginners
Office Productivity
Linux Installation
Linux Security
Linux Utilities
Linux Virtualization
Linux Kernel
System/Network Admin
Programming
Scripting Languages
Development Tools
Web Development
GUI Toolkits/Desktop
Databases
Mail Systems
openSolaris
Eclipse Documentation
Techotopia.com
Virtuatopia.com
Answertopia.com

How To Guides
Virtualization
General System Admin
Linux Security
Linux Filesystems
Web Servers
Graphics & Desktop
PC Hardware
Windows
Problem Solutions
Privacy Policy

  




 

 

Eclipse GEF
3.3

org.eclipse.gef
Interface EditPart

All Known Subinterfaces:
ConnectionEditPart, GraphicalEditPart, NodeEditPart, RootEditPart, TreeEditPart
All Known Implementing Classes:
AbstractConnectionEditPart, AbstractEditPart, AbstractGraphicalEditPart, AbstractTreeEditPart, GraphicalRootEditPart, RootTreeEditPart, SimpleRootEditPart

public interface EditPart

EditParts are the building blocks of GEF Viewers. As the Controller, an EditPart ties the application's model to a visual representation. EditParts are responsible for making changes to the model. EditParts typically control a single model object or a coupled set of object. Visual representations include Figures and TreeItems. Model objects are often composed of other objects that the User will interact with. Similarly, EditParts 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 achieved using Requests. A Request specifies the type of interaction. Requests are used in targeting, filtering the selection (using understandsRequest(Request)), graphical showSourceFeedback(Request) feedback, and most importantly, obtaining commands. Only Commands should change the model.

IMPORTANT: This interface is not intended to be implemented by clients. Clients should inherit from AbstractEditPart. New methods may be added in the future.


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 ()
          Activates the EditPart.
 void addEditPartListener ( EditPartListener listener)
          Adds a listener to the EditPart.
 void addNotify ()
          Called after the EditPart has been added to its parent.
 void deactivate ()
          Deactivates the EditPart.
 void eraseSourceFeedback ( Request request)
          Erases source feedback for the specified Request.
 void eraseTargetFeedback ( Request request)
          Erases target feedback for the specified Request.
 java.util.List getChildren ()
          Returns the List of children EditParts.
  Command getCommand ( Request request)
          Returns the Command to perform the specified Request or null.
  DragTracker getDragTracker ( Request request)
          Returns a DragTracker for dragging this EditPart.
  EditPolicy getEditPolicy (java.lang.Object key)
           
 java.lang.Object getModel ()
          Returns the primary model object that this EditPart represents.
  EditPart getParent ()
          Returns the parent EditPart.
  RootEditPart getRoot ()
          Returns the RootEditPart.
 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 specified Request.
  EditPartViewer getViewer ()
          Convenience method for returning the EditPartViewer for this part.
 boolean hasFocus ()
          Returns true if this EditPart has focus.
 void installEditPolicy (java.lang.Object role, EditPolicy editPolicy)
          Installs an EditPolicy for a specified role.
 boolean isActive ()
          returns true if the EditPart is active.
 boolean isSelectable ()
          Returns true if the EditPart is selectable.
 void performRequest ( Request request)
          Performs the specified Request.
 void refresh ()
          Called to force a refresh of this EditPart.
 void removeEditPartListener ( EditPartListener listener)
          Removes the first occurance of the specified listener from the list of listeners.
 void removeEditPolicy (java.lang.Object role)
          Removes the EditPolicy for the given role.
 void removeNotify ()
          Called when the EditPart is being permanently removed from its EditPartViewer.
 void setFocus (boolean hasFocus)
          Set the focus property to reflect the value in the EditPartViewer.
 void setModel (java.lang.Object model)
          Sets the model.
 void setParent ( EditPart parent)
          Sets the parent.
 void setSelected (int value)
           Sets the selected state property to reflect the selection in the EditPartViewer.
 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)
          Used to filter EditParts out of the current selection.
 

Field Detail

SELECTED_NONE

public static final int SELECTED_NONE
Used to indicate no selection

See Also:
Constant Field Values

SELECTED

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

See Also:
Constant Field Values

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.

See Also:
Constant Field Values
Method Detail

activate

public void activate()
Activates the EditPart. EditParts that observe a dynamic model or support editing must be active. Called by the managing EditPart, or the Viewer in the case of the RootEditPart. This method may be called again once deactivate() has been called.

During activation the receiver should:

  • begin to observe its model if appropriate, and should continue the observation until deactivate() is called.
  • activate all of its EditPolicies. EditPolicies may also observe the model, although this is rare. But it is common for EditPolicies to contribute additional visuals, such as selection handles or feedback during interactions. Therefore it is necessary to tell the EditPolicies when to start doing this, and when to stop.
  • call activate() on the EditParts it manages. This includes its children, and for GraphicalEditParts, its source connections.


addEditPartListener

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

Parameters:
listener - the Listener

addNotify

public void addNotify()
Called after the EditPart has been added to its parent. This is used to indicate to the EditPart that it should refresh itself for the first time.


deactivate

public void deactivate()
Deactivates the EditPart. EditParts that observe a dynamic model or support editing must be active. deactivate() is guaranteed to be called when an EditPart will no longer be used. Called by the managing EditPart, or the Viewer in the case of the RootEditPart. This method may be called multiple times.

During deactivation the receiver should:

  • remove all listeners that were added in activate()
  • deactivate all of its EditPolicies. EditPolicies may be contributing additional visuals, such as selection handles or feedback during interactions. Therefore it is necessary to tell the EditPolicies when to start doing this, and when to stop.
  • call deactivate() on the EditParts it manages. This includes its children, and for GraphicalEditParts, its source connections.


eraseSourceFeedback

public void eraseSourceFeedback(
Request request)
Erases source feedback for the specified Request. A Request is used to describe the type of source feedback that should be erased. This method should only be called once to erase feedback. It should only be called in conjunction with a prior call to showSourceFeedback(Request).

Parameters:
request - the type of feedback that is being erased

eraseTargetFeedback

public void eraseTargetFeedback(
Request request)
Erases target feedback for the specified Request. A Request is used to describe the type of target feedback that should be erased. This method should only be called once to erase feedback. It should only be called in conjunction with a prior call to showTargetFeedback(Request).

Parameters:
request - the type of feedback that is being erased

getChildren

public java.util.List getChildren()
Returns the List of children EditParts. 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. The returned List may be by reference, and should never be modified.

Returns:
a List of children

getCommand

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

Parameters:
request - describes the Command being requested
Returns:
null or a Command

getDragTracker

public 
DragTracker getDragTracker(
Request request)
Returns a DragTracker for dragging this EditPart. The SelectionTool is the only Tool by default that calls this method. The SelectionTool will use a SelectionRequest to provide information such as which mouse button is down, and what modifier keys are pressed.

Parameters:
request - a Request indicating the context of the drag
Returns:
null or a DragTracker

getEditPolicy

public 
EditPolicy getEditPolicy(java.lang.Object key)
Parameters:
key - the key identifying the EditPolicy
Returns:
null or the EditPolicy installed with the given key

getModel

public java.lang.Object getModel()
Returns the primary model object that this EditPart represents. EditParts may correspond to more than one model object, or even no model object. In practice, the Object returned is used by other EditParts to identify this EditPart. In addition, EditPolicies probably rely on this method to build Commands that operate on the model.

Returns:
the primary model object

getParent

public 
EditPart getParent()
Returns the parent EditPart. This method should only be called internally or by helpers such as EditPolicies.

Returns:
the parent

getRoot

public 
RootEditPart getRoot()
Returns the RootEditPart. This method should only be called internally or by helpers such as edit policies. The Root can be used to get the Viewer.

Returns:
the RootEditPart

getSelected

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

Returns:
one of:

getTargetEditPart

public 
EditPart getTargetEditPart(
Request request)
Return the EditPart that should be used as the target for the specified Request. Tools will generally call this method with 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.

Parameters:
request - the type of target being requested
Returns:
null or the target

getViewer

public 
EditPartViewer getViewer()
Convenience method for returning the EditPartViewer for this part.

Returns:
the EditPartViewer

hasFocus

public boolean hasFocus()
Returns true if this EditPart has focus. The focus EditPart is a property of the EditPartViewer. The Viewer keeps this property in sync with its focus.

Returns:
true if the EditPart has focus
See Also:
EditPartViewer.getFocusEditPart()

installEditPolicy

public void installEditPolicy(java.lang.Object role,
                              
EditPolicy editPolicy)
Installs an EditPolicy for a specified role. A role is is simply an Object used to identify the EditPolicy. An example of a role is layout. EditPolicy.LAYOUT_ROLE is generally used as the key for this EditPolicy. null is a valid value for reserving a location.

Parameters:
role - an identifier used to key the EditPolicy
editPolicy - the EditPolicy

isActive

public boolean isActive()
returns true if the EditPart is active. Editparts are active after activate() is called, and until deactivate() is called.

Returns:
true when active

isSelectable

public boolean isSelectable()
Returns true if the EditPart is selectable. A selectable EditPart may be selected as a result of the SelectionTool receiving a mouse down, or as a result of the User pressing a key to change selection.

Returns:
true if the receiver can be selected

performRequest

public void performRequest(
Request request)
Performs the specified Request. This method can be used to send a generic message to an EditPart. If the EditPart interprets this request to mean make a change in the model, it should still use Commands and the CommandStack so that the change is undoable. The CommandStack is available from the EditDomain.

Parameters:
request - the request to be performed

refresh

public void refresh()
Called to force a refresh of this EditPart. All visuals properties will be updated, as well as structural features like children.


removeEditPartListener

public void removeEditPartListener(
EditPartListener listener)
Removes the first occurance of the specified listener from the list of listeners. Does nothing if the listener was not present.

Parameters:
listener - the listener being removed

removeEditPolicy

public void removeEditPolicy(java.lang.Object role)
Removes the EditPolicy for the given role. The EditPolicy is deactivated if it is active. The position for that role is maintained with null in the place of the old EditPolicy.

Parameters:
role - the key identifying the EditPolicy to be removed
See Also:
installEditPolicy(Object, EditPolicy)

removeNotify

public void removeNotify()
Called when the EditPart is being permanently removed from its EditPartViewer. This indicates that the EditPart will no longer be in the Viewer, and therefore should remove itself from the Viewer. This method is not called when a Viewer is disposed. It is only called when the EditPart is removed from its parent. This method is the inverse of addNotify()


setFocus

public void setFocus(boolean hasFocus)
Set the focus property to reflect the value in the EditPartViewer. Focus is determined by the EditPartViewer.

Focus is considered to be part of the selected state, changing this value will fire EditPartListener.selectedStateChanged(EditPart).

IMPORTANT: This method should only be called by the EditPartViewer.

Parameters:
hasFocus - boolean indicating if this part has focus

setModel

public void setModel(java.lang.Object model)
Sets the model. This method is made public to facilitate the use of EditPartFactories.

IMPORTANT: This method should only be called once.

Parameters:
model - the Model

setParent

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

Parameters:
parent - the parent EditPart

setSelected

public void setSelected(int value)
Sets the selected state property to reflect the selection in the EditPartViewer. Fires selectedStateChanged(EditPart) to any EditPartListeners. Selection is maintained by the EditPartViewer.

IMPORTANT: This method should only be called by the EditPartViewer.

Parameters:
value - an enum indicating the selected state
See Also:
getSelected()

showSourceFeedback

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

Parameters:
request - request describing the type of feedback

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.

Parameters:
request - request describing the type of feedback

understandsRequest

public boolean understandsRequest(
Request request)
Used to filter EditParts out of the current selection. If an operation is going to be performed on the current selection, the selection can first be culled to remove EditParts that do not participate in the operation. For example, when aligning the left edges of GraphicalEditParts, it makes sense to ignore any selected ConnectionEditParts, as they cannot be aligned.

Parameters:
request - a Request describing an operation of some type
Returns:
true if Request is understood

Eclipse GEF
3.3

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

 
 
  Published under the terms of the Eclipse Public License Version 1.0 ("EPL") Design by Interspire