|
Eclipse GEF 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
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 acheived 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 . |
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(Object key)
|
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(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(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(Object model)
![]() |
void |
setParent(EditPart parent)
![]() |
void |
setSelected(int value)
![]() |
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. |
Methods inherited from interface org.eclipse.core.runtime.IAdaptable |
getAdapter |
Field Detail |
public static final int SELECTED_NONE
public static final int SELECTED
public static final int SELECTED_PRIMARY
Method Detail |
public void activate()
RootEditPart
.
This method may be called again once deactivate()
has been called.
During activation the receiver should:
deactivate()
is called.
public void addEditPartListener(EditPartListener listener)
listener
- the Listenerpublic void addNotify()
public void deactivate()
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:
activate()
GraphicalEditParts
, its source connections.
public void eraseSourceFeedback(Request request)
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)
.
request
- the type of feedback that is being erasedpublic void eraseTargetFeedback(Request request)
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)
.
request
- the type of feedback that is being erasedpublic List getChildren()
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.
List
of childrenpublic Command getCommand(Request request)
Command
to perform the specified Request or null
.
request
- describes the Command being requested
null
or a Commandpublic DragTracker getDragTracker(Request request)
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.
request
- a Request
indicating the context of the drag
null
or a DragTrackerpublic EditPolicy getEditPolicy(Object key)
key
- the key identifying the EditPolicy
null
or the EditPolicy installed with the given keypublic Object getModel()
public EditPart getParent()
EditPart
. This method should only be called internally
or by helpers such as EditPolicies.
public RootEditPart getRoot()
RootEditPart
. This method should only be called internally or by
helpers such as edit policies. The Root can be used to get the Viewer.
RootEditPart
public int getSelected()
public EditPart getTargetEditPart(Request request)
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.
request
- the type of target being requested
null
or the targetpublic EditPartViewer getViewer()
EditPartViewer
for this part.
public boolean hasFocus()
EditPartViewer.getFocusEditPart()
public void installEditPolicy(Object role, EditPolicy editPolicy)
EditPolicy.LAYOUT_ROLE
is generally used as the key for this EditPolicy.
null
is a valid value for reserving a location.
role
- an identifier used to key the EditPolicyeditPolicy
- the EditPolicypublic boolean isActive()
true
if the EditPart is active. Editparts are active after
activate()
is called, and until deactivate()
is called.
true
when activepublic boolean isSelectable()
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.
true
if the receiver can be selectedpublic void performRequest(Request request)
Commands
and the
CommandStack
so that the change is undoable. The CommandStack is available
from the EditDomain
.
request
- the request to be performedpublic void refresh()
public void removeEditPartListener(EditPartListener listener)
listener
- the listener being removedpublic void removeEditPolicy(Object role)
null
in the place
of the old EditPolicy.
role
- the key identifying the EditPolicy to be removedinstallEditPolicy(Object, EditPolicy)
public void removeNotify()
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()
public void setFocus(boolean hasFocus)
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.
hasFocus
- boolean indicating if this part has focuspublic void setModel(Object model)
EditPartFactories
.
IMPORTANT: This method should only be called once.
model
- the Modelpublic void setParent(EditPart parent)
parent
- the parent EditPartpublic void setSelected(int value)
IMPORTANT: This method should only be called by the EditPartViewer.
value
- an enum indicating the selected stategetSelected()
public void showSourceFeedback(Request request)
request
- request describing the type of feedbackpublic void showTargetFeedback(Request request)
request
- request describing the type of feedbackpublic boolean understandsRequest(Request request)
request
- a Request
describing an operation of some type
true
if Request is understood
|
Eclipse GEF 2.1 |
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |