VR
- The visual root node of the UI toolkit this
AbstractVisualPart
is used in, e.g. javafx.scene.Node in
case of JavaFX.V
- The visual node used by this AbstractVisualPart
.public abstract class AbstractVisualPart<VR,V extends VR> extends java.lang.Object implements IVisualPart<VR,V>
IAdaptable.Bound<A extends IAdaptable>
Modifier and Type | Field and Description |
---|---|
protected java.beans.PropertyChangeSupport |
pcs
A
PropertyChangeSupport that is used as a delegate to notify
listeners about changes to this object. |
ANCHORAGES_PROPERTY, ANCHOREDS_PROPERTY, CHILDREN_PROPERTY, PARENT_PROPERTY
ADAPTERS_PROPERTY
ACTIVE_PROPERTY
Constructor and Description |
---|
AbstractVisualPart()
Creates a new
AbstractVisualPart instance, setting the
AdaptableScope for each of its IAdaptable -compliant types
(super classes implementing IAdaptable and super-interfaces
extending IAdaptable ) to the newly created instance (see
AdaptableScopes#scopeTo(IAdaptable)). |
Modifier and Type | Method and Description |
---|---|
void |
activate()
Activates this
IVisualPart (if it is not already active) by
setting (and propagating) the new active state first and delegating to
doActivate() afterwards. |
void |
addAnchorage(IVisualPart<VR,? extends VR> anchorage) |
void |
addAnchorage(IVisualPart<VR,? extends VR> anchorage,
java.lang.String role) |
void |
addAnchored(IVisualPart<VR,? extends VR> anchored)
Used by an anchored
IVisualPart to establish an
anchorage-anchored relationship with this anchorage IVisualPart . |
void |
addChild(IVisualPart<VR,? extends VR> child) |
void |
addChild(IVisualPart<VR,? extends VR> child,
int index) |
void |
addChildren(java.util.List<? extends IVisualPart<VR,? extends VR>> children) |
void |
addChildren(java.util.List<? extends IVisualPart<VR,? extends VR>> children,
int index) |
protected void |
addChildVisual(IVisualPart<VR,? extends VR> child,
int index)
Performs the addition of the child's visual to this
IVisualPart 's visual. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener) |
protected void |
attachToAnchorageVisual(IVisualPart<VR,? extends VR> anchorage,
java.lang.String role) |
protected abstract V |
createVisual() |
void |
deactivate()
Deactivates this
IVisualPart (if it is active) by delegating to
doDeactivate() first and setting (and propagating) the new
active state afterwards. |
protected void |
detachFromAnchorageVisual(IVisualPart<VR,? extends VR> anchorage,
java.lang.String role) |
void |
dispose() |
protected void |
doActivate() |
protected void |
doDeactivate() |
protected abstract void |
doRefreshVisual(V visual) |
<T> T |
getAdapter(AdapterKey<? super T> key) |
<T> T |
getAdapter(java.lang.Class<? super T> classKey) |
<T> T |
getAdapter(com.google.common.reflect.TypeToken<? super T> key) |
<T> java.util.Map<AdapterKey<? extends T>,T> |
getAdapters(java.lang.Class<? super T> classKey) |
<T> java.util.Map<AdapterKey<? extends T>,T> |
getAdapters(com.google.common.reflect.TypeToken<? super T> key) |
com.google.common.collect.SetMultimap<IVisualPart<VR,? extends VR>,java.lang.String> |
getAnchorages() |
com.google.common.collect.Multiset<IVisualPart<VR,? extends VR>> |
getAnchoreds() |
java.util.Map<AdapterKey<? extends IBehavior<VR>>,IBehavior<VR>> |
getBehaviors() |
java.util.List<IVisualPart<VR,? extends VR>> |
getChildren() |
IVisualPart<VR,? extends VR> |
getParent() |
java.util.Map<AdapterKey<? extends IPolicy<VR>>,IPolicy<VR>> |
getPolicies() |
IRootPart<VR,? extends VR> |
getRoot()
Returns the
IRootPart . |
protected IViewer<VR> |
getViewer() |
V |
getVisual() |
boolean |
isActive() |
boolean |
isRefreshVisual() |
void |
refreshVisual()
Refreshes this
IVisualPart 's visuals. |
protected void |
register(IViewer<VR> viewer)
Called when a link to the Viewer is obtained.
|
protected void |
registerAtVisualPartMap(IViewer<VR> viewer,
V visual) |
void |
removeAnchorage(IVisualPart<VR,? extends VR> anchorage) |
void |
removeAnchorage(IVisualPart<VR,? extends VR> anchorage,
java.lang.String role) |
void |
removeAnchored(IVisualPart<VR,? extends VR> anchored)
Used by an anchored
IVisualPart to unestablish an
anchorage-anchored relationship with this anchorage IVisualPart . |
void |
removeChild(IVisualPart<VR,? extends VR> child) |
void |
removeChildren(java.util.List<? extends IVisualPart<VR,? extends VR>> children) |
protected void |
removeChildVisual(IVisualPart<VR,? extends VR> child,
int index)
Removes the child's visual from this
IVisualPart 's visual. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener) |
void |
reorderChild(IVisualPart<VR,? extends VR> child,
int index)
Moves a child
IVisualPart into a lower index than it currently
occupies. |
<T> void |
setAdapter(AdapterKey<? super T> key,
T adapter) |
<T> void |
setAdapter(java.lang.Class<? super T> key,
T adapter) |
<T> void |
setAdapter(com.google.common.reflect.TypeToken<? super T> key,
T adapter) |
void |
setAdapters(java.util.Map<AdapterKey<?>,java.lang.Object> adaptersWithKeys)
Adds the set of adapters to this
IAdaptable . |
void |
setParent(IVisualPart<VR,? extends VR> newParent)
Sets the parent
IVisualPart . |
void |
setRefreshVisual(boolean isRefreshVisual)
Allows to temporarily turn
IVisualPart.refreshVisual() into a no-op
operation. |
protected void |
unregister(IViewer<VR> viewer)
Called when the link to the Viewer is lost.
|
protected void |
unregisterFromVisualPartMap(IViewer<VR> viewer,
V visual) |
<T> T |
unsetAdapter(AdapterKey<? super T> key) |
protected java.beans.PropertyChangeSupport pcs
PropertyChangeSupport
that is used as a delegate to notify
listeners about changes to this object. May be used by subclasses to
trigger the notification of listeners.public AbstractVisualPart()
AbstractVisualPart
instance, setting the
AdaptableScope
for each of its IAdaptable
-compliant types
(super classes implementing IAdaptable
and super-interfaces
extending IAdaptable
) to the newly created instance (see
AdaptableScopes#scopeTo(IAdaptable)).public final void activate()
IVisualPart
(if it is not already active) by
setting (and propagating) the new active state first and delegating to
doActivate()
afterwards. During the call to
doActivate()
, isActive()
will thus already return
true
. If the IVisualPart
is already active, this
operation will be a no-op.activate
in interface IActivatable
deactivate()
,
isActive()
public void addAnchorage(IVisualPart<VR,? extends VR> anchorage)
addAnchorage
in interface IVisualPart<VR,V extends VR>
public void addAnchorage(IVisualPart<VR,? extends VR> anchorage, java.lang.String role)
addAnchorage
in interface IVisualPart<VR,V extends VR>
public void addAnchored(IVisualPart<VR,? extends VR> anchored)
IVisualPart
IVisualPart
to establish an
anchorage-anchored relationship with this anchorage IVisualPart
.
Clients should never call this operation directly but instead add the
anchorage to its anchored via the IVisualPart.addAnchorage(IVisualPart)
and
IVisualPart.addAnchorage(IVisualPart, String)
operations, which will
indirectly lead to a call here.
addAnchored
in interface IVisualPart<VR,V extends VR>
anchored
- An IVisualPart
to attach to this anchorage
IVisualPart
as anchored.public void addChild(IVisualPart<VR,? extends VR> child)
addChild
in interface IVisualPart<VR,V extends VR>
public void addChild(IVisualPart<VR,? extends VR> child, int index)
addChild
in interface IVisualPart<VR,V extends VR>
public void addChildren(java.util.List<? extends IVisualPart<VR,? extends VR>> children)
addChildren
in interface IVisualPart<VR,V extends VR>
public void addChildren(java.util.List<? extends IVisualPart<VR,? extends VR>> children, int index)
addChildren
in interface IVisualPart<VR,V extends VR>
protected void addChildVisual(IVisualPart<VR,? extends VR> child, int index)
IVisualPart
's visual.child
- The IVisualPart
being addedindex
- The child's positionaddChild(IVisualPart, int)
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
addPropertyChangeListener
in interface IPropertyChangeNotifier
protected void attachToAnchorageVisual(IVisualPart<VR,? extends VR> anchorage, java.lang.String role)
protected abstract V createVisual()
public final void deactivate()
IVisualPart
(if it is active) by delegating to
doDeactivate()
first and setting (and propagating) the new
active state afterwards. During the call to doDeactivate()
,
isActive()
will thus still return true
. If the
IVisualPart
is not active, this operation will be a no-op.deactivate
in interface IActivatable
activate()
,
isActive()
protected void detachFromAnchorageVisual(IVisualPart<VR,? extends VR> anchorage, java.lang.String role)
public void dispose()
dispose
in interface IDisposable
protected void doActivate()
protected void doDeactivate()
protected abstract void doRefreshVisual(V visual)
public <T> T getAdapter(AdapterKey<? super T> key)
getAdapter
in interface IAdaptable
public <T> T getAdapter(java.lang.Class<? super T> classKey)
getAdapter
in interface IAdaptable
public <T> T getAdapter(com.google.common.reflect.TypeToken<? super T> key)
getAdapter
in interface IAdaptable
public <T> java.util.Map<AdapterKey<? extends T>,T> getAdapters(java.lang.Class<? super T> classKey)
getAdapters
in interface IAdaptable
public <T> java.util.Map<AdapterKey<? extends T>,T> getAdapters(com.google.common.reflect.TypeToken<? super T> key)
getAdapters
in interface IAdaptable
public com.google.common.collect.SetMultimap<IVisualPart<VR,? extends VR>,java.lang.String> getAnchorages()
getAnchorages
in interface IVisualPart<VR,V extends VR>
public com.google.common.collect.Multiset<IVisualPart<VR,? extends VR>> getAnchoreds()
getAnchoreds
in interface IVisualPart<VR,V extends VR>
public java.util.Map<AdapterKey<? extends IBehavior<VR>>,IBehavior<VR>> getBehaviors()
getBehaviors
in interface IVisualPart<VR,V extends VR>
public java.util.List<IVisualPart<VR,? extends VR>> getChildren()
getChildren
in interface IVisualPart<VR,V extends VR>
public IVisualPart<VR,? extends VR> getParent()
getParent
in interface IVisualPart<VR,V extends VR>
public java.util.Map<AdapterKey<? extends IPolicy<VR>>,IPolicy<VR>> getPolicies()
getPolicies
in interface IVisualPart<VR,V extends VR>
public IRootPart<VR,? extends VR> getRoot()
IVisualPart
IRootPart
. This method should only be called
internally or by helpers such as edit policies. The root can be used to
get the viewer.public boolean isActive()
isActive
in interface IActivatable
true
if this IVisualPart
is active.public boolean isRefreshVisual()
isRefreshVisual
in interface IVisualPart<VR,V extends VR>
public final void refreshVisual()
IVisualPart
's visuals. Delegates to
doRefreshVisual(Object)
in case isRefreshVisual()
is
not set to false
.refreshVisual
in interface IVisualPart<VR,V extends VR>
protected void register(IViewer<VR> viewer)
viewer
- The viewer to register at.public void removeAnchorage(IVisualPart<VR,? extends VR> anchorage)
removeAnchorage
in interface IVisualPart<VR,V extends VR>
public void removeAnchorage(IVisualPart<VR,? extends VR> anchorage, java.lang.String role)
removeAnchorage
in interface IVisualPart<VR,V extends VR>
public void removeAnchored(IVisualPart<VR,? extends VR> anchored)
IVisualPart
IVisualPart
to unestablish an
anchorage-anchored relationship with this anchorage IVisualPart
.
Clients should never call this operation directly but instead remove the
anchorage from its anchored via the IVisualPart.removeAnchorage(IVisualPart)
or IVisualPart.removeAnchorage(IVisualPart, String)
operations, which will
indirectly lead to a call here.
removeAnchored
in interface IVisualPart<VR,V extends VR>
anchored
- An IVisualPart
(currently attached as anchored to this
anchorage IVisualPart
) to detach from this anchorage
IVisualPart
as anchored.public void removeChild(IVisualPart<VR,? extends VR> child)
removeChild
in interface IVisualPart<VR,V extends VR>
public void removeChildren(java.util.List<? extends IVisualPart<VR,? extends VR>> children)
removeChildren
in interface IVisualPart<VR,V extends VR>
protected void removeChildVisual(IVisualPart<VR,? extends VR> child, int index)
IVisualPart
's visual.child
- The child IVisualPart
.index
- The index of the child whose visual is to be removed.public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
removePropertyChangeListener
in interface IPropertyChangeNotifier
public void reorderChild(IVisualPart<VR,? extends VR> child, int index)
IVisualPart
into a lower index than it currently
occupies.reorderChild
in interface IVisualPart<VR,V extends VR>
child
- the child IVisualPart
being reorderedindex
- new index for the childpublic <T> void setAdapter(AdapterKey<? super T> key, T adapter)
setAdapter
in interface IAdaptable
public <T> void setAdapter(java.lang.Class<? super T> key, T adapter)
setAdapter
in interface IAdaptable
public <T> void setAdapter(com.google.common.reflect.TypeToken<? super T> key, T adapter)
setAdapter
in interface IAdaptable
@Inject(optional=true) public void setAdapters(@AdapterMap java.util.Map<AdapterKey<?>,java.lang.Object> adaptersWithKeys)
IAdaptable
. This method should
not be used by clients but is intended for injection of adapters by means
of an AdapterMapInjector
.
IMPORTANT: If sub-classes override this method, they will have to transfer the inject annotation to the overwritten method to ensure that adapter map injection is still functional.
adaptersWithKeys
- The adapters to add to this IAdaptable
(by means of
injection)AdapterMap
public void setParent(IVisualPart<VR,? extends VR> newParent)
IVisualPart
.setParent
in interface IVisualPart<VR,V extends VR>
newParent
- The new parent IVisualPart
or null
.public void setRefreshVisual(boolean isRefreshVisual)
IVisualPart
IVisualPart.refreshVisual()
into a no-op
operation. This may for instance be used to disable visual updates that
are initiated by the model (in case of IContentPart
s) while
interacting with the IVisualPart
.setRefreshVisual
in interface IVisualPart<VR,V extends VR>
isRefreshVisual
- Whether IVisualPart.refreshVisual()
should perform updates of the
visual (true
) or behave like a no-op operation (
false
).protected void unregister(IViewer<VR> viewer)
viewer
- The viewer to unregister from.protected void unregisterFromVisualPartMap(IViewer<VR> viewer, V visual)
public <T> T unsetAdapter(AdapterKey<? super T> key)
unsetAdapter
in interface IAdaptable
Copyright (c) 2014 itemis AG and others. All rights reserved.