MCPcopy Index your code
hub / github.com/badvision/jace / initEditor

Method initEditor

src/main/java/jace/ide/Program.java:110–135  ·  view source on GitHub ↗
(WebView editor, File sourceFile, boolean isBlank)

Source from the content-addressed store, hash-verified

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);

Callers 1

createTabMethod · 0.95

Calls 3

createEditorMethod · 0.95
getNameMethod · 0.65
addListenerMethod · 0.45

Tested by

no test coverage detected