public Callback<PromptData, String> createPromptHandler() { return promptData -> { PromptHandler promptHandler = new PromptHandler( promptData.getMessage(), promptData.getDefaultValue(), event -> { webView.setDisable(false); removeViewOverlay(); }, event -> { webView.setDisable(false); removeViewOverlay(); } ); overlayView(promptHandler); // todo block until the user confirms or denies the action. return promptData.getDefaultValue(); }; }
public void initEditor(WebView editor, File sourceFile, boolean isBlank) { this.editor = editor; targetFile = sourceFile; if (targetFile != null) { filename = targetFile.getName(); } editor.getEngine().getLoadWorker().stateProperty().addListener( (value, old, newState) -> { if (newState == Worker.State.SUCCEEDED) { JSObject document = (JSObject) editor.getEngine().executeScript("window"); document.setMember("java", this); Platform.runLater(()->createEditor(isBlank)); } }); editor.getEngine().setPromptHandler((PromptData prompt) -> { TextInputDialog dialog = new TextInputDialog(prompt.getDefaultValue()); dialog.setTitle("Jace IDE"); dialog.setHeaderText("Respond and press OK, or Cancel to abort"); dialog.setContentText(prompt.getMessage()); return dialog.showAndWait().orElse(null); }); editor.getEngine().load(getClass().getResource(CODEMIRROR_EDITOR).toExternalForm()); }
/** * JavaScriptのprompt()のハンドラ * * @return */ private Callback<PromptData, String> createPromptHandler() { return new Callback<PromptData, String>() { @Override public String call(PromptData promptData) { final String message = promptData.getMessage(); final String[] ret = new String[1]; try { SwingUtilities.invokeAndWait(new Runnable() { @Override public void run() { ret[0] = JOptionPane.showInputDialog(EmbeddedServerBrowserFrame.this, message); } }); return ret[0]; } catch (Exception ex) { logger.log(Level.SEVERE, ex.toString(), ex); } return promptData.getDefaultValue(); } }; }
public String call(PromptData p) { defaultText = p.getDefaultValue(); messageReceived = p.getMessage(); promptCalled = true; return "response"; }
@Override public String call(PromptData param) { return handler.handle(new PromptDialogEvent(param.getMessage(), param.getDefaultValue())); }