public abstract class AbstractBehavior extends Object implements IBehavior
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.Type | Property and Description |
---|---|
ReadOnlyBooleanProperty |
active |
ReadOnlyObjectProperty<IVisualPart<? extends Node>> |
adaptable |
IAdaptable.Bound.Impl<T extends IAdaptable>
ACTIVE_PROPERTY
Constructor and Description |
---|
AbstractBehavior() |
Modifier and Type | Method and Description |
---|---|
void |
activate() |
ReadOnlyBooleanProperty |
activeProperty() |
ReadOnlyObjectProperty<IVisualPart<? extends Node>> |
adaptableProperty() |
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(IVisualPart<? extends Node> target)
Adds feedback for the given target part.
|
protected void |
addFeedback(List<? extends IVisualPart<? extends Node>> targets)
Adds feedback for the given target parts.
|
protected void |
addHandles(IVisualPart<? extends Node> target)
Adds handles for the given target part.
|
protected void |
addHandles(List<? extends IVisualPart<? extends Node>> targets)
Adds handles for the given target parts.
|
protected void |
clearFeedback()
Removes all feedback.
|
protected void |
clearHandles()
Removes all handles.
|
void |
deactivate() |
protected void |
doActivate()
Post
activate() hook that may be overwritten to e.g. register
listeners. |
protected void |
doDeactivate()
Pre
deactivate() hook that may be overwritten to e.g. unregister
listeners. |
IVisualPart<? extends Node> |
getAdaptable()
Gets the value of the property adaptable.
|
protected List<IFeedbackPart<? extends Node>> |
getFeedback(Collection<? extends IVisualPart<? extends Node>> targets)
Returns a list that contains all
IHandlePart s that were generated
for the given target parts by this IBehavior . |
protected List<IFeedbackPart<? extends Node>> |
getFeedback(IVisualPart<? extends Node> target)
Returns a list that contains all
IHandlePart s that were generated
for the given target part by this IBehavior . |
protected IFeedbackPartFactory |
getFeedbackPartFactory(IViewer viewer)
Returns the
IFeedbackPartFactory that should be used for feedback
creation. |
protected IFeedbackPartFactory |
getFeedbackPartFactory(IViewer viewer,
String role)
Returns the
IFeedbackPartFactory that is registered as an adapter
at the given IViewer under the given role. |
protected Map<Set<IVisualPart<? extends Node>>,List<IFeedbackPart<? extends Node>>> |
getFeedbackPerTargetSet()
Returns the map that stores the feedback parts per target part set.
|
protected IHandlePartFactory |
getHandlePartFactory(IViewer viewer)
Returns the
IHandlePartFactory that should be used for handle
creation. |
protected IHandlePartFactory |
getHandlePartFactory(IViewer viewer,
String role)
Returns the
IHandlePartFactory that is registered as an adapter
at the given IViewer under the given role. |
protected List<IHandlePart<? extends Node>> |
getHandles(Collection<? extends IVisualPart<? extends Node>> targets)
Returns a list that contains all
IHandlePart s that were generated
for the given target parts by this IBehavior . |
protected List<IHandlePart<? extends Node>> |
getHandles(IVisualPart<? extends Node> target)
Returns a list that contains all
IHandlePart s that were generated
for the given target part by this IBehavior . |
protected Map<Set<IVisualPart<? extends Node>>,List<IHandlePart<? extends Node>>> |
getHandlesPerTargetSet()
Returns the map that stores the handle parts per target part set.
|
IVisualPart<? extends Node> |
getHost()
Returns the host
IVisualPart of this IBehavior , i.e. the
part where this behavior is registered as an adapter. |
protected boolean |
hasFeedback(Collection<? extends IVisualPart<? extends Node>> targets)
Returns
true 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)
Returns
true 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)
Returns
true 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)
Returns
true if handles were added for the given target
part, even if no handle parts were generated for the given target part. |
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(IVisualPart<? extends Node> target)
Removes feedback for the given target.
|
protected void |
removeFeedback(Set<? extends IVisualPart<? extends Node>> targetSet)
Removes feedback for the given target parts.
|
protected void |
removeHandles(Collection<? extends IVisualPart<? extends Node>> targets)
Removes handles for the given target parts.
|
protected void |
removeHandles(IVisualPart<? extends Node> target)
Removes handles for the given target.
|
protected void |
removeHandles(Set<? extends IVisualPart<? extends Node>> targetSet)
Removes handles for the given target parts.
|
void |
setAdaptable(IVisualPart<? extends Node> adaptable)
Sets the value of the property adaptable.
|
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.
|
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.
|
public final ReadOnlyBooleanProperty activeProperty
activeProperty
in interface IActivatable
isActive()
public ReadOnlyObjectProperty<IVisualPart<? extends Node>> adaptableProperty
adaptableProperty
in interface IAdaptable.Bound<IVisualPart<? extends Node>>
getAdaptable()
,
setAdaptable(IVisualPart)
public final void activate()
activate
in interface IActivatable
public final ReadOnlyBooleanProperty activeProperty()
activeProperty
in interface IActivatable
isActive()
public ReadOnlyObjectProperty<IVisualPart<? extends Node>> adaptableProperty()
adaptableProperty
in interface IAdaptable.Bound<IVisualPart<? extends Node>>
getAdaptable()
,
setAdaptable(IVisualPart)
protected void addAnchoreds(Collection<? extends IVisualPart<? extends Node>> targets, List<? extends IVisualPart<? extends Node>> anchoreds)
targets
- The anchorages for the anchoreds.anchoreds
- The anchored (feedback or handle) parts.protected void addAnchoreds(Collection<? extends IVisualPart<? extends Node>> targets, List<? extends IVisualPart<? extends Node>> anchoreds, int insertionIndex)
targets
- The target parts.anchoreds
- The anchored (feedback or handle) parts.insertionIndex
- The insertion index (controlling the z-order).protected void addFeedback(IVisualPart<? extends Node> target)
target
- The target part for which to add feedback.protected void addFeedback(List<? extends IVisualPart<? extends Node>> targets)
targets
- The target parts for which to add feedback.protected void addHandles(IVisualPart<? extends Node> target)
target
- The target part for which to add feedback.protected void addHandles(List<? extends IVisualPart<? extends Node>> targets)
targets
- The target parts for which to add handles.protected void clearFeedback()
protected void clearHandles()
public final void deactivate()
deactivate
in interface IActivatable
protected void doActivate()
activate()
hook that may be overwritten to e.g. register
listeners.protected void doDeactivate()
deactivate()
hook that may be overwritten to e.g. unregister
listeners.public IVisualPart<? extends Node> getAdaptable()
getAdaptable
in interface IAdaptable.Bound<IVisualPart<? extends Node>>
protected List<IFeedbackPart<? extends Node>> getFeedback(Collection<? extends IVisualPart<? extends Node>> targets)
IHandlePart
s that were generated
for the given target parts by this IBehavior
. If no handle parts
were generated for the given target parts, an empty list is returned.targets
- A collection of target parts.protected List<IFeedbackPart<? extends Node>> getFeedback(IVisualPart<? extends Node> target)
IHandlePart
s that were generated
for the given target part by this IBehavior
. If no handle parts
were generated for the given target part, an empty list is returned.target
- The target part.protected IFeedbackPartFactory getFeedbackPartFactory(IViewer viewer)
IFeedbackPartFactory
that should be used for feedback
creation.viewer
- The IViewer
for which to determine the
IFeedbackPartFactory
for this IBehavior
.IFeedbackPartFactory
that should be used for feedback
creation.protected IFeedbackPartFactory getFeedbackPartFactory(IViewer viewer, String role)
IFeedbackPartFactory
that is registered as an adapter
at the given IViewer
under the given role.viewer
- The IViewer
where the IFeedbackPartFactory
is
registered.role
- The role under which the IFeedbackPartFactory
is
registered.IFeedbackPartFactory
that is registered as an adapter
at the given IViewer
under the given role.protected Map<Set<IVisualPart<? extends Node>>,List<IFeedbackPart<? extends Node>>> getFeedbackPerTargetSet()
protected IHandlePartFactory getHandlePartFactory(IViewer viewer)
IHandlePartFactory
that should be used for handle
creation.viewer
- The IViewer
for which to determine the
IHandlePartFactory
for this IBehavior
.IHandlePartFactory
that should be used for feedback
creation.protected IHandlePartFactory getHandlePartFactory(IViewer viewer, String role)
IHandlePartFactory
that is registered as an adapter
at the given IViewer
under the given role.viewer
- The IViewer
where the IHandlePartFactory
is
registered.role
- The role under which the IHandlePartFactory
is
registered.IHandlePartFactory
that is registered as an adapter
at the given IViewer
under the given role.protected List<IHandlePart<? extends Node>> getHandles(Collection<? extends IVisualPart<? extends Node>> targets)
IHandlePart
s that were generated
for the given target parts by this IBehavior
. If no handle parts
were generated for the given target parts, an empty list is returned.targets
- A collection of target parts.protected List<IHandlePart<? extends Node>> getHandles(IVisualPart<? extends Node> target)
IHandlePart
s that were generated
for the given target part by this IBehavior
. If no handle parts
were generated for the given target part, an empty list is returned.target
- The target part.protected Map<Set<IVisualPart<? extends Node>>,List<IHandlePart<? extends Node>>> getHandlesPerTargetSet()
public IVisualPart<? extends Node> getHost()
IBehavior
IVisualPart
of this IBehavior
, i.e. the
part where this behavior is registered as an adapter.getHost
in interface IBehavior
IVisualPart
of this IBehavior
.protected boolean hasFeedback(Collection<? extends IVisualPart<? extends Node>> targets)
true
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 returns false
.targets
- The set of target parts.true
if feedback was added for the given set of
target parts, even if no feedback parts were generated, otherwise
false
.protected boolean hasFeedback(IVisualPart<? extends Node> target)
true
if feedback was added for the given target
part, even if no feedback parts were generated for the given target part.
Otherwise returns false
.target
- The target part.true
if feedback was added for the given target
part, even if no feedback parts were generated, otherwise
false
.protected boolean hasHandles(Collection<? extends IVisualPart<? extends Node>> targets)
true
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 returns false
.targets
- The set of target parts.true
if handles were added for the given set of
target parts, even if no handle parts were generated, otherwise
false
.protected boolean hasHandles(IVisualPart<? extends Node> target)
true
if handles were added for the given target
part, even if no handle parts were generated for the given target part.
Otherwise returns false
.target
- The target part.true
if handles were added for the given target
part, even if no handles parts were generated, otherwise
false
.public final boolean isActive()
isActive
in interface IActivatable
protected void removeAnchoreds(Collection<? extends IVisualPart<? extends Node>> targets, List<? extends IVisualPart<? extends Node>> anchoreds)
targets
- The anchorages of the anchoreds.anchoreds
- The anchoreds (feedback or handles) that are to be removed.protected void removeFeedback(Collection<? extends IVisualPart<? extends Node>> targets)
targets
- The list of target parts.protected void removeFeedback(IVisualPart<? extends Node> target)
target
- The target for which to remove feedback.protected void removeFeedback(Set<? extends IVisualPart<? extends Node>> targetSet)
targetSet
- The target parts.protected void removeHandles(Collection<? extends IVisualPart<? extends Node>> targets)
targets
- The target parts.protected void removeHandles(IVisualPart<? extends Node> target)
target
- The target for which to remove handles.protected void removeHandles(Set<? extends IVisualPart<? extends Node>> targetSet)
targetSet
- The target parts.public void setAdaptable(IVisualPart<? extends Node> adaptable)
setAdaptable
in interface IAdaptable.Bound<IVisualPart<? extends Node>>
public IHandlePart<? extends Node> updateHandles(IVisualPart<? extends Node> target, Comparator<IHandlePart<? extends Node>> interactedWithComparator, IHandlePart<? extends Node> interactedWith)
IHandlePart
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.target
- The target part for the handles.interactedWithComparator
- A Comparator
that can be used to identify a new handle
at the same position as the handle that is currently
interacted with. Can be null
if no handle should
be preserved.interactedWith
- The IHandlePart
that is interacted with and therefore,
should be preserved, or null
.IHandlePart
for the position of the handle part
that is interacted with so that its information can be applied to
the preserved handle part.public IHandlePart<? extends Node> updateHandles(List<? extends IVisualPart<? extends Node>> targets, Comparator<IHandlePart<? extends Node>> interactedWithComparator, IHandlePart<? extends Node> interactedWith)
IHandlePart
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.targets
- The target parts for the handles.interactedWithComparator
- A Comparator
that can be used to identify a new handle
at the same position as the handle that is currently
interacted with. Can be null
if no handle should
be preserved.interactedWith
- The IHandlePart
that is interacted with and therefore,
should be preserved, or null
.IHandlePart
for the position of the handle part
that is interacted with so that its information can be applied to
the preserved handle part.Copyright (c) 2014, 2016 itemis AG and others. All rights reserved.