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 intoITransactionalOperation
s that delegate to respective operations of the hostIContentPart
upon execution.In detail, the following delegations are performed to operations of the host
IContentPart
:addContentChild(Object, int)
will delegate through aAddContentChildOperation
toIContentPart.addContentChild(Object, int)
removeContentChild(Object)
will delegate through aRemoveContentChildOperation
toIContentPart.removeContentChild(Object)
attachToContentAnchorage(Object, String)
will delegate through aAttachToContentAnchorageOperation
toIContentPart.attachToContentAnchorage(Object, String)
detachFromContentAnchorage(Object, String)
will delegate through aDetachFromContentAnchorageOperation
to IContentPart#detachFromContentAnchorage(Object, String)}
This policy should be registered on each
IContentPart
.
-
-
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
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addContentChild(java.lang.Object contentChild, int index)
Creates and records operations to add the given contentChild to thehost
of thisContentPolicy
at the specified index.void
attachToContentAnchorage(java.lang.Object contentAnchorage, java.lang.String role)
Creates and records operations to attach thehost
of thisContentPolicy
to the specified contentAnchorage under the specified role.protected ITransactionalOperation
createOperation()
Creates anITransactionalOperation
that is used to encapsulate the changes that are applied by thisAbstractPolicy
through its "work" methods.void
detachFromContentAnchorage(java.lang.Object contentAnchorage, java.lang.String role)
Creates and records operations to detach thehost
of thisContentPolicy
from the specified contentAnchorage under the specified role.protected AbstractCompositeOperation
getCompositeOperation()
Extracts aAbstractCompositeOperation
from the operation created bycreateOperation()
.IContentPart<? extends javafx.scene.Node>
getHost()
void
removeContentChild(java.lang.Object contentChild)
Creates and records operations to remove the given contentChild from the content children of thehost
of thisContentPolicy
.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
-
-
-
-
Method Detail
-
addContentChild
public void addContentChild(java.lang.Object contentChild, int index)
Creates and records operations to add the given contentChild to thehost
of thisContentPolicy
at the specified index.- Parameters:
contentChild
- The contentObject
that is to be added to thehost
of thisContentPolicy
.index
- The index of the new content child.
-
attachToContentAnchorage
public void attachToContentAnchorage(java.lang.Object contentAnchorage, java.lang.String role)
Creates and records operations to attach thehost
of thisContentPolicy
to the specified contentAnchorage under the specified role.- Parameters:
contentAnchorage
- The contentObject
to which thehost
of thisContentPolicy
is to be attached.role
- The role for the attachment.
-
createOperation
protected ITransactionalOperation createOperation()
Description copied from class:AbstractPolicy
Creates anITransactionalOperation
that is used to encapsulate the changes that are applied by thisAbstractPolicy
through its "work" methods. The created operation should allow forlocal execution
at each time.- Specified by:
createOperation
in classAbstractPolicy
- Returns:
- A new
ITransactionalOperation
to encapsulate all applied changes.
-
detachFromContentAnchorage
public void detachFromContentAnchorage(java.lang.Object contentAnchorage, java.lang.String role)
Creates and records operations to detach thehost
of thisContentPolicy
from the specified contentAnchorage under the specified role.- Parameters:
contentAnchorage
- The contentObject
from which thegetHost()
of thisContentPolicy
is detached.role
- The role under which the anchorage is detached.
-
getCompositeOperation
protected AbstractCompositeOperation getCompositeOperation()
Extracts aAbstractCompositeOperation
from the operation created bycreateOperation()
. 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
.
-
removeContentChild
public void removeContentChild(java.lang.Object contentChild)
Creates and records operations to remove the given contentChild from the content children of thehost
of thisContentPolicy
.- Parameters:
contentChild
- The contentObject
that is removed from content children of thehost
of thisContentPolicy
.
-
setAdaptable
public void setAdaptable(IVisualPart<? extends javafx.scene.Node> adaptable)
- Specified by:
setAdaptable
in interfaceIAdaptable.Bound<IVisualPart<? extends javafx.scene.Node>>
- Overrides:
setAdaptable
in classIAdaptable.Bound.Impl<IVisualPart<? extends javafx.scene.Node>>
-
-