ref #9739: use common name languages for combo and adapt pref page
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / preference / NameDetailsConfigurator.java
1 /**
2 * Copyright (C) 2016 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
8 */
9 package eu.etaxonomy.taxeditor.preference;
10
11 import java.lang.reflect.Field;
12
13 /**
14 * @author k.luther
15 * @date 16.12.2016
16 *
17 */
18 public class NameDetailsConfigurator {
19
20 boolean isAllowOverride = true;
21
22
23 boolean isTaxonSectionActivated = true;
24 boolean isLSIDActivated = true;
25 boolean isNomenclaturalCodeActived = true;
26 boolean isNameCacheActivated = true;
27 boolean isAppendedPhraseActivated = true;
28 boolean isRankActivated = true;
29 boolean isAtomisedEpithetsActivated = true;
30 boolean isAuthorshipSectionActivated = true;
31 boolean isAuthorCacheActivated = true;
32 boolean isNomenclaturalReferenceSectionActivated = true;
33 boolean isNomenclaturalStatusSectionActivated = true;
34 boolean isNomenclaturalStatusRuleConsideredActivated = true;
35 boolean isNomenclaturalStatusRuleConsideredCodeEditionActivated = true;
36 boolean isTypeDesignationSectionActivated = true;
37 boolean isNameRelationsSectionActivated = true;
38 boolean isNameRelationsRuleConsideredActivated = true;
39 boolean isNameRelationsRuleConsideredCodeEditionActivated = true;
40 boolean isProtologueActivated = true;
41 boolean isHybridActivated = true;
42
43 boolean isNameApprobiationActivated = true;
44 boolean isSecEnabled = true;
45 boolean isSecDetailsActivated = true;
46
47 // public NameDetailsConfigurator(boolean isSimpleDetailsViewActivated){
48 // this.isSimpleDetailsViewActivated = isSimpleDetailsViewActivated;
49 // }
50 //
51 // public boolean isSimpleDetailsViewActivated() {
52 // return isSimpleDetailsViewActivated;
53 // }
54 //
55 // public void setSimpleDetailsViewActivated(boolean isSimpleDetailsViewActivated) {
56 // this.isSimpleDetailsViewActivated = isSimpleDetailsViewActivated;
57 // }
58
59 public boolean isTaxonSectionActivated() {
60 return isTaxonSectionActivated;
61 }
62
63 public void setTaxonSectionActivated(boolean isTaxonSectionActivated) {
64 this.isTaxonSectionActivated = isTaxonSectionActivated;
65 }
66
67 public boolean isLSIDActivated() {
68 return isLSIDActivated;
69 }
70
71 public void setLSIDActivated(boolean isLSIDActivated) {
72 this.isLSIDActivated = isLSIDActivated;
73 }
74
75 public boolean isNomenclaturalCodeActived() {
76 return isNomenclaturalCodeActived;
77 }
78
79 public void setNomenclaturalCodeActived(boolean isNomenclaturalCodeActived) {
80 this.isNomenclaturalCodeActived = isNomenclaturalCodeActived;
81 }
82
83 public boolean isNameCacheActivated() {
84 return isNameCacheActivated;
85 }
86
87 public void setNameCacheActivated(boolean isNameCacheActivated) {
88 this.isNameCacheActivated = isNameCacheActivated;
89 }
90
91 public boolean isAppendedPhraseActivated() {
92 return isAppendedPhraseActivated;
93 }
94
95 public void setAppendedPhraseActivated(boolean isAppendedPhraseActivated) {
96 this.isAppendedPhraseActivated = isAppendedPhraseActivated;
97 }
98
99 public boolean isRankActivated() {
100 return isRankActivated;
101 }
102
103 public void setRankActivated(boolean isRankActivated) {
104 this.isRankActivated = isRankActivated;
105 }
106
107 public boolean isAtomisedEpithetsActivated() {
108 return isAtomisedEpithetsActivated;
109 }
110
111 public void setAtomisedEpithetsActivated(boolean isAtomisedEpithetsActivated) {
112 this.isAtomisedEpithetsActivated = isAtomisedEpithetsActivated;
113 }
114
115 public boolean isAuthorshipSectionActivated() {
116 return isAuthorshipSectionActivated;
117 }
118
119 public void setAuthorshipSectionActivated(boolean isAuthorshipSectionActivated) {
120 this.isAuthorshipSectionActivated = isAuthorshipSectionActivated;
121 }
122
123 public boolean isNomenclaturalReferenceSectionActivated() {
124 return isNomenclaturalReferenceSectionActivated;
125 }
126
127 public void setNomenclaturalReferenceSectionActivated(boolean isNomenclaturalReferenceSectionActivated) {
128 this.isNomenclaturalReferenceSectionActivated = isNomenclaturalReferenceSectionActivated;
129 }
130
131 public boolean isNomenclaturalStatusSectionActivated() {
132 return isNomenclaturalStatusSectionActivated;
133 }
134
135 public void setNomenclaturalStatusSectionActivated(boolean isNomenclaturalStatusSectionActivated) {
136 this.isNomenclaturalStatusSectionActivated = isNomenclaturalStatusSectionActivated;
137 }
138
139 public boolean isTypeDesignationSectionActivated() {
140 return isTypeDesignationSectionActivated;
141 }
142
143 public void setTypeDesignationSectionActivated(boolean isTypeDesignationSectionActivated) {
144 this.isTypeDesignationSectionActivated = isTypeDesignationSectionActivated;
145 }
146
147 public boolean isNameRelationsSectionActivated() {
148 return isNameRelationsSectionActivated;
149 }
150
151 public void setNameRelationsSectionActivated(boolean isNameRelationsSectionActivated) {
152 this.isNameRelationsSectionActivated = isNameRelationsSectionActivated;
153 }
154
155 /**
156 * @return the isProtologueActivated
157 */
158 public boolean isProtologueActivated() {
159 return isProtologueActivated;
160 }
161
162 /**
163 * @param isProtologueActivated the isProtologueActivated to set
164 */
165 public void setProtologueActivated(boolean isProtologueActivated) {
166 this.isProtologueActivated = isProtologueActivated;
167 }
168
169 @Override
170 public String toString(){
171 StringBuffer result = new StringBuffer();
172 //the preference value is build like this:
173 //<section1>:true;<section2>:false....
174 for (Field field: this.getClass().getDeclaredFields()){
175 result.append(field.getName());
176 result.append(":");
177 try {
178 result.append(field.get(this));
179 } catch (IllegalArgumentException | IllegalAccessException e) {
180 // TODO Auto-generated catch block
181 e.printStackTrace();
182 }
183 result.append(";");
184 }
185 // result.append("simpleViewActivated");
186 // result.append(":");
187 // result.append(this.isSimpleDetailsViewActivated);
188 // result.append(";");
189 //
190 // result.append("taxon");
191 // result.append(":");
192 // result.append(this.isTaxonSectionActivated);
193 // result.append(";");
194 // result.append("taxon.SecEnabled");
195 // result.append(":");
196 // result.append(this.isSecEnabled);
197 // result.append(";");
198 // result.append("taxon.SecDetails");
199 // result.append(":");
200 // result.append(this.isSecDetailsActivated);
201 // result.append(";");
202 // result.append("nameCache");
203 // result.append(":");
204 // result.append(this.isNameCacheActivated);
205 // result.append(";");
206 // result.append("lsid");
207 // result.append(":");
208 // result.append(this.isLSIDActivated());
209 // result.append(";");
210 // result.append("nameApproviation");
211 // result.append(":");
212 // result.append(this.isNameApprobiationActivated());
213 // result.append(";");
214 // result.append("nc");
215 // result.append(":");
216 // result.append(this.isNomenclaturalCodeActived());
217 // result.append(";");
218 // result.append("ap");
219 // result.append(":");
220 // result.append(this.isAppendedPhraseActivated());
221 // result.append(";");
222 // result.append("rank");
223 // result.append(":");
224 // result.append(this.isRankActivated());
225 // result.append(";");
226 // result.append("author");
227 // result.append(":");
228 // result.append(this.isAuthorshipSectionActivated());
229 // result.append(";");
230 // result.append("authorCache");
231 // result.append(":");
232 // result.append(this.isAuthorCacheActivated());
233 // result.append(";");
234 // result.append("atomisedEpithets");
235 // result.append(":");
236 // result.append(this.isAtomisedEpithetsActivated());
237 // result.append(";");
238 // result.append("nomRef");
239 // result.append(":");
240 // result.append(this.isNomenclaturalReferenceSectionActivated());
241 // result.append(";");
242 // result.append("nomStat");
243 // result.append(":");
244 // result.append(this.isNomenclaturalStatusSectionActivated());
245 // result.append(";");
246 // result.append("nomStatRuleConsidered");
247 // result.append(":");
248 // result.append(this.isNomenclaturalStatusRuleConsideredActivated);
249 // result.append(";");
250 // result.append("nomStatRuleConsideredCodeEdition");
251 // result.append(":");
252 // result.append(this.isNomenclaturalStatusRuleConsideredCodeEditionActivated);
253 // result.append(";");
254 // result.append("protologue");
255 // result.append(":");
256 // result.append(this.isProtologueActivated());
257 // result.append(";");
258 // result.append("typeDes");
259 // result.append(":");
260 // result.append(this.isTypeDesignationSectionActivated());
261 // result.append(";");
262 // result.append("nameRelation");
263 // result.append(":");
264 // result.append(this.isNameRelationsSectionActivated());
265 // result.append(";");
266 // result.append("nameRelationRuleConsidered");
267 // result.append(":");
268 // result.append(this.isNameRelationsRuleConsideredActivated);
269 // result.append(";");
270 // result.append("nameRelationRuleConsideredCodeEdition");
271 // result.append(":");
272 // result.append(this.isNameRelationsRuleConsideredCodeEditionActivated);
273 // result.append(";");
274 // result.append("hybrid");
275 // result.append(":");
276 // result.append(this.isHybridActivated());
277 result.replace(result.length()-1, result.length(), "");
278 return result.toString();
279 }
280
281
282
283 /**
284 * @return the isAuthorCacheActivated
285 */
286 public boolean isAuthorCacheActivated() {
287 return isAuthorCacheActivated;
288 }
289
290 /**
291 * @param isAuthorCacheActivated the isAuthorCacheActivated to set
292 */
293 public void setAuthorCacheActivated(boolean isAuthorCacheActivated) {
294 this.isAuthorCacheActivated = isAuthorCacheActivated;
295 }
296
297 public boolean isHybridActivated() {
298 return isHybridActivated;
299 }
300
301 public void setHybridActivated(boolean isHybridActivated) {
302 this.isHybridActivated = isHybridActivated;
303 }
304
305 public void setNameApprobiationActivated(boolean isNameApprobiationActivated) {
306 this.isNameApprobiationActivated = isNameApprobiationActivated;
307
308 }
309 public boolean isNameApprobiationActivated() {
310 return isNameApprobiationActivated;
311
312 }
313
314 public boolean isAllowOverride() {
315 return isAllowOverride;
316 }
317
318 public void setAllowOverride(boolean isAllowOverride) {
319 this.isAllowOverride = isAllowOverride;
320 }
321
322 public boolean isSecEnabled() {
323 return isSecEnabled;
324 }
325
326 public void setSecEnabled(boolean isSecEnabled) {
327 this.isSecEnabled = isSecEnabled;
328 }
329
330 public boolean isSecDetailsActivated() {
331 return isSecDetailsActivated;
332 }
333
334 public void setSecDetailsActivated(boolean isSecDetailsActivated) {
335 this.isSecDetailsActivated = isSecDetailsActivated;
336 }
337
338 public boolean isNameRelationsRuleConsideredActivated() {
339 return isNameRelationsRuleConsideredActivated;
340 }
341
342 public void setNameRelationsRuleConsideredActivated(boolean isRuleConsideredActivated) {
343 this.isNameRelationsRuleConsideredActivated = isRuleConsideredActivated;
344 }
345
346 public boolean isNameRelationsRuleConsideredCodeEditionActivated() {
347 return isNameRelationsRuleConsideredCodeEditionActivated;
348 }
349
350 public void setNameRelationsRuleConsideredCodeEditionActivated(boolean isRuleConsideredCodeEditionActivated) {
351 this.isNameRelationsRuleConsideredCodeEditionActivated = isRuleConsideredCodeEditionActivated;
352 }
353
354 public boolean isNomenclaturalStatusRuleConsideredActivated() {
355 return isNomenclaturalStatusRuleConsideredActivated;
356 }
357
358 public void setNomenclaturalStatusRuleConsideredActivated(boolean isRuleConsideredActivated) {
359 this.isNomenclaturalStatusRuleConsideredActivated = isRuleConsideredActivated;
360 }
361
362 public boolean isNomenclaturalStatusRuleConsideredCodeEditionActivated() {
363 return isNomenclaturalStatusRuleConsideredCodeEditionActivated;
364 }
365
366 public void setNomenclaturalStatusRuleConsideredCodeEditionActivated(boolean isRuleConsideredCodeEditionActivated) {
367 this.isNomenclaturalStatusRuleConsideredCodeEditionActivated = isRuleConsideredCodeEditionActivated;
368 }
369
370
371 public boolean isDefault(){
372 boolean result = true;
373 for (Field field: this.getClass().getDeclaredFields()){
374 try {
375 result = result &&field.getBoolean(this);
376 } catch (IllegalArgumentException | IllegalAccessException e) {
377 // TODO Auto-generated catch block
378 e.printStackTrace();
379 }
380 }
381 return result;
382 }
383 }