Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenwrite.git

MainWindow: inlines Edit and Insert action methods

AuthorKarl Tauber <email>
Date2015-07-30 22:56:56 GMT+0200
Commit6d015d3ace1e5046128526856b81b0cd75c6d30b
Parente21db10
Delta14 lines added, 24 lines removed, 10-line decrease
src/main/java/org/markdownwriterfx/MainWindow.java
import org.fxmisc.wellbehaved.event.EventHandlerHelper;
import org.fxmisc.wellbehaved.event.EventPattern;
+import org.markdownwriterfx.editor.MarkdownEditorPane;
import org.markdownwriterfx.util.Action;
import org.markdownwriterfx.util.ActionUtils;
// Edit actions
- Action editUndoAction = new Action("Undo", "Shortcut+Z", UNDO, e -> editUndo(),
+ Action editUndoAction = new Action("Undo", "Shortcut+Z", UNDO,
+ e -> fileEditorTabPane.getActiveFileEditor().undo(),
createActiveBooleanProperty(FileEditor::canUndoProperty).not());
- Action editRedoAction = new Action("Redo", "Shortcut+Y", REPEAT, e -> editRedo(),
+ Action editRedoAction = new Action("Redo", "Shortcut+Y", REPEAT,
+ e -> fileEditorTabPane.getActiveFileEditor().redo(),
createActiveBooleanProperty(FileEditor::canRedoProperty).not());
// Insert actions
- Action insertBoldAction = new Action("Bold", "Shortcut+B", BOLD, e -> insertBold(), activeFileEditorIsNull);
- Action insertItalicAction = new Action("Italic", "Shortcut+I", ITALIC, e -> insertItalic(), activeFileEditorIsNull);
+ Action insertBoldAction = new Action("Bold", "Shortcut+B", BOLD,
+ e -> getActiveEditor().surroundSelection("**", "**"),
+ activeFileEditorIsNull);
+ Action insertItalicAction = new Action("Italic", "Shortcut+I", ITALIC,
+ e -> getActiveEditor().surroundSelection("*", "*"),
+ activeFileEditorIsNull);
// Help actions
}
+ private MarkdownEditorPane getActiveEditor() {
+ return fileEditorTabPane.getActiveFileEditor().getEditor();
+ }
/**
Window window = scene.getWindow();
Event.fireEvent(window, new WindowEvent(window, WindowEvent.WINDOW_CLOSE_REQUEST));
- }
-
- //---- Edit actions -------------------------------------------------------
-
- private void editUndo() {
- fileEditorTabPane.getActiveFileEditor().undo();
- }
-
- private void editRedo() {
- fileEditorTabPane.getActiveFileEditor().redo();
- }
-
- //---- Insert actions -----------------------------------------------------
-
- private void insertBold() {
- fileEditorTabPane.getActiveFileEditor().getEditor().surroundSelection("**", "**");
- }
-
- private void insertItalic() {
- fileEditorTabPane.getActiveFileEditor().getEditor().surroundSelection("*", "*");
}