/** * 웹툰조회 */ public void getWebtoon(String code) { if (!"".equals(code)) { CommonService cs = new CommonService(); Connection conn = cs.getConnection(code); conn.timeout(5000); Document doc = null; codeInputField.setText(code); wDesc.setWrapText(true); try { doc = conn.get(); String title = doc.select("title").text().split("::")[0]; setTitle(title); String author = doc.select("div.detail h2 > span").text(); wTitle.setText(title + "(" + author + ")"); String desc = doc.select("div.detail p").text(); wDesc.setText(desc); String img = doc.select("div.thumb > a img").attr("src"); thumbnail.setImage(new Image(img, true)); } catch (Exception e) { e.printStackTrace(); } } else { Platform.runLater(new Runnable() { @Override public void run() { AlertSupport alert = new AlertSupport("웹툰코드를 입력하세요."); alert.alertInfoMsg(stage); } }); } }
@Override public void handleInput(GroupInputInfo info) { try { File file = info.getFile(); if (file == null) { return; } Group group = Group.createGroup(type, file.toPath(), info.getName()); if (group == null) { return; } fileUpdated(file); navigatorPanel.updated(DisplayWindow.this, new FileResource(file.getParentFile())); suitesPanel.updated(DisplayWindow.this, new FileResource(file)); featuresPanel.updated(DisplayWindow.this, new FileResource(file)); storiesPanel.updated(DisplayWindow.this, new FileResource(file)); issuesPanel.updated(DisplayWindow.this, new FileResource(file)); Platform.runLater(() -> openFile(file)); } catch (Exception e) { e.printStackTrace(); FXUIUtils.showConfirmDialog(DisplayWindow.this, "Could not complete creation of " + type.fileType().toLowerCase() + " file.", "Error in creating a " + type.fileType().toLowerCase() + " file", AlertType.ERROR); } }
@Override protected void performSetup() { setTitle(); // TODO: Better loading. Platform.runLater(new Runnable() { @Override public void run() { devicesLoadingLabel.setVisible(true); diskListView.setCellFactory(lv -> { TextFieldListCell<Disk> cell = new TextFieldListCell<>(); cell.setConverter(workflowController.getStringConverterForDisks()); return cell; }); ObservableList<Disk> disks = FXCollections.observableArrayList(); disks.addAll(workflowController.getAvailableDisks()); devicesLoadingLabel.setVisible(false); diskListView.setItems(disks); }}); }
@Test public void getText() { ChoiceBox<?> choiceBox = (ChoiceBox<?>) getPrimaryStage().getScene().getRoot().lookup(".choice-box"); LoggingRecorder lr = new LoggingRecorder(); List<String> text = new ArrayList<>(); Platform.runLater(() -> { RFXChoiceBox rfxChoiceBox = new RFXChoiceBox(choiceBox, null, null, lr); choiceBox.getSelectionModel().select(1); rfxChoiceBox.focusLost(null); text.add(rfxChoiceBox._getText()); }); new Wait("Waiting for choice box text.") { @Override public boolean until() { return text.size() > 0; } }; AssertJUnit.assertEquals("Cat", text.get(0)); }
/** * Initialize the status bar */ private void initStatusBar() { statusPanel.getFixtureLabel().setOnMouseClicked((e) -> { onSelectFixture(); }); statusPanel.getRowLabel().setOnMouseClicked((e) -> { gotoLine(); }); statusPanel.getInsertLabel().setOnMouseClicked((e) -> { Platform.runLater(() -> { if (currentEditor != null) { currentEditor.toggleInsertMode(); } }); }); }
@Override protected void onViewCreated() { siderBarView.setOnItemSelectedListener(contentView::loadBucket); contentView.setOnItemSelectedListener(this::updateSelectItem); contentView.setUpdateListener(bucketFile -> { if (Platform.isFxApplicationThread()) { updateSelectItem(bucketFile); } else { runOnUiThread(() -> this.updateSelectItem(bucketFile)); } }); // 初始化菜单 Menu setting = new Menu("设置"); setting.getItems().add(getMenuItem("TinyPNG", "tinypng")); setting.getItems().add(getMenuItem("七牛", "qiniu")); setting.getItems().add(getMenuItem("Gif", "gif")); Menu about = new Menu("关于"); about.getItems().add(getMenuItem("关于BlogHelper", "aboutBlogHelper")); about.getItems().add(getMenuItem("关于作者cmlanche", "aboutAnchor")); menuBar.getMenus().add(setting); menuBar.getMenus().add(about); if (PlatformUtil.isMac()) { menuBar.setUseSystemMenuBar(true); } // 操作按钮 downloadBtn.setOnAction(event -> contentView.handleAction("download")); renameBtn.setOnAction(event -> contentView.handleAction("rename")); deleteBtn.setOnAction(event -> contentView.handleAction("delete")); optimizeBtn.setOnAction(event -> contentView.handleAction("optimize")); uploadBtn.setOnAction(event -> contentView.handleAction("upload")); }
public boolean spellcheckDocument() { editorToolBar.setActionText("Spell checking document \'" + file.getName() + "\'"); Platform.runLater(() -> { try { timer.start(); List<RuleMatch> matches = spellcheck.check(getContent()); MarkdownHighligher.computeSpellcheckHighlighting(matches, this); editorToolBar.setActionText("Found " + matches.size() + " misspellings in the document \'" + file.getName() + "\' (" + timer.end() + "ms)"); } catch (IOException e) { dialogFactory.buildExceptionDialogBox( dict.DIALOG_EXCEPTION_TITLE, dict.DIALOG_EXCEPTION_SPELLCHECK_CONTENT, e.getMessage(), e ); } }); return true; }
@Test public void select() { TreeView<?> treeView = (TreeView<?>) getPrimaryStage().getScene().getRoot().lookup(".tree-view"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(new Runnable() { @Override public void run() { Point2D point = getPoint(treeView, 1); RFXTreeView rfxListView = new RFXTreeView(treeView, null, point, lr); rfxListView.focusGained(rfxListView); CheckBoxTreeItem<?> treeItem = (CheckBoxTreeItem<?>) treeView.getTreeItem(1); treeItem.setSelected(true); rfxListView.focusLost(rfxListView); } }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals("Child Node 1:checked", recording.getParameters()[0]); }
public void initialize() { MenuBar menuBar = new MenuBar(); // Make same width as the stage menuBar.prefWidthProperty().bind(primaryStage.widthProperty()); rootPane.setTop(menuBar); // File menu - new, save, exit Menu fileMenu = new Menu("File"); MenuItem newMenuItem = createMenuItem("New", actionEvent -> this.onNewFile()); MenuItem openMenuItem = createMenuItem("Open", actionEvent -> this.onOpenFile()); MenuItem saveMenuItem = createMenuItem("Save", actionEvent -> this.onSaveFile()); saveMenuItem.disableProperty().bind(jwkSetData.changedProperty().not()); MenuItem exitMenuItem = createMenuItem("Exit", actionEvent -> Platform.exit()); fileMenu.getItems().addAll(newMenuItem, openMenuItem, saveMenuItem, new SeparatorMenuItem(), exitMenuItem); menuBar.getMenus().addAll(fileMenu); }
@Test public void testNormalStart() throws Exception { Platform.runLater(() -> { Ember ember = new Ember(); Stage stage = new Stage(); try { ember.start(stage); } catch (Exception ex) { fail("An exception is thrown."); Logger.getLogger( EmberTest.class.getName()). log(Level.SEVERE, null, ex); } }); }
public void startGUI(Pane pane) { Platform.runLater(new Runnable() { @Override public void run() { primaryStage.hide(); primaryStage.setScene(new Scene(pane)); primaryStage.sizeToScene(); primaryStage.show(); } }); new Wait("Waiting for applicationHelper to be initialized") { @Override public boolean until() { try { return primaryStage.getScene().getRoot() == pane; } catch (Throwable t) { return false; } } }; }
@FXML public void startAutoSync() { DataSync.getMainStage().setOnCloseRequest(closeEvent -> this.syncController.kill()); this.syncController.execute((count) -> { Platform.runLater(() -> { Date date = new Date(); TOALogger.log(Level.INFO, "Executing update #" + count + " at " + DateFormat.getTimeInstance(DateFormat.SHORT).format(date)); TOALogger.log(Level.INFO, "There are " + Thread.activeCount() + " threads."); this.matchesController.syncMatches(); this.matchesController.checkMatchSchedule(); this.matchesController.checkMatchDetails(); // this.rankingsController.syncRankings(); // We're going to try THIS instead.... this.rankingsController.getRankingsByFile(); this.rankingsController.postRankings(); if (this.btnSyncMatches.selectedProperty().get()) { this.matchesController.postCompletedMatches(); } }); }); }
@Test public void duplicateMenuPath() { List<String> path = new ArrayList<>(); Platform.runLater(() -> { Menu menuFile = new Menu("File"); MenuItem add = new MenuItem("Shuffle"); MenuItem clear = new MenuItem("Clear"); MenuItem clear1 = new MenuItem("Clear"); MenuItem clear2 = new MenuItem("Clear"); MenuItem exit = new MenuItem("Exit"); menuFile.getItems().addAll(add, clear, clear1, clear2, new SeparatorMenuItem(), exit); RFXMenuItem rfxMenuItem = new RFXMenuItem(null, null); path.add(rfxMenuItem.getSelectedMenuPath(clear2)); }); new Wait("Waiting for menu selection path") { @Override public boolean until() { return path.size() > 0; } }; AssertJUnit.assertEquals("File>>Clear(2)", path.get(0)); }
/** * Called by a thread created when */ public static void startMe() { if (primaryStage == null) { try { Platform.setImplicitExit(false); Bootstrap.launch(); } catch (Exception exception) { FlexFXBundle.setStartupException(exception); } } else { FlexFXBundle.setStage(primaryStage, IS_FX_THREAD_RESTART); } }
private void registerListeners() { widthProperty().addListener(o -> resize()); heightProperty().addListener(o -> resize()); sceneProperty().addListener(o -> { if (!locations.isEmpty()) { addShapesToScene(locations.values()); } if (isZoomEnabled()) { getScene().addEventFilter( ScrollEvent.ANY, new WeakEventHandler<>(_scrollEventHandler)); } locations.addListener((MapChangeListener<Location, Shape>) CHANGE -> { if (CHANGE.wasAdded()) { addShapesToScene(CHANGE.getValueAdded()); } else if(CHANGE.wasRemoved()) { Platform.runLater(() -> pane.getChildren().remove(CHANGE.getValueRemoved())); } }); }); }
protected void updateValues() { if (playTime != null && timeSlider != null && volumeSlider != null && duration != null) { Platform.runLater(new Runnable() { public void run() { Duration currentTime = mp.getCurrentTime(); playTime.setText(formatTime(currentTime, duration)); timeSlider.setDisable(duration.isUnknown()); if (!timeSlider.isDisabled() && duration.greaterThan(Duration.ZERO) && !timeSlider.isValueChanging()) { timeSlider.setValue(currentTime.divide(duration).toMillis() * 100.0); } if (!volumeSlider.isValueChanging()) { volumeSlider.setValue((int) Math.round(mp.getVolume() * 100)); } } }); } }
@Override public void initialize(URL location, ResourceBundle resources) { Main.bot.currentChannel = Main.bot.getChannels().get(0); vbox.setSpacing(30); System.out.println("initialized"); updateViewCount(); new Timer().schedule(new TimerTask() { @Override public void run() { Platform.runLater(() -> { Controller.controller.viewCount .setText("Viewers: " + Main.bot.getChannels().get(0).getViewersNum()); }); } }, 0, 10000); vbox.heightProperty().addListener(new ChangeListener<Number>() { @Override public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) { scrollPane.setVvalue(1.0); } }); }
private void loadData(int page) { ThreadUtils.run(() ->{ Result<Article> result; synchronized (ArticleFragment.class) { result = ArticleDao.getInstance().getPage(page); } Platform.runLater(()->{ listView.getItems().clear(); List<Article> datas = result.recordList; listView.getItems().addAll(datas); pager_article.setPageCount(result.pageCount);// ע��ҳ���Ķ�̬�仯 if(FIRST){ pager_article.setVisible(true); FIRST = false; } }); }); }
/** * * @param root */ private void setExitAnimationToNode(Node root) { if(about.isShowing()) { this.popupCloser(about, about_box); } if(help.isShowing()) { this.popupCloser(help, help_box); } ScaleTransition st = new ScaleTransition(Duration.seconds(.4), root); st.setToX(0); st.setToY(0); st.play(); FadeTransition fd = new FadeTransition(Duration.seconds(.3), root); fd.setToValue(.1); fd.play(); st.setOnFinished(e -> Platform.exit()); }
private void openFile(File file) { Platform.runLater(() -> { try { MavenBean bean = handler.handle(file); bean.setId(filesInfo.size() + 1); if (null != bean) { filesInfo.add(bean); } } catch (Exception ex) { StringBuilder reason = new StringBuilder(); reason.append(Application.getResource().getString("error.reason")) .append(":") .append(file.getName()) .append(ex.getMessage()); Alert alert = ComponentUtils.dialog(stage, "", reason.toString()); alert.show(); } }); }
@Test public void click() { Button button = (Button) getPrimaryStage().getScene().getRoot().lookup(".button"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(new Runnable() { @Override public void run() { RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr); Point2D sceneXY = button.localToScene(new Point2D(3, 3)); PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY()); Point2D screenXY = button.localToScreen(new Point2D(3, 3)); MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(), MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult); rfxButtonBase.mouseButton1Pressed(me); } }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording select = recordings.get(0); AssertJUnit.assertEquals("click", select.getCall()); AssertJUnit.assertEquals("", select.getParameters()[0]); }
@Override public void start(Stage primaryStage) throws Exception { UIToolBox toolBox = DemoConstants.getToolBox(); AnnotationTableController controller = new AnnotationTableController(toolBox); Scene scene = new Scene(controller.getTableView()); scene.getStylesheets().add("/css/common.css"); scene.getStylesheets().add("/css/annotable.css"); primaryStage.setScene(scene); primaryStage.show(); final List<Annotation> annotations = makeAnnotations(); controller.getTableView().setItems(FXCollections.observableList(annotations)); primaryStage.setOnCloseRequest(e -> { Platform.exit(); System.exit(0); }); }
@Override public void handleDiskInsertion(Disk insertedDisk) { if (state.getSelectedDevice() != null) { return; } else { Platform.runLater(() -> { state.setSelectedDevice(insertedDisk); setupImaging(); // TODO: Not this way. This code is terrible. ImagingController imagingController = BaseController.getCurrentController().loadFXML(ImagingController.class, ImagingController.getFXMLLocation()); BaseController.changeScene(imagingController.getScene()); beginImaging(); }); } }
/** * 处理通知信息的显示 * @param notice */ public void addNotification(String notice){ Platform.runLater(() ->{ SimpleDateFormat df = new SimpleDateFormat("HH:mm:ss");//设置日期格式 String timer = df.format(new Date());// new Date()为获取当前系统时间 String content = timer + ": " + notice; BubbledTextFlow noticeBubbled = new BubbledTextFlow(EmojiDisplayer.createEmojiAndTextNode(content)); //noticeBubbled.setTextFill(Color.web("#031c30")); noticeBubbled.setBackground(new Background(new BackgroundFill(Color.WHITE, null, null))); HBox x = new HBox(); //x.setMaxWidth(chatPaneListView.getWidth() - 20); x.setAlignment(Pos.TOP_CENTER); noticeBubbled.setBubbleSpec(BubbleSpec.FACE_TOP); x.getChildren().addAll(noticeBubbled); chatPaneListView.getItems().add(x); }); }
/** * Vytvoří nový kontext apliakce * * @param databaseName Název databáze */ public Context(String databaseName, ResourceBundle resources) throws FileNotFoundException { this.resources = resources; this.appDirectory = new File(appDirs .getUserDataDir(CREDENTAILS_APP_NAME, CREDENTAILS_APP_VERSION, CREDENTILS_APP_AUTHOR)); if (!appDirectory.exists()) { if (!appDirectory.mkdirs()) { logger.error("Nepodařilo se vytvořit složku aplikace, zavírám..."); Platform.exit(); } } logger.info("Používám pracovní adresář: {}", appDirectory.getPath()); try { database = new SQLite(appDirectory.getPath() + SEPARATOR + databaseName); } catch (SQLException e) { throw new FileNotFoundException(); } initFirebase(); userManager = new UserManager(FirebaseDatabase.getInstance()); initManagers(); }
public ListView<String> getVideoSequenceListView() { if (videoSequenceListView == null) { videoSequenceListView = new ListView<>(); videoSequenceListView.getSelectionModel().setSelectionMode(SelectionMode.SINGLE); // When a video sequence is selected set the next list to all the video names // available in the video sequence videoSequenceListView.getSelectionModel() .selectedItemProperty() .addListener((obs, oldValue, newValue) -> { mediaService.findVideoNamesByVideoSequenceName(newValue) .thenAccept(vs -> Platform.runLater(() -> { getVideoListView().setItems(FXCollections.observableArrayList(vs)); if (vs.size() == 1) { getVideoListView().getSelectionModel().select(0); } })); }); videoSequenceListView.getSelectionModel() .selectedItemProperty() .addListener(obs -> getVideoListView().setItems(FXCollections.emptyObservableList())); } return videoSequenceListView; }
@Test void testOpenGffFile() throws IOException, ExecutionException, InterruptedException { final File file = new File("src/test/resources/gff/simple.gff"); final CompletableFuture<Object> future = new CompletableFuture<>(); Platform.runLater(() -> { try { graphStore.loadGffFile(file, ProgressUpdater.DUMMY); } catch (final IOException e) { e.printStackTrace(); } Platform.runLater(() -> { assertThat(graphStore.getGffFileProperty().get()).isNotNull(); future.complete(null); }); }); assertThat(future.get()).isNull(); Files.deleteIfExists(Paths.get(file.getPath() + FileDatabaseDriver.DB_FILE_EXTENSION)); }
@Override @SuppressWarnings("InfiniteLoopStatement") public void run() { while (true) { Platform.runLater(() -> { calendarView.setToday(LocalDate.now()); calendarView.setTime(LocalTime.now()); }); try { sleep(TEN_SECONDS); } catch (InterruptedException e) { // Do nothing } } }
@Test public void scrollToCell() throws Throwable { Stage primaryStage = getPrimaryStage(); primaryStage.setWidth(250); primaryStage.setHeight(250); TableView<?> tableViewNode = (TableView<?>) primaryStage.getScene().getRoot().lookup(".table-view"); Platform.runLater(() -> { tableViewNode.getSelectionModel().setCellSelectionEnabled(true); tableView.marathon_select("{\"cells\":[[\"10\",\"Email\"]]}"); }); new Wait("Waiting for the point to be in viewport") { @Override public boolean until() { return getPoint(tableViewNode, 2, 10) != null; } }; Point2D point = getPoint(tableViewNode, 2, 10); AssertJUnit.assertTrue(tableViewNode.getBoundsInLocal().contains(point)); }
public static void lollipop(double x, double y) { Circle circle = new Circle(x, y, 2); circle.setFill(randomColor()); FrameController.instance.hover.getChildren().add(circle); FadeTransition fadeTransition = new FadeTransition(Duration.millis(500), circle); fadeTransition.setAutoReverse(true); fadeTransition.setCycleCount(2); fadeTransition.setFromValue(0.0); fadeTransition.setToValue(1.0); ScaleTransition scaleTransition = new ScaleTransition(Duration.millis(1000), circle); scaleTransition.setToX(10.0); scaleTransition.setToY(10.0); scaleTransition.setCycleCount(1); ParallelTransition parallelTransition = new ParallelTransition(fadeTransition, scaleTransition); parallelTransition.play(); executorService.schedule(() -> Platform.runLater(() -> FrameController.instance.hover.getChildren().remove(circle)), 1000, TimeUnit.MILLISECONDS); }
@Override public void addListener(InvalidationListener invalidationListener) { synchronized (this) { // If first listener start listening to inner value if (invalidationListeners.isEmpty()) { invalidationListenerObject = (observable) -> { Platform.runLater(() -> { synchronized (this) { for (InvalidationListener listener : invalidationListeners) { listener.invalidated(this); } } }); }; inner.addListener(invalidationListenerObject); } invalidationListeners.add(invalidationListener); } }
@Test public void testVehiclePresenter() throws Exception { FXMLSampleApp sampleApp = new FXMLSampleApp("vehiclePresenter"); sampleApp.showAndOpen(); VehiclePresenter vehiclePresenter = sampleApp.fxml.loadPresenter("vehicle", Vehicle.class, exceptionHandler); assertNotNull(vehiclePresenter); Platform.runLater(() -> { try { vehiclePresenter.show(Vehicle.getInstance()); } catch (Exception e) { ErrorHandler.handle(e); fail("there should be no exception"); } }); Thread.sleep(SHOW_TIME); sampleApp.close(); }
@Test public void loadFX() throws Exception { final CountDownLatch cdl = new CountDownLatch(1); final CountDownLatch done = new CountDownLatch(1); final JFXPanel p = new JFXPanel(); Platform.runLater(new Runnable() { @Override public void run() { Node wv = TestPages.getFX(10, cdl); Scene s = new Scene(new Group(wv)); p.setScene(s); done.countDown(); } }); done.await(); JFrame f = new JFrame(); f.getContentPane().add(p); f.pack(); f.setVisible(true); cdl.await(); }
public static void runAndWait(Runnable runnable) { CompletableFuture<Void> future = new CompletableFuture<>(); Platform.runLater(() -> { try { runnable.run(); } catch (Throwable t) { future.completeExceptionally(t); return; } future.complete(null); }); try { future.get(); } catch (InterruptedException | ExecutionException e) { throw new RuntimeException(e); } }
protected void updateValues() { if (playTime != null && timeSlider != null && volumeSlider != null) { Platform.runLater(() -> { MediaPlayer mp = getMediaPlayer(); Duration currentTime = mp.getCurrentTime(); playTime.setText(formatTime(currentTime, duration)); timeSlider.setDisable(duration.isUnknown()); if (!timeSlider.isDisabled() && duration.greaterThan(Duration.ZERO) && !timeSlider.isValueChanging()) { timeSlider.setValue(currentTime.divide(duration).toMillis() * 100.0); } if (!volumeSlider.isValueChanging()) { volumeSlider.setValue((int) Math.round(mp.getVolume() * 100)); } }); } }
@Override public void start(Stage primaryStage) { this.primaryStage = primaryStage; MainViewController mainController = new MainViewController(); initStartView(); /*Thread CardGameThread = new Thread(CardGame.instance); CardGameThread.start(); socketClient = new GUISocket(CardGame.instance.getSocketServer());*/ primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() { @Override public void handle(WindowEvent t) { Platform.exit(); System.exit(0); } }); }
@Test public void getText() { Button button = (Button) getPrimaryStage().getScene().getRoot().lookup(".button"); LoggingRecorder lr = new LoggingRecorder(); List<String> text = new ArrayList<>(); Platform.runLater(new Runnable() { @Override public void run() { RFXButtonBase rfxButtonBase = new RFXButtonBase(button, null, null, lr); Point2D sceneXY = button.localToScene(new Point2D(3, 3)); PickResult pickResult = new PickResult(button, sceneXY.getX(), sceneXY.getY()); Point2D screenXY = button.localToScreen(new Point2D(3, 3)); MouseEvent me = new MouseEvent(button, button, MouseEvent.MOUSE_PRESSED, 3, 3, sceneXY.getX(), screenXY.getY(), MouseButton.PRIMARY, 1, false, false, false, false, true, false, false, false, false, false, pickResult); rfxButtonBase.mouseButton1Pressed(me); text.add(rfxButtonBase.getAttribute("text")); } }); new Wait("Waiting for button text.") { @Override public boolean until() { return text.size() > 0; } }; AssertJUnit.assertEquals("Color", text.get(0)); }
protected void apply() { Media media = toolBox.getData().getMedia(); List<Annotation> selected = new ArrayList<>(toolBox.getData().getSelectedAnnotations()); decorator.findReferenceNumberAssociations(media, associationKey) .thenAccept(as -> { List<String> refNums = associationToIdentityRefs(as); Platform.runLater(() -> { ChoiceDialog<String> dlg = getDialog(); dlg.getItems().clear(); if (!refNums.isEmpty()) { dlg.getItems().addAll(refNums); dlg.setSelectedItem(refNums.iterator().next()); Optional<String> integer = dlg.showAndWait(); integer.ifPresent(i -> { Association a = new Association(associationKey, Association.VALUE_SELF, i); toolBox.getEventBus() .send(new CreateAssociationsCmd(a, selected)); }); } }); }); }
@Test public void selectOptionWithQuotes() { @SuppressWarnings("unchecked") ChoiceBox<String> choiceBox = (ChoiceBox<String>) getPrimaryStage().getScene().getRoot().lookup(".choice-box"); LoggingRecorder lr = new LoggingRecorder(); Platform.runLater(() -> { RFXChoiceBox rfxChoiceBox = new RFXChoiceBox(choiceBox, null, null, lr); choiceBox.getItems().add(" \"Mouse \" "); choiceBox.getSelectionModel().select(" \"Mouse \" "); rfxChoiceBox.focusLost(null); }); List<Recording> recordings = lr.waitAndGetRecordings(1); Recording recording = recordings.get(0); AssertJUnit.assertEquals("recordSelect", recording.getCall()); AssertJUnit.assertEquals(" \"Mouse \" ", recording.getParameters()[0]); }