List of usage examples for javafx.application Platform runLater
public static void runLater(Runnable runnable)
From source file:com.github.vatbub.tictactoe.view.Main.java
private void reloadImage(ImageView imageView, String imageURL, double newWidth, double newHeight) { if (loadTimerMap.get(imageURL) != null) { loadTimerMap.get(imageURL).cancel(); }//from w ww . ja v a 2 s. c om Timer loadTimer = new Timer(); loadTimerMap.put(imageURL, loadTimer); loadTimer.schedule(new TimerTask() { @Override public void run() { Image image = new Image(imageURL, newWidth, newHeight, false, true); Platform.runLater(() -> imageView.setImage(image)); } }, 300); }
From source file:org.noroomattheinn.visibletesla.MainController.java
private void exitWithMobileAccessError() { Platform.runLater(new Runnable() { @Override/*from w w w . j ava 2 s .c o m*/ public void run() { Dialogs.showErrorDialog(app.stage, "Your Tesla has not been configured to allow mobile " + "access. You have to enable this on your car's touch" + "screen using Controls / Settings / Vehicle." + "\n\nChange that setting in your car, then relaunch VisibleTesla.", "Unable to communicate with your Tesla", "Communication Problem"); logger.log(Level.SEVERE, "Mobile access is not enabled - exiting."); Platform.exit(); } }); }
From source file:acmi.l2.clientmod.l2smr.Controller.java
@FXML private void copyStaticMesh() { Actor selected = this.table.getSelectionModel().getSelectedItem(); if (selected == null) return;//from w w w .ja v a 2s .c o m longTask(progress -> { try (UnrealPackage up = new UnrealPackage( new File(getMapsDir(), this.unrChooser.getSelectionModel().getSelectedItem()), false)) { int actorInd = StaticMeshActorUtil.copyStaticMeshActor(up, selected.getInd()) - 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("Copy failed", e)); }
From source file:de.dkfz.roddy.client.fxuiclient.RoddyUIController.java
private void refillListOfDataSets() { //TODO Think about a good update mechanism Maybe a counter which only allowes update if the count fits? if (!Platform.isFxApplicationThread()) { Platform.runLater(new Runnable() { @Override/*from www .jav a 2 s . c o m*/ public void run() { refillListOfDataSets(); } }); return; } List<FXDataSetWrapper> newList; List<FXDataSetWrapper> acceptedItems = new LinkedList<>(); synchronized (currentListOfDataSets) { newList = new LinkedList<>(currentListOfDataSets); } try { WildcardFileFilter wff = new WildcardFileFilter(txtDataSetFilter.getText()); listViewDataSets.getSelectionModel().select(-1); listViewDataSets.getItems().clear(); for (FXDataSetWrapper dsw : newList) { if (wff.accept(new File(dsw.getId()))) { acceptedItems.add(dsw); } } listViewDataSets.getItems().addAll(acceptedItems); } catch (Exception e) { e.printStackTrace(); } }
From source file:eu.ggnet.dwoss.redtape.document.DocumentUpdateView.java
private void convertToWarrantyPositionButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_convertToWarrantyPositionButtonActionPerformed if (!positionsFxList.getSelectionModel().isEmpty()) { Platform.runLater(() -> { try { //constructor made sure the service is present document.appendAll(/*from w w w.jav a 2 s. co m*/ lookup(WarrantyHook.class) .addWarrantyForUnitPosition( positionsFxList.getSelectionModel().getSelectedItem(), document.getId()) .request(new SwingInteraction(this))); positions.clear(); positions.addAll(document.getPositions().values()); } catch (UserInfoException ex) { UiCore.handle(ex); } }); } }
From source file:org.noroomattheinn.visibletesla.MainController.java
private void exitWithCachingError() { Platform.runLater(new Runnable() { @Override/*from www.j a va 2 s .co m*/ public void run() { Dialogs.showErrorDialog(app.stage, "Failed to connect to your vehicle even after a successful " + "login. It may be in a deep sleep and can't be woken up.\n" + "\nPlease try to wake your Tesla and then try VisibleTesla again.", "Unable to communicate with your Tesla", "Communication Problem"); logger.severe("Can't communicate with vehicle - exiting."); Platform.exit(); } }); }
From source file:de.bayern.gdi.gui.Controller.java
/** * Handle search and filter the service list. * * @param event the event/*w ww. ja va2 s .co m*/ */ @FXML protected void handleSearch(KeyEvent event) { if (!catalogReachable) { setStatusTextUI(I18n.getMsg("status.catalog-not-available")); } String currentText = this.searchField.getText(); this.serviceList.getItems().clear(); dataBean.resetCatalogLists(); if (currentText == null || currentText.isEmpty()) { this.serviceList.setItems(this.dataBean.getServicesAsList()); } String searchValue = currentText == null ? "" : currentText.toUpperCase(); ObservableList<ServiceModel> subentries = FXCollections.observableArrayList(); ObservableList<ServiceModel> all = this.dataBean.getServicesAsList(); for (ServiceModel entry : all) { boolean match = entry.getName().toUpperCase().contains(searchValue); if (match) { subentries.add(entry); } } if (currentText != null && currentText.length() > 2) { Task task = new Task() { @Override protected Integer call() throws Exception { Platform.runLater(() -> { searchButton.setVisible(false); searchButton.setManaged(false); progressSearch.setVisible(true); progressSearch.setManaged(true); }); if (catalogReachable) { List<Service> catalog = dataBean.getCatalogService().getServicesByFilter(currentText); for (Service entry : catalog) { dataBean.addCatalogServiceToList(entry); } Platform.runLater(() -> { for (Service entry : catalog) { subentries.add(new ServiceModel(entry)); } }); } Platform.runLater(() -> { progressSearch.setVisible(false); progressSearch.setManaged(false); searchButton.setManaged(true); searchButton.setVisible(true); }); return 0; } }; Thread th = new Thread(task); if (catalogReachable) { setStatusTextUI(I18n.getMsg("status.calling-service")); } th.setDaemon(true); th.start(); } this.serviceList.setItems(subentries); }
From source file:de.bayern.gdi.gui.Controller.java
private boolean selectService(Service service) { log.info("User selected: " + service.toString()); if (ServiceChecker.isReachable(service.getServiceURL())) { try {//from ww w .ja v a 2 s. c o m service.load(); } catch (IOException e) { log.error(e.getMessage(), e); Platform.runLater(() -> setStatusTextUI(I18n.format(STATUS_SERVICE_BROKEN))); return false; } } else { Platform.runLater(() -> setStatusTextUI(I18n.format("status.service-not-available"))); return false; } if (dataBean.getSelectedService() != null && dataBean.getSelectedService().equals(service)) { Platform.runLater(() -> setStatusTextUI(I18n.format(STATUS_READY))); return true; } dataBean.setSelectedService(service); Platform.runLater(() -> { resetGui(); this.serviceURL.setText(dataBean.getSelectedService().getServiceURL().toString()); }); //Check if Username and Password are given if (((dataBean.getSelectedService().getUsername() != null && dataBean.getSelectedService().getPassword() != null) || (dataBean.getSelectedService().getUsername().isEmpty() && dataBean.getSelectedService().getPassword().isEmpty())) && dataBean.getSelectedService().isRestricted()) { Platform.runLater(() -> { setStatusTextUI(I18n.format("status.service-needs-auth")); this.serviceAuthenticationCbx.setSelected(true); this.serviceUser.setDisable(false); this.servicePW.setDisable(false); }); return false; } else { Platform.runLater(() -> { this.serviceAuthenticationCbx.setSelected(false); this.serviceUser.setDisable(true); this.servicePW.setDisable(true); clearUserNamePassword(); }); } //Check if this thing could be loaded if (dataBean.getSelectedService().getServiceType() == null) { Platform.runLater(() -> setStatusTextUI(I18n.format(STATUS_SERVICE_BROKEN))); return false; } Platform.runLater(() -> setStatusTextUI(I18n.format(STATUS_READY))); return true; }
From source file:com.vladsch.idea.multimarkdown.editor.MultiMarkdownFxPreviewEditor.java
protected void updateHtmlContent(boolean force) { if (updateDelayTimer != null) { updateDelayTimer.cancel();/*from www. j a va 2 s . c o m*/ updateDelayTimer = null; } if (previewIsObsolete && isEditorTabVisible && (isActive || force)) { try { final RootNode rootNode = MultiMarkdownLexParserManager.parseMarkdownRoot( document.getCharsSequence(), MultiMarkdownGlobalSettings.getInstance().getExtensionsValue(), getParsingTimeout()); if (isRawHtml) { final String htmlTxt = isShowModified() ? makeHtmlPage(markdownToHtml(true, rootNode)) : markdownToHtml(false, rootNode); updateRawHtmlText(htmlTxt); } else { if (!htmlWorkerRunning) { htmlWorkerRunning = true; previewIsObsolete = false; final String html = makeHtmlPage(markdownToHtml(true, rootNode)); Platform.runLater(new Runnable() { @Override public void run() { if (project.isDisposed()) return; // TODO: add option to enable/disable keeping scroll position on update Worker.State state = webEngine.getLoadWorker().getState(); //logger.info("[" + instance + "] " + "State on update " + state); Double pageZoom = MultiMarkdownGlobalSettings.getInstance().pageZoom.getValue(); if (webView.getZoom() != pageZoom) { //logger.info("[" + instance + "] " + "setZoom(" + pageZoom + ")"); webView.setZoom(pageZoom); } //logger.info("[" + instance + "] " + "loadContent"); webEngine.loadContent(html); } }); } else { // reschedule the update for later delayedHtmlPreviewUpdate(false); } } } catch (Exception e) { logger.info("[" + instance + "] " + "Failed processing Markdown document", e); } } }
From source file:org.beryx.viewreka.fxapp.Viewreka.java
public void onShown() { projectTabPane.requestFocus();/*from w ww . ja va 2s . c o m*/ Tab tab = projectTabPane.getSelectionModel().getSelectedItem(); if (tab != null) { Platform.runLater(() -> tab.getContent().requestFocus()); } }