public void init() { PlatformUtil.assertFxApplicationThread(); if (WizardState.NEW != stateProperty.get()) throw new IllegalStateException( "This wizard is not in state NEW! Current state: " + stateProperty.get()); stateProperty.set(WizardState.IN_USER_INTERACTION); }
public void setFinishingPage(final Parent finishingPage) { assertNotNull("finishingPage", finishingPage); PlatformUtil.assertFxApplicationThread(); if (!(finishingPage instanceof FinishingPage)) throw new IllegalArgumentException("finishingPage is not an instance of FinishingPage!"); if (stateProperty.get() == WizardState.FINISHING) hideFinishingPage(); // hide the old one. getChildren().remove(this.finishingPage); this.finishingPage = finishingPage; getChildren().add(0, finishingPage); if (stateProperty.get() == WizardState.FINISHING) showFinishingPage(); // immediately show the new one. }
protected void navTo(final WizardPage wizardPage, boolean addToHistory) { assertNotNull("wizardPage", wizardPage); PlatformUtil.assertFxApplicationThread(); { WizardPage currentPage = getCurrentPage(); if (currentPage != null) currentPage.onHidden(); if (currentPage != null && addToHistory) history.addLast(currentPage); } setCurrentPage(wizardPage); for (Node child : getChildren()) child.setVisible(false); wizardPage.setVisible(true); getChildren().remove(wizardPage); // remove from z-order wherever it is (it might be missing!). getChildren().add(wizardPage); // re-add as last, which means top-most z-order. wizardPage.updateButtonsDisable(); updateCanFinish(); if (getParent() != null) getParent().requestFocus(); this.requestFocus(); wizardPage.requestFocus(); Platform.runLater( new Runnable() { @Override public void run() { final Scene scene = getScene(); final Window window = scene == null ? null : scene.getWindow(); if (window != null) window.sizeToScene(); if (getParent() != null) getParent().requestFocus(); Wizard.this.requestFocus(); wizardPage.requestFocus(); wizardPage.onShown(); } }); }
/** * Finish this wizard. * * <p>Do not override this method! Override the following callback-methods instead: * * <ol> * <li>{@link #finishing()} * <li>{@link #finish(ProgressMonitor)} * <li>{@link #failed(Throwable)} * <li>{@link #finished()} * </ol> */ public void finish() { PlatformUtil.assertFxApplicationThread(); final Thread finishThread = new Thread( getClass().getName() + '@' + Integer.toHexString(System.identityHashCode(this)) + ".finishThread") { @Override public void run() { try { finish( new NullProgressMonitor()); // reserving the progress-monitor stuff for later ;-) Platform.runLater( () -> { preFinished(); stateProperty.set(WizardState.FINISHED); finished(); }); } catch (final Throwable x) { Platform.runLater( () -> { error = x; preFailed(x); stateProperty.set(WizardState.FAILED); failed(x); }); } } }; error = null; stateProperty.set(WizardState.FINISHING); finishing(); finishThread.start(); }
/** * Cancel this wizard. * * <p>Do not override this method! You can instead register a listener on the {@link * #stateProperty() state}. */ public void cancel() { PlatformUtil.assertFxApplicationThread(); stateProperty.set(WizardState.CANCELLED); }