Eclipse GEF
2.1

org.eclipse.gef.editpolicies
Class LayoutEditPolicy

java.lang.Object
  |
  +--org.eclipse.gef.editpolicies.AbstractEditPolicy
        |
        +--org.eclipse.gef.editpolicies.GraphicalEditPolicy
              |
              +--org.eclipse.gef.editpolicies.LayoutEditPolicy
All Implemented Interfaces:
EditPolicy, RequestConstants
Direct Known Subclasses:
ConstrainedLayoutEditPolicy, OrderedLayoutEditPolicy

public abstract class LayoutEditPolicy
extends GraphicalEditPolicy

Provides support for interacting with children GraphicalEditParts with the host figure's current LayoutManager.

LayoutEditPolicies are responsible for moving, resizing, reparenting, and creating children. The should provide Commands for all of these operations. Feedback on the container can also be useful for some layouts like grids.

LayoutEditPolicies will decorate the host's children with "satellite" EditPolicies. These policies are installed using the EditPolicy.PRIMARY_DRAG_ROLE. Simple layouts will use either ResizableEditPolicy or NonResizableEditPolicy, depending on how the LayoutManager works, and/or attributes of the child EditPart.


Field Summary
 
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_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
LayoutEditPolicy()
           
 
Method Summary
 void activate()
          Extends activate() to
protected abstract  EditPolicy createChildEditPolicy(EditPart child)
          Returns the "satellite" EditPolicy used to decorate the child.
protected  EditPartListener createListener()
          creates the EditPartListener for observing when children are added to the host.
 void deactivate()
          Overrides deactivate to remove the EditPartListener.
protected  void decorateChild(EditPart child)
          Decorates the child with a EditPolicy.PRIMARY_DRAG_ROLE such as ResizableEditPolicy.
protected  void decorateChildren()
          Decorates all existing children.
protected  void eraseDragTargetFeedback(Request request)
          Made final for compatibility.
protected  void eraseLayoutTargetFeedback(Request request)
          Erases target layout feedback.
protected  void eraseSizeOnDropFeedback(Request request)
          Erases size-on-drop feedback used during creation.
 void eraseTargetFeedback(Request request)
          Calls two more specific methods depending on the Request.
protected  Command getAddCommand(Request request)
          Override to return the Command to perform an ADD.
 Command getCommand(Request request)
          Factors incoming requests into various specific methods.
protected abstract  Command getCreateCommand(CreateRequest request)
          Returns the Command to perform a create.
protected abstract  Command getDeleteDependantCommand(Request request)
          Returns the Command to delete a child.
protected  IFigure getLayoutContainer()
          Returns the host's contentPane.
protected abstract  Command getMoveChildrenCommand(Request request)
          Returns the Command to move a group of children.
protected  Command getOrphanChildrenCommand(Request request)
          Returns the Command to orphan a group of children.
protected  IFigure getSizeOnDropFeedback()
          Lazily creates and returns the Figure to use for size-on-drop feedback.
 EditPart getTargetEditPart(Request request)
          Returns the host if the Request is an ADD, MOVE, or CREATE.
protected  void setListener(EditPartListener listener)
          Sets the EditPartListener used to decorate new children.
protected  void showDragTargetFeedback(Request request)
          Made final for compatibility.
protected  void showLayoutTargetFeedback(Request request)
          Shows target layout feedback.
protected  void showSizeOnDropFeedback(CreateRequest request)
          Shows size-on-drop feedback during creation.
 void showTargetFeedback(Request request)
          Factors feedback requests into two more specific methods.
 
Methods inherited from class org.eclipse.gef.editpolicies.GraphicalEditPolicy
addFeedback, 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
 

Constructor Detail

LayoutEditPolicy

public LayoutEditPolicy()
Method Detail

activate

public void activate()
Extends activate() to

Specified by:
activate in interface EditPolicy
Overrides:
activate in class AbstractEditPolicy
See Also:
EditPolicy.activate()

createChildEditPolicy

protected abstract EditPolicy createChildEditPolicy(EditPart child)
Returns the "satellite" EditPolicy used to decorate the child.

Parameters:
child - the child EditPart
Returns:
an EditPolicy to be installed as the EditPolicy.PRIMARY_DRAG_ROLE

createListener

protected EditPartListener createListener()
creates the EditPartListener for observing when children are added to the host.

Returns:
EditPartListener

deactivate

public void deactivate()
Overrides deactivate to remove the EditPartListener.

Specified by:
deactivate in interface EditPolicy
Overrides:
deactivate in class AbstractEditPolicy
See Also:
EditPolicy.deactivate()

decorateChild

protected void decorateChild(EditPart child)
Decorates the child with a EditPolicy.PRIMARY_DRAG_ROLE such as ResizableEditPolicy.

Parameters:
child - the child EditPart being decorated

decorateChildren

