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 Node>>
,IBehavior
- Direct Known Subclasses:
ConnectionClickableAreaBehavior
,ContentBehavior
,FocusBehavior
,GridBehavior
,HoverBehavior
,HoverIntentBehavior
,RevealPrimarySelectionBehavior
,SelectionBehavior
,SnappingBehavior
The
AbstractBehavior
can be used as a base class for
IBehavior
implementations. 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.-
Property Summary
PropertiesTypePropertyDescriptionfinal ReadOnlyBooleanProperty
ReadOnlyObjectProperty<IVisualPart<? extends Node>>
-
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 -
Method Summary
Modifier and TypeMethodDescriptionfinal void
activate()
final ReadOnlyBooleanProperty
ReadOnlyObjectProperty<IVisualPart<? extends Node>>
protected void
addAnchoreds
(Collection<? extends IVisualPart<? extends Node>> targets, List<? extends IVisualPart<? extends Node>> anchoreds) Adds the given anchoreds as children to the root part and anchors them to the given target parts.protected void
addAnchoreds
(Collection<? extends IVisualPart<? extends Node>> targets, List<? extends IVisualPart<? extends Node>> anchoreds, int insertionIndex) Adds the given anchoreds as children to the root part and anchors them to the given target parts.protected void
addFeedback
(List<? extends IVisualPart<? extends Node>> targets) Adds feedback for the given target parts.protected void
addFeedback
(IVisualPart<? extends Node> target) Adds feedback for the given target part.protected void
addHandles
(List<? extends IVisualPart<? extends Node>> targets) Adds handles for the given target parts.protected void
addHandles
(IVisualPart<? extends Node> target) Adds handles for the given target part.protected void
Removes all feedback.protected void
Removes all handles.final void
protected void
Postactivate()
hook that may be overwritten to e.g. register listeners.protected void
Predeactivate()
hook that may be overwritten to e.g. unregister listeners.IVisualPart<? extends Node>
Gets the value of the property adaptable.protected List<IFeedbackPart<? extends Node>>
getFeedback
(Collection<? extends IVisualPart<? extends Node>> targets) Returns a list that contains allIHandlePart
s that were generated for the given target parts by thisIBehavior
.protected List<IFeedbackPart<? extends Node>>
getFeedback
(IVisualPart<? extends Node> target) Returns a list that contains allIHandlePart
s that were generated for the given target part by thisIBehavior
.protected IFeedbackPartFactory
getFeedbackPartFactory
(IViewer viewer) Returns theIFeedbackPartFactory
that should be used for feedback creation.protected IFeedbackPartFactory
getFeedbackPartFactory
(IViewer viewer, String role) Returns theIFeedbackPartFactory
that is registered as an adapter at the givenIViewer
under the given role.protected Map<Set<IVisualPart<? extends Node>>,
List<IFeedbackPart<? extends Node>>> Returns the map that stores the feedback parts per target part set.protected IHandlePartFactory
getHandlePartFactory
(IViewer viewer) Returns theIHandlePartFactory
that should be used for handle creation.protected IHandlePartFactory
getHandlePartFactory
(IViewer viewer, String role) Returns theIHandlePartFactory
that is registered as an adapter at the givenIViewer
under the given role.protected List<IHandlePart<? extends Node>>
getHandles
(Collection<? extends IVisualPart<? extends Node>> targets) Returns a list that contains allIHandlePart
s that were generated for the given target parts by thisIBehavior
.protected List<IHandlePart<? extends Node>>
getHandles
(IVisualPart<? extends Node> target) Returns a list that contains allIHandlePart
s that were generated for the given target part by thisIBehavior
.protected Map<Set<IVisualPart<? extends Node>>,
List<IHandlePart<? extends Node>>> Returns the map that stores the handle parts per target part set.IVisualPart<? extends Node>
getHost()
Returns the hostIVisualPart
of thisIBehavior
, i.e. the part where this behavior is registered as an adapter.protected boolean
hasFeedback
(Collection<? extends IVisualPart<? extends Node>> targets) Returnstrue
if 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 boolean
hasFeedback
(IVisualPart<? extends Node> target) Returnstrue
if feedback was added for the given target part, even if no feedback parts were generated for the given target part.protected boolean
hasHandles
(Collection<? extends IVisualPart<? extends Node>> targets) Returnstrue
if 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 boolean
hasHandles
(IVisualPart<? extends Node> target) Returnstrue
if handles were added for the given target part, even if no handle parts were generated for the given target part.final boolean
isActive()
Gets the value of the property active.protected void
removeAnchoreds
(Collection<? extends IVisualPart<? extends Node>> targets, List<? extends IVisualPart<? extends Node>> anchoreds) Removes the given anchoreds as children from the root part and as anchoreds from the given target parts.protected void
removeFeedback
(Collection<? extends IVisualPart<? extends Node>> targets) Removes feedback for the given targets.protected void
removeFeedback
(Set<? extends IVisualPart<? extends Node>> targetSet) Removes feedback for the given target parts.protected void
removeFeedback
(IVisualPart<? extends Node> target) Removes feedback for the given target.protected void
removeHandles
(Collection<? extends IVisualPart<? extends Node>> targets) Removes handles for the given target parts.protected void
removeHandles
(Set<? extends IVisualPart<? extends Node>> targetSet) Removes handles for the given target parts.protected void
removeHandles
(IVisualPart<? extends Node> target) Removes handles for the given target.void
setAdaptable
(IVisualPart<? extends Node> adaptable) Sets the value of the property adaptable.IHandlePart<? extends Node>
updateHandles
(List<? extends IVisualPart<? extends Node>> targets, Comparator<IHandlePart<? extends Node>> interactedWithComparator, IHandlePart<? extends Node> interactedWith) Updates the handles of the given targets.IHandlePart<? extends Node>
updateHandles
(IVisualPart<? extends Node> target, Comparator<IHandlePart<? extends Node>> interactedWithComparator, IHandlePart<? extends Node> interactedWith) Updates the handles of the given target part.
-
Property Details
-
active
- Specified by:
activeProperty
in interfaceIActivatable
- See Also:
-
adaptable
- Specified by:
adaptableProperty
in interfaceIAdaptable.Bound<IVisualPart<? extends Node>>
- See Also:
-
-
Constructor Details
-
AbstractBehavior
public AbstractBehavior()
-
-
Method Details
-
activate
public final void activate()- Specified by:
activate
in interfaceIActivatable
-
activeProperty
- Specified by:
activeProperty
in interfaceIActivatable
- See Also:
-
adaptableProperty
- Specified by:
adaptableProperty
in interfaceIAdaptable.Bound<IVisualPart<? extends Node>>
- See Also:
-
addAnchoreds
protected void addAnchoreds(Collection<? extends IVisualPart<? extends Node>> targets, List<? extends IVisualPart<? extends 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(Collection<? extends IVisualPart<? extends Node>> targets, List<? extends IVisualPart<? extends 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
Adds feedback for the given target part.- Parameters:
target
- The target part for which to add feedback.
-
addFeedback
Adds feedback for the given target parts.- Parameters:
targets
- The target parts for which to add feedback.
-
addHandles
Adds handles for the given target part.- Parameters:
target
- The target part for which to add feedback.
-
addHandles
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:
deactivate
in 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
Gets the value of the property adaptable.- Specified by:
getAdaptable
in interfaceIAdaptable.Bound<IVisualPart<? extends Node>>
- Property description:
-
getFeedback
protected List<IFeedbackPart<? extends Node>> getFeedback(Collection<? extends IVisualPart<? extends Node>> targets) Returns a list that contains allIHandlePart
s 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
Returns a list that contains allIHandlePart
s 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
Returns theIFeedbackPartFactory
that should be used for feedback creation.- Parameters:
viewer
- TheIViewer
for which to determine theIFeedbackPartFactory
for thisIBehavior
.- Returns:
- The
IFeedbackPartFactory
that should be used for feedback creation.
-
getFeedbackPartFactory
Returns theIFeedbackPartFactory
that is registered as an adapter at the givenIViewer
under the given role.- Parameters:
viewer
- TheIViewer
where theIFeedbackPartFactory
is registered.role
- The role under which theIFeedbackPartFactory
is registered.- Returns:
- The
IFeedbackPartFactory
that is registered as an adapter at the givenIViewer
under the given role.
-
getFeedbackPerTargetSet
protected Map<Set<IVisualPart<? extends Node>>,List<IFeedbackPart<? extends 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
Returns theIHandlePartFactory
that should be used for handle creation.- Parameters:
viewer
- TheIViewer
for which to determine theIHandlePartFactory
for thisIBehavior
.- Returns:
- The
IHandlePartFactory
that should be used for feedback creation.
-
getHandlePartFactory
Returns theIHandlePartFactory
that is registered as an adapter at the givenIViewer
under the given role.- Parameters:
viewer
- TheIViewer
where theIHandlePartFactory
is registered.role
- The role under which theIHandlePartFactory
is registered.- Returns:
- The
IHandlePartFactory
that is registered as an adapter at the givenIViewer
under the given role.
-
getHandles
protected List<IHandlePart<? extends Node>> getHandles(Collection<? extends IVisualPart<? extends Node>> targets) Returns a list that contains allIHandlePart
s 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
Returns a list that contains allIHandlePart
s 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 Map<Set<IVisualPart<? extends Node>>,List<IHandlePart<? extends 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
Description copied from interface:IBehavior
Returns the hostIVisualPart
of thisIBehavior
, i.e. the part where this behavior is registered as an adapter.- Specified by:
getHost
in interfaceIBehavior
- Returns:
- The host
IVisualPart
of thisIBehavior
.
-
hasFeedback
Returnstrue
if 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:
true
if feedback was added for the given set of target parts, even if no feedback parts were generated, otherwisefalse
.
-
hasFeedback
Returnstrue
if 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:
true
if feedback was added for the given target part, even if no feedback parts were generated, otherwisefalse
.
-
hasHandles
Returnstrue
if 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:
true
if handles were added for the given set of target parts, even if no handle parts were generated, otherwisefalse
.
-
hasHandles
Returnstrue
if 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:
true
if handles were added for the given target part, even if no handles parts were generated, otherwisefalse
.
-
isActive
public final boolean isActive()Gets the value of the property active.- Specified by:
isActive
in interfaceIActivatable
- Property description:
-
removeAnchoreds
protected void removeAnchoreds(Collection<? extends IVisualPart<? extends Node>> targets, List<? extends IVisualPart<? extends 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
Removes feedback for the given targets.- Parameters:
targets
- The list of target parts.
-
removeFeedback
Removes feedback for the given target.- Parameters:
target
- The target for which to remove feedback.
-
removeFeedback
Removes feedback for the given target parts.- Parameters:
targetSet
- The target parts.
-
removeHandles
Removes handles for the given target parts.- Parameters:
targets
- The target parts.
-
removeHandles
Removes handles for the given target.- Parameters:
target
- The target for which to remove handles.
-
removeHandles
Removes handles for the given target parts.- Parameters:
targetSet
- The target parts.
-
setAdaptable
Sets the value of the property adaptable.- Specified by:
setAdaptable
in interfaceIAdaptable.Bound<IVisualPart<? extends Node>>
- Property description:
-
updateHandles
public IHandlePart<? extends Node> updateHandles(IVisualPart<? extends Node> target, Comparator<IHandlePart<? extends Node>> interactedWithComparator, IHandlePart<? extends Node> interactedWith) Updates the handles of the given target part. Returns a newIHandlePart
that 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
- AComparator
that can be used to identify a new handle at the same position as the handle that is currently interacted with. Can benull
if no handle should be preserved.interactedWith
- TheIHandlePart
that is interacted with and therefore, should be preserved, ornull
.- Returns:
- The new
IHandlePart
for 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 Node> updateHandles(List<? extends IVisualPart<? extends Node>> targets, Comparator<IHandlePart<? extends Node>> interactedWithComparator, IHandlePart<? extends Node> interactedWith) Updates the handles of the given targets. Returns a newIHandlePart
that 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
- AComparator
that can be used to identify a new handle at the same position as the handle that is currently interacted with. Can benull
if no handle should be preserved.interactedWith
- TheIHandlePart
that is interacted with and therefore, should be preserved, ornull
.- Returns:
- The new
IHandlePart
for the position of the handle part that is interacted with so that its information can be applied to the preserved handle part.
-