001 ///////////////////////////////////////////////// 002 // This file is part of Sears project. 003 // Subtitle Editor And Re-Synch 004 // A tool to easily modify and resynch movies subtitles. 005 ///////////////////////////////////////////////// 006 //This program is free software; 007 //you can redistribute it and/or modify it under the terms 008 //of the GNU General Public License 009 //as published by the Free Software Foundation; 010 //either version 2 of the License, or (at your option) any later version. 011 ///////////////////////////////////////////////// 012 //Sears project is availbale under sourceforge 013 // at adress: http://sourceforge.net/projects/sears/ 014 //Copyright (C) 2005 Booba Skaya 015 //Mail: booba.skaya@gmail.com 016 //////////////////////////////////////////////// 017 package sears.tools; 018 019 import javax.swing.AbstractAction; 020 import javax.swing.ImageIcon; 021 import javax.swing.KeyStroke; 022 import sears.gui.resources.SearsResources; 023 024 /** 025 * Class SearsAction. 026 * <br><b>Summary:</b><br> 027 * This class is an action for Sears. 028 * It is composed by a message, a tool tip and an icon. 029 * Use the resource facility to retrieve infos. 030 */ 031 public abstract class SearsAction extends AbstractAction { 032 /** Default Serial UID*/ 033 private static final long serialVersionUID = 1L; 034 035 public SearsAction(String actionTag) { 036 super(); 037 //Set action name 038 String name = //SearsResourceBundle.getString(actionTag + "Name"); 039 SearsResourceBundle.getResource(actionTag + "Name"); 040 if (name != null) { 041 putValue(NAME, name); 042 } 043 //Set action tool tip/ 044 String tip = //SearsResourceBundle.getString(actionTag + "Tip"); 045 SearsResourceBundle.getResource(actionTag + "Tip"); 046 if (tip != null) { 047 putValue(SHORT_DESCRIPTION, tip); 048 } 049 //Set action icon/ 050 ImageIcon icon= SearsResources.getIcon(actionTag + "Icon"); 051 if (icon != null) { 052 putValue(SMALL_ICON, icon); 053 } 054 //set a shortKey 055 KeyStroke key = SearsResources.getKey(actionTag+"Key"); 056 if(key != null){ 057 putValue(ACCELERATOR_KEY, key); 058 } 059 } 060 }