Top Description Inners Fields Constructors Methods
com.dlsc.gemsfx

public Class LoadingPane

extends StackPane
Class Inheritance
Annotations
@DefaultProperty:content
Imports
javafx.application.Platform, javafx.beans.DefaultProperty, .InvalidationListener, javafx.beans.binding.Bindings, javafx.beans.property.DoubleProperty, .LongProperty, .ObjectProperty, .ReadOnlyObjectProperty, .ReadOnlyObjectWrapper, .SimpleDoubleProperty, .SimpleLongProperty, .SimpleObjectProperty, .SimpleStringProperty, .StringProperty, javafx.css.PseudoClass, javafx.scene.Node, javafx.scene.control.Label, .ProgressIndicator, javafx.scene.layout.Region, .StackPane, java.util.Objects

A custom pane that supports the visual feedback for data loading / refreshing its content. The pane is a wrapper around a given content node. This node will be hidden and a progress indicator shown instead when the status of this pane changes to Status#LOADING. Once the status changes back to Status#OK the node will be shown again. If anything goes wrong while loading new data or refreshing the content a third state called Status#ERROR can be applied resulting in an error icon and error text being shown. The pane also supports a progressProperty() for detailed progress feedback.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private class
LoadingPane.CommitStatusThread

A thread runnable used to delay the actual status change.

public static enum
LoadingPane.Size

The possible sizes for the pane.

public static enum
LoadingPane.Status

The possible states that the loading pane can be in.

Field Summary

Modifier and TypeField and Description
private final LongProperty
private LoadingPane.CommitStatusThread
private final ReadOnlyObjectWrapper<LoadingPane.Status>
private final ObjectProperty<Node>
private final StringProperty
private final ObjectProperty<Node>
private final StackPane
private final DoubleProperty
private final ObjectProperty<ProgressIndicator>
private final ObjectProperty<LoadingPane.Size>
private final ObjectProperty<LoadingPane.Status>

Constructor Summary

AccessConstructor and Description
public
LoadingPane()

Constructs a new loading pane.

public
LoadingPane(Node
the wrapped node
node
)

Constructs a new loading pane.

Method Summary

Modifier and TypeMethod and Description
public final LongProperty

Returns:

the delay duration in milliseconds
commitDelayProperty
()

The commit delay duration that will be applied before the control does change to a new state.

public final ReadOnlyObjectProperty<LoadingPane.Status>

Returns:

the read-only property storing the committed status
committedStatusProperty
()

A read-only property that contains the "committed" status value.

public final ObjectProperty<Node>

Returns:

the node / the view wrapped by the loading pane, e.g. a list or a table view
contentProperty
()

The wrapped content node.

public final void
error(String message)

Convenience method to change the status of the pane to Status#ERROR.

public final void
error(Throwable ex)

Convenience method to change the status of the pane to Status#ERROR.

public final void
error()

Convenience method to change the status of the pane to Status#ERROR.

public final ObjectProperty<Node>

Returns:

the error node
errorNodeProperty
()

The node that will be shown when the loading pane is in status Status#ERROR.

public final StringProperty

Returns:

the error message
errorProperty
()

The error text that will be shown if the pane is in status Status#ERROR.

public final long
public final LoadingPane.Status
public final Node
public final String
public final Node
public final double
public final ProgressIndicator
public final LoadingPane.Size
public final LoadingPane.Status
public String
getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method.

public final void
load()

Convenience method to change the status of the pane to Status#LOADING.

public final void
ok()

Convenience method to change the status of the pane to Status#OK.

public final ObjectProperty<ProgressIndicator>

Returns:

the progress indicator
progressIndicatorProperty
()

The progress indicator that will be used to display percentage progress or the indeterminate state of the loading progress.

public final DoubleProperty

Returns:

the progress of the loading process
progressProperty
()

The progress (value between 0 and 1).

public final void
setCommitDelay(long commitDelay)

public final void
setContent(Node content)

public final void
public final void
setErrorNode(Node errorNode)

public final void
setProgress(double progress)

public final void
public final void
public final void
public final ObjectProperty<LoadingPane.Size>

Returns:

the size of the progress indicator
sizeProperty
()

The size of the progress indicator.

public final ObjectProperty<LoadingPane.Status>

Returns:

the status of the loading pane
statusProperty
()

The current status of the loading pane.

private void
private void
updatePseudoClass(Enum<?> oldValue, Enum<?> newValue)

private void
private Node
wrapErrorNode(Node errorNode)

Inherited from javafx.scene.layout.StackPane:
alignmentPropertyclearConstraintscomputeMinHeightcomputeMinWidthcomputePrefHeightcomputePrefWidthgetAlignmentgetAlignmentgetClassCssMetaDatagetContentBiasgetCssMetaDatagetMarginlayoutChildrenrequestLayoutsetAlignmentsetAlignmentsetMargin

Field Detail

