f@0: /* f@0: Cross-Modal DAW Prototype - Prototype of a simple Cross-Modal Digital Audio Workstation. f@0: f@0: Copyright (C) 2015 Queen Mary University of London (http://depic.eecs.qmul.ac.uk/) f@0: f@0: This program is free software: you can redistribute it and/or modify f@0: it under the terms of the GNU General Public License as published by f@0: the Free Software Foundation, either version 3 of the License, or f@0: (at your option) any later version. f@0: f@0: This program is distributed in the hope that it will be useful, f@0: but WITHOUT ANY WARRANTY; without even the implied warranty of f@0: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the f@0: GNU General Public License for more details. f@0: f@0: You should have received a copy of the GNU General Public License f@0: along with this program. If not, see . f@0: */ f@0: package uk.ac.qmul.eecs.depic.daw.gui.actions; f@0: f@0: import java.awt.event.KeyEvent; f@0: import java.util.MissingResourceException; f@0: import java.util.ResourceBundle; f@0: f@0: import javax.swing.AbstractAction; f@0: import javax.swing.KeyStroke; f@0: f@2: /** f@2: * f@2: * Actions that are associated with the menu ( also Edit actions are in the menu though) f@2: * f@2: */ f@0: abstract class MenuAction extends AbstractAction { f@0: private static final long serialVersionUID = 1L; f@0: f@0: public MenuAction(String resourceName){ f@0: ResourceBundle bundle = ResourceBundle.getBundle(MenuAction.class.getName()); f@0: /* set the menu label */ f@0: String name = bundle.getString(resourceName+".text"); f@0: putValue(AbstractAction.NAME,name); f@0: /* try and set the accelerator and mnemonic */ f@0: try{ f@0: String accelerator = bundle.getString(resourceName+".accelerator"); f@0: putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(accelerator)); f@0: }catch(MissingResourceException mre){ f@0: // do nothing, accelerator just won't be set f@0: } f@0: f@0: try{ f@0: String mnemonic = bundle.getString(resourceName+".mnemonic"); f@0: putValue(AbstractAction.MNEMONIC_KEY,KeyEvent.getExtendedKeyCodeForChar(mnemonic.charAt(0))); f@0: }catch(MissingResourceException mre){ f@0: // do nothing, mnmonic just won't be set f@0: } f@0: } f@0: f@0: public void setText(String resourceName){ f@0: ResourceBundle bundle = ResourceBundle.getBundle(MenuAction.class.getName()); f@0: String name = bundle.getString(resourceName+".text"); f@0: putValue(AbstractAction.NAME,name); f@0: } f@0: f@0: }