List of usage examples for javafx.fxml FXMLLoader getNamespace
public ObservableMap<String, Object> getNamespace()
From source file:net.sourceforge.pmd.util.fxdesigner.XPathPanelController.java
private void initGenerateXPathFromStackTrace() { ContextMenu menu = new ContextMenu(); MenuItem item = new MenuItem("Generate from stack trace..."); item.setOnAction(e -> {//from www .java2 s . c om try { Stage popup = new Stage(); FXMLLoader loader = new FXMLLoader(DesignerUtil.getFxml("generate-xpath-from-stack-trace.fxml")); Parent root = loader.load(); Button button = (Button) loader.getNamespace().get("generateButton"); TextArea area = (TextArea) loader.getNamespace().get("stackTraceArea"); ValidationSupport validation = new ValidationSupport(); validation.registerValidator(area, Validator.createEmptyValidator("The stack trace may not be empty")); button.disableProperty().bind(validation.invalidProperty()); button.setOnAction(f -> { DesignerUtil.stackTraceToXPath(area.getText()).ifPresent(xpathExpressionArea::replaceText); popup.close(); }); popup.setScene(new Scene(root)); popup.initStyle(StageStyle.UTILITY); popup.initModality(Modality.WINDOW_MODAL); popup.initOwner(designerRoot.getMainStage()); popup.show(); } catch (IOException e1) { throw new RuntimeException(e1); } }); menu.getItems().add(item); xpathExpressionArea.addEventHandler(MouseEvent.MOUSE_CLICKED, t -> { if (t.getButton() == MouseButton.SECONDARY) { menu.show(xpathExpressionArea, t.getScreenX(), t.getScreenY()); } }); }