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`, `javafx.event.EventTarget`

    public class FXControlAdapter<T extends Control>
    extends javafx.scene.layout.Region

The FXControlAdapter can be used to embed SWT controls into a JavaFX scene graph.

### Nested Class Summary

Nested Classes
`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
`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

All Methods Instance Methods Concrete Methods
`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 javafx.collections.ObservableList<javafx.scene.Node>` `getChildren()` We do not manage children.
`T` `getControl()` Returns the SWT `Control` that is wrapped by this `FXControlAdapter`.
`protected javafx.embed.swt.FXCanvas` `getFXCanvas​(javafx.scene.Node node)` Returns the `FXCanvas` which embeds the `Scene` which contains the given `Node`.
`protected javafx.embed.swt.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​(javafx.embed.swt.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​(javafx.embed.swt.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 Detail

#### 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 Detail

#### computeMaxHeight

    protected double computeMaxHeight​(double width)

Overrides:
  `computeMaxHeight` in class `javafx.scene.layout.Region`

#### computeMaxWidth

    protected double computeMaxWidth​(double height)

Overrides:
  `computeMaxWidth` in class `javafx.scene.layout.Region`

#### computeMinHeight

    protected double computeMinHeight​(double width)

Overrides:
  `computeMinHeight` in class `javafx.scene.layout.Region`

#### computeMinWidth

    protected double computeMinWidth​(double height)

Overrides:
  `computeMinWidth` in class `javafx.scene.layout.Region`

#### computePrefHeight

    protected double computePrefHeight​(double width)

Overrides:
  `computePrefHeight` in class `javafx.scene.layout.Region`

#### computePrefWidth

    protected double computePrefWidth​(double height)

Overrides:
  `computePrefWidth` in class `javafx.scene.layout.Region`

#### dispose

    public void dispose()

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

#### getChildren

    protected javafx.collections.ObservableList<javafx.scene.Node> getChildren()

We do not manage children. Therefore, it is illegal to alter the children list in any way.

Overrides:
  `getChildren` in class `javafx.scene.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 javafx.embed.swt.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 javafx.embed.swt.FXCanvas getFXCanvas​(javafx.scene.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​(javafx.embed.swt.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 `javafx.scene.Node`

#### resize

    public void resize​(double width,
                       double height)

Overrides:
  `resize` in class `javafx.scene.layout.Region`

#### setCanvas

    protected void setCanvas​(javafx.embed.swt.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:
  `java.lang.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`.