public void savePreferences() { saveMacros(); MacroPrefs prefs = new MacroPrefs(); StandardAction a = (StandardAction) app.getAction(NEW_MACRO_ACTION); prefs.newMacroAccelerator = a.getAccelerator(); a = (StandardAction) app.getAction(EDIT_MACROS_ACTION); prefs.editMacrosAccelerator = a.getAccelerator(); File prefsFile = getPrefsFile(); try { prefs.save(prefsFile); } catch (IOException ioe) { app.displayException(ioe); } }
/** * Constructor. * * @param app The parent RText application. */ public MacroPlugin(AbstractPluggableGUIApplication app) { URL url = getClass().getResource("cog.png"); if (url != null) { // Should always be true try { icon = new ImageIcon(ImageIO.read(url)); } catch (IOException ioe) { app.displayException(ioe); } } MacroPrefs prefs = loadPrefs(); RText rtext = (RText) app; this.app = rtext; StandardAction a = new NewMacroAction(this, rtext, msg); a.setAccelerator(prefs.newMacroAccelerator); rtext.addAction(NEW_MACRO_ACTION, a); a = new EditMacrosAction(rtext, msg); a.setAccelerator(prefs.editMacrosAccelerator); rtext.addAction(EDIT_MACROS_ACTION, a); }