Configure shortcut keys
There's a lot of duplicated code inside createMenuBarAndToolBar() that can be refactored:
Messages.get
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.
Sure, using static imports and additional helper function can make the code shorter. I'll have a look...
Moving the shortcut keys to messages.properties makes them only localizable, but not configurable (by the user) because this file is in the JAR and not changeable by the user.
Moving the shortcut keys to messages.properties makes them only localizable, but not configurable (by the user) because this file is in the JAR and not changeable by the user.
Right, of course. Perhaps they can move into the preferences?
Yes, a 'Shortcut Keys' tab in the Options dialog would be nice.