Package org.eclipse.gef.mvc.fx.policies

# Class ContentPolicy

java.lang.Object
org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl<IVisualPart<? extends javafx.scene.Node>>
org.eclipse.gef.mvc.fx.policies.AbstractPolicy
org.eclipse.gef.mvc.fx.policies.ContentPolicy

All Implemented Interfaces:
  `IAdaptable.Bound<IVisualPart<? extends javafx.scene.Node>>`, `IPolicy`

public class ContentPolicy extends AbstractPolicy
A (transaction) policy to handle content changes, i.e. adding/removing of content children as well as attaching/detaching to/from content anchorages. All changes are wrapped into `ITransactionalOperation`s that delegate to respective operations of the host `IContentPart` upon execution.

In detail, the following delegations are performed to operations of the host `IContentPart`:

- `addContentChild(Object, int)` will delegate through a `AddContentChildOperation` to `IContentPart.addContentChild(Object, int)`
- `removeContentChild(Object)` will delegate through a `RemoveContentChildOperation` to `IContentPart.removeContentChild(Object)`
- `attachToContentAnchorage(Object, String)` will delegate through a `AttachToContentAnchorageOperation` to `IContentPart.attachToContentAnchorage(Object, String)`
- `detachFromContentAnchorage(Object, String)` will delegate through a `DetachFromContentAnchorageOperation` to IContentPart#detachFromContentAnchorage(Object, String)}

This policy should be registered on each `IContentPart`.

## Property Summary

### Properties inherited from class org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl

`adaptable`

### Properties inherited from interface org.eclipse.gef.common.adapt.IAdaptable.Bound

`adaptable`

## Nested Class Summary

## Nested classes/interfaces inherited from interface org.eclipse.gef.common.adapt.IAdaptable.Bound

`IAdaptable.Bound.Impl<T extends IAdaptable>`

## Constructor Summary

Constructors
Constructor
Description
`ContentPolicy()`

## Method Summary

Modifier and Type
Method
Description
`void`
`addContentChild(Object contentChild, int index)`
Creates and records operations to add the given contentChild to the `host` of this `ContentPolicy` at the specified index.
`void`
`attachToContentAnchorage(Object contentAnchorage, String role)`
Creates and records operations to attach the `host` of this `ContentPolicy` to the specified contentAnchorage under the specified role.
`protected ITransactionalOperation`
`createOperation()`
Creates an `ITransactionalOperation` that is used to encapsulate the changes that are applied by this `AbstractPolicy` through its "work" methods.
`void`
`detachFromContentAnchorage(Object contentAnchorage, String role)`
Creates and records operations to detach the `host` of this `ContentPolicy` from the specified contentAnchorage under the specified role.
`protected AbstractCompositeOperation`
`getCompositeOperation()`
Extracts a `AbstractCompositeOperation` from the operation created by `createOperation()`.
`IContentPart<? extends javafx.scene.Node>`
`getHost()`
Returns the host of this `IPolicy`, i.e. the `IVisualPart` this `IPolicy` is attached to.
`void`
`removeContentChild(Object contentChild)`
Creates and records operations to remove the given contentChild from the content children of the `host` of this `ContentPolicy`.
`void`
`setAdaptable(IVisualPart<? extends javafx.scene.Node> adaptable)`

### Methods inherited from class org.eclipse.gef.mvc.fx.policies.AbstractPolicy

`checkInitialized, commit, getOperation, init, isInitialized, locallyExecuteOperation, rollback`

### Methods inherited from class org.eclipse.gef.common.adapt.IAdaptable.Bound.Impl

`adaptableProperty, getAdaptable`

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

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

### Methods inherited from interface org.eclipse.gef.common.adapt.IAdaptable.Bound

`adaptableProperty, getAdaptable`

## Constructor Details

### ContentPolicy

public ContentPolicy()

## Method Details

### addContentChild

public void addContentChild(Object contentChild, int index)
Creates and records operations to add the given contentChild to the `host` of this `ContentPolicy` at the specified index.

Parameters:
  `contentChild` - The content `Object` that is to be added to the `host` of this `ContentPolicy`.
  `index` - The index of the new content child.

### attachToContentAnchorage

public void attachToContentAnchorage(Object contentAnchorage, String role)
Creates and records operations to attach the `host` of this `ContentPolicy` to the specified contentAnchorage under the specified role.

Parameters:
  `contentAnchorage` - The content `Object` to which the `host` of this `ContentPolicy` is to be attached.
  `role` - The role for the attachment.

### createOperation

protected ITransactionalOperation createOperation()
Description copied from class: `AbstractPolicy`
Creates an `ITransactionalOperation` that is used to encapsulate the changes that are applied by this `AbstractPolicy` through its "work" methods. The created operation should allow for `local execution` at each time.

Specified by:
  `createOperation` in class `AbstractPolicy`
Returns:
  A new `ITransactionalOperation` to encapsulate all applied changes.

### detachFromContentAnchorage

public void detachFromContentAnchorage(Object contentAnchorage, String role)
Creates and records operations to detach the `host` of this `ContentPolicy` from the specified contentAnchorage under the specified role.

Parameters:
  `contentAnchorage` - The content `Object` from which the `getHost()` of this `ContentPolicy` is detached.
  `role` - The role under which the anchorage is detached.

### getCompositeOperation

protected AbstractCompositeOperation getCompositeOperation()
Extracts a `AbstractCompositeOperation` from the operation created by `createOperation()`. The composite operation is used to combine individual content change operations.

Returns:
  The `AbstractCompositeOperation` that is used to combine the individual content change operations.

### getHost

public IContentPart<? extends javafx.scene.Node> getHost()
Description copied from interface: `IPolicy`
Returns the host of this `IPolicy`, i.e. the `IVisualPart` this `IPolicy` is attached to.

Returns:
  The host of this `IPolicy`.

### removeContentChild

public void removeContentChild(Object contentChild)
Creates and records operations to remove the given contentChild from the content children of the `host` of this `ContentPolicy`.

Parameters:
  `contentChild` - The content `Object` that is removed from content children of the `host` of this `ContentPolicy`.

### setAdaptable

public void setAdaptable(IVisualPart<? extends javafx.scene.Node> adaptable)

Specified by:
  `setAdaptable` in interface `IAdaptable.Bound<IVisualPart<? extends javafx.scene.Node>>`
Overrides:
  `setAdaptable` in class `IAdaptable.Bound.Impl<IVisualPart<? extends javafx.scene.Node>>`