commitDelayback to summary
private final LongProperty commitDelay
commitStatusThreadback to summary
private LoadingPane.CommitStatusThread commitStatusThread
committedStatusback to summary
private final ReadOnlyObjectWrapper<LoadingPane.Status> committedStatus
contentback to summary
private final ObjectProperty<Node> content
errorback to summary
private final StringProperty error
errorNodeback to summary
private final ObjectProperty<Node> errorNode
indicatorWrapperback to summary
private final StackPane indicatorWrapper
progressback to summary
private final DoubleProperty progress
progressIndicatorback to summary
private final ObjectProperty<ProgressIndicator> progressIndicator
sizeback to summary
private final ObjectProperty<LoadingPane.Size> size
statusback to summary
private final ObjectProperty<LoadingPane.Status> status

Constructor Detail

LoadingPaneback to summary
public LoadingPane()

Constructs a new loading pane.

LoadingPaneback to summary
public LoadingPane(Node node)

Constructs a new loading pane.

Parameters
node:Node

the wrapped node

Method Detail

commitDelayPropertyback to summary
public final LongProperty commitDelayProperty()

The commit delay duration that will be applied before the control does change to a new state. The default is 200 milliseconds.

Returns:LongProperty

the delay duration in milliseconds

committedStatusPropertyback to summary
public final ReadOnlyObjectProperty<LoadingPane.Status> committedStatusProperty()

A read-only property that contains the "committed" status value. Applications request a status property change via the statusProperty() which will be delayed via the commitDelayProperty(). Once the delay has passed the control will updated this property.

Returns:ReadOnlyObjectProperty<LoadingPane.Status>

the read-only property storing the committed status

contentPropertyback to summary
public final ObjectProperty<Node> contentProperty()

The wrapped content node.

Returns:ObjectProperty<Node>

the node / the view wrapped by the loading pane, e.g. a list or a table view

errorback to summary
public final void error(String message)

Convenience method to change the status of the pane to Status#ERROR. Also changes the error text to the given value. This method is thread-safe.

errorback to summary
public final void error(Throwable ex)

Convenience method to change the status of the pane to Status#ERROR. Also changes the error text to the message provided by the throwable. This method is thread-safe.

errorback to summary
public final void error()

Convenience method to change the status of the pane to Status#ERROR. There will be no error message shown. This method is thread-safe.

errorNodePropertyback to summary
public final ObjectProperty<Node> errorNodeProperty()

The node that will be shown when the loading pane is in status Status#ERROR. The default node for this is a simple label which binds to the errorProperty().

Returns:ObjectProperty<Node>

the error node

errorPropertyback to summary
public final StringProperty errorProperty()

The error text that will be shown if the pane is in status Status#ERROR.

Returns:StringProperty

the error message

getCommitDelayback to summary
public final long getCommitDelay()
getCommittedStatusback to summary
public final LoadingPane.Status getCommittedStatus()
getContentback to summary
public final Node getContent()
getErrorback to summary
public final String getError()
getErrorNodeback to summary
public final Node getErrorNode()
getProgressback to summary
public final double getProgress()
getProgressIndicatorback to summary
public final ProgressIndicator getProgressIndicator()
getSizeback to summary
public final LoadingPane.Size getSize()
getStatusback to summary
public final LoadingPane.Status getStatus()
getUserAgentStylesheetback to summary
public String getUserAgentStylesheet()

Overrides javafx.scene.layout.Region.getUserAgentStylesheet.

Doc from javafx.scene.layout.Region.getUserAgentStylesheet.

An implementation may specify its own user-agent styles for this Region, and its children, by overriding this method. These styles are used in addition to whatever user-agent stylesheets are in use. This provides a mechanism for third parties to introduce styles for custom controls.

