/* ========================
* JSynoptic : a free Synoptic editor
* ========================
*
* Project Info: http://jsynoptic.sourceforge.net/index.html
*
* This program is free software; you can redistribute it and/or modify it under the terms
* of the GNU Lesser General Public License as published by the Free Software Foundation;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License along with this
* program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
* Boston, MA 02111-1307, USA.
*
* (C) Copyright 2001-2005, by :
* Corporate:
* EADS Astrium SAS
* EADS CRC
* Individual:
* Claude Cazenave
*
* $Id: HelpFinder.java,v 1.1 2006/08/31 14:40:20 ogor Exp $
*
* Changes
* -------
* 5 juil. 2006 : Initial public release (CC);
*
*/
package simtools.ui;
import java.util.ResourceBundle;
/**
* This class avoid to duplicate the same code over and over in all localized files.
* It works by looking for a help class after the class name passed as argument.
* Example: "MyPackage.MyClass" => "MyPackage.help.MyClassHelp"
* It then tries to load help files (html files for instance).
* Either it fails => program stops with an error message
* It succeed => return value never null
*
* @author zxpletran007
* @version 1.6 2006
*
*/
public class HelpFinder {
static public ResourceBundle get(Class c) {
if (c==null) {
System.err.println("Can't load null resources.");
System.exit(0);
}
StringBuffer sb = new StringBuffer(c.getName());
sb.insert(sb.lastIndexOf("."),".help");
sb.append("Help");
try {
ResourceBundle rb = ResourceBundle.getBundle(sb.toString(),CustomizedLocale.get());
return rb;
} catch (Exception e) {
System.err.println("Can't load help resource : "+ sb.toString());
System.exit(0);
}
// Never reached
return null;
}
static public HelpBundle getMenu(Class c) {
return (HelpBundle)get(c);
}
}