Verified Owner
Top Description Fields Constructors Methods
org.jabref.gui.walkthrough

pack-priv Class WindowOverlay

extends Object
Class Inheritance
Annotations
@NullMarked
Imports
java.util.ArrayList, .List, .Optional, java.util.concurrent.atomic.AtomicReference, javafx.beans.value.ChangeListener, javafx.event.EventHandler, .EventTarget, javafx.geometry.Insets, .Pos, javafx.scene.Node, .Scene, javafx.scene.control.Button, javafx.scene.input.KeyEvent, javafx.scene.layout.StackPane, .VBox, javafx.stage.Window, javafx.util.Duration, org.jabref.gui.StateManager, org.jabref.gui.icon.IconTheme, .JabRefIconView, org.jabref.gui.keyboard.KeyBindingRepository, .SelectableTextFlowKeyBindings, .WalkthroughKeyBindings, org.jabref.gui.util.DelayedExecution, org.jabref.gui.walkthrough.declarative.step.PanelStep, .QuitButtonPosition, .TooltipPosition, .TooltipStep, .VisibleComponent, org.jabref.gui.walkthrough.utils.WalkthroughUtils, com.airhacks.afterburner.injection.Injector, com.sun.javafx.scene.NodeHelper, org.controlsfx.control.PopOver, org.jspecify.annotations.NonNull, .NullMarked, .Nullable, org.slf4j.Logger, .LoggerFactory

Manages the overlay for displaying walkthrough steps in a single window.

Field Summary

Modifier and TypeField and Description
private final List<Runnable>
cleanupTasks

Mutable list of clean up tasks that are executed when the overlay is hidden or detached.

private @Nullable Node
private final KeyBindingRepository
private static final Logger
private final WalkthroughPane
private static final double
POPOVER_ARROW_GAP

Negative = distance between the arrow tip and the target node.

private static final int
private @Nullable Button
private final WalkthroughRenderer
private boolean
private final StateManager
private final Walkthrough
private final Window

Constructor Summary

AccessConstructor and Description
public
WindowOverlay(Window window, WalkthroughPane pane, Walkthrough walkthrough)

Method Summary

Modifier and TypeMethod and Description
private void
private PopOver
createPopover(TooltipStep step, Runnable beforeNavigate)

private Button
public void
detach()

Detaches the overlay.

public void
hide()

Hide the overlay and clean up any resources.

private void
listenKeybindings(EventTarget target, Scene scene)

Adds keybinding listeners to the scene to handle key events for the walkthrough.

private Optional<PopOver.ArrowLocation>
private void
private void
private QuitButtonPosition
public void
showPanel(PanelStep step, Runnable beforeNavigate)

Convenience method to show a panel for the given step without a node.

public void
showPanel(PanelStep
The step to display.
step
,
@Nullable Node
The node to anchor highlight to (e.g., BackdropHighlight may poke a hole at the position of the node), or null to use fallback effect of corresponding position.
node
,
Runnable
A runnable to execute before navigating to the next step. More precisely, the runnable to execute immediately upon the button press before Walkthrough's state change to the next step and before the original button/node's action is executed. Usually used to prevent automatic revert from unexpected reverting to the previous step when the node is not yet ready to be displayed
beforeNavigate
)

Display a Panel for the given step at the specified node.

public void
showTooltip(TooltipStep
The step to display.
step
,
@Nullable Node
The node to anchor the tooltip to, or null to show it at the window. The node is expected to be positionable by WalkthroughUtils#cannotPositionNode(Node) standard.
node
,
Runnable
A runnable to execute before navigating to the next step.
beforeNavigate
)

Display a tooltip for the given step at the specified node.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cleanupTasksback to summary
private final List<Runnable> cleanupTasks

Mutable list of clean up tasks that are executed when the overlay is hidden or detached.

currentContentNodeback to summary
private @Nullable Node currentContentNode
keyBindingRepositoryback to summary
private final KeyBindingRepository keyBindingRepository
LOGGERback to summary
private static final Logger LOGGER
paneback to summary
private final WalkthroughPane pane
POPOVER_ARROW_GAPback to summary
private static final double POPOVER_ARROW_GAP

Negative = distance between the arrow tip and the target node. The popup window is ~22px larger than the visible box (arrow plus drop shadow) and swallows clicks in that margin, so with the default overlap of 4px an icon button next to the arrow could not be clicked.