The URL is a hierarchical URI of the form [scheme:][//authority][path]. If the URL does not have a [scheme:] component, the URL is considered to be the [path] component only. Any leading '/' character of the [path] is ignored and the [path] is treated as a path relative to the root of the application's classpath.

Subclasses overriding this method should not assume any particular implementation approach as to the number and frequency with which it is called. For this reason, attempting any kind of dynamic implementation (i.e. returning different user agent stylesheet values) based on some state change is highly discouraged, as there is no guarantee when, or even if, this method will be called. Some JavaFX CSS implementations may choose to cache this response for an indefinite period of time, and therefore there should be no expectation around when this method is called.



package com.example.javafx.app;

import javafx.application.Application;
import javafx.scene.Group;
import javafx.scene.Scene;
import javafx.stage.Stage;

public class MyApp extends Application {

    @Override public void start(Stage stage) {
        Scene scene = new Scene(new Group());
        scene.getStylesheets().add("/com/example/javafx/app/mystyles.css");
        stage.setScene(scene);
        stage.show();
    }

    public static void main(String[] args) {
        launch(args);
    }
}
For additional information about using CSS with the scene graph, see the CSS Reference Guide.
Annotations
@Override
loadback to summary
public final void load()

Convenience method to change the status of the pane to Status#LOADING. Automatically clears the error text. This method is thread-safe.

okback to summary
public final void ok()

Convenience method to change the status of the pane to Status#OK. Automatically clears the error text. This method is thread-safe.

progressIndicatorPropertyback to summary
public final ObjectProperty<ProgressIndicator> progressIndicatorProperty()

The progress indicator that will be used to display percentage progress or the indeterminate state of the loading progress.

Returns:ObjectProperty<ProgressIndicator>

the progress indicator

progressPropertyback to summary
public final DoubleProperty progressProperty()

The progress (value between 0 and 1).

Returns:DoubleProperty

the progress of the loading process

setCommitDelayback to summary
public final void setCommitDelay(long commitDelay)
setContentback to summary
public final void setContent(Node content)
setErrorback to summary
public final void setError(String error)
setErrorNodeback to summary
public final void setErrorNode(Node errorNode)
setProgressback to summary
public final void setProgress(double progress)
setProgressIndicatorback to summary
public final void setProgressIndicator(ProgressIndicator progressIndicator)
setSizeback to summary
public final void setSize(LoadingPane.Size size)
setStatusback to summary
public final void setStatus(LoadingPane.Status status)
sizePropertyback to summary
public final ObjectProperty<LoadingPane.Size> sizeProperty()

The size of the progress indicator. The size should match the size of the wrapped node.

Returns:ObjectProperty<LoadingPane.Size>

the size of the progress indicator

statusPropertyback to summary
public final ObjectProperty<LoadingPane.Status> statusProperty()

The current status of the loading pane.

Returns:ObjectProperty<LoadingPane.Status>

the status of the loading pane

See Also
Status
toggleIndicatorback to summary
private void toggleIndicator()
updatePseudoClassback to summary
private void updatePseudoClass(Enum<?> oldValue, Enum<?> newValue)
updateViewback to summary
private void updateView()
wrapErrorNodeback to summary
private Node wrapErrorNode(Node errorNode)
com.dlsc.gemsfx back to summary

private Class LoadingPane.CommitStatusThread

extends Object
implements Runnable
Class Inheritance
All Implemented Interfaces
java.lang.Runnable

A thread runnable used to delay the actual status change. Delaying is important so that a fast loading process does not cause a quick flicker inside the UI.

Field Summary

Modifier and TypeField and Description
private final LoadingPane.Status
private boolean

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Modifier and TypeMethod and Description
public void
public void
run()

Implements java.lang.Runnable.run.

Runs this operation.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

statusback to summary
private final LoadingPane.Status status
stoppedback to summary
private boolean stopped

Constructor Detail

CommitStatusThreadback to summary
pack-priv CommitStatusThread(LoadingPane.Status status)

Method Detail

abortback to summary
public void abort()
runback to summary
public void run()

Implements java.lang.Runnable.run.

Doc from java.lang.Runnable.run.

Runs this operation.

Annotations
@Override
com.dlsc.gemsfx back to summary

public final Enum LoadingPane.Size

extends Enum<LoadingPane.Size>
Class Inheritance

The possible sizes for the pane. Sizes will also be reflected by matching pseudo-classes.
See Also
sizeProperty()

Field Summary

Modifier and TypeField and Description
public static final LoadingPane.Size
public static final LoadingPane.Size
public static final LoadingPane.Size

Constructor Summary

AccessConstructor and Description
private
Size()

Method Summary

Modifier and TypeMethod and Description
public static LoadingPane.Size
public static LoadingPane.Size[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

LARGEback to summary
public static final LoadingPane.Size LARGE
MEDIUMback to summary
public static final LoadingPane.Size MEDIUM
SMALLback to summary
public static final LoadingPane.Size SMALL

Constructor Detail

Sizeback to summary
private Size()

Method Detail

valueOfback to summary
public static LoadingPane.Size valueOf(String name)
valuesback to summary
public static LoadingPane.Size[] values()
com.dlsc.gemsfx back to summary

public final Enum LoadingPane.Status

extends Enum<LoadingPane.Status>
Class Inheritance

The possible states that the loading pane can be in.
See Also
statusProperty()

Field Summary

Modifier and TypeField and Description
public static final LoadingPane.Status
ERROR

The pane will show the error message.

public static final LoadingPane.Status
LOADING

The pane will show the progress indicator.

public static final LoadingPane.Status
OK

The pane will show the wrapped node.

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static LoadingPane.Status
public static LoadingPane.Status[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

ERRORback to summary
public static final LoadingPane.Status ERROR

The pane will show the error message.

LOADINGback to summary
public static final LoadingPane.Status LOADING

The pane will show the progress indicator.

OKback to summary
public static final LoadingPane.Status OK

The pane will show the wrapped node.

Constructor Detail

Statusback to summary
private Status()

Method Detail

valueOfback to summary
public static LoadingPane.Status valueOf(String name)
valuesback to summary
public static LoadingPane.Status[] values()