Package org.eclipse.gef.fx.swt.controls

# Class FXControlAdapter<T extends Control>

java.lang.Object
javafx.scene.Node
javafx.scene.Parent
javafx.scene.layout.Region
org.eclipse.gef.fx.swt.controls.FXControlAdapter<T>

Type Parameters:
  `T` - The SWT Control class which is wrapped by this `FXControlAdapter`.

All Implemented Interfaces:
  `javafx.css.Styleable`, `EventTarget`

public class FXControlAdapter<T extends Control> extends Region
The FXControlAdapter can be used to embed SWT controls into a JavaFX scene graph.

## Property Summary

### Properties inherited from class javafx.scene.layout.Region

`background, border, cacheShape, centerShape, height, insets, maxHeight, maxWidth, minHeight, minWidth, opaqueInsets, padding, prefHeight, prefWidth, scaleShape, shape, snapToPixel, width`

### Properties inherited from class javafx.scene.Parent

`needsLayout`

### Properties inherited from class javafx.scene.Node

`accessibleHelp, accessibleRoleDescription, accessibleRole, accessibleText, blendMode, boundsInLocal, boundsInParent, cacheHint, cache, clip, cursor, depthTest, disabled, disable, effectiveNodeOrientation, effect, eventDispatcher, focused, focusTraversable, hover, id, inputMethodRequests, layoutBounds, layoutX, layoutY, localToParentTransform, localToSceneTransform, managed, mouseTransparent, nodeOrientation, onContextMenuRequested, onDragDetected, onDragDone, onDragDropped, onDragEntered, onDragExited, onDragOver, onInputMethodTextChanged, onKeyPressed, onKeyReleased, onKeyTyped, onMouseClicked, onMouseDragEntered, onMouseDragExited, onMouseDragged, onMouseDragOver, onMouseDragReleased, onMouseEntered, onMouseExited, onMouseMoved, onMousePressed, onMouseReleased, onRotate, onRotationFinished, onRotationStarted, onScrollFinished, onScroll, onScrollStarted, onSwipeDown, onSwipeLeft, onSwipeRight, onSwipeUp, onTouchMoved, onTouchPressed, onTouchReleased, onTouchStationary, onZoomFinished, onZoom, onZoomStarted, opacity, parent, pickOnBounds, pressed, rotate, rotationAxis, scaleX, scaleY, scaleZ, scene, style, translateX, translateY, translateZ, viewOrder, visible`

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static interface`
`FXControlAdapter.IControlFactory<T extends Control>`
The `FXControlAdapter.IControlFactory` can be used in conjunction with `FXControlAdapter` to create the wrapped SWT `Control` when the surrounding `FXCanvas` changes.

## Field Summary

### Fields inherited from class javafx.scene.layout.Region

`USE_COMPUTED_SIZE, USE_PREF_SIZE`

### Fields inherited from class javafx.scene.Node

`BASELINE_OFFSET_SAME_AS_HEIGHT`

## Constructor Summary

Constructors
Constructor
Description
`FXControlAdapter(FXControlAdapter.IControlFactory<T> controlFactory)`
Creates a new `FXControlAdapter` which uses the given `FXControlAdapter.IControlFactory` for the creation of the SWT `Control`.
`FXControlAdapter(T control)`
Creates a new `FXControlAdapter` which wraps the given SWT `Control`.

## Method Summary

Modifier and Type
Method
Description
`protected double`
`computeMaxHeight(double width)`
`protected double`
`computeMaxWidth(double height)`
`protected double`
`computeMinHeight(double width)`
`protected double`
`computeMinWidth(double height)`
`protected double`
`computePrefHeight(double width)`
`protected double`
`computePrefWidth(double height)`
`void`
`dispose()`
Deactivates this `FXControlAdapter`, so that the SWT `Control` will not be re-created when the `FXCanvas` changes.
`protected ObservableList<Node>`
`getChildren()`
We do not manage children.
`T`
`getControl()`
Returns the SWT `Control` that is wrapped by this `FXControlAdapter`.
`protected FXCanvas`
`getFXCanvas(Node node)`
Returns the `FXCanvas` which embeds the `Scene` which contains the given `Node`.
`protected FXCanvas`
`getFXCanvas(Control control)`
Returns the first `FXCanvas` which is found by walking up the widget hierarchy of the given `Control`.
`protected void`
`hookControl(T control)`
Hooks the given `Control` into the JavaFX scene graph, for example, registering event forwarding from SWT to JavaFX.
`protected void`
`init()`
Initializes this `FXControlAdapter`.
`protected void`
`registerListeners()`
Registers JavaFX listeners for forwarding JavaFX state to SWT.
`protected void`
`registerSwtToFXEventForwarders(FXCanvas newCanvas)`
Registers SWT to JavaFX event forwarders for the given `FXCanvas`.
`void`
`relocate(double paramDouble1, double paramDouble2)`
`void`
`resize(double width, double height)`
`protected void`
`setCanvas(FXCanvas newCanvas)`
Changes the `FXCanvas` in which the `Control` is hooked.
`protected void`
`setControl(T control)`
Sets the `Control` of this `FXControlAdapter` to the given value and `hooks` or `unhooks` the `Control`, respectively.
`protected void`
`unhookControl(T control)`
Unhooks the given `Control` from the JavaFX scene graph, for example, unregistering event forwarding from SWT to JavaFX.
`protected void`
`unregisterListeners()`
Unregisters the listeners which have previously been registered during `registerListeners()`.
`protected void`
`unregisterSwtToFXEventForwarders()`
Unregisters the event forwarders which have previously been registered during `registerSwtToFXEventForwarders(FXCanvas)`.
`void`
`updateSwtBounds()`
Updates the `bounds` of the `Control` which is wrapped by this `FXControlAdapter`.

### Methods inherited from class javafx.scene.layout.Region

`backgroundProperty, borderProperty, cacheShapeProperty, centerShapeProperty, getBackground, getBorder, getClassCssMetaData, getCssMetaData, getHeight, getInsets, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getOpaqueInsets, getPadding, getPrefHeight, getPrefWidth, getShape, getUserAgentStylesheet, getWidth, heightProperty, insetsProperty, isCacheShape, isCenterShape, isResizable, isScaleShape, isSnapToPixel, layoutInArea, layoutInArea, layoutInArea, layoutInArea, maxHeight, maxHeightProperty, maxWidth, maxWidthProperty, minHeight, minHeightProperty, minWidth, minWidthProperty, opaqueInsetsProperty, paddingProperty, positionInArea, positionInArea, prefHeight, prefHeightProperty, prefWidth, prefWidthProperty, scaleShapeProperty, setBackground, setBorder, setCacheShape, setCenterShape, setHeight, setMaxHeight, setMaxSize, setMaxWidth, setMinHeight, setMinSize, setMinWidth, setOpaqueInsets, setPadding, setPrefHeight, setPrefSize, setPrefWidth, setScaleShape, setShape, setSnapToPixel, setWidth, shapeProperty, snappedBottomInset, snappedLeftInset, snappedRightInset, snappedTopInset, snapPosition, snapPositionX, snapPositionY, snapSize, snapSizeX, snapSizeY, snapSpace, snapSpaceX, snapSpaceY, snapToPixelProperty, widthProperty`

### Methods inherited from class javafx.scene.Parent

`getBaselineOffset, getChildrenUnmodifiable, getManagedChildren, getStylesheets, isNeedsLayout, layout, layoutChildren, lookup, needsLayoutProperty, queryAccessibleAttribute, requestLayout, requestParentLayout, setNeedsLayout, updateBounds`

### Methods inherited from class javafx.scene.Node

`accessibleHelpProperty, accessibleRoleDescriptionProperty, accessibleRoleProperty, accessibleTextProperty, addEventFilter, addEventHandler, applyCss, autosize, blendModeProperty, boundsInLocalProperty, boundsInParentProperty, buildEventDispatchChain, cacheHintProperty, cacheProperty, clipProperty, computeAreaInScreen, contains, contains, cursorProperty, depthTestProperty, disabledProperty, disableProperty, effectiveNodeOrientationProperty, effectProperty, eventDispatcherProperty, executeAccessibleAction, fireEvent, focusedProperty, focusTraversableProperty, getAccessibleHelp, getAccessibleRole, getAccessibleRoleDescription, getAccessibleText, getBlendMode, getBoundsInLocal, getBoundsInParent, getCacheHint, getClip, getContentBias, getCursor, getDepthTest, getEffect, getEffectiveNodeOrientation, getEventDispatcher, getId, getInitialCursor, getInitialFocusTraversable, getInputMethodRequests, getLayoutBounds, getLayoutX, getLayoutY, getLocalToParentTransform, getLocalToSceneTransform, getNodeOrientation, getOnContextMenuRequested, getOnDragDetected, getOnDragDone, getOnDragDropped, getOnDragEntered, getOnDragExited, getOnDragOver, getOnInputMethodTextChanged, getOnKeyPressed, getOnKeyReleased, getOnKeyTyped, getOnMouseClicked, getOnMouseDragEntered, getOnMouseDragExited, getOnMouseDragged, getOnMouseDragOver, getOnMouseDragReleased, getOnMouseEntered, getOnMouseExited, getOnMouseMoved, getOnMousePressed, getOnMouseReleased, getOnRotate, getOnRotationFinished, getOnRotationStarted, getOnScroll, getOnScrollFinished, getOnScrollStarted, getOnSwipeDown, getOnSwipeLeft, getOnSwipeRight, getOnSwipeUp, getOnTouchMoved, getOnTouchPressed, getOnTouchReleased, getOnTouchStationary, getOnZoom, getOnZoomFinished, getOnZoomStarted, getOpacity, getParent, getProperties, getPseudoClassStates, getRotate, getRotationAxis, getScaleX, getScaleY, getScaleZ, getScene, getStyle, getStyleableParent, getStyleClass, getTransforms, getTranslateX, getTranslateY, getTranslateZ, getTypeSelector, getUserData, getViewOrder, hasProperties, hoverProperty, idProperty, inputMethodRequestsProperty, intersects, intersects, isCache, isDisable, isDisabled, isFocused, isFocusTraversable, isHover, isManaged, isMouseTransparent, isPickOnBounds, isPressed, isVisible, layoutBoundsProperty, layoutXProperty, layoutYProperty, localToParent, localToParent, localToParent, localToParent, localToParent, localToParentTransformProperty, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToScene, localToSceneTransformProperty, localToScreen, localToScreen, localToScreen, localToScreen, localToScreen, lookupAll, managedProperty, mouseTransparentProperty, nodeOrientationProperty, notifyAccessibleAttributeChanged, onContextMenuRequestedProperty, onDragDetectedProperty, onDragDoneProperty, onDragDroppedProperty, onDragEnteredProperty, onDragExitedProperty, onDragOverProperty, onInputMethodTextChangedProperty, onKeyPressedProperty, onKeyReleasedProperty, onKeyTypedProperty, onMouseClickedProperty, onMouseDragEnteredProperty, onMouseDragExitedProperty, onMouseDraggedProperty, onMouseDragOverProperty, onMouseDragReleasedProperty, onMouseEnteredProperty, onMouseExitedProperty, onMouseMovedProperty, onMousePressedProperty, onMouseReleasedProperty, onRotateProperty, onRotationFinishedProperty, onRotationStartedProperty, onScrollFinishedProperty, onScrollProperty, onScrollStartedProperty, onSwipeDownProperty, onSwipeLeftProperty, onSwipeRightProperty, onSwipeUpProperty, onTouchMovedProperty, onTouchPressedProperty, onTouchReleasedProperty, onTouchStationaryProperty, onZoomFinishedProperty, onZoomProperty, onZoomStartedProperty, opacityProperty, parentProperty, parentToLocal, parentToLocal, parentToLocal, parentToLocal, parentToLocal, pickOnBoundsProperty, pressedProperty, pseudoClassStateChanged, removeEventFilter, removeEventHandler, requestFocus, resizeRelocate, rotateProperty, rotationAxisProperty, scaleXProperty, scaleYProperty, scaleZProperty, sceneProperty, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, sceneToLocal, screenToLocal, screenToLocal, screenToLocal, setAccessibleHelp, setAccessibleRole, setAccessibleRoleDescription, setAccessibleText, setBlendMode, setCache, setCacheHint, setClip, setCursor, setDepthTest, setDisable, setDisabled, setEffect, setEventDispatcher, setEventHandler, setFocused, setFocusTraversable, setHover, setId, setInputMethodRequests, setLayoutX, setLayoutY, setManaged, setMouseTransparent, setNodeOrientation, setOnContextMenuRequested, setOnDragDetected, setOnDragDone, setOnDragDropped, setOnDragEntered, setOnDragExited, setOnDragOver, setOnInputMethodTextChanged, setOnKeyPressed, setOnKeyReleased, setOnKeyTyped, setOnMouseClicked, setOnMouseDragEntered, setOnMouseDragExited, setOnMouseDragged, setOnMouseDragOver, setOnMouseDragReleased, setOnMouseEntered, setOnMouseExited, setOnMouseMoved, setOnMousePressed, setOnMouseReleased, setOnRotate, setOnRotationFinished, setOnRotationStarted, setOnScroll, setOnScrollFinished, setOnScrollStarted, setOnSwipeDown, setOnSwipeLeft, setOnSwipeRight, setOnSwipeUp, setOnTouchMoved, setOnTouchPressed, setOnTouchReleased, setOnTouchStationary, setOnZoom, setOnZoomFinished, setOnZoomStarted, setOpacity, setPickOnBounds, setPressed, setRotate, setRotationAxis, setScaleX, setScaleY, setScaleZ, setStyle, setTranslateX, setTranslateY, setTranslateZ, setUserData, setViewOrder, setVisible, snapshot, snapshot, startDragAndDrop, startFullDrag, styleProperty, toBack, toFront, toString, translateXProperty, translateYProperty, translateZProperty, usesMirroring, viewOrderProperty, visibleProperty`

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

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

### Methods inherited from interface javafx.css.Styleable

`getStyleableNode`

## Constructor Details

### FXControlAdapter

public FXControlAdapter(FXControlAdapter.IControlFactory<T> controlFactory)
Creates a new `FXControlAdapter` which uses the given `FXControlAdapter.IControlFactory` for the creation of the SWT `Control`.

Parameters:
  `controlFactory` - The `FXControlAdapter.IControlFactory` to use to create the SWT `Control`.

### FXControlAdapter

public FXControlAdapter(T control)
Creates a new `FXControlAdapter` which wraps the given SWT `Control`.

Parameters:
  `control` - The SWT `Control` to wrap in this `FXControlAdapter`.

## Method Details

### computeMaxHeight

protected double computeMaxHeight(double width)

Overrides:
  `computeMaxHeight` in class `Region`

### computeMaxWidth

protected double computeMaxWidth(double height)

Overrides:
  `computeMaxWidth` in class `Region`

### computeMinHeight

protected double computeMinHeight(double width)

Overrides:
  `computeMinHeight` in class `Region`

### computeMinWidth

protected double computeMinWidth(double height)

Overrides:
  `computeMinWidth` in class `Region`

### computePrefHeight

protected double computePrefHeight(double width)

Overrides:
  `computePrefHeight` in class `Region`

### computePrefWidth

protected double computePrefWidth(double height)

Overrides:
  `computePrefWidth` in class `Region`

### dispose

public void dispose()
Deactivates this `FXControlAdapter`, so that the SWT `Control` will not be re-created when the `FXCanvas` changes.

### getChildren

protected ObservableList<Node> getChildren()
We do not manage children. Therefore, it is illegal to alter the children list in any way.

Overrides:
  `getChildren` in class `Parent`

### getControl

public T getControl()
Returns the SWT `Control` that is wrapped by this `FXControlAdapter`.

Returns:
  The SWT `Control` that is wrapped by this `FXControlAdapter`.

### getFXCanvas

protected FXCanvas getFXCanvas(Control control)
Returns the first `FXCanvas` which is found by walking up the widget hierarchy of the given `Control`. If no `FXCanvas` can be found, `null` is returned.

Parameters:
  `control` - The `Control` for which to identify the surrounding `FXCanvas`.
Returns:
  The first `FXCanvas` which is found by walking up the widget hierarchy of the given `Control`, or `null`.

### getFXCanvas

protected FXCanvas getFXCanvas(Node node)
Returns the `FXCanvas` which embeds the `Scene` which contains the given `Node`.

Parameters:
  `node` - The `Node` for which the embedding `FXCanvas` is determined.
Returns:
  The `FXCanvas` which embeds the `Scene` which contains the given `Node`.

### hookControl

protected void hookControl(T control)
Hooks the given `Control` into the JavaFX scene graph, for example, registering event forwarding from SWT to JavaFX.

Parameters:
  `control` - The `Control` which is wrapped by this `FXControlAdapter`.
See Also:
  - `registerSwtToFXEventForwarders(FXCanvas)`

### init

protected void init()
Initializes this `FXControlAdapter`. Per default, this `FXControlAdapter` is added to the focus traversal cycle and JavaFX listeners are registered for forwarding JavaFX state to SWT.

See Also:
  - `registerListeners()`

### registerListeners

protected void registerListeners()
Registers JavaFX listeners for forwarding JavaFX state to SWT. Among other things, this registers a listener for `Scene` changes which will then hook the SWT `Control` to the `FXCanvas` of the new `Scene`.

See Also:
  - `unregisterListeners()`
  - `setCanvas(FXCanvas)`

### registerSwtToFXEventForwarders

protected void registerSwtToFXEventForwarders(FXCanvas newCanvas)
Registers SWT to JavaFX event forwarders for the given `FXCanvas`.

Parameters:
  `newCanvas` - The `FXCanvas` for which event forwarding is registered.
See Also:
  - `unregisterSwtToFXEventForwarders()`

### relocate

public void relocate(double paramDouble1, double paramDouble2)

Overrides:
  `relocate` in class `Node`

### resize

public void resize(double width, double height)

Overrides:
  `resize` in class `Region`

### setCanvas

protected void setCanvas(FXCanvas newCanvas)
Changes the `FXCanvas` in which the `Control` is hooked. An `FXControlAdapter.IControlFactory` has to be available for re-creating the `Control` within the new `FXCanvas`, otherwise an exception is thrown.

Parameters:
  `newCanvas` - The new `FXCanvas` for the `Control`.
Throws:
  `IllegalArgumentException` - when the `FXCanvas` is changed, but no `FXControlAdapter.IControlFactory` is available.
See Also:
  - `setControl(Control)`

### setControl

protected void setControl(T control)
Sets the `Control` of this `FXControlAdapter` to the given value and `hooks` or `unhooks` the `Control`, respectively.

Parameters:
  `control` - The new `Control` for this `FXControlAdapter`.
See Also:
  - `hookControl(Control)`
  - `unhookControl(Control)`

### unhookControl

protected void unhookControl(T control)
Unhooks the given `Control` from the JavaFX scene graph, for example, unregistering event forwarding from SWT to JavaFX.

Parameters:
  `control` - The `Control` which is wrapped by this `FXControlAdapter`.
See Also:
  - `hookControl(Control)`
  - `unregisterSwtToFXEventForwarders()`

### unregisterListeners

protected void unregisterListeners()
Unregisters the listeners which have previously been registered during `registerListeners()`.

### unregisterSwtToFXEventForwarders

protected void unregisterSwtToFXEventForwarders()
Unregisters the event forwarders which have previously been registered during `registerSwtToFXEventForwarders(FXCanvas)`.

### updateSwtBounds

public void updateSwtBounds()
Updates the `bounds` of the `Control` which is wrapped by this `FXControlAdapter`. This method is automatically called when this `FXControlAdapter` is `relocated` or `resized`.