X-Git-Url: http://git.nikiroo.be/?p=jvcard.git;a=blobdiff_plain;f=src%2Fbe%2Fnikiroo%2Fjvcard%2Fresources%2FColorBundle.java;fp=src%2Fbe%2Fnikiroo%2Fjvcard%2Fresources%2FColorBundle.java;h=4fcef5edfb60bdc9d546b456cf0c6a925220e787;hp=0000000000000000000000000000000000000000;hb=f06c81000632cfb5f525ca458f719338f55f9f66;hpb=a73a906356c971b080c36368e71a15d87e8b8d31 diff --git a/src/be/nikiroo/jvcard/resources/ColorBundle.java b/src/be/nikiroo/jvcard/resources/ColorBundle.java new file mode 100644 index 0000000..4fcef5e --- /dev/null +++ b/src/be/nikiroo/jvcard/resources/ColorBundle.java @@ -0,0 +1,71 @@ +package be.nikiroo.jvcard.resources; + +import java.io.IOException; +import java.io.Writer; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +import be.nikiroo.utils.resources.Bundle; + +/** + * All colour information must come from here. + *

+ * TODO: delete this class, and think about a better way to get BG/FG colours... + * + * @author niki + */ +public class ColorBundle extends Bundle { + public ColorBundle() { + super(ColorOption.class, Target.colors, null); + } + + @Override + protected void writeHeader(Writer writer) throws IOException { + ColorOption.writeHeader(writer); + } + + @Override + protected void writeValue(Writer writer, ColorOption id) throws IOException { + String name = id.name() + "_FG"; + String value = ""; + if (containsKey(name)) + value = getString(name).trim(); + + writeValue(writer, name, value); + + name = id.name() + "_BG"; + value = ""; + if (containsKey(name)) + value = getString(name).trim(); + + writeValue(writer, name, value); + } + + @Override + protected void resetMap(ResourceBundle bundle) { + // this.map.clear(); + + if (bundle != null) { + for (ColorOption field : type.getEnumConstants()) { + try { + // String value = bundle.getString(field.name()); + // this.map.put(field.name(), value == null ? null : + // value.trim()); + setString(field.name() + "_FG", + bundle.getString(field.name() + "_FG")); + setString(field.name() + "_BG", + bundle.getString(field.name() + "_BG")); + } catch (MissingResourceException e) { + } + } + } + } + + @Override + public String getStringX(ColorOption id, String suffix) { + String key = id.name() + + (suffix == null ? "" : "_" + suffix.toUpperCase()); + + return getString(key); + } +}