List of usage examples for javafx.application Platform runLater
public static void runLater(Runnable runnable)
From source file:org.nmrfx.processor.gui.MainApp.java
@Override public void datasetAdded(Dataset dataset) { if (Platform.isFxApplicationThread()) { FXMLController.updateDatasetList(); } else {/* www.j a va2s . c o m*/ Platform.runLater(() -> { FXMLController.updateDatasetList(); }); } }
From source file:org.martus.client.swingui.PureFxMainWindow.java
public void showSearchHelpMessage(String title, String message, String closeButton) { Platform.runLater(() -> { SwingInFxSearchHelpDialog dialog = new SwingInFxSearchHelpDialog(this, title, message, closeButton); dialog.showAndWait();//from www .j av a 2 s .com }); }
From source file:org.nmrfx.processor.gui.MainApp.java
@Override public void datasetRemoved(Dataset dataset) { if (Platform.isFxApplicationThread()) { FXMLController.updateDatasetList(); } else {//from ww w . j ava2s . com Platform.runLater(() -> { FXMLController.updateDatasetList(); }); } }
From source file:genrsa.GenRSAController.java
/** * Comprueba la primalidad de P y Q por el metodo de Fermat * @param event /*from w w w. ja va 2s.c om*/ */ public void primalityFermat(ActionEvent event) { Task CAstart = new Task() { @Override protected Object call() throws Exception { progress.setVisible(true); Platform.runLater(() -> { mainWindow.clearPrimality(); disableOnProgress(true); }); boolean isMiller = false; checkPrimes.check(primo_P.getText(), primo_Q.getText(), iteraciones_primalidad.getText(), isMiller); Platform.runLater(() -> { disableOnProgress(false); disableButtons(); }); progress.setVisible(false); return null; } }; new Thread(CAstart).start(); }
From source file:net.java.html.charts.ChartsTest.java
private void run(final Callable<?> r) throws Exception { final CountDownLatch await = new CountDownLatch(1); final Throwable[] arr = { null }; Platform.runLater(() -> { try (Closeable c = Fn.activate(presenter)) { r.call();//from w ww . jav a 2 s . c om } catch (Throwable t) { arr[0] = t; } finally { await.countDown(); } }); await.await(); if (arr[0] instanceof Exception) { throw (Exception) arr[0]; } if (arr[0] instanceof Error) { throw (Error) arr[0]; } }
From source file:org.nmrfx.processor.gui.MainApp.java
@Override public void datasetRenamed(Dataset dataset) { if (Platform.isFxApplicationThread()) { FXMLController.updateDatasetList(); } else {//from w w w. j a v a 2 s. co m Platform.runLater(() -> { FXMLController.updateDatasetList(); }); } }
From source file:org.beryx.viewreka.fxapp.Viewreka.java
public void setProject(FxProject newProject, String newProjectPath, boolean doOnlyViewUpdates) { if (newProject != null) { ProjectSettings projectSettings = newProject.getProjectSettingsManager().getSettings(); String chartStylesheet = projectSettings.getProperty(PROP_CHART_STYLESHEET, null, true); if (chartStylesheet == null) { try { chartStylesheet = new File(newProject.getName() + ".css").toURI().normalize().toURL() .toExternalForm(); projectSettings.setProperty(PROP_CHART_STYLESHEET, chartStylesheet); } catch (Exception e) { log.warn("Cannot get chartStylesheet uri.", e); }// w w w .j ava 2 s . c o m } } if (doOnlyViewUpdates) { List<String> recentProjectPaths = guiSettingsManager.getSettings().getRecentProjectPaths(); String lastProjectPath = recentProjectPaths.isEmpty() ? null : recentProjectPaths.get(0); if (!Objects.equals(lastProjectPath, newProjectPath)) { log.warn("Changing project from '{}' to '{}'. doOnlyViewUpdates will be set to false.", lastProjectPath, newProjectPath); doOnlyViewUpdates = false; } } if (doOnlyViewUpdates) { forceCloseProject(false); } else { if (!tryCloseProject()) return; butSaveFile.disableProperty().unbind(); butSaveFile.setDisable(newProject == null); mnuSaveFile.disableProperty().unbind(); mnuSaveFile.setDisable(newProject == null); mnuShowSourceCode.disableProperty().unbind(); mnuShowSourceCode.setDisable(newProject == null); if (sourceCodeCaretPositionListener != null) { sourceCodeArea.caretPositionProperty().removeListener(sourceCodeCaretPositionListener); } } this.project = newProject; this.projectPathProperty.set(newProjectPath); sourceCodeArea.setProjectModel(newProject); if (newProject == null) { updateProjectTabs(null); viewsTabPane.getTabs().clear(); return; } updateRecentProjectPaths(newProjectPath); if (!doOnlyViewUpdates) { ProjectSettings projectSettings = newProject.getProjectSettingsManager().getSettings(); updateProjectTabs(projectSettings); boolean showFilePane = projectSettings.getProperty(PROP_FILE_AREA_VISIBLE, true, false); showFilePane(showFilePane, newProject); Divider fileSplitDivider = fileSplitPane.getDividers().get(0); double fileSplitPosition = projectSettings.getProperty(PROP_FILE_SPLIT_PANE_DIVIDER_POSITION, -1.0, false); if (fileSplitPosition >= 0) { fileSplitDivider.setPosition(fileSplitPosition); } fileSplitDivider.positionProperty().addListener((observable, oldValue, newValue) -> projectSettings .setProperty(PROP_FILE_SPLIT_PANE_DIVIDER_POSITION, newValue.doubleValue())); Platform.runLater(() -> { if (fileSplitPosition >= 0) { fileSplitDivider.setPosition(fileSplitPosition); } }); String projTitle = newProject.getTitle(); getStage().setTitle( newProject.getName() + ((projTitle == null || projTitle.isEmpty()) ? "" : (" - " + projTitle))); sourceCodeArea.getCodeTemplates().clear(); for (ViewrekaBundle bundle : project.getBundles()) { bundle.addTo(this); sourceCodeArea.getCodeTemplates().addAll(bundle.getTemplates()); } String initialScriptText = newProject.getScriptText(); sourceCodeArea.setText(initialScriptText); CodeTabData sourceData = getData(tabSourceCode); sourceData.setFilePath(FILE_ALIAS_SOURCE_CODE); sourceData.setInitialText(initialScriptText); sourceData.setTextProperty(sourceCodeArea.textProperty()); // TODO - find a better way to position the caret. sourceCodeArea.positionCaret(0); Platform.runLater(() -> { int caretPos = projectSettings.getProperty(PROP_SOURCE_CODE_CARET_POSITION, 0, false); sourceCodeArea.selectRange(caretPos, caretPos); sourceCodeCaretPositionListener = (obs, oldValue, newValue) -> projectSettings .setProperty(PROP_SOURCE_CODE_CARET_POSITION, newValue); sourceCodeArea.caretPositionProperty().addListener(sourceCodeCaretPositionListener); }); } refreshViews(); }
From source file:org.sleuthkit.autopsy.imagegallery.gui.GroupPane.java
/** * assigns a grouping for this pane to represent and initializes grouping * specific properties and listeners/*from www.j a v a 2 s . co m*/ * * @param grouping the new grouping assigned to this group */ void setViewState(GroupViewState viewState) { if (nonNull(getGrouping())) { getGrouping().fileIds().removeListener(filesSyncListener); } if (isNull(viewState) || isNull(viewState.getGroup())) { this.grouping.set(null); Platform.runLater(() -> { gridView.getItems().setAll(Collections.emptyList()); setCenter(null); groupLabel.setText(""); resetScrollBar(); if (false == Case.isCaseOpen()) { cellMap.values().stream().forEach(DrawableCell::resetItem); cellMap.clear(); } }); } else { if (this.grouping.get() != viewState.getGroup()) { this.grouping.set(viewState.getGroup()); this.getGrouping().fileIds().addListener(filesSyncListener); final String header = getHeaderString(); gridView.getItems().setAll(getGrouping().fileIds()); Platform.runLater(() -> { slideShowToggle.setDisable(gridView.getItems().isEmpty()); groupLabel.setText(header); resetScrollBar(); if (viewState.getMode() == GroupViewMode.TILE) { activateTileViewer(); } else { activateSlideShowViewer(viewState.getSlideShowfileID().orElse(null)); } }); } } }
From source file:org.sleuthkit.autopsy.imageanalyzer.gui.GroupPane.java
/** * assigns a grouping for this pane to represent and initializes grouping * specific properties and listeners/* w w w. j av a2s .c o m*/ * * @param grouping the new grouping assigned to this group */ void setViewState(GroupViewState viewState) { if (viewState == null) { Platform.runLater(() -> { setCenter(null); groupLabel.setText(null); }); } else { if (this.grouping.get() != viewState.getGroup()) { this.grouping.set(viewState.getGroup()); } if (viewState.getMode() == GroupViewMode.TILE) { activateTileViewer(); } else { activateSlideShowViewer(viewState.getSlideShowfileID().orElse(null)); } } }
From source file:acmi.l2.clientmod.l2smr.Controller.java
@FXML private void createStaticMeshToUnr() { Platform.runLater(() -> { StaticMeshActorDialog dlg = new StaticMeshActorDialog(); ButtonType response = dlg.showAndWait().orElse(null); if (response != ButtonType.OK) return; boolean rot = dlg.isRotating(); boolean zrs = dlg.isZoneRenderState(); longTask(progress -> {// w ww . ja va 2 s . c o m String usx = this.usxChooser.getSelectionModel().getSelectedItem(); usx = usx.substring(0, usx.indexOf('.')); try (UnrealPackage up = new UnrealPackage( new File(getMapsDir(), this.unrChooser.getSelectionModel().getSelectedItem()), false)) { addStaticMeshToUnr(up); int actorInd = StaticMeshActorUtil.addStaticMeshActor(up, up.objectReferenceByName( usx + "." + this.smChooser.getSelectionModel().getSelectedItem(), c -> true), dlg.getActorClass(), rot, zrs, this.oldFormat.isSelected()) - 1; Platform.runLater(() -> { int ind = this.unrChooser.getSelectionModel().getSelectedIndex(); this.unrChooser.getSelectionModel().clearSelection(); this.unrChooser.getSelectionModel().select(ind); ind = 0; for (int i = 0; i < actors.size(); i++) if (actors.get(i).getInd() == actorInd) ind = i; table.getSelectionModel().select(ind); table.scrollTo(ind); }); } }, e -> onException("Creation failed", e)); }); }