Package org.eclipse.gef.editpolicies

# Class DirectEditPolicy

java.lang.Object
org.eclipse.gef.editpolicies.AbstractEditPolicy
org.eclipse.gef.editpolicies.GraphicalEditPolicy
org.eclipse.gef.editpolicies.DirectEditPolicy

All Implemented Interfaces:
  `EditPolicy`, `RequestConstants`

public abstract class DirectEditPolicy extends GraphicalEditPolicy
Shows DirectEdit feedback and creates the Command to perform a "direct edit". Direct Edit is when the User is editing a property of an EditPart directly (as opposed to in the Properties View) in the Viewer using a `CellEditor`. This EditPolicy is typically installed using `EditPolicy.DIRECT_EDIT_ROLE`.

Since:
  2.0

## 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_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
`DirectEditPolicy()`

## Method Summary

Modifier and Type
Method
Description
`protected void`
`eraseDirectEditFeedback(DirectEditRequest request)`
If feedback is being shown, this method calls `revertOldEditValue(DirectEditRequest)`.
`void`
`eraseSourceFeedback(Request request)`
Does nothing by default.
`Command`
`getCommand(Request request)`
Returns `null` by default.
`protected abstract Command`
`getDirectEditCommand(DirectEditRequest request)`
Returns the `Command` to perform the direct edit.
`protected void`
`revertOldEditValue(DirectEditRequest request)`
Helps erase feedback by reverting the original edit value.
`protected abstract void`
`showCurrentEditValue(DirectEditRequest request)`
Override to show the current direct edit value in the host's Figure.
`protected void`
`showDirectEditFeedback(DirectEditRequest request)`
Pushes the original edit value if necessary, and shows feedback.
`void`
`showSourceFeedback(Request request)`
Does nothing by default.
`protected void`
`storeOldEditValue(DirectEditRequest request)`
Called to remember the old value before direct edit feedback begins.
`boolean`
`understandsRequest(Request request)`
Returns `true` for `RequestConstants.REQ_DIRECT_EDIT`.

### Methods inherited from class org.eclipse.gef.editpolicies.GraphicalEditPolicy

`addFeedback, getFeedbackLayer, getHostFigure, getLayer, removeFeedback`

### Methods inherited from class org.eclipse.gef.editpolicies.AbstractEditPolicy

`activate, deactivate, debugFeedback, eraseTargetFeedback, getHost, getTargetEditPart, setHost, showTargetFeedback, toString`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### DirectEditPolicy

public DirectEditPolicy()

## Method Details

### eraseSourceFeedback

public void eraseSourceFeedback(Request request)
Description copied from class: `AbstractEditPolicy`
Does nothing by default.

Specified by:
  `eraseSourceFeedback` in interface `EditPolicy`
Overrides:
  `eraseSourceFeedback` in class `AbstractEditPolicy`
Parameters:
  `request` - the Request
See Also:
  - `EditPolicy.eraseSourceFeedback(Request)`

### eraseDirectEditFeedback

protected void eraseDirectEditFeedback(DirectEditRequest request)
If feedback is being shown, this method calls `revertOldEditValue(DirectEditRequest)`.

Parameters:
  `request` - the DirectEditRequest

### getCommand

public Command getCommand(Request request)
Description copied from class: `AbstractEditPolicy`
Returns `null` by default. `null` is used to indicate that the EditPolicy does not contribute to the specified `Request`.

Specified by:
  `getCommand` in interface `EditPolicy`
Overrides:
  `getCommand` in class `AbstractEditPolicy`
Parameters:
  `request` - the Request
Returns:
  `null` or a Command contribution
See Also:
  - `EditPolicy.getCommand(Request)`

### getDirectEditCommand

protected abstract Command getDirectEditCommand(DirectEditRequest request)
Returns the `Command` to perform the direct edit.

Parameters:
  `request` - the DirectEditRequest
Returns:
  the command to perform the direct edit

### revertOldEditValue

protected void revertOldEditValue(DirectEditRequest request)
Helps erase feedback by reverting the original edit value. The rule when using GEF is that all feedback is removed before changes to the model are made. By default, the host is sent `EditPart.refresh()`, which should cause it to refresh all properties. Subclasses can override this method to perform a more specific revert.

Parameters:
  `request` - the DirectEditRequest
See Also:
  - `storeOldEditValue(DirectEditRequest)`

### showSourceFeedback

public void showSourceFeedback(Request request)
Description copied from class: `AbstractEditPolicy`
Does nothing by default.

Specified by:
  `showSourceFeedback` in interface `EditPolicy`
Overrides:
  `showSourceFeedback` in class `AbstractEditPolicy`
Parameters:
  `request` - the Request
See Also:
  - `EditPolicy.showSourceFeedback(Request)`

### showDirectEditFeedback

protected void showDirectEditFeedback(DirectEditRequest request)
Pushes the original edit value if necessary, and shows feedback.

Parameters:
  `request` - the DirectEditRequest

### showCurrentEditValue

protected abstract void showCurrentEditValue(DirectEditRequest request)
Override to show the current direct edit value in the host's Figure. Although the CellEditor will probably cover the figure's display of this value, updating the figure will cause its preferred size to reflect the new value.

Parameters:
  `request` - the DirectEditRequest

### storeOldEditValue

protected void storeOldEditValue(DirectEditRequest request)
Called to remember the old value before direct edit feedback begins. After feedback is over, `revertOldEditValue(DirectEditRequest)` is called to undo the changes done by feedback. By default, this method nothing.

Parameters:
  `request` - the DirectEditRequest

### understandsRequest

public boolean understandsRequest(Request request)
Returns `true` for `RequestConstants.REQ_DIRECT_EDIT`. `DirectEditAction` will determine enablement based on whether the selected EditPart understands "direct edit".

Specified by:
  `understandsRequest` in interface `EditPolicy`
Overrides:
  `understandsRequest` in class `AbstractEditPolicy`
Parameters:
  `request` - the Request
Returns:
  boolean `true` if the EditPolicy understands the specified request
See Also:
  - `EditPolicy.understandsRequest(Request)`