Package org.eclipse.gef.editpolicies
Class BendpointEditPolicy
- java.lang.Object
-
- org.eclipse.gef.editpolicies.AbstractEditPolicy
-
- org.eclipse.gef.editpolicies.GraphicalEditPolicy
-
- org.eclipse.gef.editpolicies.SelectionEditPolicy
-
- org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy
-
- org.eclipse.gef.editpolicies.BendpointEditPolicy
-
- All Implemented Interfaces:
java.beans.PropertyChangeListener
,java.util.EventListener
,IAdaptable
,EditPolicy
,RequestConstants
public abstract class BendpointEditPolicy extends SelectionHandlesEditPolicy implements java.beans.PropertyChangeListener
Used to add bendpoint handles on aConnectionEditPart
.BendpointEditPolicy will automatically observe the
Connection
figure. If the number of bends in theConnection
changes, the handles will be updated.
-
-
Field Summary
-
Fields inherited from class org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy
handles
-
Fields inherited from interface org.eclipse.gef.EditPolicy
COMPONENT_ROLE, CONNECTION_BENDPOINTS_ROLE, CONNECTION_ENDPOINTS_ROLE, CONNECTION_ROLE, CONTAINER_ROLE, DIRECT_EDIT_ROLE, GRAPHICAL_NODE_ROLE, LAYOUT_ROLE, NODE_ROLE, PRIMARY_DRAG_ROLE, SELECTION_FEEDBACK_ROLE, TREE_CONTAINER_ROLE
-
Fields inherited from interface org.eclipse.gef.RequestConstants
REQ_ADD, REQ_ALIGN, REQ_ALIGN_CHILDREN, REQ_CLONE, REQ_CONNECTION_END, REQ_CONNECTION_START, REQ_CREATE, REQ_CREATE_BENDPOINT, REQ_DELETE, REQ_DELETE_DEPENDANT, REQ_DIRECT_EDIT, REQ_MOVE, REQ_MOVE_BENDPOINT, REQ_MOVE_CHILDREN, REQ_OPEN, REQ_ORPHAN, REQ_ORPHAN_CHILDREN, REQ_RECONNECT_SOURCE, REQ_RECONNECT_TARGET, REQ_RESIZE, REQ_RESIZE_CHILDREN, REQ_SELECTION, REQ_SELECTION_HOVER
-
-
Constructor Summary
Constructors Constructor Description BendpointEditPolicy()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
activate()
activate()
is extended to add a listener to theConnection
figure.protected java.util.List
createSelectionHandles()
Creates selection handles for the bendpoints.void
deactivate()
deactivate()
is extended to remove the property change listener on theConnection
figure.protected void
eraseConnectionFeedback(BendpointRequest request)
Erases all bendpoint feedback.void
eraseSourceFeedback(Request request)
Does nothing by default.Command
getCommand(Request request)
Factors the Request into either a MOVE, a DELETE, or a CREATE of a bendpoint.protected org.eclipse.draw2d.Connection
getConnection()
Convenience method for obtaining the host'sConnection
figure.protected abstract Command
getCreateBendpointCommand(BendpointRequest request)
Implement this method to return a Command that will create a bendpoint.protected abstract Command
getDeleteBendpointCommand(BendpointRequest request)
Implement this method to return a Command that will delete a bendpoint.protected abstract Command
getMoveBendpointCommand(BendpointRequest request)
Implement this method to return a Command that will move a bendpoint.void
propertyChange(java.beans.PropertyChangeEvent evt)
If the number of bendpoints changes, handles are updated.protected void
restoreOriginalConstraint()
Restores the original constraint that was saved before feedback began to show.protected void
saveOriginalConstraint()
Since the original figure is used for feedback, this method saves the original constraint, so that is can be restored when the feedback is erased.protected void
showCreateBendpointFeedback(BendpointRequest request)
Shows feedback when a bendpoint is being created.protected void
showDeleteBendpointFeedback(BendpointRequest request)
Shows feedback when a bendpoint is being deleted.protected void
showMoveBendpointFeedback(BendpointRequest request)
Shows feedback when a bendpoint is being moved.void
showSourceFeedback(Request request)
Shows feedback when appropriate.-
Methods inherited from class org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy
addSelectionHandles, getAdapter, hideSelection, removeSelectionHandles, showSelection
-
Methods inherited from class org.eclipse.gef.editpolicies.SelectionEditPolicy
addSelectionListener, getTargetEditPart, hideFocus, removeSelectionListener, setFocus, setSelectedState, showFocus, showPrimarySelection
-
Methods inherited from class org.eclipse.gef.editpolicies.GraphicalEditPolicy
addFeedback, getFeedbackLayer, getHostFigure, getLayer, removeFeedback
-
Methods inherited from class org.eclipse.gef.editpolicies.AbstractEditPolicy
debugFeedback, eraseTargetFeedback, getHost, setHost, showTargetFeedback, toString, understandsRequest
-
-
-
-
Method Detail
-
activate
public void activate()
activate()
is extended to add a listener to theConnection
figure.- Specified by:
activate
in interfaceEditPolicy
- Overrides:
activate
in classSelectionEditPolicy
- See Also:
EditPolicy.activate()
-
createSelectionHandles
protected java.util.List createSelectionHandles()
Creates selection handles for the bendpoints. Explicit (user-defined) bendpoints will haveBendpointMoveHandle
s on them with a singleBendpointCreationHandle
between 2 consecutive explicit bendpoints. If implicit bendpoints (such as those created by theAutomaticRouter
) are used, oneBendpointCreationHandle
is placed in the middle of the Connection.- Specified by:
createSelectionHandles
in classSelectionHandlesEditPolicy
- Returns:
- List of handles; cannot be
null
- See Also:
SelectionHandlesEditPolicy.createSelectionHandles()
-
deactivate
public void deactivate()
deactivate()
is extended to remove the property change listener on theConnection
figure.- Specified by:
deactivate
in interfaceEditPolicy
- Overrides:
deactivate
in classSelectionEditPolicy
- See Also:
EditPolicy.deactivate()
-
eraseConnectionFeedback
protected void eraseConnectionFeedback(BendpointRequest request)
Erases all bendpoint feedback. Since the originalConnection
figure is used for feedback, we just restore the original constraint that was saved before feedback started to show.- Parameters:
request
- the BendpointRequest
-
eraseSourceFeedback
public void eraseSourceFeedback(Request request)
Description copied from class:AbstractEditPolicy
Does nothing by default.- Specified by:
eraseSourceFeedback
in interfaceEditPolicy
- Overrides:
eraseSourceFeedback
in classAbstractEditPolicy
- Parameters:
request
- the Request- See Also:
EditPolicy.eraseSourceFeedback(Request)
-
getCommand
public Command getCommand(Request request)
Factors the Request into either a MOVE, a DELETE, or a CREATE of a bendpoint.- Specified by:
getCommand
in interfaceEditPolicy
- Overrides:
getCommand
in classAbstractEditPolicy
- Parameters:
request
- the Request- Returns:
null
or a Command contribution- See Also:
EditPolicy.getCommand(Request)
-
getConnection
protected org.eclipse.draw2d.Connection getConnection()
Convenience method for obtaining the host'sConnection
figure.- Returns:
- the Connection figure
-
getCreateBendpointCommand
protected abstract Command getCreateBendpointCommand(BendpointRequest request)
Implement this method to return a Command that will create a bendpoint.- Parameters:
request
- the BendpointRequest- Returns:
- a Command to create a bendpoint
-
getDeleteBendpointCommand
protected abstract Command getDeleteBendpointCommand(BendpointRequest request)
Implement this method to return a Command that will delete a bendpoint.- Parameters:
request
- the BendpointRequest- Returns:
- a Command to delete a bendpoint
-
getMoveBendpointCommand
protected abstract Command getMoveBendpointCommand(BendpointRequest request)
Implement this method to return a Command that will move a bendpoint.- Parameters:
request
- the BendpointRequest- Returns:
- a Command to move a bendpoint
-
propertyChange
public void propertyChange(java.beans.PropertyChangeEvent evt)
If the number of bendpoints changes, handles are updated.- Specified by:
propertyChange
in interfacejava.beans.PropertyChangeListener
- See Also:
PropertyChangeListener.propertyChange(PropertyChangeEvent)
-
restoreOriginalConstraint
protected void restoreOriginalConstraint()
Restores the original constraint that was saved before feedback began to show.
-
saveOriginalConstraint
protected void saveOriginalConstraint()
Since the original figure is used for feedback, this method saves the original constraint, so that is can be restored when the feedback is erased.
-
showCreateBendpointFeedback
protected void showCreateBendpointFeedback(BendpointRequest request)
Shows feedback when a bendpoint is being created. The original figure is used for feedback and the original constraint is saved, so that it can be restored when feedback is erased.- Parameters:
request
- the BendpointRequest
-
showDeleteBendpointFeedback
protected void showDeleteBendpointFeedback(BendpointRequest request)
Shows feedback when a bendpoint is being deleted. This method is only called once when the bendpoint is first deleted, not every mouse move. The original figure is used for feedback and the original constraint is saved, so that it can be restored when feedback is erased.- Parameters:
request
- the BendpointRequest
-
showMoveBendpointFeedback
protected void showMoveBendpointFeedback(BendpointRequest request)
Shows feedback when a bendpoint is being moved. Also checks to see if the bendpoint should be deleted and then callsshowDeleteBendpointFeedback(BendpointRequest)
if needed. The original figure is used for feedback and the original constraint is saved, so that it can be restored when feedback is erased.- Parameters:
request
- the BendpointRequest
-
showSourceFeedback
public void showSourceFeedback(Request request)
Shows feedback when appropriate. Calls a different method depending on the request type.- Specified by:
showSourceFeedback
in interfaceEditPolicy
- Overrides:
showSourceFeedback
in classAbstractEditPolicy
- Parameters:
request
- the Request- See Also:
showCreateBendpointFeedback(BendpointRequest)
,showMoveBendpointFeedback(BendpointRequest)
-
-