POPOVER_CREATION_DELAYback to summary
private static final int POPOVER_CREATION_DELAY
quitButtonback to summary
private @Nullable Button quitButton
rendererback to summary
private final WalkthroughRenderer renderer
showingback to summary
private boolean showing
stateManagerback to summary
private final StateManager stateManager
walkthroughback to summary
private final Walkthrough walkthrough
windowback to summary
private final Window window

Constructor Detail

WindowOverlayback to summary
public WindowOverlay(Window window, WalkthroughPane pane, Walkthrough walkthrough)

Method Detail

addQuitButtonback to summary
private void addQuitButton(VisibleComponent component)
createPopoverback to summary
private PopOver createPopover(TooltipStep step, Runnable beforeNavigate)
createQuitButtonback to summary
private Button createQuitButton()
detachback to summary
public void detach()

Detaches the overlay. The pane it drew into belongs to the window and stays.

hideback to summary
public void hide()

Hide the overlay and clean up any resources.

listenKeybindingsback to summary
private void listenKeybindings(EventTarget target, Scene scene)

Adds keybinding listeners to the scene to handle key events for the walkthrough.

This method is necessary because:

  1. PopOver is in a separate scene, so the org.jabref.gui.JabRefGUI's keybindings registration on the main scene doesn't/cannot capture the key events on the PopOver scene. If a user, presumably, focus on the PopOver and press Esc, quit Walkthrough will not work.
  2. Likewise, for new dialog windows, the keybindings doesn't work. If a user is interested in copy/paste walkthrough text, they will not be able to do so.
mapToArrowLocationback to summary
private Optional<PopOver.ArrowLocation> mapToArrowLocation(TooltipPosition position)
positionQuitButtonback to summary
private void positionQuitButton(Button button, QuitButtonPosition position)
removeQuitButtonback to summary
private void removeQuitButton()
resolveQuitButtonPositionback to summary
private QuitButtonPosition resolveQuitButtonPosition(VisibleComponent component)
showPanelback to summary
public void showPanel(PanelStep step, Runnable beforeNavigate)

Convenience method to show a panel for the given step without a node.

See WindowOverlay#showPanel(PanelStep, Node, Runnable) for details.

showPanelback to summary
public void showPanel(PanelStep step, @Nullable Node node, Runnable beforeNavigate)

Display a Panel for the given step at the specified node.

Parameters
step:PanelStep

The step to display.

node:@Nullable Node

The node to anchor highlight to (e.g., BackdropHighlight may poke a hole at the position of the node), or null to use fallback effect of corresponding position.

beforeNavigate:Runnable

A runnable to execute before navigating to the next step. More precisely, the runnable to execute immediately upon the button press before Walkthrough's state change to the next step and before the original button/node's action is executed. Usually used to prevent automatic revert from unexpected reverting to the previous step when the node is not yet ready to be displayed

See Also
WindowOverlay#showPanel(PanelStep, Runnable), WindowOverlay#showTooltip(TooltipStep, Node, Runnable)
showTooltipback to summary
public void showTooltip(TooltipStep step, @Nullable Node node, Runnable beforeNavigate)

Display a tooltip for the given step at the specified node.

Note on beforeNavigate runnable: The runnable to execute immediately upon the button press before Walkthrough's state change to the next step and before the original button/node's action is executed. Usually used to prevent automatic revert from unexpected reverting to the previous step when the node is not yet ready to be displayed.

Implementation Note

The requirement for the node to be positionable by WalkthroughUtils#cannotPositionNode(Node) standard is just to make things easier to define. This requirement come from javafx.stage.PopupWindow#show(Node), which check whether the node is tree visible before showing the popup and PopOver#show(Node), which checks whether the node contains a scene and window to assign the owning window to the popover.

Parameters
step:TooltipStep

The step to display.

node:@Nullable Node

The node to anchor the tooltip to, or null to show it at the window. The node is expected to be positionable by WalkthroughUtils#cannotPositionNode(Node) standard.

beforeNavigate:Runnable

A runnable to execute before navigating to the next step.

See Also
WindowOverlay#showPanel(PanelStep, Runnable), WindowOverlay#showPanel(PanelStep, Node, Runnable)