annotate src/uk/ac/qmul/eecs/depic/daw/gui/actions/MenuAction.java @ 4:473da40f3d39 tip

added html formatting to Daw/package-info.java
author Fiore Martin <f.martin@qmul.ac.uk>
date Thu, 25 Feb 2016 17:50:09 +0000
parents c0412c81d274
children
rev   line source
f@0 1 /*
f@0 2 Cross-Modal DAW Prototype - Prototype of a simple Cross-Modal Digital Audio Workstation.
f@0 3
f@0 4 Copyright (C) 2015 Queen Mary University of London (http://depic.eecs.qmul.ac.uk/)
f@0 5
f@0 6 This program is free software: you can redistribute it and/or modify
f@0 7 it under the terms of the GNU General Public License as published by
f@0 8 the Free Software Foundation, either version 3 of the License, or
f@0 9 (at your option) any later version.
f@0 10
f@0 11 This program is distributed in the hope that it will be useful,
f@0 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
f@0 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f@0 14 GNU General Public License for more details.
f@0 15
f@0 16 You should have received a copy of the GNU General Public License
f@0 17 along with this program. If not, see <http://www.gnu.org/licenses/>.
f@0 18 */
f@0 19 package uk.ac.qmul.eecs.depic.daw.gui.actions;
f@0 20
f@0 21 import java.awt.event.KeyEvent;
f@0 22 import java.util.MissingResourceException;
f@0 23 import java.util.ResourceBundle;
f@0 24
f@0 25 import javax.swing.AbstractAction;
f@0 26 import javax.swing.KeyStroke;
f@0 27
f@2 28 /**
f@2 29 *
f@2 30 * Actions that are associated with the menu ( also Edit actions are in the menu though)
f@2 31 *
f@2 32 */
f@0 33 abstract class MenuAction extends AbstractAction {
f@0 34 private static final long serialVersionUID = 1L;
f@0 35
f@0 36 public MenuAction(String resourceName){
f@0 37 ResourceBundle bundle = ResourceBundle.getBundle(MenuAction.class.getName());
f@0 38 /* set the menu label */
f@0 39 String name = bundle.getString(resourceName+".text");
f@0 40 putValue(AbstractAction.NAME,name);
f@0 41 /* try and set the accelerator and mnemonic */
f@0 42 try{
f@0 43 String accelerator = bundle.getString(resourceName+".accelerator");
f@0 44 putValue(AbstractAction.ACCELERATOR_KEY, KeyStroke.getKeyStroke(accelerator));
f@0 45 }catch(MissingResourceException mre){
f@0 46 // do nothing, accelerator just won't be set
f@0 47 }
f@0 48
f@0 49 try{
f@0 50 String mnemonic = bundle.getString(resourceName+".mnemonic");
f@0 51 putValue(AbstractAction.MNEMONIC_KEY,KeyEvent.getExtendedKeyCodeForChar(mnemonic.charAt(0)));
f@0 52 }catch(MissingResourceException mre){
f@0 53 // do nothing, mnmonic just won't be set
f@0 54 }
f@0 55 }
f@0 56
f@0 57 public void setText(String resourceName){
f@0 58 ResourceBundle bundle = ResourceBundle.getBundle(MenuAction.class.getName());
f@0 59 String name = bundle.getString(resourceName+".text");
f@0 60 putValue(AbstractAction.NAME,name);
f@0 61 }
f@0 62
f@0 63 }