List of usage examples for javafx.application Platform runLater
public static void runLater(Runnable runnable)
From source file:com.github.drbookings.ui.controller.MainController.java
@FXML private void handleButtonSelectCurrentMonth(final ActionEvent event) { Platform.runLater(() -> selectCurrentMonthFX()); }
From source file:org.wandora.application.gui.topicpanels.webview.WebViewPanel.java
private void backButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_backButtonActionPerformed if (webEngine != null) { Platform.runLater(new Runnable() { @Override// ww w . jav a2s . co m public void run() { webEngine.executeScript("history.back()"); } }); } }
From source file:gov.va.isaac.gui.ConceptNode.java
@Override public void lookupComplete(final ConceptVersionBI concept, final long submitTime, Integer callId) { Platform.runLater(new Runnable() { @Override/*from w w w .j a v a 2 s .c o m*/ public void run() { logger.debug("lookupComplete - found '{}'", (concept == null ? "-null-" : concept.toUserString())); synchronized (lookupsCurrentlyInProgress_) { lookupsCurrentlyInProgress_.decrementAndGet(); isLookupInProgress_.invalidate(); lookupsCurrentlyInProgress_.notifyAll(); } if (submitTime < lookupUpdateTime_) { // Throw it away, we already got back a newer lookup. logger.debug("throwing away a lookup"); return; } else { lookupUpdateTime_ = submitTime; } if (concept != null) { c_ = concept; AppContext.getService(CommonlyUsedConcepts.class).addConcept(new SimpleDisplayConcept(c_)); isValid.setValid(); } else { // lookup failed c_ = null; if (StringUtils.isNotBlank(cb_.getValue().getDescription())) { isValid.setInvalid("The specified concept was not found in the database"); } else if (flagAsInvalidWhenBlank_) { isValid.setInvalid("Concept required"); } else { isValid.setValid(); } } updateGUI(); conceptBinding_.invalidate(); } }); }
From source file:org.sleuthkit.autopsy.imageanalyzer.gui.GroupPane.java
/** * called automatically during constructor by FXMLConstructor. * * checks that FXML loading went ok and performs additional setup *//*from w ww.jav a 2s . co m*/ @FXML void initialize() { assert gridView != null : "fx:id=\"tilePane\" was not injected: check your FXML file 'GroupPane.fxml'."; assert grpCatSplitMenu != null : "fx:id=\"grpCatSplitMenu\" was not injected: check your FXML file 'GroupHeader.fxml'."; assert grpTagSplitMenu != null : "fx:id=\"grpTagSplitMenu\" was not injected: check your FXML file 'GroupHeader.fxml'."; assert headerToolBar != null : "fx:id=\"headerToolBar\" was not injected: check your FXML file 'GroupHeader.fxml'."; assert segButton != null : "fx:id=\"previewList\" was not injected: check your FXML file 'GroupHeader.fxml'."; assert slideShowToggle != null : "fx:id=\"segButton\" was not injected: check your FXML file 'GroupHeader.fxml'."; assert tileToggle != null : "fx:id=\"tileToggle\" was not injected: check your FXML file 'GroupHeader.fxml'."; grouping.addListener(new InvalidationListener() { private void updateFiles() { final ObservableList<Long> fileIds = grouping.get().fileIds(); Platform.runLater(() -> { gridView.setItems(FXCollections.observableArrayList(fileIds)); }); resetHeaderString(); } @Override public void invalidated(Observable o) { getScrollBar().ifPresent((scrollBar) -> { scrollBar.setValue(0); }); //set the embeded header resetHeaderString(); //and assign fileIDs to gridView if (grouping.get() == null) { Platform.runLater(gridView.getItems()::clear); } else { grouping.get().fileIds().addListener((Observable observable) -> { updateFiles(); }); updateFiles(); } } }); //configure flashing glow animation on next unseen group button flashAnimation.setCycleCount(Timeline.INDEFINITE); flashAnimation.setAutoReverse(true); //configure gridView cell properties gridView.cellHeightProperty().bind(Toolbar.getDefault().sizeSliderValue().add(75)); gridView.cellWidthProperty().bind(Toolbar.getDefault().sizeSliderValue().add(75)); gridView.setCellFactory((GridView<Long> param) -> new DrawableCell()); //configure toolbar properties HBox.setHgrow(spacer, Priority.ALWAYS); spacer.setMinWidth(Region.USE_PREF_SIZE); ArrayList<MenuItem> grpTagMenues = new ArrayList<>(); for (final TagName tn : TagUtils.getNonCategoryTagNames()) { MenuItem menuItem = createGrpTagMenuItem(tn); grpTagMenues.add(menuItem); } try { grpTagSplitMenu.setText(TagUtils.getFollowUpTagName().getDisplayName()); grpTagSplitMenu.setOnAction(createGrpTagMenuItem(TagUtils.getFollowUpTagName()).getOnAction()); } catch (TskCoreException tskCoreException) { LOGGER.log(Level.WARNING, "failed to load FollowUpTagName", tskCoreException); } grpTagSplitMenu.setGraphic(new ImageView(DrawableAttribute.TAGS.getIcon())); grpTagSplitMenu.getItems().setAll(grpTagMenues); ArrayList<MenuItem> grpCategoryMenues = new ArrayList<>(); for (final Category cat : Category.values()) { MenuItem menuItem = createGrpCatMenuItem(cat); grpCategoryMenues.add(menuItem); } grpCatSplitMenu.setText(Category.FIVE.getDisplayName()); grpCatSplitMenu.setGraphic(new ImageView(DrawableAttribute.CATEGORY.getIcon())); grpCatSplitMenu.getItems().setAll(grpCategoryMenues); grpCatSplitMenu.setOnAction(createGrpCatMenuItem(Category.FIVE).getOnAction()); Runnable syncMode = () -> { switch (groupViewMode.get()) { case SLIDE_SHOW: slideShowToggle.setSelected(true); break; case TILE: tileToggle.setSelected(true); break; } }; syncMode.run(); //make togle states match view state groupViewMode.addListener((o) -> { syncMode.run(); }); slideShowToggle.toggleGroupProperty().addListener((o) -> { slideShowToggle.getToggleGroup().selectedToggleProperty() .addListener((observable, oldToggle, newToggle) -> { if (newToggle == null) { oldToggle.setSelected(true); } }); }); //listen to toggles and update view state slideShowToggle.setOnAction((ActionEvent t) -> { activateSlideShowViewer(globalSelectionModel.lastSelectedProperty().get()); }); tileToggle.setOnAction((ActionEvent t) -> { activateTileViewer(); }); controller.viewState().addListener((ObservableValue<? extends GroupViewState> observable, GroupViewState oldValue, GroupViewState newValue) -> { setViewState(newValue); }); addEventFilter(KeyEvent.KEY_PRESSED, tileKeyboardNavigationHandler); gridView.addEventHandler(MouseEvent.MOUSE_CLICKED, new EventHandler<MouseEvent>() { private ContextMenu buildContextMenu() { ArrayList<MenuItem> menuItems = new ArrayList<>(); menuItems.add(CategorizeAction.getPopupMenu()); menuItems.add(AddDrawableTagAction.getInstance().getPopupMenu()); Collection<? extends ContextMenuActionsProvider> menuProviders = Lookup.getDefault() .lookupAll(ContextMenuActionsProvider.class); for (ContextMenuActionsProvider provider : menuProviders) { for (final Action act : provider.getActions()) { if (act instanceof Presenter.Popup) { Presenter.Popup aact = (Presenter.Popup) act; menuItems.add(SwingMenuItemAdapter.create(aact.getPopupPresenter())); } } } final MenuItem extractMenuItem = new MenuItem("Extract File(s)"); extractMenuItem.setOnAction((ActionEvent t) -> { SwingUtilities.invokeLater(() -> { TopComponent etc = WindowManager.getDefault() .findTopComponent(ImageAnalyzerTopComponent.PREFERRED_ID); ExtractAction.getInstance().actionPerformed(new java.awt.event.ActionEvent(etc, 0, null)); }); }); menuItems.add(extractMenuItem); ContextMenu contextMenu = new ContextMenu(menuItems.toArray(new MenuItem[] {})); contextMenu.setAutoHide(true); return contextMenu; } @Override public void handle(MouseEvent t) { switch (t.getButton()) { case PRIMARY: if (t.getClickCount() == 1) { globalSelectionModel.clearSelection(); if (contextMenu != null) { contextMenu.hide(); } } t.consume(); break; case SECONDARY: if (t.getClickCount() == 1) { selectAllFiles(); } if (contextMenu == null) { contextMenu = buildContextMenu(); } contextMenu.hide(); contextMenu.show(GroupPane.this, t.getScreenX(), t.getScreenY()); t.consume(); break; } } }); // Platform.runLater(() -> { ActionUtils.configureButton(nextGroupAction, nextButton); final EventHandler<ActionEvent> onAction = nextButton.getOnAction(); nextButton.setOnAction((ActionEvent event) -> { flashAnimation.stop(); nextButton.setEffect(null); onAction.handle(event); }); ActionUtils.configureButton(forwardAction, forwardButton); ActionUtils.configureButton(backAction, backButton); // }); nextGroupAction.disabledProperty().addListener( (ObservableValue<? extends Boolean> observable, Boolean oldValue, Boolean newValue) -> { nextButton.setEffect(newValue ? null : DROP_SHADOW); if (newValue == false) { flashAnimation.play(); } else { flashAnimation.stop(); } }); //listen to tile selection and make sure it is visible in scroll area //TODO: make sure we are testing complete visability not just bounds intersection globalSelectionModel.lastSelectedProperty().addListener((observable, oldFileID, newFileId) -> { if (groupViewMode.get() == GroupViewMode.SLIDE_SHOW) { slideShowPane.setFile(newFileId); } else { scrollToFileID(newFileId); } }); setViewState(controller.viewState().get()); }
From source file:de.unibw.inf2.fishification.FishWorld.java
/** * Asynchronoulsy takes screenshots with short delay. *///from w w w.j a v a 2 s .com public void asyncTakeScreenshot() { // First, asynchronous wait new Thread(new Runnable() { @Override public void run() { try { Thread.sleep(SCREENSHOT_DELAY); } catch (InterruptedException e) { m_log.warn("Screenshot sleep interrupted."); } // Second, Screenshot in main thread Platform.runLater(new Runnable() { @Override public void run() { takeScreenshot(s_screenshotsPath, s_screenshotsFileName); } }); } }).start(); }
From source file:com.github.drbookings.ui.controller.MainController.java
@FXML private void handleButtonSelectPrevMonth(final ActionEvent event) { Platform.runLater(() -> selectPrevMonthFX()); }
From source file:com.github.drbookings.ui.controller.MainController.java
@FXML private void handleButtonSelectNextMonth(final ActionEvent event) { Platform.runLater(() -> selectNextMonthFX()); }
From source file:org.sleuthkit.autopsy.imagegallery.ImageGalleryController.java
/** * reset the state of the controller (eg if the case is closed) *//*ww w.j a v a2 s .c o m*/ public synchronized void reset() { LOGGER.info("resetting ImageGalleryControler to initial state."); selectionModel.clearSelection(); setListeningEnabled(false); ThumbnailCache.getDefault().clearCache(); Platform.runLater(() -> { historyManager.clear(); }); Category.clearTagNames(); Toolbar.getDefault().reset(); groupManager.clear(); if (db != null) { db.closeDBCon(); } db = null; }
From source file:acmi.l2.clientmod.l2smr.Controller.java
private void updateSMAPane() { Platform.runLater(() -> { smaPane.setDisable(true);/*from w w w . ja v a 2 s . c o m*/ Arrays.stream(new TextField[] { locationX, locationY, locationZ, rotationPitch, rotationYaw, rotationRoll, drawScale3DX, drawScale3DY, drawScale3DZ, drawScale, rotationPitchRate, rotationYawRate, rotationRollRate, zoneState }).forEach(this::clearTextAndDisable); actorStaticMeshChooser.getSelectionModel().clearSelection(); Actor actor2 = table.getSelectionModel().getSelectedItem(); if (actor2 == null) return; smaPane.setDisable(false); float[] location = actor2.getLocation(); if (location != null) { setTextAndEnable(locationX, String.valueOf(location[0])); setTextAndEnable(locationY, String.valueOf(location[1])); setTextAndEnable(locationZ, String.valueOf(location[2])); } int[] rotator = actor2.getRotation(); if (rotator != null) { setTextAndEnable(rotationPitch, String.valueOf(rotator[0])); setTextAndEnable(rotationYaw, String.valueOf(rotator[1])); setTextAndEnable(rotationRoll, String.valueOf(rotator[2])); } Float ds = actor2.getScale(); if (ds != null) { setTextAndEnable(drawScale, ds.toString()); } float[] drawScale3D = actor2.getScale3D(); if (drawScale3D != null) { setTextAndEnable(drawScale3DX, String.valueOf(drawScale3D[0])); setTextAndEnable(drawScale3DY, String.valueOf(drawScale3D[1])); setTextAndEnable(drawScale3DZ, String.valueOf(drawScale3D[2])); } int[] rotationRate = actor2.getRotationRate(); if (rotationRate != null) { setTextAndEnable(rotationPitchRate, String.valueOf(rotationRate[0])); setTextAndEnable(rotationYawRate, String.valueOf(rotationRate[1])); setTextAndEnable(rotationRollRate, String.valueOf(rotationRate[2])); } int[] zoneRenderState = actor2.getZoneRenderState(); if (zoneRenderState != null) { String s = Arrays.toString(zoneRenderState); setTextAndEnable(zoneState, s.substring(1, s.length() - 1)); } actorStaticMeshChooser.getSelectionModel().select(indexIf(actorStaticMeshChooser.getItems(), ie -> ie.getObjectReference() == actor2.getStaticMeshRef())); }); }
From source file:com.github.drbookings.ui.controller.MainController.java
@FXML private void handleButtonClearFilter(final ActionEvent event) { Platform.runLater(() -> guestNameFilterInput.clear()); }