00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00027 package org.mpcl.nui;
00028
00029 import java.awt.Color;
00030 import java.util.MissingResourceException;
00031 import java.util.ResourceBundle;
00032
00033
00040 public class TResourceSupplier implements IResourceSupplier
00041 {
00042
00044 private static String _kyColorSuffix = ".color";
00045
00047 private static String _kyMnemonicSuffix = ".mnemonic";
00048
00050 private static String _kyTextSuffix = ".text";
00051
00053 private ResourceBundle tResourceBundle;
00054
00055
00056
00057
00058
00059
00064 public TResourceSupplier (ResourceBundle tRESOURCE_BUNDLE)
00065 {
00066 tResourceBundle = tRESOURCE_BUNDLE;
00067 }
00068
00069
00070
00071
00072
00073
00081 protected String getResourceString (final String kyRESOURCE_NAME, final String kySUFFIX)
00082 {
00083 return tResourceBundle.getString (kyRESOURCE_NAME + kySUFFIX);
00084 }
00085
00086
00087
00088
00089
00090
00097 public Color getColor (final String kyRESOURCE_NAME)
00098 {
00099 return Color.decode (getResourceString (kyRESOURCE_NAME, _kyColorSuffix));
00100 }
00101
00108 public String getText (final String kyRESOURCE_NAME)
00109 {
00110 return getResourceString (kyRESOURCE_NAME, _kyTextSuffix);
00111 }
00112
00119 public char getMnemonic (final String kyRESOURCE_NAME)
00120 {
00121 return getResourceString (kyRESOURCE_NAME, _kyMnemonicSuffix).charAt (0);
00122 }
00123
00129 public boolean hasMnemonic (final String kyRESOURCE_NAME)
00130 {
00131 boolean gHasMnemonic = true;
00132
00133 try
00134 {
00135 getResourceString (kyRESOURCE_NAME, _kyMnemonicSuffix);
00136 }
00137 catch (final MissingResourceException ktEXCEPTION)
00138 {
00139 gHasMnemonic = false;
00140 }
00141 return gHasMnemonic;
00142 }
00143
00144 }