T
- The type of the items.public class FocusIndicatorManager<T extends ILookup> extends ModelManager<T>
ModelManager
implementation that manages the visual decoration of the focused element in a canvas.
For the item that should be focused this class uses the ILookup
mechanism of the item to lookup an IFocusIndicatorInstaller
implementation which will do the actual installation of the decoration in the canvas.
Constructor and Description |
---|
FocusIndicatorManager(CanvasControl canvas)
Creates an instance that for all focused items in the model dynamically installs a decoration.
|
Modifier and Type | Method and Description |
---|---|
protected ICanvasObject |
add(T item)
Overridden to do nothing.
|
void |
addPropertyChangedListener(IEventHandler<PropertyChangedEventArgs> propertyChangedEvent)
Adds the given listener for the
PropertyChanged event that occurs when the FocusedItem
property has been changed. |
protected ICanvasObjectGroup |
getCanvasObjectGroup(T item)
Callback used by
ModelManager.install(java.lang.Object) to retrieve the installer for a given item. |
T |
getFocusedItem()
Gets the focused item, updates the canvas and fires the corresponding property change event.
|
protected ICanvasObjectInstaller |
getInstaller(T item)
Callback used by
ModelManager.install(java.lang.Object) to retrieve the installer for a given item. |
ShowFocusPolicy |
getShowFocusPolicy()
Gets the show focus policy.
|
boolean |
isFocused()
Gets a value indicating whether the
container this manager is installed in currently is focused. |
protected void |
onDisabled()
Called when this mode gets
disabled . |
protected void |
onEnabled()
Called when this mode gets
enabled . |
protected void |
onFocusedChanged()
Called when the
Focused property has changed. |
protected void |
onPropertyChanged(PropertyChangedEventArgs args)
Callback method that is triggered when the focused item has changed.
|
protected void |
remove(T item)
Overridden to do nothing.
|
void |
removePropertyChangedListener(IEventHandler<PropertyChangedEventArgs> propertyChangedEvent)
Removes the given listener for the
PropertyChanged event that occurs when the FocusedItem
property has been changed. |
void |
setFocused(boolean value)
Sets a value indicating whether the
container this manager is installed in currently is focused. |
void |
setFocusedItem(T value)
Sets the focused item, updates the canvas and fires the corresponding property change event.
|
void |
setShowFocusPolicy(ShowFocusPolicy value)
Sets the show focus policy.
|
getCanvas, install, isEnabled, setEnabled, unInstall
public FocusIndicatorManager(CanvasControl canvas)
canvas
- The canvas to add the focus marks to.protected ICanvasObject add(T item)
add
in class ModelManager<T extends ILookup>
item
- The item to add.null
if nothing was installed.public final void addPropertyChangedListener(IEventHandler<PropertyChangedEventArgs> propertyChangedEvent)
PropertyChanged
event that occurs when the FocusedItem
property has been changed.propertyChangedEvent
- The listener to add.removePropertyChangedListener(IEventHandler)
protected ICanvasObjectGroup getCanvasObjectGroup(T item)
ModelManager.install(java.lang.Object)
to retrieve the installer for a given item.
This implementation always returns the FocusGroup
of the Canvas
of this instance.
getCanvasObjectGroup
in class ModelManager<T extends ILookup>
item
- The item to find a canvas object group for.ICanvasObjectGroup
or null
public final T getFocusedItem()
null
.setFocusedItem(ILookup)
protected ICanvasObjectInstaller getInstaller(T item)
ModelManager.install(java.lang.Object)
to retrieve the installer for a given item.
This implementation uses the ILookup.lookup(java.lang.Class)
of the item to retrieve an IFocusIndicatorInstaller
instance.
getInstaller
in class ModelManager<T extends ILookup>
item
- The item to find an installer for.null
public final ShowFocusPolicy getShowFocusPolicy()
The default is ShowFocusPolicy.WHEN_FOCUSED
.
Focused
attribute.setShowFocusPolicy(ShowFocusPolicy)
public final boolean isFocused()
container
this manager is installed in currently is focused.true
if the container is currently focused; false
otherwise. Depending on the
ShowFocusPolicy
, this will influence the visibility of the rendering.setFocused(boolean)
protected void onDisabled()
ModelManager
disabled
.onDisabled
in class ModelManager<T extends ILookup>
protected void onEnabled()
ModelManager
enabled
.onEnabled
in class ModelManager<T extends ILookup>
protected void onFocusedChanged()
Focused
property has changed.isFocused()
protected void onPropertyChanged(PropertyChangedEventArgs args)
This method raises the PropertyChanged
event. Subclasses overriding
this method should make sure to invoke the super class implementation.
args
- a description of the eventgetFocusedItem()
,
addPropertyChangedListener(IEventHandler)
protected void remove(T item)
remove
in class ModelManager<T extends ILookup>
item
- The item to remove.public final void removePropertyChangedListener(IEventHandler<PropertyChangedEventArgs> propertyChangedEvent)
PropertyChanged
event that occurs when the FocusedItem
property has been changed.propertyChangedEvent
- The listener to remove.addPropertyChangedListener(IEventHandler)
public final void setFocused(boolean value)
container
this manager is installed in currently is focused.value
- true
if the container is currently focused; false
otherwise. Depending on the
ShowFocusPolicy
, this will influence the visibility of the rendering.isFocused()
public final void setFocusedItem(T value)
value
- The focused item, which can be null
.getFocusedItem()
public final void setShowFocusPolicy(ShowFocusPolicy value)
The default is ShowFocusPolicy.WHEN_FOCUSED
.
value
- The show focus policy. Changing this property influences the visibility of the rendering depending on the current value
of Focused
attribute.getShowFocusPolicy()