org.eclipse.gef.mvc.fx.policies

## Class CreationPolicy

- 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.CreationPolicy

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

    public class CreationPolicy
    extends AbstractPolicy

The `CreationPolicy` is an `AbstractPolicy` that handles the creation of content.

It handles the creation by initiating the adding of a content child to the content parent via the `ContentPolicy` of the parent `IContentPart`, as well as the attachment of anchored content elements via the `ContentPolicy`s of anchored `IContentPart`s.

This policy should be registered at an `IRootPart`. It depends on `ContentPolicy`s being registered on all `IContentPart`s that are affected by the creation.

### 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 and Description
`CreationPolicy()`

### Method Summary

All Methods Instance Methods Concrete Methods
`IContentPart<? extends javafx.scene.Node>` `create(java.lang.Object content, IVisualPart<? extends javafx.scene.Node> parent, int index, SetMultimap<IContentPart<? extends javafx.scene.Node>,java.lang.String> anchoreds, boolean doFocus, boolean doSelect)` Creates an `IContentPart` for the given content `Object` and establishes parent and anchored relationships for the newly created part.
`IContentPart<? extends javafx.scene.Node>` `create(java.lang.Object content, IVisualPart<? extends javafx.scene.Node> parent, SetMultimap<IContentPart<? extends javafx.scene.Node>,java.lang.String> anchoreds)` Creates an `IContentPart` for the given content `Object` and establishes parent and anchored relationships for the newly created part.
`protected ITransactionalOperation` `createFocusOperation(IContentPart<? extends javafx.scene.Node> part)` Returns an `ITransactionalOperation` that adds the given `IContentPart` to the `FocusModel` of the corresponding `IViewer`.
`protected ITransactionalOperation` `createOperation()` Creates an `ITransactionalOperation` that is used to encapsulate the changes that are applied by this `AbstractPolicy` through its "work" methods.
`protected ITransactionalOperation` `createSelectOperation(IContentPart<? extends javafx.scene.Node> part)` Returns an `ITransactionalOperation` that adds the given `IContentPart` to the `SelectionModel` of the corresponding `IViewer`.
`protected AbstractCompositeOperation` `getCompositeOperation()` Extracts a `AbstractCompositeOperation` from the operation created by `createOperation()`.
`protected IContentPartFactory` `getContentPartFactory()` Returns the `IContentPartFactory` of the current viewer.

### 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, setAdaptable`

### 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.mvc.fx.policies.IPolicy

`getHost`

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

`adaptableProperty, getAdaptable, setAdaptable`

### Constructor Detail

#### CreationPolicy

    public CreationPolicy()

### Method Detail

#### create

    public IContentPart<? extends javafx.scene.Node> create(java.lang.Object content,
                                                            IVisualPart<? extends javafx.scene.Node> parent,
                                                            int index,
                                                            SetMultimap<IContentPart<? extends javafx.scene.Node>,java.lang.String> anchoreds,
                                                            boolean doFocus,
                                                            boolean doSelect)

Creates an `IContentPart` for the given content `Object` and establishes parent and anchored relationships for the newly created part. Besides, operations are created for the establishment of the parent and anchored relationships within the content model. These operations are part of the operation returned by `AbstractPolicy.commit()`.

Parameters:
  `content` - The content `Object` to be created.
  `parent` - The `IContentPart` where the content is added as a child or the `IRootPart` for 'root' content.
  `index` - The index for the new element.
  `anchoreds` - The `IContentPart` whose content should be attached to the new content under the given roles.
  `doFocus` - `true` if the newly created part should be focused.
  `doSelect` - `true` if the newly created part should be selected.
Returns:
  The `IContentPart` controlling the newly created content.

#### create

    public IContentPart<? extends javafx.scene.Node> create(java.lang.Object content,
                                                            IVisualPart<? extends javafx.scene.Node> parent,
                                                            SetMultimap<IContentPart<? extends javafx.scene.Node>,java.lang.String> anchoreds)

Creates an `IContentPart` for the given content `Object` and establishes parent and anchored relationships for the newly created part. The respective content operations are also created. In case the given part is to be created for root contents, the root part is expected to be passed in as parent. The content will then be added to the viewer contents. Besides, operations are created for the establishment of the parent and anchored relationships within the content model. These operations are part of the operation returned by `AbstractPolicy.commit()`.

Parameters:
  `content` - The content `Object` to be created.
  `parent` - The `IContentPart` where the content is added as a child.
  `anchoreds` - The `IContentPart` whose content should be attached to the new content under the given roles.
Returns:
  The `IContentPart` controlling the newly created content.

#### createFocusOperation

    protected ITransactionalOperation createFocusOperation(IContentPart<? extends javafx.scene.Node> part)

Returns an `ITransactionalOperation` that adds the given `IContentPart` to the `FocusModel` of the corresponding `IViewer`.

Parameters:
  `part` - The `IContentPart` that is added to the viewer models.
Returns:
  An `ITransactionalOperation` that changes the viewer models.

#### 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.

#### createSelectOperation

    protected ITransactionalOperation createSelectOperation(IContentPart<? extends javafx.scene.Node> part)

Returns an `ITransactionalOperation` that adds the given `IContentPart` to the `SelectionModel` of the corresponding `IViewer`.

Parameters:
  `part` - The `IContentPart` that is added to the viewer models.
Returns:
  An `ITransactionalOperation` that changes the viewer models.

#### 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.

#### getContentPartFactory

    protected IContentPartFactory getContentPartFactory()

Returns the `IContentPartFactory` of the current viewer.

Returns:
  the `IContentPartFactory` of the current viewer.