Package org.eclipse.gef.mvc.fx.behaviors

# Class FocusBehavior

java.lang.Object
org.eclipse.gef.mvc.fx.behaviors.AbstractBehavior
org.eclipse.gef.mvc.fx.behaviors.FocusBehavior

All Implemented Interfaces:
  `IActivatable`, `IAdaptable.Bound<IVisualPart<? extends Node>>`, `IBehavior`

public class FocusBehavior extends AbstractBehavior
The `FocusBehavior` can be registered on an `IVisualPart` to transfer the focus information from the `FocusModel` to the part's visualization. It will assign keyboard focus to the visualization if the part is focused, and it will display focus feedback around the visualization to indicate that the part has focus.

## Property Summary

### Properties inherited from class org.eclipse.gef.mvc.fx.behaviors.AbstractBehavior

`active, adaptable`

## 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
Modifier and Type
Field
Description
`static final String`
`FOCUS_FEEDBACK_PART_FACTORY`
The adapter role for the "focus" `IFeedbackPartFactory`.
`static final String`
`FOCUSED_STYLE`
Defines the CSS styling that is used to highlight a focused viewer.
`static final String`
`UNFOCUSED_STYLE`
Defines the default CSS styling for the `InfiniteCanvas`: no background, no border.

### Fields inherited from interface org.eclipse.gef.common.activate.IActivatable

`ACTIVE_PROPERTY`

## Constructor Summary

Constructors
Constructor
Description
`FocusBehavior()`

## Method Summary

Modifier and Type
Method
Description
`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`
`addViewerFocusedFeedback()`
Adds viewer focused feedback.
`protected void`
`applyFocusToVisual()`
Transfers the keyboard focus to JavaFX, i.e. calls `Node.requestFocus()` on the visual of the focus part, or on the root visual if no part is focused.
`protected void`
`doActivate()`
Post `AbstractBehavior.activate()` hook that may be overwritten to e.g. register listeners.
`protected void`
`doDeactivate()`
Pre `AbstractBehavior.deactivate()` hook that may be overwritten to e.g. unregister listeners.
`protected IFeedbackPartFactory`
`getFeedbackPartFactory(IViewer viewer)`
Returns the `IFeedbackPartFactory` that should be used for feedback creation.
`protected FocusModel`
`getFocusModel()`
Returns the `FocusModel` at which this `FocusBehavior` is registered for changes.
`protected void`
`refreshFocusFeedback()`
Refreshes focus feedback, i.e. adds or removes feedback.
`protected void`
`removeViewerFocusedFeedback()`
Removes viewer focused feedback.

### Methods inherited from class org.eclipse.gef.mvc.fx.behaviors.AbstractBehavior

`activate, activeProperty, adaptableProperty, addAnchoreds, addFeedback, addFeedback, addHandles, addHandles, clearFeedback, clearHandles, deactivate, getAdaptable, getFeedback, getFeedback, getFeedbackPartFactory, getFeedbackPerTargetSet, getHandlePartFactory, getHandlePartFactory, getHandles, getHandles, getHandlesPerTargetSet, getHost, hasFeedback, hasFeedback, hasHandles, hasHandles, isActive, removeAnchoreds, removeFeedback, removeFeedback, removeFeedback, removeHandles, removeHandles, removeHandles, setAdaptable, updateHandles, updateHandles`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### UNFOCUSED_STYLE

public static final String UNFOCUSED_STYLE
Defines the default CSS styling for the `InfiniteCanvas`: no background, no border.

See Also:
  - Constant Field Values

### FOCUSED_STYLE

public static final String FOCUSED_STYLE
Defines the CSS styling that is used to highlight a focused viewer.

See Also:
  - Constant Field Values

### FOCUS_FEEDBACK_PART_FACTORY

public static final String FOCUS_FEEDBACK_PART_FACTORY
The adapter role for the "focus" `IFeedbackPartFactory`.

See Also:
  - Constant Field Values

## Constructor Details

### FocusBehavior

public FocusBehavior()

## Method Details

### addAnchoreds

protected void addAnchoreds(Collection<? extends IVisualPart<? extends Node>> targets, List<? extends IVisualPart<? extends Node>> anchoreds)
Description copied from class: `AbstractBehavior`
Adds the given anchoreds as children to the root part and anchors them to the given target parts.

Overrides:
  `addAnchoreds` in class `AbstractBehavior`
Parameters:
  `targets` - The anchorages for the anchoreds.
  `anchoreds` - The anchored (feedback or handle) parts.

### addViewerFocusedFeedback

protected void addViewerFocusedFeedback()
Adds viewer focused feedback.

### applyFocusToVisual

protected void applyFocusToVisual()
Transfers the keyboard focus to JavaFX, i.e. calls `Node.requestFocus()` on the visual of the focus part, or on the root visual if no part is focused.

### doActivate

protected void doActivate()
Description copied from class: `AbstractBehavior`
Post `AbstractBehavior.activate()` hook that may be overwritten to e.g. register listeners.

Overrides:
  `doActivate` in class `AbstractBehavior`

### doDeactivate

protected void doDeactivate()
Description copied from class: `AbstractBehavior`
Pre `AbstractBehavior.deactivate()` hook that may be overwritten to e.g. unregister listeners.

Overrides:
  `doDeactivate` in class `AbstractBehavior`

### getFeedbackPartFactory

protected IFeedbackPartFactory getFeedbackPartFactory(IViewer viewer)
Description copied from class: `AbstractBehavior`
Returns the `IFeedbackPartFactory` that should be used for feedback creation.

Overrides:
  `getFeedbackPartFactory` in class `AbstractBehavior`
Parameters:
  `viewer` - The `IViewer` for which to determine the `IFeedbackPartFactory` for this `IBehavior`.
Returns:
  The `IFeedbackPartFactory` that should be used for feedback creation.

### getFocusModel

protected FocusModel getFocusModel()
Returns the `FocusModel` at which this `FocusBehavior` is registered for changes.

Returns:
  The `FocusModel` at which this `FocusBehavior` is registered for changes.

### refreshFocusFeedback

protected void refreshFocusFeedback()
Refreshes focus feedback, i.e. adds or removes feedback.

### removeViewerFocusedFeedback

protected void removeViewerFocusedFeedback()
Removes viewer focused feedback.