List of usage examples for javafx.application Platform runLater
public static void runLater(Runnable runnable)
From source file:org.wandora.application.gui.topicpanels.webview.WebViewPanel.java
public void openContent(final String str) { try {//from w ww.jav a 2 s. co m if (str != null) { if (!isUIInitialized) { isUIInitialized = true; initializeUI(); } Platform.runLater(new Runnable() { @Override public void run() { webEngine.loadContent(str); } }); } } catch (Exception e) { e.printStackTrace(); } }
From source file:eu.ggnet.dwoss.redtape.document.DocumentUpdateView.java
private void changePositionOrderAction(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_changePositionOrderAction final MultipleSelectionModel<Position> selection = positionsFxList.getSelectionModel(); final int index = selection.getSelectedIndex(); Position selectedItem = selection.getSelectedItem(); if (index < 0) return;// w w w .ja va2 s . c o m if (evt.getSource() == moveUpButton) { if (index == 0) return; // Don't move at the beginning document.moveUp(selectedItem); Platform.runLater(new Runnable() { @Override public void run() { Position removed = positions.remove(index); positions.add(index - 1, removed); selection.select(index - 1); } }); } else { if (index == positions.size() - 1) return; // Don't move at the end document.moveDown(selectedItem); Platform.runLater(new Runnable() { @Override public void run() { Position removed = positions.remove(index); positions.add(index + 1, removed); selection.select(index + 1); } }); } }
From source file:acmi.l2.clientmod.xdat.Controller.java
@FXML private void open() { FileChooser fileChooser = new FileChooser(); fileChooser.setTitle("Open interface.xdat"); fileChooser.getExtensionFilters().addAll(new FileChooser.ExtensionFilter("XDAT (*.xdat)", "*.xdat"), new FileChooser.ExtensionFilter("All files", "*.*")); if (initialDirectory.getValue() != null && initialDirectory.getValue().exists() && initialDirectory.getValue().isDirectory()) fileChooser.setInitialDirectory(initialDirectory.getValue()); File selected = fileChooser.showOpenDialog(editor.getStage()); if (selected == null) return;//from w ww . ja va2 s. c om xdatFile.setValue(selected); initialDirectory.setValue(selected.getParentFile()); try { IOEntity xdat = editor.getXdatClass().getConstructor().newInstance(); editor.execute(() -> { CountingInputStream cis = new CountingInputStream( new BufferedInputStream(new FileInputStream(selected))); try (InputStream is = cis) { xdat.read(is); Platform.runLater(() -> editor.setXdatObject(xdat)); } catch (Exception e) { log.log(Level.WARNING, String.format("Read error before offset 0x%x", cis.getCount()), e); throw e; } return null; }, e -> Platform.runLater(() -> Dialogs.show(Alert.AlertType.ERROR, "Read error", null, "Try to choose another version"))); } catch (ReflectiveOperationException e) { log.log(Level.WARNING, "XDAT class should have empty public constructor", e); Dialogs.show(Alert.AlertType.ERROR, "ReflectiveOperationException", null, "XDAT class should have empty public constructor"); } }
From source file:org.sleuthkit.autopsy.imagegallery.gui.drawableviews.GroupPane.java
/** * assigns a grouping for this pane to represent and initializes grouping * specific properties and listeners//from w ww .j a v a 2 s. com * * @param grouping the new grouping assigned to this group */ void setViewState(GroupViewState viewState) { if (isNull(viewState) || isNull(viewState.getGroup())) { if (nonNull(getGroup())) { getGroup().getFileIDs().removeListener(filesSyncListener); } this.grouping.set(null); Platform.runLater(() -> { gridView.getItems().setAll(Collections.emptyList()); setCenter(null); slideShowToggle.setDisable(true); groupLabel.setText(""); resetScrollBar(); if (false == Case.isCaseOpen()) { cellMap.values().stream().forEach(DrawableCell::resetItem); cellMap.clear(); } }); } else { if (getGroup() != viewState.getGroup()) { if (nonNull(getGroup())) { getGroup().getFileIDs().removeListener(filesSyncListener); } this.grouping.set(viewState.getGroup()); getGroup().getFileIDs().addListener(filesSyncListener); final String header = getHeaderString(); Platform.runLater(() -> { gridView.getItems().setAll(getGroup().getFileIDs()); slideShowToggle.setDisable(gridView.getItems().isEmpty()); groupLabel.setText(header); resetScrollBar(); if (viewState.getMode() == GroupViewMode.TILE) { activateTileViewer(); } else { activateSlideShowViewer(viewState.getSlideShowfileID().orElse(null)); } }); } } }
From source file:com.mycompany.trafficimportfileconverter2.Main2Controller.java
public void log(String str) { Platform.runLater(() -> { txtAreaOutput.appendText("\n" + str); }); }
From source file:org.wandora.application.gui.topicpanels.webview.WebViewPanel.java
private void initializeUI() { Wandora wandora = Wandora.getWandora(); if (options == null) { if (USE_LOCAL_OPTIONS) { options = new Options(wandora.getOptions()); } else {/* w ww . j a v a2 s . c o m*/ options = wandora.getOptions(); } } tm = wandora.getTopicMap(); initComponents(); Platform.setImplicitExit(false); final WandoraJFXPanel fxPanel = new WandoraJFXPanel(); fxPanelHandle = fxPanel; this.add(fxPanel, BorderLayout.CENTER); Platform.runLater(new Runnable() { @Override public void run() { initFX(fxPanel); browse(rootTopic); } }); this.addComponentListener(this); backButton.setText(""); backButton.setIcon(UIBox.getIcon("gui/icons/webview/backward.png")); forwardButton.setText(""); forwardButton.setIcon(UIBox.getIcon("gui/icons/webview/forward.png")); stopButton.setText(""); stopButton.setIcon(UIBox.getIcon("gui/icons/webview/stop.png")); reloadButton.setText(""); reloadButton.setIcon(UIBox.getIcon("gui/icons/webview/reload.png")); menuButton.setText(""); menuButton.setIcon(UIBox.getIcon("gui/icons/webview/menu.png")); }
From source file:org.beryx.viewreka.fxapp.Viewreka.java
private void configureMainSplitDivider(FxProject newProject) { if (newProject == null) return;//from w ww.ja v a 2s. c o m if (!mainSplitPane.getDividers().isEmpty()) { Divider mainSplitDivider = mainSplitPane.getDividers().get(0); ProjectSettings projectSettings = newProject.getProjectSettingsManager().getSettings(); double mainSplitPosition = projectSettings.getProperty(PROP_MAIN_SPLIT_PANE_DIVIDER_POSITION, 0.3, false); if (mainSplitPosition >= 0) { mainSplitDivider.setPosition(mainSplitPosition); } mainSplitDivider.positionProperty().addListener((observable, oldValue, newValue) -> projectSettings .setProperty(PROP_MAIN_SPLIT_PANE_DIVIDER_POSITION, newValue.doubleValue())); Platform.runLater(() -> { if (mainSplitPosition >= 0) { mainSplitDivider.setPosition(mainSplitPosition); } }); } }
From source file:org.sleuthkit.autopsy.imagegallery.datamodel.grouping.GroupManager.java
private DrawableGroup popuplateIfAnalyzed(GroupKey<?> groupKey, ReGroupTask<?> task) { if (Objects.nonNull(task) && (task.isCancelled())) { /*//from ww w . j a va2 s .co m * if this method call is part of a ReGroupTask and that task is * cancelled, no-op * * this allows us to stop if a regroup task has been cancelled (e.g. * the user picked a different group by attribute, while the current * task was still running) */ } else { // no task or un-cancelled task if ((groupKey.getAttribute() != DrawableAttribute.PATH) || db.isGroupAnalyzed(groupKey)) { /* * for attributes other than path we can't be sure a group is * fully analyzed because we don't know all the files that will * be a part of that group,. just show them no matter what. */ try { Set<Long> fileIDs = getFileIDsInGroup(groupKey); if (Objects.nonNull(fileIDs)) { DrawableGroup group; final boolean groupSeen = db.isGroupSeen(groupKey); synchronized (groupMap) { if (groupMap.containsKey(groupKey)) { group = groupMap.get(groupKey); group.setFiles(ObjectUtils.defaultIfNull(fileIDs, Collections.emptySet())); } else { group = new DrawableGroup(groupKey, fileIDs, groupSeen); controller.getCategoryManager().registerListener(group); group.seenProperty().addListener((o, oldSeen, newSeen) -> { Platform.runLater(() -> markGroupSeen(group, newSeen)); }); groupMap.put(groupKey, group); } } Platform.runLater(() -> { if (analyzedGroups.contains(group) == false) { analyzedGroups.add(group); if (Objects.isNull(task)) { FXCollections.sort(analyzedGroups, applySortOrder(sortOrder, sortBy)); } } markGroupSeen(group, groupSeen); }); return group; } } catch (TskCoreException ex) { LOGGER.log( Level.SEVERE, "failed to get files for group: " + groupKey.getAttribute().attrName.toString() + " = " + groupKey.getValue(), ex); //NON-NLS } } } return null; }
From source file:acmi.l2.clientmod.xdat.Controller.java
@FXML private void save() { if (xdatFile.getValue() == null) return;/*from ww w . j a v a 2 s. c o m*/ editor.execute(() -> { try (OutputStream os = new BufferedOutputStream(new FileOutputStream(xdatFile.getValue()))) { editor.getXdatObject().write(os); } return null; }, e -> { log.log(Level.WARNING, "Write error", e); Platform.runLater( () -> Dialogs.show(Alert.AlertType.ERROR, e.getClass().getSimpleName(), null, e.getMessage())); }); }
From source file:com.github.drbookings.ui.controller.MainController.java
private void setWorking(final boolean working) { Platform.runLater(() -> setWorkingFX(working, true)); }