1 /*
2 * Metis: Java Data Framework
3 * Copyright 2012-2026. Tony Washer
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not
6 * use this file except in compliance with the License. You may obtain a copy
7 * of the License at
8 *
9 * http://www.apache.org/licenses/LICENSE-2.0
10 *
11 * Unless required by applicable law or agreed to in writing, software
12 * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14 * License for the specific language governing permissions and limitations under
15 * the License.
16 */
17 package io.github.tonywasher.joceanus.metis.preference;
18
19 import io.github.tonywasher.joceanus.metis.data.MetisDataResource;
20 import io.github.tonywasher.joceanus.oceanus.resource.OceanusBundleId;
21 import io.github.tonywasher.joceanus.oceanus.resource.OceanusBundleLoader;
22
23 import java.util.ResourceBundle;
24
25 /**
26 * Resource IDs for JMetis preferences.
27 */
28 public enum MetisPreferenceResource implements OceanusBundleId {
29 /**
30 * Preference type STRING.
31 */
32 TYPE_STRING("type.STRING"),
33
34 /**
35 * Preference type INTEGER.
36 */
37 TYPE_INTEGER("type.INTEGER"),
38
39 /**
40 * Preference type BOOLEAN.
41 */
42 TYPE_BOOLEAN("type.BOOLEAN"),
43
44 /**
45 * Preference type DATE.
46 */
47 TYPE_DATE("type.DATE"),
48
49 /**
50 * Preference type FILE.
51 */
52 TYPE_FILE("type.FILE"),
53
54 /**
55 * Preference type DIRECTORY.
56 */
57 TYPE_DIRECTORY("type.DIRECTORY"),
58
59 /**
60 * Preference type ENUM.
61 */
62 TYPE_ENUM("type.ENUM"),
63
64 /**
65 * Preference type COLOR.
66 */
67 TYPE_COLOR("type.COLOR"),
68
69 /**
70 * OK button text.
71 */
72 UI_BUTTON_OK("ui.button.Ok"),
73
74 /**
75 * Reset button text.
76 */
77 UI_BUTTON_RESET("ui.button.Reset"),
78
79 /**
80 * Save Title text.
81 */
82 UI_TITLE_SAVE("ui.title.Save"),
83
84 /**
85 * Select Title text.
86 */
87 UI_TITLE_SELECT("ui.title.Select"),
88
89 /**
90 * Preferences Title text.
91 */
92 UI_TITLE_PREFERENCES("ui.title.Preferences"),
93
94 /**
95 * Options Title text.
96 */
97 UI_TITLE_OPTIONS("ui.title.Options"),
98
99 /**
100 * Colour Title text.
101 */
102 UI_TITLE_COLOR("ui.title.Color"),
103
104 /**
105 * Colour Prompt text.
106 */
107 UI_PROMPT_COLOR("ui.prompt.Color"),
108
109 /**
110 * PreferenceSet label text.
111 */
112 UI_LABEL_SET("ui.label.Set"),
113
114 /**
115 * Range minimum.
116 */
117 UI_RANGE_MIN("ui.range.Minimum"),
118
119 /**
120 * Range maximum.
121 */
122 UI_RANGE_MAX("ui.range.Maximum"),
123
124 /**
125 * Range error.
126 */
127 UI_RANGE_ERROR("ui.range.Error"),
128
129 /**
130 * Store Error text.
131 */
132 UI_ERROR_STORE("ui.error.Store"),
133
134 /**
135 * Select header text.
136 */
137 UI_HEADER_SELECT("ui.header.Select"),
138
139 /**
140 * SecurityPreference Display Name.
141 */
142 SECPREF_BASEPREFNAME("secpref.baseprefname"),
143
144 /**
145 * SecurityPreference Display Name.
146 */
147 SECPREF_PREFNAME("secpref.prefname"),
148
149 /**
150 * SecurityPreference Factory.
151 */
152 SECPREF_FACTORY("secpref.factory"),
153
154 /**
155 * SecurityPreference keyLength.
156 */
157 SECPREF_KEYLEN("secpref.keylen"),
158
159 /**
160 * SecurityPreference Cipher Steps.
161 */
162 SECPREF_CIPHERSTEPS("secpref.ciphersteps"),
163
164 /**
165 * SecurityPreference Hash Iterations.
166 */
167 SECPREF_ITERATIONS("secpref.hashiterations"),
168
169 /**
170 * SecurityPreference Phrase.
171 */
172 SECPREF_PHRASE("secpref.phrase"),
173
174 /**
175 * SecurityPreference Active KeySets.
176 */
177 SECPREF_KEYSETS("secpref.keysets");
178
179 /**
180 * The Resource Loader.
181 */
182 private static final OceanusBundleLoader LOADER = OceanusBundleLoader.getLoader(MetisDataResource.class.getCanonicalName(),
183 ResourceBundle::getBundle);
184
185 /**
186 * The Id.
187 */
188 private final String theKeyName;
189
190 /**
191 * The Value.
192 */
193 private String theValue;
194
195 /**
196 * Constructor.
197 *
198 * @param pKeyName the key name
199 */
200 MetisPreferenceResource(final String pKeyName) {
201 theKeyName = pKeyName;
202 }
203
204 @Override
205 public String getKeyName() {
206 return theKeyName;
207 }
208
209 @Override
210 public String getNameSpace() {
211 return "Metis.preference";
212 }
213
214 @Override
215 public String getValue() {
216 /* If we have not initialised the value */
217 if (theValue == null) {
218 /* Derive the value */
219 theValue = LOADER.getValue(this);
220 }
221
222 /* return the value */
223 return theValue;
224 }
225 }