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 intoITransactionalOperations that delegate to respective operations of the hostIContentPartupon execution.In detail, the following delegations are performed to operations of the host
IContentPart:addContentChild(Object, int)will delegate through aAddContentChildOperationtoIContentPart.addContentChild(Object, int)removeContentChild(Object)will delegate through aRemoveContentChildOperationtoIContentPart.removeContentChild(Object)attachToContentAnchorage(Object, String)will delegate through aAttachToContentAnchorageOperationtoIContentPart.attachToContentAnchorage(Object, String)detachFromContentAnchorage(Object, String)will delegate through aDetachFromContentAnchorageOperationto 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 voidaddContentChild(java.lang.Object contentChild, int index)Creates and records operations to add the given contentChild to thehostof thisContentPolicyat the specified index.voidattachToContentAnchorage(java.lang.Object contentAnchorage, java.lang.String role)Creates and records operations to attach thehostof thisContentPolicyto the specified contentAnchorage under the specified role.protected ITransactionalOperationcreateOperation()Creates anITransactionalOperationthat is used to encapsulate the changes that are applied by thisAbstractPolicythrough its "work" methods.voiddetachFromContentAnchorage(java.lang.Object contentAnchorage, java.lang.String role)Creates and records operations to detach thehostof thisContentPolicyfrom the specified contentAnchorage under the specified role.protected AbstractCompositeOperationgetCompositeOperation()Extracts aAbstractCompositeOperationfrom the operation created bycreateOperation().IContentPart<? extends javafx.scene.Node>getHost()voidremoveContentChild(java.lang.Object contentChild)Creates and records operations to remove the given contentChild from the content children of thehostof thisContentPolicy.voidsetAdaptable(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 thehostof thisContentPolicyat the specified index.- Parameters:
contentChild- The contentObjectthat is to be added to thehostof 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 thehostof thisContentPolicyto the specified contentAnchorage under the specified role.- Parameters:
contentAnchorage- The contentObjectto which thehostof thisContentPolicyis to be attached.role- The role for the attachment.
-
createOperation
protected ITransactionalOperation createOperation()
Description copied from class:AbstractPolicyCreates anITransactionalOperationthat is used to encapsulate the changes that are applied by thisAbstractPolicythrough its "work" methods. The created operation should allow forlocal executionat each time.- Specified by:
createOperationin classAbstractPolicy- Returns:
- A new
ITransactionalOperationto encapsulate all applied changes.
-
detachFromContentAnchorage
public void detachFromContentAnchorage(java.lang.Object contentAnchorage, java.lang.String role)Creates and records operations to detach thehostof thisContentPolicyfrom the specified contentAnchorage under the specified role.- Parameters:
contentAnchorage- The contentObjectfrom which thegetHost()of thisContentPolicyis detached.role- The role under which the anchorage is detached.
-
getCompositeOperation
protected AbstractCompositeOperation getCompositeOperation()
Extracts aAbstractCompositeOperationfrom the operation created bycreateOperation(). The composite operation is used to combine individual content change operations.- Returns:
- The
AbstractCompositeOperationthat 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 thehostof thisContentPolicy.- Parameters:
contentChild- The contentObjectthat is removed from content children of thehostof thisContentPolicy.
-
setAdaptable
public void setAdaptable(IVisualPart<? extends javafx.scene.Node> adaptable)
- Specified by:
setAdaptablein interfaceIAdaptable.Bound<IVisualPart<? extends javafx.scene.Node>>- Overrides:
setAdaptablein classIAdaptable.Bound.Impl<IVisualPart<? extends javafx.scene.Node>>
-
-