p2izing the editor
[taxeditor.git] / eclipseprojects / eu.etaxonomy.taxeditor / src / eu / etaxonomy / taxeditor / actions / name / Messages.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.taxeditor.actions.name;
10
11 import java.util.Locale;
12 import java.util.MissingResourceException;
13 import java.util.ResourceBundle;
14
15 import org.apache.log4j.Logger;
16
17 import eu.etaxonomy.cdm.model.name.BotanicalName;
18 import eu.etaxonomy.cdm.model.name.TaxonNameBase;
19 import eu.etaxonomy.cdm.model.name.ZoologicalName;
20 import eu.etaxonomy.taxeditor.ITaxEditorConstants;
21 import eu.etaxonomy.taxeditor.controller.PreferencesController;
22
23 /**
24 * @author p.ciardelli
25 * @created 09.10.2008
26 * @version 1.0
27 */
28 public class Messages {
29 private static final Logger logger = Logger.getLogger(Messages.class);
30 private static final String BUNDLE_NAME = "eu.etaxonomy.taxeditor.actions.name.messages"; //$NON-NLS-1$
31
32 private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle
33 .getBundle(BUNDLE_NAME, Locale.getDefault());
34
35 private Messages() {
36 }
37
38 public static String getString(String key) {
39 try {
40 return RESOURCE_BUNDLE.getString(PreferencesController.concatCodeMessageSuffix(key));
41 } catch (MissingResourceException e1) {
42 try {
43 return RESOURCE_BUNDLE.getString(key);
44 } catch (MissingResourceException e2) {
45 return '!' + key + '!';
46 }
47 }
48 }
49
50 public static String getString(String key, TaxonNameBase name) {
51 if (name instanceof BotanicalName) {
52 key += "." + ITaxEditorConstants.CODE_PREFERENCE_ICBN;
53 } else if (name instanceof ZoologicalName) {
54 key += "." + ITaxEditorConstants.CODE_PREFERENCE_ICZN;
55 } else {
56 getString(key);
57 }
58 try {
59 return RESOURCE_BUNDLE.getString(key);
60 } catch (MissingResourceException e2) {
61 return '!' + key + '!';
62 }
63 }
64 }