@FXML public void HandleSaveButtonAction(ActionEvent event) { extract.setMarkdown(SourceText.getText()); extract.save(); tab.setText(extract.getTitle()); this.isSaved = true; SourceText.requestFocus(); }
public void setMdBox(MdTextController mdBox, Textual extract, Tab tab) throws IOException { this.mainApp = mdBox.getMainApp(); this.config = mainApp.getConfig(); this.mdBox = mdBox; this.tab = tab; this.extract = extract; FXMLLoader loader = new FXMLLoader(); loader.setLocation(MainApp.class.getResource("fxml/Editor.fxml")); loader.load(); if (mainApp.getConfig().getEditorToolbarView().equals("no")) { BoxEditor.setTop(null); BoxRender.setTop(null); } SourceText.setFont(new Font(config.getEditorFont(), config.getEditorFontsize())); SourceText.setStyle("-fx-font-family: \"" + config.getEditorFont() + "\";"); SourceText.replaceText(extract.getMarkdown()); SourceText.textProperty() .addListener( (observableValue, s, s2) -> { tab.setText("! " + extract.getTitle()); this.isSaved = false; SourceText.getUndoManager().mark(); updateRender(); }); updateRender(); tab.getContent() .getScene() .getAccelerators() .put(new KeyCodeCombination(S, SHORTCUT_DOWN), () -> HandleSaveButtonAction(null)); tab.getContent() .getScene() .getAccelerators() .put(new KeyCodeCombination(G, SHORTCUT_DOWN), () -> HandleBoldButtonAction(null)); tab.getContent() .getScene() .getAccelerators() .put(new KeyCodeCombination(I, SHORTCUT_DOWN), () -> HandleItalicButtonAction(null)); tab.getContent() .getScene() .getAccelerators() .put(new KeyCodeCombination(B, SHORTCUT_DOWN), () -> HandleBarredButtonAction(null)); tab.getContent() .getScene() .getAccelerators() .put(new KeyCodeCombination(K, SHORTCUT_DOWN), () -> HandleTouchButtonAction(null)); tab.getContent() .getScene() .getAccelerators() .put(new KeyCodeCombination(PLUS, SHORTCUT_DOWN), () -> HandleExpButtonAction(null)); tab.getContent() .getScene() .getAccelerators() .put(new KeyCodeCombination(EQUALS, SHORTCUT_DOWN), () -> HandleIndButtonAction(null)); tab.getContent() .getScene() .getAccelerators() .put(new KeyCodeCombination(E, SHORTCUT_DOWN), () -> HandleCenterButtonAction(null)); tab.getContent() .getScene() .getAccelerators() .put( new KeyCodeCombination(D, SHORTCUT_DOWN, SHIFT_DOWN), () -> HandleRightButtonAction(null)); tab.getContent() .getScene() .getAccelerators() .put(new KeyCodeCombination(SPACE, SHORTCUT_DOWN), () -> HandleUnbreakableAction(null)); tab.getContent() .getScene() .getAccelerators() .put(new KeyCodeCombination(L, SHORTCUT_DOWN), this::HandleGoToLineAction); tab.getContent() .getScene() .getAccelerators() .put(new KeyCodeCombination(F, SHORTCUT_DOWN), this::HandleFindReplaceDialog); tab.getContent() .getScene() .getAccelerators() .put(new KeyCodeCombination(A, SHORTCUT_DOWN), () -> SourceText.selectAll()); SourceText.requestFocus(); }