Commit | Line | Data |
---|---|---|
f06c8100 NR |
1 | package be.nikiroo.jvcard.resources; |
2 | ||
3 | import java.io.IOException; | |
4 | import java.io.Writer; | |
5 | import java.util.MissingResourceException; | |
6 | import java.util.ResourceBundle; | |
7 | ||
8 | import be.nikiroo.utils.resources.Bundle; | |
9 | ||
10 | /** | |
11 | * All colour information must come from here. | |
12 | * <p> | |
13 | * TODO: delete this class, and think about a better way to get BG/FG colours... | |
14 | * | |
15 | * @author niki | |
16 | */ | |
17 | public class ColorBundle extends Bundle<ColorOption> { | |
18 | public ColorBundle() { | |
19 | super(ColorOption.class, Target.colors, null); | |
20 | } | |
21 | ||
22 | @Override | |
23 | protected void writeHeader(Writer writer) throws IOException { | |
24 | ColorOption.writeHeader(writer); | |
25 | } | |
26 | ||
27 | @Override | |
28 | protected void writeValue(Writer writer, ColorOption id) throws IOException { | |
29 | String name = id.name() + "_FG"; | |
30 | String value = ""; | |
31 | if (containsKey(name)) | |
32 | value = getString(name).trim(); | |
33 | ||
34 | writeValue(writer, name, value); | |
35 | ||
36 | name = id.name() + "_BG"; | |
37 | value = ""; | |
38 | if (containsKey(name)) | |
39 | value = getString(name).trim(); | |
40 | ||
41 | writeValue(writer, name, value); | |
42 | } | |
43 | ||
44 | @Override | |
45 | protected void resetMap(ResourceBundle bundle) { | |
46 | // this.map.clear(); | |
47 | ||
48 | if (bundle != null) { | |
49 | for (ColorOption field : type.getEnumConstants()) { | |
50 | try { | |
51 | // String value = bundle.getString(field.name()); | |
52 | // this.map.put(field.name(), value == null ? null : | |
53 | // value.trim()); | |
54 | setString(field.name() + "_FG", | |
55 | bundle.getString(field.name() + "_FG")); | |
56 | setString(field.name() + "_BG", | |
57 | bundle.getString(field.name() + "_BG")); | |
58 | } catch (MissingResourceException e) { | |
59 | } | |
60 | } | |
61 | } | |
62 | } | |
63 | ||
64 | @Override | |
65 | public String getStringX(ColorOption id, String suffix) { | |
66 | String key = id.name() | |
67 | + (suffix == null ? "" : "_" + suffix.toUpperCase()); | |
68 | ||
69 | return getString(key); | |
70 | } | |
71 | } |