/** * This method is used to run a specified Runnable in the FX Application thread, * it returns before the task finished execution * * @param doRun This is the sepcifed task to be excuted by the FX Application thread * @return Nothing */ public static void runInFX(Runnable doRun) { if (Platform.isFxApplicationThread()) { doRun.run(); return; } Platform.runLater(doRun); }
/** * This method is used to run a specified Runnable in the FX Application thread, * it waits for the task to finish before returning to the main thread. * * @param doRun This is the sepcifed task to be excuted by the FX Application thread * @return Nothing */ public static void runInFXAndWait(Runnable doRun) { if (Platform.isFxApplicationThread()) { doRun.run(); return; } final CountDownLatch doneLatch = new CountDownLatch(1); Platform.runLater(() -> { try { doRun.run(); } finally { doneLatch.countDown(); } }); try { doneLatch.await(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } }
/** * Return true if we are into the JavaFX Application Thread (JAT). * * @return true if currentThread == JRebirthThread */ public static boolean isJAT() { return Platform.isFxApplicationThread(); }
@Override protected void schedule(Runnable runnable) { if (Platform.isFxApplicationThread()) { runnable.run(); } else { Platform.runLater(runnable); } } }
@Override public void actionPerformed() { assertThat("Must not be in the FX thread!", Platform.isFxApplicationThread(), is(false)); } }));
@Override protected void sourceChanged(@Nonnull final ListChangeListener.Change<? extends E> c) { if (Platform.isFxApplicationThread()) { fireChange(c); } else { Platform.runLater(() -> fireChange(c)); } } }
/** * Handle the displaying of an event video. * @param event display event video, containg the parameters to initiate the video to be played */ @Subscribe public void handleEventVideoDisplay(DisplayEventVideo event) { if (Platform.isFxApplicationThread()) { displayEventVideoUnwrapped(event); } else { Platform.runLater(() -> displayEventVideoUnwrapped(event)); } }
private void handleListModification( Change<? extends ResourceItem> change) { if( ! Platform.isFxApplicationThread() ) { Platform.runLater(() -> _handleListModification(change)); } else { _handleListModification(change); } }
private void handleListModification( Change<? extends ResourceItem> change) { if( ! Platform.isFxApplicationThread() ) { Platform.runLater(() -> _handleListModification(change)); } else { _handleListModification(change); } }
public void setDefaultTheme(String primary, String accent) { if(Platform.isFxApplicationThread()) { _setDefaultTheme(primary, accent); } else { Platform.runLater(()->_setDefaultTheme(primary, accent)); } }
@Override public void changed(final ObservableValue<? extends T> observable, final T oldValue, final T newValue) { if (isFxApplicationThread()) { getDelegate().changed(observable, oldValue, newValue); } else { runLater(() -> getDelegate().changed(observable, oldValue, newValue)); } } }
@Override public void setValue(final Integer value) { if (isFxApplicationThread()) { getDelegate().setValue(value); } else { runLater(() -> getDelegate().setValue(value)); } } }
@Override public void onChanged(final Change<? extends E> change) { if (isFxApplicationThread()) { getDelegate().onChanged(change); } else { runLater(() -> getDelegate().onChanged(change)); } } }
@Override public void set(final String value) { if (isFxApplicationThread()) { getDelegate().set(value); } else { runLater(() -> getDelegate().set(value)); } }
@Override public void set(final float value) { if (isFxApplicationThread()) { getDelegate().set(value); } else { runLater(() -> getDelegate().set(value)); } }
@Override public void setValue(final String value) { if (isFxApplicationThread()) { getDelegate().setValue(value); } else { runLater(() -> getDelegate().setValue(value)); } } }
@Override public void onChanged(final Change<? extends K, ? extends V> change) { if (isFxApplicationThread()) { getDelegate().onChanged(change); } else { runLater(() -> getDelegate().onChanged(change)); } } }
@Override public void pushContent(StandardViewController c, Node node) { if (Platform.isFxApplicationThread()) { editorPane.beginEdition(node); layoutManager.pushContent(editorPane); } else { Platform.runLater(() -> { editorPane.beginEdition(node); layoutManager.pushContent(editorPane); }); } }
public void makeCentralPaneLighter() { if (Platform.isFxApplicationThread()) { rootStructure.getChildren().remove(notificationsStack); } else { Platform.runLater(() -> rootStructure.getChildren().remove(notificationsStack)); } }
public void setLoading() { if (Platform.isFxApplicationThread()) { getRootViewStructureContentArea().getChildren().clear(); getRootViewStructureContentArea().getChildren().add(getLoadingPane()); } else { Platform.runLater(() -> { getRootViewStructureContentArea().getChildren().clear(); getRootViewStructureContentArea().getChildren().add(getLoadingPane()); }); } }