modules/controls/src/main/java/com/sun/javafx/scene/control/skin/ProgressIndicatorSkin.java

Print this page
rev 7080 : RT-37174: if ProgressIndicator is removed from scene and then later added back, re-initialize the ProgressIndicator.

*** 1,7 **** /* ! * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this --- 1,7 ---- /* ! * Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. Oracle designates this
*** 37,46 **** --- 37,47 ---- import javafx.beans.binding.BooleanExpression; import javafx.beans.property.BooleanProperty; import javafx.beans.property.DoubleProperty; import javafx.beans.property.IntegerProperty; import javafx.beans.property.ObjectProperty; + import javafx.beans.value.ChangeListener; import javafx.beans.value.WritableValue; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.geometry.Bounds; import javafx.geometry.NodeOrientation;
*** 104,114 **** super(control, new ProgressIndicatorBehavior<ProgressIndicator>(control)); this.control = control; this.control.indeterminateProperty().addListener(indeterminateListener); this.control.progressProperty().addListener(progressListener); ! initialize(); } private void initialize() { boolean isIndeterminate = control.isIndeterminate(); --- 105,115 ---- super(control, new ProgressIndicatorBehavior<ProgressIndicator>(control)); this.control = control; this.control.indeterminateProperty().addListener(indeterminateListener); this.control.progressProperty().addListener(progressListener); ! this.control.sceneProperty().addListener(sceneChangeListener); initialize(); } private void initialize() { boolean isIndeterminate = control.isIndeterminate();
*** 136,155 **** getChildren().setAll(determinateIndicator); } } @Override public void dispose() { - super.dispose(); if (spinner != null) { if (spinner.indeterminateTimeline != null) { spinner.indeterminateTimeline.stop(); } spinner = null; } control.indeterminateProperty().removeListener(indeterminateListener); control.progressProperty().removeListener(progressListener); ! control = null; } @Override protected void layoutChildren(final double x, final double y, final double w, final double h) { if (spinner != null && control.isIndeterminate()) { --- 137,157 ---- getChildren().setAll(determinateIndicator); } } @Override public void dispose() { if (spinner != null) { if (spinner.indeterminateTimeline != null) { spinner.indeterminateTimeline.stop(); } spinner = null; } control.indeterminateProperty().removeListener(indeterminateListener); control.progressProperty().removeListener(progressListener); ! control.sceneProperty().removeListener(sceneChangeListener); ! ! super.dispose(); } @Override protected void layoutChildren(final double x, final double y, final double w, final double h) { if (spinner != null && control.isIndeterminate()) {
*** 170,184 **** // Listen to ProgressIndicator indeterminateProperty private final InvalidationListener indeterminateListener = valueModel -> { initialize(); }; ! private final InvalidationListener progressListener = new InvalidationListener() { ! @Override public void invalidated(Observable valueModel) { if (determinateIndicator != null) { determinateIndicator.updateProgress(((DoubleProperty)valueModel).doubleValue()); } } }; /*************************************************************************** * * --- 172,191 ---- // Listen to ProgressIndicator indeterminateProperty private final InvalidationListener indeterminateListener = valueModel -> { initialize(); }; ! private final InvalidationListener progressListener = valueModel -> { if (determinateIndicator != null) { determinateIndicator.updateProgress(((DoubleProperty)valueModel).doubleValue()); } + }; + + private final ChangeListener<Scene> sceneChangeListener = (observable, oldValue, newValue) -> { + // if ProgressIndicator was removed from scene and then added back in... + if (oldValue == null) { + initialize(); } }; /*************************************************************************** * *