Package org.eclipse.gef.editpolicies
Class NonResizableEditPolicy
- 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.NonResizableEditPolicy
-
- All Implemented Interfaces:
IAdaptable
,EditPolicy
,RequestConstants
- Direct Known Subclasses:
ResizableEditPolicy
public class NonResizableEditPolicy extends SelectionHandlesEditPolicy
Provide support for selecting and positioning a non-resizable editpart. Selection is indicated via four square handles at each corner of the editpart's figure, and a rectangular handle that outlines the editpart with a 1-pixel black line. All of these handles returnDragEditPartsTracker
s, which allows the current selection to be dragged.During feedback, a rectangle filled using XOR and outlined with dashes is drawn. Subclasses can tailor the feedback.
-
-
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 NonResizableEditPolicy()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
createDragHandle(java.util.List handles, int direction)
Creates a 'resize'/'drag' handle, which uses aDragEditPartsTracker
in caseisDragAllowed()
returns true, and aSelectEditPartTracker
otherwise.protected org.eclipse.draw2d.IFigure
createDragSourceFeedbackFigure()
Creates the figure used for feedback.protected void
createMoveHandle(java.util.List handles)
Creates a 'move' handle, which uses aDragEditPartsTracker
in caseisDragAllowed()
returns true, and aSelectEditPartTracker
otherwise.protected java.util.List
createSelectionHandles()
Subclasses must implement to provide the list of handles.void
deactivate()
Extends deactivate to unhook the seleciton listener and to remove the visual changes for representing selection/focus.protected void
eraseChangeBoundsFeedback(ChangeBoundsRequest request)
Erases drag feedback.void
eraseSourceFeedback(Request request)
Does nothing by default.protected Command
getAlignCommand(AlignmentRequest request)
Returns the command contribution to an alignment requestCommand
getCommand(Request request)
Returnsnull
by default.protected org.eclipse.draw2d.IFigure
getDragSourceFeedbackFigure()
Lazily creates and returns the feedback figure used during drags.protected DragEditPartsTracker
getDragTracker()
Returns a drag tracker to use by a resize handle.protected org.eclipse.draw2d.geometry.Rectangle
getInitialFeedbackBounds()
Returns the bounds of the host's figure by reference to be used to calculate the initial location of the feedback.protected Command
getMoveCommand(ChangeBoundsRequest request)
Returns the command contribution to a change bounds request.protected Command
getOrphanCommand(Request req)
Subclasses may override to contribute to the orphan request.protected SelectEditPartTracker
getSelectTracker()
Returns a selection tracker to use by a selection handle.protected void
hideFocus()
Hides the focus rectangle displayed inshowFocus()
.boolean
isDragAllowed()
Returns true if this EditPolicy allows its EditPart to be dragged.void
setDragAllowed(boolean isDragAllowed)
Sets the dragability of the EditPolicy to the given value.protected void
showChangeBoundsFeedback(ChangeBoundsRequest request)
Shows or updates feedback for a change bounds request.protected void
showFocus()
Shows a focus rectangle around the host's figure.void
showSourceFeedback(Request request)
Calls other methods as appropriate.boolean
understandsRequest(Request request)
Returnstrue
for move, align, add, and orphan request types.-
Methods inherited from class org.eclipse.gef.editpolicies.SelectionHandlesEditPolicy
addSelectionHandles, getAdapter, hideSelection, removeSelectionHandles, showSelection
-
Methods inherited from class org.eclipse.gef.editpolicies.SelectionEditPolicy
activate, addSelectionListener, getTargetEditPart, removeSelectionListener, setFocus, setSelectedState, 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
-
-
-
-
Method Detail
-
createDragSourceFeedbackFigure
protected org.eclipse.draw2d.IFigure createDragSourceFeedbackFigure()
Creates the figure used for feedback.- Returns:
- the new feedback figure
-
createSelectionHandles
protected java.util.List createSelectionHandles()
Description copied from class:SelectionHandlesEditPolicy
Subclasses must implement to provide the list of handles.- Specified by:
createSelectionHandles
in classSelectionHandlesEditPolicy
- Returns:
- List of handles; cannot be
null
- See Also:
SelectionHandlesEditPolicy.createSelectionHandles()
-
createDragHandle
protected void createDragHandle(java.util.List handles, int direction)
Creates a 'resize'/'drag' handle, which uses aDragEditPartsTracker
in caseisDragAllowed()
returns true, and aSelectEditPartTracker
otherwise.- Parameters:
handles
- The list of handles to add the resize handle todirection
- A position constant indicating the direction to create the handle for- Since:
- 3.7
-
getSelectTracker
protected SelectEditPartTracker getSelectTracker()
Returns a selection tracker to use by a selection handle.- Returns:
- a new
ResizeTracker
- Since:
- 3.7
-
getDragTracker
protected DragEditPartsTracker getDragTracker()
Returns a drag tracker to use by a resize handle.- Returns:
- a new
ResizeTracker
- Since:
- 3.7
-
createMoveHandle
protected void createMoveHandle(java.util.List handles)
Creates a 'move' handle, which uses aDragEditPartsTracker
in caseisDragAllowed()
returns true, and aSelectEditPartTracker
otherwise.- Parameters:
handles
- The list of handles to add the move handle to.- Since:
- 3.7
-
deactivate
public void deactivate()
Description copied from class:SelectionEditPolicy
Extends deactivate to unhook the seleciton listener and to remove the visual changes for representing selection/focus.- Specified by:
deactivate
in interfaceEditPolicy
- Overrides:
deactivate
in classSelectionEditPolicy
- See Also:
EditPolicy.deactivate()
-
eraseChangeBoundsFeedback
protected void eraseChangeBoundsFeedback(ChangeBoundsRequest request)
Erases drag feedback. This method called whenever an erase feedback request is received of the appropriate type.- Parameters:
request
- the request
-
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(org.eclipse.gef.Request)
-
getCommand
public Command getCommand(Request request)
Description copied from class:AbstractEditPolicy
Returnsnull
by default.null
is used to indicate that the EditPolicy does not contribute to the specifiedRequest
.- Specified by:
getCommand
in interfaceEditPolicy
- Overrides:
getCommand
in classAbstractEditPolicy
- Parameters:
request
- the Request- Returns:
null
or a Command contribution- See Also:
EditPolicy.getCommand(org.eclipse.gef.Request)
-
getDragSourceFeedbackFigure
protected org.eclipse.draw2d.IFigure getDragSourceFeedbackFigure()
Lazily creates and returns the feedback figure used during drags.- Returns:
- the feedback figure
-
getAlignCommand
protected Command getAlignCommand(AlignmentRequest request)
Returns the command contribution to an alignment request- Parameters:
request
- the alignment request- Returns:
- the contribution to the alignment
-
getInitialFeedbackBounds
protected org.eclipse.draw2d.geometry.Rectangle getInitialFeedbackBounds()
Returns the bounds of the host's figure by reference to be used to calculate the initial location of the feedback. The returned Rectangle should not be modified. Uses handle bounds if available.- Returns:
- the host figure's bounding Rectangle
-
getMoveCommand
protected Command getMoveCommand(ChangeBoundsRequest request)
Returns the command contribution to a change bounds request. The implementation actually redispatches the request to the host's parent editpart as aRequestConstants.REQ_MOVE_CHILDREN
request. The parent's contribution is returned.- Parameters:
request
- the change bounds request- Returns:
- the command contribution to the request
-
getOrphanCommand
protected Command getOrphanCommand(Request req)
Subclasses may override to contribute to the orphan request. By default,null
is returned to indicate no participation. Orphan requests are not forwarded to the host's parent here. That is done inComponentEditPolicy
. So, if the host has a component editpolicy, then the parent will already have a chance to contribute.- Parameters:
req
- the orphan request- Returns:
null
by default
-
hideFocus
protected void hideFocus()
Hides the focus rectangle displayed inshowFocus()
.- Overrides:
hideFocus
in classSelectionEditPolicy
- See Also:
showFocus()
,SelectionEditPolicy.hideFocus()
-
isDragAllowed
public boolean isDragAllowed()
Returns true if this EditPolicy allows its EditPart to be dragged.- Returns:
- true if the EditPart can be dragged.
-
setDragAllowed
public void setDragAllowed(boolean isDragAllowed)
Sets the dragability of the EditPolicy to the given value. If the value is false, the EditPolicy should not allow its EditPart to be dragged.- Parameters:
isDragAllowed
- whether or not the EditPolicy can be dragged.
-
showChangeBoundsFeedback
protected void showChangeBoundsFeedback(ChangeBoundsRequest request)
Shows or updates feedback for a change bounds request.- Parameters:
request
- the request
-
showFocus
protected void showFocus()
Shows a focus rectangle around the host's figure. The focus rectangle is expanded by 5 pixels from the figure's bounds.- Overrides:
showFocus
in classSelectionEditPolicy
- See Also:
SelectionEditPolicy.showFocus()
-
showSourceFeedback
public void showSourceFeedback(Request request)
Calls other methods as appropriate.- Specified by:
showSourceFeedback
in interfaceEditPolicy
- Overrides:
showSourceFeedback
in classAbstractEditPolicy
- Parameters:
request
- the Request- See Also:
EditPolicy.showSourceFeedback(org.eclipse.gef.Request)
-
understandsRequest
public boolean understandsRequest(Request request)
Returnstrue
for move, align, add, and orphan request types. This method is never called for some of these types, but they are included for possible future use.- Specified by:
understandsRequest
in interfaceEditPolicy
- Overrides:
understandsRequest
in classAbstractEditPolicy
- Parameters:
request
- the Request- Returns:
- boolean
true
if the EditPolicy understands the specified request - See Also:
EditPolicy.understandsRequest(org.eclipse.gef.Request)
-
-