protected void decorateChildren()
Decorates all existing children. This method is called on activation.


eraseDragTargetFeedback

protected final void eraseDragTargetFeedback(Request request)
                                      throws Exception
Made final for compatibility. Override eraseLayoutTargetFeedback(). The term "drag" is actually confusing, since when the User actually releases the mouse is considered a "drop" by most conventions.

Parameters:
request - the Request
Throws:
Exception - exception

eraseLayoutTargetFeedback

protected void eraseLayoutTargetFeedback(Request request)
Erases target layout feedback. This method is the inverse of showLayoutTargetFeedback(Request).

Parameters:
request - the Request

eraseSizeOnDropFeedback

protected void eraseSizeOnDropFeedback(Request request)
Erases size-on-drop feedback used during creation.

Parameters:
request - the Request

eraseTargetFeedback

public void eraseTargetFeedback(Request request)
Calls two more specific methods depending on the Request.

Specified by:
eraseTargetFeedback in interface EditPolicy
Overrides:
eraseTargetFeedback in class AbstractEditPolicy
See Also:
EditPolicy.eraseTargetFeedback(Request)

getAddCommand

protected Command getAddCommand(Request request)
Override to return the Command to perform an ADD. By default, null is returned.

Parameters:
request - the ADD Request
Returns:
A command to perform the ADD.

getCommand

public Command getCommand(Request request)
Factors incoming requests into various specific methods.

Specified by:
getCommand in interface EditPolicy
Overrides:
getCommand in class AbstractEditPolicy
See Also:
EditPolicy.getCommand(Request)

getCreateCommand

protected abstract Command getCreateCommand(CreateRequest request)
Returns the Command to perform a create.

Parameters:
request - the CreateRequest
Returns:
a Command to perform a create

getDeleteDependantCommand

protected abstract Command getDeleteDependantCommand(Request request)
Returns the Command to delete a child.

Parameters:
request - the Request
Returns:
the Command to delete the child

getLayoutContainer

protected IFigure getLayoutContainer()
Returns the host's contentPane. The contentPane is the Figure which parents the childrens' figures. It is also the figure which has the LayoutManager that corresponds to this EditPolicy. All operations should be interpreted with respect to this figure.

Returns:
the Figure that owns the corresponding LayoutManager

getMoveChildrenCommand

protected abstract Command getMoveChildrenCommand(Request request)
Returns the Command to move a group of children.

Parameters:
request - the Request
Returns:
the Command to perform the move

getOrphanChildrenCommand

protected Command getOrphanChildrenCommand(Request request)
Returns the Command to orphan a group of children. The contribution to orphan might contain two parts, both of which are option. The first part is to actually remove the children from their existing parent. Some application models will perform an orphan implicitly when the children are added to their new parent. The second part is to perform some adjustments on the remaining children. For example, a Table layout might simplify itself by collapsing any unused columns and rows.

Parameters:
request - the Request
Returns:
null or a Command to perform an orphan

getSizeOnDropFeedback

protected IFigure getSizeOnDropFeedback()
Lazily creates and returns the Figure to use for size-on-drop feedback.

Returns:
the size-on-drop feedback figure

getTargetEditPart

public EditPart getTargetEditPart(Request request)
Returns the host if the Request is an ADD, MOVE, or CREATE.

Specified by:
getTargetEditPart in interface EditPolicy
Overrides:
getTargetEditPart in class AbstractEditPolicy
See Also:
EditPolicy.getTargetEditPart(Request)

setListener

protected void setListener(EditPartListener listener)
Sets the EditPartListener used to decorate new children. If the listener is currently set, it will be unhooked. If the new value is not null, it will be hooked.

The listener must be remembered in case this EditPolicy is removed from the host and replaced with another LayoutEditPolicy.

Parameters:
listener - null or the listener.

showDragTargetFeedback

protected final void showDragTargetFeedback(Request request)
                                     throws Exception
Made final for compatibility.

Parameters:
request - the Request
Throws:
Exception - bogus

showLayoutTargetFeedback

protected void showLayoutTargetFeedback(Request request)
Shows target layout feedback. During moves, reparents, and creation, this method is called to allow the LayoutEditPolicy to temporarily show features of its layout that will help the User understand what will happen if the operation is performed in the current location.

By default, no feedback is shown.

Parameters:
request - the Request
See Also:
eraseLayoutTargetFeedback(Request)

showSizeOnDropFeedback

protected void showSizeOnDropFeedback(CreateRequest request)
Shows size-on-drop feedback during creation.

Parameters:
request - the CreateRequest

showTargetFeedback

public void showTargetFeedback(Request request)
Factors feedback requests into two more specific methods.

Specified by:
showTargetFeedback in interface EditPolicy
Overrides:
showTargetFeedback in class AbstractEditPolicy
See Also:
EditPolicy.showTargetFeedback(Request)

Eclipse GEF
2.1

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