(WebView editor, File sourceFile, boolean isBlank)
| 108 | } |
| 109 | |
| 110 | public void initEditor(WebView editor, File sourceFile, boolean isBlank) { |
| 111 | this.editor = editor; |
| 112 | targetFile = sourceFile; |
| 113 | if (targetFile != null) { |
| 114 | filename = targetFile.getName(); |
| 115 | } |
| 116 | |
| 117 | editor.getEngine().getLoadWorker().stateProperty().addListener( |
| 118 | (value, old, newState) -> { |
| 119 | if (newState == Worker.State.SUCCEEDED) { |
| 120 | JSObject document = (JSObject) editor.getEngine().executeScript("window"); |
| 121 | document.setMember("java", this); |
| 122 | Platform.runLater(()->createEditor(isBlank)); |
| 123 | } |
| 124 | }); |
| 125 | |
| 126 | editor.getEngine().setPromptHandler((PromptData prompt) -> { |
| 127 | TextInputDialog dialog = new TextInputDialog(prompt.getDefaultValue()); |
| 128 | dialog.setTitle("Jace IDE"); |
| 129 | dialog.setHeaderText("Respond and press OK, or Cancel to abort"); |
| 130 | dialog.setContentText(prompt.getMessage()); |
| 131 | return dialog.showAndWait().orElse(null); |
| 132 | }); |
| 133 | |
| 134 | editor.getEngine().load(getClass().getResource(CODEMIRROR_EDITOR).toExternalForm()); |
| 135 | } |
| 136 | |
| 137 | public void createEditor(boolean isBlank) { |
| 138 | String document = targetFile == null ? isBlank ? "" : getHandler().getNewDocumentContent() : getFileContents(targetFile); |
no test coverage detected