Package org.eclipse.gef.mvc.fx.behaviors
Class AbstractBehavior
- java.lang.Object
-
- org.eclipse.gef.mvc.fx.behaviors.AbstractBehavior
-
- All Implemented Interfaces:
IActivatable,IAdaptable.Bound<IVisualPart<? extends javafx.scene.Node>>,IBehavior
- Direct Known Subclasses:
ConnectionClickableAreaBehavior,ContentBehavior,FocusBehavior,GridBehavior,HoverBehavior,HoverIntentBehavior,RevealPrimarySelectionBehavior,SelectionBehavior,SnappingBehavior
public abstract class AbstractBehavior extends java.lang.Object implements IBehavior
TheAbstractBehaviorcan be used as a base class forIBehaviorimplementations. It implements activation and deactivation of its adapters, and provides methods for the addition and removal of feedback and handles, as well as a method that can be used to update the handles for a given target part.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.eclipse.gef.common.adapt.IAdaptable.Bound
IAdaptable.Bound.Impl<T extends IAdaptable>
-
-
Field Summary
-
Fields inherited from interface org.eclipse.gef.common.activate.IActivatable
ACTIVE_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description AbstractBehavior()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidactivate()javafx.beans.property.ReadOnlyBooleanPropertyactiveProperty()javafx.beans.property.ReadOnlyObjectProperty<IVisualPart<? extends javafx.scene.Node>>adaptableProperty()protected voidaddAnchoreds(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets, java.util.List<? extends IVisualPart<? extends javafx.scene.Node>> anchoreds)Adds the given anchoreds as children to the root part and anchors them to the given target parts.protected voidaddAnchoreds(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets, java.util.List<? extends IVisualPart<? extends javafx.scene.Node>> anchoreds, int insertionIndex)Adds the given anchoreds as children to the root part and anchors them to the given target parts.protected voidaddFeedback(java.util.List<? extends IVisualPart<? extends javafx.scene.Node>> targets)Adds feedback for the given target parts.protected voidaddFeedback(IVisualPart<? extends javafx.scene.Node> target)Adds feedback for the given target part.protected voidaddHandles(java.util.List<? extends IVisualPart<? extends javafx.scene.Node>> targets)Adds handles for the given target parts.protected voidaddHandles(IVisualPart<? extends javafx.scene.Node> target)Adds handles for the given target part.protected voidclearFeedback()Removes all feedback.protected voidclearHandles()Removes all handles.voiddeactivate()protected voiddoActivate()Postactivate()hook that may be overwritten to e.g. register listeners.protected voiddoDeactivate()Predeactivate()hook that may be overwritten to e.g. unregister listeners.IVisualPart<? extends javafx.scene.Node>getAdaptable()protected java.util.List<IFeedbackPart<? extends javafx.scene.Node>>getFeedback(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets)Returns a list that contains allIHandleParts that were generated for the given target parts by thisIBehavior.protected java.util.List<IFeedbackPart<? extends javafx.scene.Node>>getFeedback(IVisualPart<? extends javafx.scene.Node> target)Returns a list that contains allIHandleParts that were generated for the given target part by thisIBehavior.protected IFeedbackPartFactorygetFeedbackPartFactory(IViewer viewer)Returns theIFeedbackPartFactorythat should be used for feedback creation.protected IFeedbackPartFactorygetFeedbackPartFactory(IViewer viewer, java.lang.String role)Returns theIFeedbackPartFactorythat is registered as an adapter at the givenIViewerunder the given role.protected java.util.Map<java.util.Set<IVisualPart<? extends javafx.scene.Node>>,java.util.List<IFeedbackPart<? extends javafx.scene.Node>>>getFeedbackPerTargetSet()Returns the map that stores the feedback parts per target part set.protected IHandlePartFactorygetHandlePartFactory(IViewer viewer)Returns theIHandlePartFactorythat should be used for handle creation.protected IHandlePartFactorygetHandlePartFactory(IViewer viewer, java.lang.String role)Returns theIHandlePartFactorythat is registered as an adapter at the givenIViewerunder the given role.protected java.util.List<IHandlePart<? extends javafx.scene.Node>>getHandles(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets)Returns a list that contains allIHandleParts that were generated for the given target parts by thisIBehavior.protected java.util.List<IHandlePart<? extends javafx.scene.Node>>getHandles(IVisualPart<? extends javafx.scene.Node> target)Returns a list that contains allIHandleParts that were generated for the given target part by thisIBehavior.protected java.util.Map<java.util.Set<IVisualPart<? extends javafx.scene.Node>>,java.util.List<IHandlePart<? extends javafx.scene.Node>>>getHandlesPerTargetSet()Returns the map that stores the handle parts per target part set.IVisualPart<? extends javafx.scene.Node>getHost()Returns the hostIVisualPartof thisIBehavior, i.e. the part where this behavior is registered as an adapter.protected booleanhasFeedback(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets)Returnstrueif feedback was added for the given set of target parts, even if no feedback parts were generated for the given set of target parts.protected booleanhasFeedback(IVisualPart<? extends javafx.scene.Node> target)Returnstrueif feedback was added for the given target part, even if no feedback parts were generated for the given target part.protected booleanhasHandles(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets)Returnstrueif handles were added for the given set of target parts, even if no handle parts were generated for the given set of target parts.protected booleanhasHandles(IVisualPart<? extends javafx.scene.Node> target)Returnstrueif handles were added for the given target part, even if no handle parts were generated for the given target part.booleanisActive()protected voidremoveAnchoreds(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets, java.util.List<? extends IVisualPart<? extends javafx.scene.Node>> anchoreds)Removes the given anchoreds as children from the root part and as anchoreds from the given target parts.protected voidremoveFeedback(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets)Removes feedback for the given targets.protected voidremoveFeedback(java.util.Set<? extends IVisualPart<? extends javafx.scene.Node>> targetSet)Removes feedback for the given target parts.protected voidremoveFeedback(IVisualPart<? extends javafx.scene.Node> target)Removes feedback for the given target.protected voidremoveHandles(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets)Removes handles for the given target parts.protected voidremoveHandles(java.util.Set<? extends IVisualPart<? extends javafx.scene.Node>> targetSet)Removes handles for the given target parts.protected voidremoveHandles(IVisualPart<? extends javafx.scene.Node> target)Removes handles for the given target.voidsetAdaptable(IVisualPart<? extends javafx.scene.Node> adaptable)IHandlePart<? extends javafx.scene.Node>updateHandles(java.util.List<? extends IVisualPart<? extends javafx.scene.Node>> targets, java.util.Comparator<IHandlePart<? extends javafx.scene.Node>> interactedWithComparator, IHandlePart<? extends javafx.scene.Node> interactedWith)Updates the handles of the given targets.IHandlePart<? extends javafx.scene.Node>updateHandles(IVisualPart<? extends javafx.scene.Node> target, java.util.Comparator<IHandlePart<? extends javafx.scene.Node>> interactedWithComparator, IHandlePart<? extends javafx.scene.Node> interactedWith)Updates the handles of the given target part.
-
-
-
Method Detail
-
activate
public final void activate()
- Specified by:
activatein interfaceIActivatable
-
activeProperty
public final javafx.beans.property.ReadOnlyBooleanProperty activeProperty()
- Specified by:
activePropertyin interfaceIActivatable
-
adaptableProperty
public javafx.beans.property.ReadOnlyObjectProperty<IVisualPart<? extends javafx.scene.Node>> adaptableProperty()
- Specified by:
adaptablePropertyin interfaceIAdaptable.Bound<IVisualPart<? extends javafx.scene.Node>>
-
addAnchoreds
protected void addAnchoreds(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets, java.util.List<? extends IVisualPart<? extends javafx.scene.Node>> anchoreds)
Adds the given anchoreds as children to the root part and anchors them to the given target parts.- Parameters:
targets- The anchorages for the anchoreds.anchoreds- The anchored (feedback or handle) parts.
-
addAnchoreds
protected void addAnchoreds(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets, java.util.List<? extends IVisualPart<? extends javafx.scene.Node>> anchoreds, int insertionIndex)
Adds the given anchoreds as children to the root part and anchors them to the given target parts. The given index determines the position where the anchoreds are inserted into the children list of the root part. The index can be used to control the z-order.- Parameters:
targets- The target parts.anchoreds- The anchored (feedback or handle) parts.insertionIndex- The insertion index (controlling the z-order).
-
addFeedback
protected void addFeedback(IVisualPart<? extends javafx.scene.Node> target)
Adds feedback for the given target part.- Parameters:
target- The target part for which to add feedback.
-
addFeedback
protected void addFeedback(java.util.List<? extends IVisualPart<? extends javafx.scene.Node>> targets)
Adds feedback for the given target parts.- Parameters:
targets- The target parts for which to add feedback.
-
addHandles
protected void addHandles(IVisualPart<? extends javafx.scene.Node> target)
Adds handles for the given target part.- Parameters:
target- The target part for which to add feedback.
-
addHandles
protected void addHandles(java.util.List<? extends IVisualPart<? extends javafx.scene.Node>> targets)
Adds handles for the given target parts.- Parameters:
targets- The target parts for which to add handles.
-
clearFeedback
protected void clearFeedback()
Removes all feedback.
-
clearHandles
protected void clearHandles()
Removes all handles.
-
deactivate
public final void deactivate()
- Specified by:
deactivatein interfaceIActivatable
-
doActivate
protected void doActivate()
Postactivate()hook that may be overwritten to e.g. register listeners.
-
doDeactivate
protected void doDeactivate()
Predeactivate()hook that may be overwritten to e.g. unregister listeners.
-
getAdaptable
public IVisualPart<? extends javafx.scene.Node> getAdaptable()
- Specified by:
getAdaptablein interfaceIAdaptable.Bound<IVisualPart<? extends javafx.scene.Node>>
-
getFeedback
protected java.util.List<IFeedbackPart<? extends javafx.scene.Node>> getFeedback(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets)
Returns a list that contains allIHandleParts that were generated for the given target parts by thisIBehavior. If no handle parts were generated for the given target parts, an empty list is returned.- Parameters:
targets- A collection of target parts.- Returns:
- A list that contains all handle parts that were generated for the given target parts.
-
getFeedback
protected java.util.List<IFeedbackPart<? extends javafx.scene.Node>> getFeedback(IVisualPart<? extends javafx.scene.Node> target)
Returns a list that contains allIHandleParts that were generated for the given target part by thisIBehavior. If no handle parts were generated for the given target part, an empty list is returned.- Parameters:
target- The target part.- Returns:
- A list that contains all handle parts that were generated for the given target part.
-
getFeedbackPartFactory
protected IFeedbackPartFactory getFeedbackPartFactory(IViewer viewer)
Returns theIFeedbackPartFactorythat should be used for feedback creation.- Parameters:
viewer- TheIViewerfor which to determine theIFeedbackPartFactoryfor thisIBehavior.- Returns:
- The
IFeedbackPartFactorythat should be used for feedback creation.
-
getFeedbackPartFactory
protected IFeedbackPartFactory getFeedbackPartFactory(IViewer viewer, java.lang.String role)
Returns theIFeedbackPartFactorythat is registered as an adapter at the givenIViewerunder the given role.- Parameters:
viewer- TheIViewerwhere theIFeedbackPartFactoryis registered.role- The role under which theIFeedbackPartFactoryis registered.- Returns:
- The
IFeedbackPartFactorythat is registered as an adapter at the givenIViewerunder the given role.
-
getFeedbackPerTargetSet
protected java.util.Map<java.util.Set<IVisualPart<? extends javafx.scene.Node>>,java.util.List<IFeedbackPart<? extends javafx.scene.Node>>> getFeedbackPerTargetSet()
Returns the map that stores the feedback parts per target part set.- Returns:
- The map that stores the feedback parts per target part set.
-
getHandlePartFactory
protected IHandlePartFactory getHandlePartFactory(IViewer viewer)
Returns theIHandlePartFactorythat should be used for handle creation.- Parameters:
viewer- TheIViewerfor which to determine theIHandlePartFactoryfor thisIBehavior.- Returns:
- The
IHandlePartFactorythat should be used for feedback creation.
-
getHandlePartFactory
protected IHandlePartFactory getHandlePartFactory(IViewer viewer, java.lang.String role)
Returns theIHandlePartFactorythat is registered as an adapter at the givenIViewerunder the given role.- Parameters:
viewer- TheIViewerwhere theIHandlePartFactoryis registered.role- The role under which theIHandlePartFactoryis registered.- Returns:
- The
IHandlePartFactorythat is registered as an adapter at the givenIViewerunder the given role.
-
getHandles
protected java.util.List<IHandlePart<? extends javafx.scene.Node>> getHandles(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets)
Returns a list that contains allIHandleParts that were generated for the given target parts by thisIBehavior. If no handle parts were generated for the given target parts, an empty list is returned.- Parameters:
targets- A collection of target parts.- Returns:
- A list that contains all handle parts that were generated for the given target parts.
-
getHandles
protected java.util.List<IHandlePart<? extends javafx.scene.Node>> getHandles(IVisualPart<? extends javafx.scene.Node> target)
Returns a list that contains allIHandleParts that were generated for the given target part by thisIBehavior. If no handle parts were generated for the given target part, an empty list is returned.- Parameters:
target- The target part.- Returns:
- A list that contains all handle parts that were generated for the given target part.
-
getHandlesPerTargetSet
protected java.util.Map<java.util.Set<IVisualPart<? extends javafx.scene.Node>>,java.util.List<IHandlePart<? extends javafx.scene.Node>>> getHandlesPerTargetSet()
Returns the map that stores the handle parts per target part set.- Returns:
- The map that stores the handle parts per target part set.
-
getHost
public IVisualPart<? extends javafx.scene.Node> getHost()
Description copied from interface:IBehaviorReturns the hostIVisualPartof thisIBehavior, i.e. the part where this behavior is registered as an adapter.- Specified by:
getHostin interfaceIBehavior- Returns:
- The host
IVisualPartof thisIBehavior.
-
hasFeedback
protected boolean hasFeedback(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets)
Returnstrueif feedback was added for the given set of target parts, even if no feedback parts were generated for the given set of target parts. Otherwise returnsfalse.- Parameters:
targets- The set of target parts.- Returns:
trueif feedback was added for the given set of target parts, even if no feedback parts were generated, otherwisefalse.
-
hasFeedback
protected boolean hasFeedback(IVisualPart<? extends javafx.scene.Node> target)
Returnstrueif feedback was added for the given target part, even if no feedback parts were generated for the given target part. Otherwise returnsfalse.- Parameters:
target- The target part.- Returns:
trueif feedback was added for the given target part, even if no feedback parts were generated, otherwisefalse.
-
hasHandles
protected boolean hasHandles(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets)
Returnstrueif handles were added for the given set of target parts, even if no handle parts were generated for the given set of target parts. Otherwise returnsfalse.- Parameters:
targets- The set of target parts.- Returns:
trueif handles were added for the given set of target parts, even if no handle parts were generated, otherwisefalse.
-
hasHandles
protected boolean hasHandles(IVisualPart<? extends javafx.scene.Node> target)
Returnstrueif handles were added for the given target part, even if no handle parts were generated for the given target part. Otherwise returnsfalse.- Parameters:
target- The target part.- Returns:
trueif handles were added for the given target part, even if no handles parts were generated, otherwisefalse.
-
isActive
public final boolean isActive()
- Specified by:
isActivein interfaceIActivatable
-
removeAnchoreds
protected void removeAnchoreds(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets, java.util.List<? extends IVisualPart<? extends javafx.scene.Node>> anchoreds)
Removes the given anchoreds as children from the root part and as anchoreds from the given target parts.- Parameters:
targets- The anchorages of the anchoreds.anchoreds- The anchoreds (feedback or handles) that are to be removed.
-
removeFeedback
protected void removeFeedback(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets)
Removes feedback for the given targets.- Parameters:
targets- The list of target parts.
-
removeFeedback
protected void removeFeedback(IVisualPart<? extends javafx.scene.Node> target)
Removes feedback for the given target.- Parameters:
target- The target for which to remove feedback.
-
removeFeedback
protected void removeFeedback(java.util.Set<? extends IVisualPart<? extends javafx.scene.Node>> targetSet)
Removes feedback for the given target parts.- Parameters:
targetSet- The target parts.
-
removeHandles
protected void removeHandles(java.util.Collection<? extends IVisualPart<? extends javafx.scene.Node>> targets)
Removes handles for the given target parts.- Parameters:
targets- The target parts.
-
removeHandles
protected void removeHandles(IVisualPart<? extends javafx.scene.Node> target)
Removes handles for the given target.- Parameters:
target- The target for which to remove handles.
-
removeHandles
protected void removeHandles(java.util.Set<? extends IVisualPart<? extends javafx.scene.Node>> targetSet)
Removes handles for the given target parts.- Parameters:
targetSet- The target parts.
-
setAdaptable
public void setAdaptable(IVisualPart<? extends javafx.scene.Node> adaptable)
- Specified by:
setAdaptablein interfaceIAdaptable.Bound<IVisualPart<? extends javafx.scene.Node>>
-
updateHandles
public IHandlePart<? extends javafx.scene.Node> updateHandles(IVisualPart<? extends javafx.scene.Node> target, java.util.Comparator<IHandlePart<? extends javafx.scene.Node>> interactedWithComparator, IHandlePart<? extends javafx.scene.Node> interactedWith)
Updates the handles of the given target part. Returns a newIHandlePartthat would be replacing the given interactedWith handle part if that part was not preserved (which it is). The user can then apply the information of the replacement part to the preserved interactedWith part.- Parameters:
target- The target part for the handles.interactedWithComparator- AComparatorthat can be used to identify a new handle at the same position as the handle that is currently interacted with. Can benullif no handle should be preserved.interactedWith- TheIHandlePartthat is interacted with and therefore, should be preserved, ornull.- Returns:
- The new
IHandlePartfor the position of the handle part that is interacted with so that its information can be applied to the preserved handle part.
-
updateHandles
public IHandlePart<? extends javafx.scene.Node> updateHandles(java.util.List<? extends IVisualPart<? extends javafx.scene.Node>> targets, java.util.Comparator<IHandlePart<? extends javafx.scene.Node>> interactedWithComparator, IHandlePart<? extends javafx.scene.Node> interactedWith)
Updates the handles of the given targets. Returns a newIHandlePartthat would be replacing the given interactedWith handle part if that part was not preserved (which it is). The user can then apply the information of the replacement part to the preserved interactedWith part.- Parameters:
targets- The target parts for the handles.interactedWithComparator- AComparatorthat can be used to identify a new handle at the same position as the handle that is currently interacted with. Can benullif no handle should be preserved.interactedWith- TheIHandlePartthat is interacted with and therefore, should be preserved, ornull.- Returns:
- The new
IHandlePartfor the position of the handle part that is interacted with so that its information can be applied to the preserved handle part.
-
-