There's a lot of duplicated code inside createMenuBarAndToolBar() that can be refactored:
Can be:
import static Messages.get;
//...
get
The reference to MainWindow. should be abstracted. For example:
Action fileNewAction = new Action(Messages.get("MainWindow.fileNewAction"), "Shortcut+N", FILE_ALT, e -> fileNew());
can become:
Action fileNewAction = createAction("fileNewAction"), FILE_ALT, e -> fileNew());
Similarly:
Action insertBlockquoteAction = createAction("insertBlockquoteAction", QUOTE_LEFT, e -> getActiveEditor().surroundSelection("\n\n> "), activeFileEditorIsNull);
Once these simplifications are made, the "createAction" method can use a configuration property value to look up the associated shortcut value. For example:
keyboard.modifier.separator=+
keyboard.shortcut=Shortcut${keyboard.modifier.separator}
keyboard.ctrl=Ctrl${keyboard.modifier.separator}
keyboard.action.fileNewAction=${keyboard.shortcut}n
keyboard.action.insertBlockquoteAction=${keyboard.ctrl}q
Note also that Ctrl+q should be distinguishable from Ctrl+Q, which could be a short-hand for Ctrl+Shift+q.
There's a lot of duplicated code inside
createMenuBarAndToolBar()that can be refactored:Can be:
The reference to
MainWindow.should be abstracted. For example:can become:
Similarly:
Once these simplifications are made, the "createAction" method can use a configuration property value to look up the associated shortcut value. For example:
Note also that
Ctrl+qshould be distinguishable fromCtrl+Q, which could be a short-hand forCtrl+Shift+q.