ConfigItem: remove logic from UI, improve UI
[fanfix.git] / src / be / nikiroo / utils / resources / Meta.java
1 package be.nikiroo.utils.resources;
2
3 import java.lang.annotation.ElementType;
4 import java.lang.annotation.Retention;
5 import java.lang.annotation.RetentionPolicy;
6 import java.lang.annotation.Target;
7
8 /**
9 * Annotation used to give some information about the translation keys, so the
10 * translation .properties file can be created programmatically.
11 *
12 * @author niki
13 */
14 @Retention(RetentionPolicy.RUNTIME)
15 @Target(ElementType.FIELD)
16 public @interface Meta {
17 /**
18 * The format of an item (the values it is expected to be of).
19 * <p>
20 * Note that the INI file can contain arbitrary data, but it is expected to
21 * be valid.
22 *
23 * @author niki
24 */
25 public enum Format {
26 /** An integer value, can be negative. */
27 INT,
28 /** true or false. */
29 BOOLEAN,
30 /** Any text String. */
31 STRING,
32 /** A password field. */
33 PASSWORD,
34 /** A colour (either by name or #rrggbb or #aarrggbb). */
35 COLOR,
36 /** A locale code (e.g., fr-BE, en-GB, es...). */
37 LOCALE,
38 /** A path to a file. */
39 FILE,
40 /** A path to a directory. */
41 DIRECTORY,
42 /** A fixed list of values (see {@link Meta#list()} for the values). */
43 FIXED_LIST,
44 /**
45 * A fixed list of values (see {@link Meta#list()} for the values) OR a
46 * custom String value (basically, a {@link Format#FIXED_LIST} with an
47 * option to enter a not accounted for value).
48 */
49 COMBO_LIST,
50 /**
51 * A list of {@link Format#STRING}s.
52 * <p>
53 * The list items are separated by a comma, each surrounded by
54 * double-quotes, with backslashes and double-quotes escaped by a
55 * backslash.
56 * <p>
57 * Example: <tt>"un", "deux"</tt>
58 */
59 LIST_OF_STRINGS,
60 }
61
62 /**
63 * A description of this item (what it is or does, how to explain that item
64 * to the user).
65 *
66 * @return what it is
67 */
68 String description() default "";
69
70 /**
71 * This item is only used as a group, not as an option.
72 * <p>
73 * For instance, you could have LANGUAGE_CODE as a group for which you won't
74 * use the value in the program, and LANGUAGE_CODE_FR, LANGUAGE_CODE_EN
75 * inside for which the value must be set.
76 *
77 * @return TRUE if it is a group
78 */
79 boolean group() default false;
80
81 /**
82 * What format should/must this key be in.
83 *
84 * @return the format it is in
85 */
86 Format format() default Format.STRING;
87
88 /**
89 * The list of fixed values this item can be (either for
90 * {@link Format#FIXED_LIST} or {@link Format#COMBO_LIST}).
91 *
92 * @return the list of values
93 */
94 String[] list() default {};
95
96 /**
97 * This item can be left unspecified.
98 *
99 * @return TRUE if it can
100 */
101 boolean nullable() default true;
102
103 /**
104 * The default value of this item.
105 *
106 * @return the value
107 */
108 String def() default "";
109
110 /**
111 * This item is a comma-separated list of values instead of a single value.
112 *
113 * @return TRUE if it is
114 */
115 boolean array() default false;
116
117 /**
118 * An addition to the format.
119 * <p>
120 * Free info text to help translate, for instance the parameters order and
121 * type for String translations (i.e., %s = input file name, %d = file size
122 * in MB).
123 *
124 * @return some info
125 */
126 String info() default "";
127 }