|
Eclipse GEF 3.8.1.201208200205 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.eclipse.gef.editpolicies.AbstractEditPolicy
org.eclipse.gef.editpolicies.GraphicalEditPolicy
org.eclipse.gef.editpolicies.LayoutEditPolicy
org.eclipse.gef.editpolicies.ConstrainedLayoutEditPolicy
public abstract class ConstrainedLayoutEditPolicy
For use with LayoutManager
that require a constraint.
ConstrainedLayoutEditPolicy understands
RequestConstants.REQ_ALIGN_CHILDREN
in addition to the Requests
handled in the superclass.
Field Summary | |
---|---|
protected static Dimension |
UNSPECIFIED_SIZE
Constant being used to indicate that upon creation (or during move) a size was not specified. |
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 | |
---|---|
ConstrainedLayoutEditPolicy()
|
Method Summary | |
---|---|
protected Command |
createAddCommand(ChangeBoundsRequest request,
EditPart child,
java.lang.Object constraint)
Returns the Command to perform an Add with the specified
child and constraint. |
protected Command |
createAddCommand(EditPart child,
java.lang.Object constraint)
Deprecated. Use createAddCommand(ChangeBoundsRequest, EditPart, Object)
instead. |
protected Command |
createChangeConstraintCommand(ChangeBoundsRequest request,
EditPart child,
java.lang.Object constraint)
The request is now made available when creating the change constraint command. |
protected Command |
createChangeConstraintCommand(EditPart child,
java.lang.Object constraint)
Deprecated. Use createChangeConstraintCommand(ChangeBoundsRequest, EditPart, Object)
instead. |
protected EditPolicy |
createChildEditPolicy(EditPart child)
A ResizableEditPolicy is used by default for children. |
protected Command |
getAddCommand(Request generic)
Overrides getAddCommand() to generate the proper constraint
for each child being added. |
protected Command |
getAlignChildrenCommand(AlignmentRequest request)
Returns the command to align a group of children. |
protected Command |
getChangeConstraintCommand(ChangeBoundsRequest request)
Returns the Command for changing bounds for a group of
children. |
Command |
getCommand(Request request)
Factors out RESIZE and ALIGN requests, otherwise calls super
. |
protected java.lang.Object |
getConstraintFor(ChangeBoundsRequest request,
GraphicalEditPart child)
Generates a draw2d constraint object for the given ChangeBoundsRequest and child EditPart by delegating to
getConstraintFor(Request, GraphicalEditPart, Rectangle) . |
protected java.lang.Object |
getConstraintFor(CreateRequest request)
Generates a draw2d constraint for the given CreateRequest by
delegating to
getConstraintFor(Request, GraphicalEditPart, Rectangle) . |
protected abstract java.lang.Object |
getConstraintFor(Point point)
Generates a draw2d constraint given a Point . |
protected abstract java.lang.Object |
getConstraintFor(Rectangle rect)
Generates a draw2d constraint given a Rectangle . |
protected java.lang.Object |
getConstraintFor(Request request,
GraphicalEditPart child,
Rectangle rectangle)
Responsible of generating a draw2d constraint for the given Rectangle, which represents the already transformed (layout-relative) position and size of the given Request. |
protected java.lang.Object |
getConstraintForClone(GraphicalEditPart part,
ChangeBoundsRequest request)
Deprecated. Use getConstraintFor(ChangeBoundsRequest, GraphicalEditPart)
instead. |
protected Command |
getMoveChildrenCommand(Request request)
Returns the Command to move a group of children. |
protected Command |
getResizeChildrenCommand(ChangeBoundsRequest request)
Returns the Command to resize a group of children. |
protected java.lang.Object |
translateToModelConstraint(java.lang.Object figureConstraint)
Converts a constraint from the format used by LayoutManagers, to the form stored in the model. |
Methods inherited from class org.eclipse.gef.editpolicies.GraphicalEditPolicy |
---|
addFeedback, getFeedbackLayer, getHostFigure, getLayer, removeFeedback |
Methods inherited from class org.eclipse.gef.editpolicies.AbstractEditPolicy |
---|
debugFeedback, eraseSourceFeedback, getHost, setHost, showSourceFeedback, toString, understandsRequest |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
protected static final Dimension UNSPECIFIED_SIZE
Constructor Detail |
---|
public ConstrainedLayoutEditPolicy()
Method Detail |
---|
protected Command createAddCommand(ChangeBoundsRequest request, EditPart child, java.lang.Object constraint)
Command
to perform an Add with the specified
child and constraint. The constraint has been converted from a draw2d
constraint to an object suitable for the model by calling
translateToModelConstraint(Object)
.
request
- the ChangeBoundsRequestchild
- the EditPart of the child being addedconstraint
- the model constraint, after being
translated
protected Command createAddCommand(EditPart child, java.lang.Object constraint)
createAddCommand(ChangeBoundsRequest, EditPart, Object)
instead.
Command
to perform an Add with the specified
child and constraint. The constraint has been converted from a draw2d
constraint to an object suitable for the model by calling
translateToModelConstraint(Object)
.
child
- the EditPart of the child being addedconstraint
- the model constraint, after being
translated
protected Command createChangeConstraintCommand(ChangeBoundsRequest request, EditPart child, java.lang.Object constraint)
method
.
request
- the ChangeBoundsRequestchild
- the EditPart of the child being changedconstraint
- the new constraint, after being
translated
createChangeConstraintCommand(EditPart,
Object)
protected Command createChangeConstraintCommand(EditPart child, java.lang.Object constraint)
createChangeConstraintCommand(ChangeBoundsRequest, EditPart, Object)
instead.
Command
to change the specified child's
constraint. The constraint has been converted from a draw2d constraint to
an object suitable for the model. Clients should overwrite
createChangeConstraintCommand(ChangeBoundsRequest, EditPart, Object)
instead.
child
- the EditPart of the child being changedconstraint
- the new constraint, after being
translated
createChangeConstraintCommand(ChangeBoundsRequest, EditPart,
Object)
protected EditPolicy createChildEditPolicy(EditPart child)
ResizableEditPolicy
is used by default for children. Subclasses
may override this method to supply a different EditPolicy.
createChildEditPolicy
in class LayoutEditPolicy
child
- the child EditPart
EditPolicy.PRIMARY_DRAG_ROLE
LayoutEditPolicy.createChildEditPolicy(EditPart)
protected Command getAddCommand(Request generic)
getAddCommand()
to generate the proper constraint
for each child being added. Once the constraint is calculated,
createAddCommand(EditPart,Object)
is called. Subclasses must
implement this method.
getAddCommand
in class LayoutEditPolicy
generic
- the ADD Request
LayoutEditPolicy.getAddCommand(Request)
protected Command getAlignChildrenCommand(AlignmentRequest request)
getResizeChildrenCommand(ChangeBoundsRequest)
is returned.
request
- the AligmentRequest
public Command getCommand(Request request)
super
.
getCommand
in interface EditPolicy
getCommand
in class LayoutEditPolicy
request
- the Request
null
or a Command contributionEditPolicy.getCommand(Request)
protected java.lang.Object getConstraintFor(ChangeBoundsRequest request, GraphicalEditPart child)
ChangeBoundsRequest
and child EditPart by delegating to
getConstraintFor(Request, GraphicalEditPart, Rectangle)
.
The rectangle being passed over to
getConstraintFor(Request, GraphicalEditPart, Rectangle)
is
calculated based on the child figure's current bounds and the
ChangeBoundsRequest's move and resize deltas. It is made layout-relative
by using LayoutEditPolicy.translateFromAbsoluteToLayoutRelative(Translatable)
before calling
getConstraintFor(Request, GraphicalEditPart, Rectangle)
.
request
- the ChangeBoundsRequestchild
- the child EditPart for which the constraint should be
generated
protected java.lang.Object getConstraintFor(Request request, GraphicalEditPart child, Rectangle rectangle)
getConstraintFor(Point)
or
getConstraintFor(Rectangle)
, dependent on whether the size of
the rectangle is an UNSPECIFIED_SIZE
or not.
Subclasses may overwrite this method in case they need the request or the
edit part (which will of course not be set during creation) to calculate
a layout constraint for the request.
rectangle
- the Rectangle relative to the layout
origin
protected abstract java.lang.Object getConstraintFor(Point point)
Point
. This method is
called during creation, when only a mouse location is available, as well
as during move, in case no resizing is involved.
point
- the Point relative to the layout
origin
protected abstract java.lang.Object getConstraintFor(Rectangle rect)
Rectangle
. This method
is called during most operations.
rect
- the Rectangle relative to the layout
origin
protected java.lang.Object getConstraintFor(CreateRequest request)
CreateRequest
by
delegating to
getConstraintFor(Request, GraphicalEditPart, Rectangle)
.
If the CreateRequest has a size, is used during size-on-drop creation, a
Rectangle of the request's location and size is passed with the
delegation. Otherwise, a rectangle with the request's location and an
empty size (0,0) is passed over.
The CreateRequest's location is relative to the Viewer. The location is
made layout-relative by using
LayoutEditPolicy.translateFromAbsoluteToLayoutRelative(Translatable)
before
calling getConstraintFor(Request, GraphicalEditPart, Rectangle)
.
request
- the CreateRequest
protected java.lang.Object getConstraintForClone(GraphicalEditPart part, ChangeBoundsRequest request)
getConstraintFor(ChangeBoundsRequest, GraphicalEditPart)
instead.
part
- the graphical edit part representing the object to be cloned.request
- the ChangeBoundsRequest that knows where to place the new
object.
protected java.lang.Object translateToModelConstraint(java.lang.Object figureConstraint)
figureConstraint
- the draw2d constraint
protected Command getResizeChildrenCommand(ChangeBoundsRequest request)
Command
to resize a group of children.
request
- the ChangeBoundsRequest
protected Command getChangeConstraintCommand(ChangeBoundsRequest request)
Command
for changing bounds for a group of
children.
request
- the ChangeBoundsRequest
protected Command getMoveChildrenCommand(Request request)
Command
to move a group of children. By default,
move is treated the same as a resize.
getMoveChildrenCommand
in class LayoutEditPolicy
request
- the Request
LayoutEditPolicy.getMoveChildrenCommand(Request)
|
Eclipse GEF 3.8.1.201208200205 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |