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 thisFXControlAdapter
.
- 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 Modifier and Type Class Description static interface
FXControlAdapter.IControlFactory<T extends Control>
TheFXControlAdapter.IControlFactory
can be used in conjunction withFXControlAdapter
to create the wrapped SWTControl
when the surroundingFXCanvas
changes.
-
Constructor Summary
Constructors Constructor Description FXControlAdapter(FXControlAdapter.IControlFactory<T> controlFactory)
Creates a newFXControlAdapter
which uses the givenFXControlAdapter.IControlFactory
for the creation of the SWTControl
.FXControlAdapter(T control)
Creates a newFXControlAdapter
which wraps the given SWTControl
.
-
Method Summary
All Methods Instance Methods Concrete Methods 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 thisFXControlAdapter
, so that the SWTControl
will not be re-created when theFXCanvas
changes.protected javafx.collections.ObservableList<javafx.scene.Node>
getChildren()
We do not manage children.T
getControl()
Returns the SWTControl
that is wrapped by thisFXControlAdapter
.protected javafx.embed.swt.FXCanvas
getFXCanvas(javafx.scene.Node node)
Returns theFXCanvas
which embeds theScene
which contains the givenNode
.protected javafx.embed.swt.FXCanvas
getFXCanvas(Control control)
Returns the firstFXCanvas
which is found by walking up the widget hierarchy of the givenControl
.protected void
hookControl(T control)
Hooks the givenControl
into the JavaFX scene graph, for example, registering event forwarding from SWT to JavaFX.protected void
init()
Initializes thisFXControlAdapter
.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 givenFXCanvas
.void
relocate(double paramDouble1, double paramDouble2)
void
resize(double width, double height)
protected void
setCanvas(javafx.embed.swt.FXCanvas newCanvas)
Changes theFXCanvas
in which theControl
is hooked.protected void
setControl(T control)
Sets theControl
of thisFXControlAdapter
to the given value andhooks
orunhooks
theControl
, respectively.protected void
unhookControl(T control)
Unhooks the givenControl
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 duringregisterListeners()
.protected void
unregisterSwtToFXEventForwarders()
Unregisters the event forwarders which have previously been registered duringregisterSwtToFXEventForwarders(FXCanvas)
.void
updateSwtBounds()
-
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
-
-
-
-
Constructor Detail
-
FXControlAdapter
public FXControlAdapter(FXControlAdapter.IControlFactory<T> controlFactory)
Creates a newFXControlAdapter
which uses the givenFXControlAdapter.IControlFactory
for the creation of the SWTControl
.- Parameters:
controlFactory
- TheFXControlAdapter.IControlFactory
to use to create the SWTControl
.
-
FXControlAdapter
public FXControlAdapter(T control)
Creates a newFXControlAdapter
which wraps the given SWTControl
.- Parameters:
control
- The SWTControl
to wrap in thisFXControlAdapter
.
-
-
Method Detail
-
computeMaxHeight
protected double computeMaxHeight(double width)
- Overrides:
computeMaxHeight
in classjavafx.scene.layout.Region
-
computeMaxWidth
protected double computeMaxWidth(double height)
- Overrides:
computeMaxWidth
in classjavafx.scene.layout.Region
-
computeMinHeight
protected double computeMinHeight(double width)
- Overrides:
computeMinHeight
in classjavafx.scene.layout.Region
-
computeMinWidth
protected double computeMinWidth(double height)
- Overrides:
computeMinWidth
in classjavafx.scene.layout.Region
-
computePrefHeight
protected double computePrefHeight(double width)
- Overrides:
computePrefHeight
in classjavafx.scene.layout.Region
-
computePrefWidth
protected double computePrefWidth(double height)
- Overrides:
computePrefWidth
in classjavafx.scene.layout.Region
-
dispose
public void dispose()
Deactivates thisFXControlAdapter
, so that the SWTControl
will not be re-created when theFXCanvas
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 classjavafx.scene.Parent
-
getControl
public T getControl()
Returns the SWTControl
that is wrapped by thisFXControlAdapter
.- Returns:
- The SWT
Control
that is wrapped by thisFXControlAdapter
.
-
getFXCanvas
protected javafx.embed.swt.FXCanvas getFXCanvas(Control control)
Returns the firstFXCanvas
which is found by walking up the widget hierarchy of the givenControl
. If noFXCanvas
can be found,null
is returned.
-
getFXCanvas
protected javafx.embed.swt.FXCanvas getFXCanvas(javafx.scene.Node node)
Returns theFXCanvas
which embeds theScene
which contains the givenNode
.- Parameters:
node
- TheNode
for which the embeddingFXCanvas
is determined.- Returns:
- The
FXCanvas
which embeds theScene
which contains the givenNode
.
-
hookControl
protected void hookControl(T control)
Hooks the givenControl
into the JavaFX scene graph, for example, registering event forwarding from SWT to JavaFX.- Parameters:
control
- TheControl
which is wrapped by thisFXControlAdapter
.- See Also:
registerSwtToFXEventForwarders(FXCanvas)
-
init
protected void init()
Initializes thisFXControlAdapter
. Per default, thisFXControlAdapter
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 forScene
changes which will then hook the SWTControl
to theFXCanvas
of the newScene
.- See Also:
unregisterListeners()
,setCanvas(FXCanvas)
-
registerSwtToFXEventForwarders
protected void registerSwtToFXEventForwarders(javafx.embed.swt.FXCanvas newCanvas)
Registers SWT to JavaFX event forwarders for the givenFXCanvas
.- Parameters:
newCanvas
- TheFXCanvas
for which event forwarding is registered.- See Also:
unregisterSwtToFXEventForwarders()
-
relocate
public void relocate(double paramDouble1, double paramDouble2)
- Overrides:
relocate
in classjavafx.scene.Node
-
resize
public void resize(double width, double height)
- Overrides:
resize
in classjavafx.scene.layout.Region
-
setCanvas
protected void setCanvas(javafx.embed.swt.FXCanvas newCanvas)
Changes theFXCanvas
in which theControl
is hooked. AnFXControlAdapter.IControlFactory
has to be available for re-creating theControl
within the newFXCanvas
, otherwise an exception is thrown.- Parameters:
newCanvas
- The newFXCanvas
for theControl
.- Throws:
java.lang.IllegalArgumentException
- when theFXCanvas
is changed, but noFXControlAdapter.IControlFactory
is available.- See Also:
setControl(Control)
-
setControl
protected void setControl(T control)
Sets theControl
of thisFXControlAdapter
to the given value andhooks
orunhooks
theControl
, respectively.- Parameters:
control
- The newControl
for thisFXControlAdapter
.- See Also:
hookControl(Control)
,unhookControl(Control)
-
unhookControl
protected void unhookControl(T control)
Unhooks the givenControl
from the JavaFX scene graph, for example, unregistering event forwarding from SWT to JavaFX.- Parameters:
control
- TheControl
which is wrapped by thisFXControlAdapter
.- See Also:
hookControl(Control)
,unregisterSwtToFXEventForwarders()
-
unregisterListeners
protected void unregisterListeners()
Unregisters the listeners which have previously been registered duringregisterListeners()
.
-
unregisterSwtToFXEventForwarders
protected void unregisterSwtToFXEventForwarders()
Unregisters the event forwarders which have previously been registered duringregisterSwtToFXEventForwarders(FXCanvas)
.
-
updateSwtBounds
public void updateSwtBounds()
Updates thebounds
of theControl
which is wrapped by thisFXControlAdapter
. This method is automatically called when thisFXControlAdapter
isrelocated
orresized
.
-
-