1
|
/**
|
2
|
* Copyright (C) 2007 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
|
|
10
|
package eu.etaxonomy.taxeditor.preference;
|
11
|
|
12
|
import java.io.File;
|
13
|
import java.io.FileInputStream;
|
14
|
import java.io.FileOutputStream;
|
15
|
import java.io.IOException;
|
16
|
import java.net.URI;
|
17
|
import java.net.URISyntaxException;
|
18
|
import java.util.ArrayList;
|
19
|
import java.util.Arrays;
|
20
|
import java.util.Collections;
|
21
|
import java.util.HashMap;
|
22
|
import java.util.List;
|
23
|
import java.util.Map;
|
24
|
import java.util.Properties;
|
25
|
import java.util.Set;
|
26
|
import java.util.StringTokenizer;
|
27
|
import java.util.UUID;
|
28
|
|
29
|
import org.apache.commons.lang.StringUtils;
|
30
|
import org.apache.log4j.Logger;
|
31
|
import org.eclipse.equinox.internal.p2.ui.model.MetadataRepositoryElement;
|
32
|
import org.eclipse.jface.preference.IPreferenceStore;
|
33
|
import org.eclipse.jface.window.Window;
|
34
|
import org.eclipse.swt.widgets.Composite;
|
35
|
import org.eclipse.swt.widgets.Control;
|
36
|
import org.eclipse.swt.widgets.Shell;
|
37
|
import org.eclipse.ui.PlatformUI;
|
38
|
|
39
|
import eu.etaxonomy.cdm.api.application.ICdmRepository;
|
40
|
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacadeConfigurator;
|
41
|
import eu.etaxonomy.cdm.api.service.IFeatureTreeService;
|
42
|
import eu.etaxonomy.cdm.api.service.ITermService;
|
43
|
import eu.etaxonomy.cdm.api.service.config.FindTaxaAndNamesConfiguratorImpl;
|
44
|
import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
|
45
|
import eu.etaxonomy.cdm.common.CdmUtils;
|
46
|
import eu.etaxonomy.cdm.hibernate.HibernateProxyHelper;
|
47
|
import eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator;
|
48
|
import eu.etaxonomy.cdm.model.common.ICdmBase;
|
49
|
import eu.etaxonomy.cdm.model.common.IDefinedTerm;
|
50
|
import eu.etaxonomy.cdm.model.common.ISimpleTerm;
|
51
|
import eu.etaxonomy.cdm.model.common.Language;
|
52
|
import eu.etaxonomy.cdm.model.common.MarkerType;
|
53
|
import eu.etaxonomy.cdm.model.common.TermBase;
|
54
|
import eu.etaxonomy.cdm.model.description.FeatureTree;
|
55
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
|
56
|
import eu.etaxonomy.cdm.model.metadata.CdmPreference.PrefKey;
|
57
|
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
|
58
|
import eu.etaxonomy.cdm.model.metadata.PreferenceSubject;
|
59
|
import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
|
60
|
import eu.etaxonomy.cdm.strategy.match.DefaultMatchStrategy;
|
61
|
import eu.etaxonomy.cdm.strategy.match.IMatchStrategy;
|
62
|
import eu.etaxonomy.cdm.strategy.match.MatchException;
|
63
|
import eu.etaxonomy.cdm.strategy.match.MatchMode;
|
64
|
import eu.etaxonomy.taxeditor.model.AbstractUtility;
|
65
|
import eu.etaxonomy.taxeditor.model.MessagingUtils;
|
66
|
import eu.etaxonomy.taxeditor.model.NomenclaturalCodeHelper;
|
67
|
import eu.etaxonomy.taxeditor.store.CdmStore;
|
68
|
import eu.etaxonomy.taxeditor.store.internal.TaxeditorStorePlugin;
|
69
|
import eu.etaxonomy.taxeditor.ui.dialog.DefaultLanguageDialog;
|
70
|
|
71
|
/**
|
72
|
* <p>
|
73
|
* PreferencesUtil class.
|
74
|
* </p>
|
75
|
*
|
76
|
* @author p.ciardelli
|
77
|
* @author n.hoffmann
|
78
|
* @created 05.12.2008
|
79
|
* @version 1.0
|
80
|
*/
|
81
|
public class PreferencesUtil implements IPreferenceKeys {
|
82
|
|
83
|
/**
|
84
|
*
|
85
|
*/
|
86
|
public static final String PREFERRED_TERMS_CHANGE = "preferred_terms";
|
87
|
|
88
|
public static final String P2_REPOSITORIES_DELIM = ",";
|
89
|
public static final String P2_REPOSITORY_FIELDS_DELIM = ";";
|
90
|
|
91
|
private final static Logger logger = Logger.getLogger(PreferencesUtil.class);
|
92
|
|
93
|
/**
|
94
|
* <p>
|
95
|
* getPreferenceStore
|
96
|
* </p>
|
97
|
*
|
98
|
* @return a {@link org.eclipse.jface.preference.IPreferenceStore} object.
|
99
|
*/
|
100
|
public static IPreferenceStore getPreferenceStore() {
|
101
|
return TaxeditorStorePlugin.getDefault().getPreferenceStore();
|
102
|
}
|
103
|
|
104
|
/**
|
105
|
* <p>
|
106
|
* setPreferredNomenclaturalCode
|
107
|
* </p>
|
108
|
*
|
109
|
* @param preferredCode
|
110
|
* a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode}
|
111
|
* object.
|
112
|
*/
|
113
|
public static CdmPreference setPreferredNomenclaturalCode(
|
114
|
String preferenceKey, boolean local) {
|
115
|
if (local){
|
116
|
getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
|
117
|
preferenceKey);
|
118
|
}
|
119
|
else{
|
120
|
ICdmRepository controller;
|
121
|
controller = CdmStore.getCurrentApplicationConfiguration();
|
122
|
PrefKey key = null;
|
123
|
try{
|
124
|
key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
|
125
|
}catch (Exception e){
|
126
|
System.out.println(e.getStackTrace());
|
127
|
}
|
128
|
CdmPreference preference = null;
|
129
|
if (controller == null){
|
130
|
return null;
|
131
|
}
|
132
|
if (preferenceKey == null){
|
133
|
preference = controller.getPreferenceService().find(key);
|
134
|
if (preference == null){
|
135
|
return null;
|
136
|
} else{
|
137
|
// int index = StringUtils.lastIndexOf(preference.getValue(), ".");
|
138
|
// UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
|
139
|
// preferredCode = NomenclaturalCode.getByUuid(uuid);
|
140
|
|
141
|
getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
|
142
|
preferenceKey);
|
143
|
getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY,preference.isAllowOverride());
|
144
|
return preference;
|
145
|
}
|
146
|
} else{
|
147
|
preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode, preferenceKey);
|
148
|
controller.getPreferenceService().set(preference);
|
149
|
|
150
|
}
|
151
|
}
|
152
|
return null;
|
153
|
|
154
|
|
155
|
|
156
|
}
|
157
|
|
158
|
public static NomenclaturalCode getPreferredNomenclaturalCode(){
|
159
|
if (getPreferenceStore().getBoolean(OVERRIDE_NOMENCLATURAL_CODE_KEY)) {
|
160
|
return getPreferredNomenclaturalCode(true);
|
161
|
} else{
|
162
|
return getPreferredNomenclaturalCode(false);
|
163
|
}
|
164
|
}
|
165
|
|
166
|
/**
|
167
|
* <p>
|
168
|
* getPreferredNomenclaturalCode
|
169
|
* </p>
|
170
|
*
|
171
|
* @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
|
172
|
*/
|
173
|
public static NomenclaturalCode getPreferredNomenclaturalCode(boolean useLocal) {
|
174
|
|
175
|
CdmPreference pref = null;
|
176
|
if (!useLocal){
|
177
|
pref = getPreferenceFromDB(PreferencePredicate.NomenclaturalCode);
|
178
|
}
|
179
|
|
180
|
String preferredCode;
|
181
|
if(pref == null){
|
182
|
preferredCode = getPreferenceStore().getString(
|
183
|
PREFERRED_NOMENCLATURAL_CODE_KEY);
|
184
|
|
185
|
}else{
|
186
|
preferredCode = pref.getValue();
|
187
|
}
|
188
|
|
189
|
return getPreferredNomenclaturalCode(preferredCode);
|
190
|
|
191
|
}
|
192
|
|
193
|
/**
|
194
|
* <p>
|
195
|
* getPreferredNomenclaturalCode
|
196
|
* </p>
|
197
|
*
|
198
|
* @return a {@link eu.etaxonomy.cdm.model.name.NomenclaturalCode} object.
|
199
|
*/
|
200
|
public static NomenclaturalCode getPreferredNomenclaturalCode(String preferenceKeyNomenclaturalCode) {
|
201
|
|
202
|
for (NomenclaturalCode code : NomenclaturalCodeHelper.getAllCodes()) {
|
203
|
if (getPreferenceKey(code).equals(preferenceKeyNomenclaturalCode)) {
|
204
|
return code;
|
205
|
}
|
206
|
}
|
207
|
return null;
|
208
|
}
|
209
|
|
210
|
public static boolean isShowTaxonAssociations(){
|
211
|
if (getPreferenceStore().getBoolean(OVERRIDE_SPECIMEN_PREF) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF)) {
|
212
|
return getPreferenceStore().getBoolean(SHOW_TAXON_ASSOCIATIONS);
|
213
|
} else{
|
214
|
CdmPreference pref = getPreferenceFromDB(PreferencePredicate.ShowTaxonAssociations);
|
215
|
|
216
|
return pref!=null?Boolean.valueOf(pref.getValue()):false;
|
217
|
}
|
218
|
}
|
219
|
|
220
|
public static boolean isShowLifeForm(){
|
221
|
if (getPreferenceStore().getBoolean(OVERRIDE_SPECIMEN_PREF) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF)) {
|
222
|
return getPreferenceStore().getBoolean(SHOW_LIFE_FORM);
|
223
|
} else{
|
224
|
CdmPreference pref = getPreferenceFromDB(PreferencePredicate.ShowLifeForm);
|
225
|
|
226
|
return pref!=null?Boolean.valueOf(pref.getValue()):false;
|
227
|
}
|
228
|
}
|
229
|
|
230
|
public static boolean isDeterminationOnlyForFieldUnits(){
|
231
|
if (getPreferenceStore().getBoolean(OVERRIDE_SPECIMEN_PREF) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF)) {
|
232
|
return getPreferenceStore().getBoolean(DETERMINATION_ONLY_FOR_FIELD_UNITS);
|
233
|
} else{
|
234
|
CdmPreference pref = getPreferenceFromDB(PreferencePredicate.DeterminationOnlyForFieldUnits);
|
235
|
|
236
|
return pref!=null?Boolean.valueOf(pref.getValue()):false;
|
237
|
}
|
238
|
}
|
239
|
|
240
|
public static boolean isCollectingAreaInGeneralSection(){
|
241
|
if (getPreferenceStore().getBoolean(OVERRIDE_SPECIMEN_PREF) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_SPECIMEN_PREF)) {
|
242
|
return getPreferenceStore().getBoolean(SHOW_COLLECTING_AREAS_IN_GENERAL_SECTION);
|
243
|
} else{
|
244
|
CdmPreference pref = getPreferenceFromDB(PreferencePredicate.ShowCollectingAreasInGeneralSection);
|
245
|
|
246
|
return pref!=null?Boolean.valueOf(pref.getValue()):false;
|
247
|
}
|
248
|
}
|
249
|
|
250
|
public static boolean isShowSimpleDetailsView(){
|
251
|
if (getPreferenceStore().getBoolean(OVERRIDE_NAME_DETAILS) && getPreferenceStore().getBoolean(ALLOW_OVERRIDE_NAME_DETAILS)) {
|
252
|
return getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_SECTION);
|
253
|
} else{
|
254
|
CdmPreference pref = getPreferenceFromDB(PreferencePredicate.NameDetailsView);
|
255
|
|
256
|
return pref!=null?Boolean.valueOf(pref.getValue()):false;
|
257
|
}
|
258
|
}
|
259
|
|
260
|
|
261
|
|
262
|
public static CdmPreference getPreferenceFromDB(PreferencePredicate predicate){
|
263
|
ICdmRepository controller;
|
264
|
CdmPreference pref = null;
|
265
|
|
266
|
try{
|
267
|
if(CdmStore.isActive()){
|
268
|
controller = CdmStore.getCurrentApplicationConfiguration();
|
269
|
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), predicate);
|
270
|
pref = controller.getPreferenceService().find(key);
|
271
|
}
|
272
|
}catch(Exception e){
|
273
|
e.printStackTrace();
|
274
|
}
|
275
|
|
276
|
return pref;
|
277
|
|
278
|
}
|
279
|
|
280
|
public static void setPreferenceToDB(CdmPreference preference){
|
281
|
ICdmRepository controller;
|
282
|
try{
|
283
|
if(CdmStore.isActive()){
|
284
|
controller = CdmStore.getCurrentApplicationConfiguration();
|
285
|
controller.getPreferenceService().set(preference);
|
286
|
}
|
287
|
}catch(Exception e){
|
288
|
e.printStackTrace();
|
289
|
}
|
290
|
|
291
|
}
|
292
|
|
293
|
|
294
|
|
295
|
public static String getPreferredDefaultLangugae(){
|
296
|
String preferredLanguage = getPreferenceStore().getString(DEFAULT_LANGUAGE_EDITOR);
|
297
|
if(StringUtils.isNotEmpty(preferredLanguage) && StringUtils.isNotBlank(preferredLanguage)){
|
298
|
return preferredLanguage;
|
299
|
}
|
300
|
return null;
|
301
|
}
|
302
|
|
303
|
public static boolean isShowMediaPreview(){
|
304
|
boolean isShowMediaPreview = getPreferenceStore().getBoolean(SHOW_MEDIA_PREVIEW);
|
305
|
return isShowMediaPreview;
|
306
|
}
|
307
|
|
308
|
/**
|
309
|
* Get the match strategy for the given class that was stored in preferences
|
310
|
* or the default strategy if it was not stored in preferences
|
311
|
*
|
312
|
* @param clazz
|
313
|
* a {@link java.lang.Class} object.
|
314
|
* @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
|
315
|
*/
|
316
|
public static IMatchStrategy getMatchStrategy(Class clazz) {
|
317
|
String className = clazz.getName();
|
318
|
if (getPreferenceStore().getBoolean(MATCH_STRATEGY_PREFIX + className)) {
|
319
|
IMatchStrategy matchStrategy = getDefaultMatchStrategy(clazz);
|
320
|
|
321
|
for (String fieldName : matchStrategy.getMatchFieldPropertyNames()) {
|
322
|
String matchModeName = getPreferenceStore().getString(
|
323
|
getMatchStrategyFieldName(className, fieldName));
|
324
|
MatchMode matchMode = MatchMode.valueOf(matchModeName);
|
325
|
try {
|
326
|
matchStrategy.setMatchMode(fieldName, matchMode);
|
327
|
} catch (MatchException e) {
|
328
|
MessagingUtils.error(PreferencesUtil.class, e);
|
329
|
throw new RuntimeException(e);
|
330
|
}
|
331
|
}
|
332
|
|
333
|
return matchStrategy;
|
334
|
}
|
335
|
return getDefaultMatchStrategy(clazz);
|
336
|
}
|
337
|
|
338
|
/**
|
339
|
* Stores a matchStrategy into the preference store.
|
340
|
*
|
341
|
* @param matchStrategy
|
342
|
* a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy}
|
343
|
* object.
|
344
|
*/
|
345
|
public static void setMatchStrategy(IMatchStrategy matchStrategy) {
|
346
|
String className = matchStrategy.getMatchClass().getName();
|
347
|
getPreferenceStore().setValue(MATCH_STRATEGY_PREFIX + className, true);
|
348
|
|
349
|
Set<String> matchFields = matchStrategy.getMatchFieldPropertyNames();
|
350
|
|
351
|
for (String fieldName : matchFields) {
|
352
|
getPreferenceStore().setValue(
|
353
|
getMatchStrategyFieldName(className, fieldName),
|
354
|
matchStrategy.getMatchMode(fieldName).name());
|
355
|
}
|
356
|
}
|
357
|
|
358
|
/**
|
359
|
* Helper method to create the preference property for a match field.
|
360
|
*
|
361
|
* @param className
|
362
|
* @param fieldName
|
363
|
* @return
|
364
|
*/
|
365
|
private static String getMatchStrategyFieldName(String className,
|
366
|
String fieldName) {
|
367
|
return MATCH_STRATEGY_PREFIX + className + "." + fieldName;
|
368
|
}
|
369
|
|
370
|
/**
|
371
|
* Returns the default match strategy for a given class.
|
372
|
*
|
373
|
* @param clazz
|
374
|
* a {@link java.lang.Class} object.
|
375
|
* @return a {@link eu.etaxonomy.cdm.strategy.match.IMatchStrategy} object.
|
376
|
*/
|
377
|
public static IMatchStrategy getDefaultMatchStrategy(Class clazz) {
|
378
|
return DefaultMatchStrategy.NewInstance(clazz);
|
379
|
}
|
380
|
|
381
|
/**
|
382
|
* <p>
|
383
|
* getDateFormatPattern
|
384
|
* </p>
|
385
|
*
|
386
|
* @return a {@link java.lang.String} object.
|
387
|
*/
|
388
|
public static String getDateFormatPattern() {
|
389
|
// TODO make this configurable in properties
|
390
|
String pattern = "Y-M-d H:m";
|
391
|
return pattern;
|
392
|
}
|
393
|
|
394
|
/**
|
395
|
* <p>
|
396
|
* addTermToPreferredTerms
|
397
|
* </p>
|
398
|
*
|
399
|
* @param term
|
400
|
* a T object.
|
401
|
* @param <T>
|
402
|
* a T object.
|
403
|
*/
|
404
|
public static <T extends TermBase> void addTermToPreferredTerms(T term) {
|
405
|
|
406
|
// VocabularyEnum vocabulary =
|
407
|
// VocabularyEnum.getVocabularyEnum(term.getClass());
|
408
|
//
|
409
|
// getPreferenceStore().setValue(getPreferenceKey(term),
|
410
|
// VocabularyStore.getTermVocabulary(vocabulary).getTerms().contains(term));
|
411
|
//
|
412
|
// firePreferencesChanged(term.getClass());
|
413
|
}
|
414
|
|
415
|
/**
|
416
|
* Construct a unique key using the CdmBase object's uuid
|
417
|
*
|
418
|
* @param cdmBase
|
419
|
* @return
|
420
|
*/
|
421
|
private static String getPreferenceKey(ICdmBase cdmBase) {
|
422
|
cdmBase = HibernateProxyHelper.deproxy(cdmBase);
|
423
|
|
424
|
String key = cdmBase.getClass().getName().concat(".")
|
425
|
.concat(cdmBase.getUuid().toString());
|
426
|
if (key.contains("javassist")) {
|
427
|
MessagingUtils.info("proxy");
|
428
|
}
|
429
|
return key;
|
430
|
}
|
431
|
|
432
|
/**
|
433
|
* Construct a unique key using the CdmBase object's uuid
|
434
|
*
|
435
|
* @param cdmBase
|
436
|
* @return
|
437
|
*/
|
438
|
public static String getPreferenceKey(ISimpleTerm simpleTerm) {
|
439
|
simpleTerm = HibernateProxyHelper.deproxy(simpleTerm);
|
440
|
String key = simpleTerm.getClass().getName().concat(".")
|
441
|
.concat(simpleTerm.getUuid().toString());
|
442
|
if (key.contains("javassist")) {
|
443
|
MessagingUtils.warn(PreferencesUtil.class,
|
444
|
"Trying to persist a preference based on a proxy class.");
|
445
|
}
|
446
|
return key;
|
447
|
}
|
448
|
|
449
|
|
450
|
|
451
|
/**
|
452
|
* Construct a unique key using the CdmBase object's uuid
|
453
|
*
|
454
|
* @param cdmBase
|
455
|
* @return
|
456
|
*/
|
457
|
public static String getPreferenceKey(IDefinedTerm definedTerm) {
|
458
|
definedTerm = HibernateProxyHelper.deproxy(definedTerm);
|
459
|
String key = definedTerm.getClass().getName().concat(".")
|
460
|
.concat(definedTerm.getUuid().toString());
|
461
|
if (key.contains("javassist")) {
|
462
|
MessagingUtils.warn(PreferencesUtil.class,
|
463
|
"Trying to persist a preference based on a proxy class.");
|
464
|
}
|
465
|
return key;
|
466
|
}
|
467
|
|
468
|
/**
|
469
|
* Retrieves search preferences from the preference store
|
470
|
*
|
471
|
* @return an {@link ITaxonServiceConfigurator} to pass to search methods
|
472
|
*/
|
473
|
public static IFindTaxaAndNamesConfigurator getSearchConfigurator() {
|
474
|
IFindTaxaAndNamesConfigurator configurator = initializeSearchConfigurator();
|
475
|
|
476
|
configurator.setDoTaxa(getPreferenceStore().getBoolean(
|
477
|
TAXON_SERVICE_CONFIGURATOR_TAXA));
|
478
|
configurator.setDoSynonyms(getPreferenceStore().getBoolean(
|
479
|
TAXON_SERVICE_CONFIGURATOR_SYNONYMS));
|
480
|
configurator.setDoNamesWithoutTaxa(getPreferenceStore().getBoolean(
|
481
|
TAXON_SERVICE_CONFIGURATOR_NAMES));
|
482
|
configurator.setDoTaxaByCommonNames(getPreferenceStore().getBoolean(
|
483
|
TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES));
|
484
|
//configurator.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.valueOf(getPreferenceStore().getString(TAXON_SERVICE_CONFIGURATOR_MATCH_MODE)));
|
485
|
|
486
|
return configurator;
|
487
|
}
|
488
|
|
489
|
/**
|
490
|
* create new preferences, setting all search options to true
|
491
|
*
|
492
|
* @return a
|
493
|
* {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
|
494
|
* object.
|
495
|
*/
|
496
|
public static IFindTaxaAndNamesConfigurator initializeSearchConfigurator() {
|
497
|
IFindTaxaAndNamesConfigurator configurator = new FindTaxaAndNamesConfiguratorImpl();
|
498
|
|
499
|
configurator.setDoTaxa(true);
|
500
|
configurator.setDoSynonyms(true);
|
501
|
configurator.setDoNamesWithoutTaxa(true);
|
502
|
configurator.setDoTaxaByCommonNames(true);
|
503
|
|
504
|
configurator.setTaxonPropertyPath(Arrays.asList("$", "titleCache",
|
505
|
"name", "name.$", "relationsFromThisTaxon.$"));
|
506
|
|
507
|
configurator.setSynonymPropertyPath(Arrays.asList("$", "titleCache",
|
508
|
"name", "name.$", "synonyms.relatedTo.*"));
|
509
|
|
510
|
// DEFAULT VALUES
|
511
|
// match mode is a simple like, actually all other match modes are kind
|
512
|
// of bogus
|
513
|
configurator
|
514
|
.setMatchMode(eu.etaxonomy.cdm.persistence.query.MatchMode.ANYWHERE);
|
515
|
// we set page number and size here as this should always be unlimited
|
516
|
configurator.setPageNumber(0);
|
517
|
// TODO currently limit results to 10000
|
518
|
configurator.setPageSize(10000);
|
519
|
|
520
|
return configurator;
|
521
|
}
|
522
|
|
523
|
/**
|
524
|
* Store search preferences
|
525
|
*
|
526
|
* @param configurator
|
527
|
* a
|
528
|
* {@link eu.etaxonomy.cdm.api.service.config.ITaxonServiceConfigurator}
|
529
|
* object.
|
530
|
*/
|
531
|
public static void setSearchConfigurator(
|
532
|
IFindTaxaAndNamesConfigurator configurator) {
|
533
|
getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_TAXA,
|
534
|
configurator.isDoTaxa());
|
535
|
getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
|
536
|
configurator.isDoSynonyms());
|
537
|
getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_NAMES,
|
538
|
configurator.isDoNamesWithoutTaxa());
|
539
|
getPreferenceStore().setValue(TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES,
|
540
|
configurator.isDoTaxaByCommonNames());
|
541
|
}
|
542
|
|
543
|
/**
|
544
|
* <p>
|
545
|
* firePreferencesChanged
|
546
|
* </p>
|
547
|
*
|
548
|
* @param clazz
|
549
|
* a {@link java.lang.Class} object.
|
550
|
*/
|
551
|
public static void firePreferencesChanged(Class clazz) {
|
552
|
getPreferenceStore().firePropertyChangeEvent(PREFERRED_TERMS_CHANGE,
|
553
|
null, clazz);
|
554
|
}
|
555
|
|
556
|
/**
|
557
|
* Set default values for preferences
|
558
|
*/
|
559
|
public static void setDefaults() {
|
560
|
getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_TAXA, true);
|
561
|
getPreferenceStore().setDefault(TAXON_SERVICE_CONFIGURATOR_SYNONYMS,
|
562
|
true);
|
563
|
getPreferenceStore().setDefault(EDIT_MAP_SERVICE_ACCES_POINT,
|
564
|
"http://edit.africamuseum.be/edit_wp5/v1.2/rest_gen.php");
|
565
|
//FIXME : changed default for SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
|
566
|
getPreferenceStore().setDefault(SHOULD_CONNECT_AT_STARTUP, false);
|
567
|
getPreferenceStore().setDefault(OPENURL_ACCESS_POINT,
|
568
|
"http://www.biodiversitylibrary.org/openurl");
|
569
|
getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_WIDTH, "1000");
|
570
|
getPreferenceStore().setDefault(OPENURL_IMAGE_MAX_HEIGHT, "1000");
|
571
|
getPreferenceStore().setDefault(IPreferenceKeys.DISTRIBUTION_AREA_PREFRENCES_ACTIVE, false);
|
572
|
getPreferenceStore().setDefault(CHECKLIST_ID_IN_VOCABULARY, true);
|
573
|
getPreferenceStore().setDefault(CHECKLIST_SYMBOL, false);
|
574
|
getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS, true);
|
575
|
getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE, true);
|
576
|
getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP, true);
|
577
|
getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_HYBRID, true);
|
578
|
getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_LSID, true);
|
579
|
getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP, true);
|
580
|
getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NAMECACHE, true);
|
581
|
getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE, true);
|
582
|
getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE, true);
|
583
|
getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS, true);
|
584
|
getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE, true);
|
585
|
getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_RANK, true);
|
586
|
getPreferenceStore().setDefault(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION, true);
|
587
|
getPreferenceStore().setDefault(SORT_NODES_NATURALLY, false);
|
588
|
getPreferenceStore().setDefault(SORT_NODES_ALPHABETICALLY, false);
|
589
|
getPreferenceStore().setDefault(SORT_TAXA_BY_RANK_AND_NAME, true);
|
590
|
|
591
|
}
|
592
|
|
593
|
/**
|
594
|
* <p>
|
595
|
* checkNomenclaturalCode
|
596
|
* </p>
|
597
|
*/
|
598
|
public static void checkNomenclaturalCode() {
|
599
|
// First time Editor is opened, no nomenclatural code has been set
|
600
|
|
601
|
|
602
|
if (PreferencesUtil.getPreferredNomenclaturalCode(true) == null) {
|
603
|
PreferencesUtil.setPreferredNomenclaturalCode(getPreferenceKey(NomenclaturalCode.ICNAFP), true);
|
604
|
}
|
605
|
|
606
|
|
607
|
|
608
|
}
|
609
|
public static void setNomenclaturalCodePreferences(){
|
610
|
ICdmRepository controller;
|
611
|
controller = CdmStore.getCurrentApplicationConfiguration();
|
612
|
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.NomenclaturalCode);
|
613
|
CdmPreference preference = null;
|
614
|
if (controller == null){
|
615
|
return ;
|
616
|
}
|
617
|
preference = controller.getPreferenceService().find(key);
|
618
|
if (preference == null){
|
619
|
return;
|
620
|
}
|
621
|
getPreferenceStore().setValue(ALLOW_OVERRIDE_NOMENCLATURAL_CODE_KEY, preference.isAllowOverride());
|
622
|
|
623
|
int index = StringUtils.lastIndexOf(preference.getValue(), ".");
|
624
|
UUID uuid = UUID.fromString(preference.getValue().substring(index +1, preference.getValue().length()));
|
625
|
NomenclaturalCode preferredCode = NomenclaturalCode.getByUuid(uuid);
|
626
|
|
627
|
getPreferenceStore().setValue(CDM_NOMENCLATURAL_CODE_KEY,
|
628
|
getPreferenceKey(preferredCode));
|
629
|
|
630
|
if (!preference.isAllowOverride()){
|
631
|
getPreferenceStore().setValue(PREFERRED_NOMENCLATURAL_CODE_KEY,
|
632
|
getPreferenceKey(preferredCode));
|
633
|
}
|
634
|
}
|
635
|
|
636
|
public static void checkDefaultLanguage(){
|
637
|
if(PreferencesUtil.getPreferredDefaultLangugae() == null){
|
638
|
Shell shell = AbstractUtility.getShell();
|
639
|
int open = new DefaultLanguageDialog(shell).open();
|
640
|
if(open == Window.OK){
|
641
|
PlatformUI.getWorkbench().restart();
|
642
|
}
|
643
|
}else{
|
644
|
//TODO:In case of a reinstall, the config.ini will be overwritten
|
645
|
// here you create config.ini with the stored key from preferences
|
646
|
}
|
647
|
}
|
648
|
|
649
|
/**
|
650
|
* <p>
|
651
|
* getMapServiceAccessPoint
|
652
|
* </p>
|
653
|
*
|
654
|
* @return a {@link java.lang.String} object.
|
655
|
*/
|
656
|
public static String getMapServiceAccessPoint() {
|
657
|
return getPreferenceStore().getString(EDIT_MAP_SERVICE_ACCES_POINT);
|
658
|
}
|
659
|
|
660
|
/**
|
661
|
* <p>
|
662
|
* shouldConnectAtStartUp
|
663
|
* </p>
|
664
|
*
|
665
|
* @return a boolean.
|
666
|
*/
|
667
|
public static boolean shouldConnectAtStartUp() {
|
668
|
//FIXME : force SHOULD_CONNECT_AT_STARTUP to false (ticket 3828) until resolution
|
669
|
//return getPreferenceStore().getBoolean(SHOULD_CONNECT_AT_STARTUP);
|
670
|
return false;
|
671
|
}
|
672
|
|
673
|
/**
|
674
|
* <p>
|
675
|
* getDefaultFeatureTreeForTextualDescription
|
676
|
* </p>
|
677
|
*
|
678
|
* @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
|
679
|
*/
|
680
|
public static FeatureTree getDefaultFeatureTreeForTextualDescription() {
|
681
|
String uuidString = getPreferenceStore().getString(
|
682
|
FEATURE_TREE_DEFAULT_TEXT);
|
683
|
return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(
|
684
|
IFeatureTreeService.class).load(UUID.fromString(uuidString));
|
685
|
}
|
686
|
|
687
|
/**
|
688
|
* <p>
|
689
|
* getDefaultFeatureTreeForStructuredDescription
|
690
|
* </p>
|
691
|
*
|
692
|
* @return a {@link eu.etaxonomy.cdm.model.description.FeatureTree} object.
|
693
|
*/
|
694
|
public static FeatureTree getDefaultFeatureTreeForStructuredDescription() {
|
695
|
String uuidString = getPreferenceStore().getString(
|
696
|
FEATURE_TREE_DEFAULT_STRUCTURE);
|
697
|
return CdmUtils.isEmpty(uuidString) ? null : CdmStore.getService(
|
698
|
IFeatureTreeService.class).load(UUID.fromString(uuidString));
|
699
|
}
|
700
|
|
701
|
/**
|
702
|
* <p>
|
703
|
* setSortRanksHierarchichally
|
704
|
* </p>
|
705
|
*
|
706
|
* @param selection
|
707
|
* a boolean.
|
708
|
*/
|
709
|
public static void setSortRanksHierarchichally(boolean selection) {
|
710
|
getPreferenceStore().setValue(SORT_RANKS_HIERARCHICHALLY, selection);
|
711
|
}
|
712
|
|
713
|
/**
|
714
|
* <p>
|
715
|
* getSortRanksHierarchichally
|
716
|
* </p>
|
717
|
*
|
718
|
* @return a boolean.
|
719
|
*/
|
720
|
public static boolean getSortRanksHierarchichally() {
|
721
|
return getPreferenceStore().getBoolean(SORT_RANKS_HIERARCHICHALLY);
|
722
|
}
|
723
|
|
724
|
public static boolean isMultilanguageTextEditingCapability() {
|
725
|
return getPreferenceStore().getBoolean(
|
726
|
MULTILANGUAGE_TEXT_EDITING_CAPABILITY);
|
727
|
}
|
728
|
|
729
|
public static Language getGlobalLanguage() {
|
730
|
|
731
|
|
732
|
String languageUuidString = getPreferenceStore().getString(
|
733
|
GLOBAL_LANGUAGE_UUID);
|
734
|
|
735
|
if(!CdmStore.isActive()) {
|
736
|
MessagingUtils.noDataSourceWarningDialog(languageUuidString);
|
737
|
return null;
|
738
|
}
|
739
|
|
740
|
if (CdmUtils.isBlank(languageUuidString)) {
|
741
|
return Language.getDefaultLanguage();
|
742
|
}
|
743
|
|
744
|
UUID languageUuid = UUID.fromString(languageUuidString);
|
745
|
return (Language) CdmStore.getService(ITermService.class).load(
|
746
|
languageUuid);
|
747
|
}
|
748
|
|
749
|
public static void setGlobalLanguage(Language language) {
|
750
|
if(language != null) {
|
751
|
getPreferenceStore().setValue(GLOBAL_LANGUAGE_UUID,language.getUuid().toString());
|
752
|
CdmStore.setDefaultLanguage(language);
|
753
|
}
|
754
|
|
755
|
}
|
756
|
|
757
|
/**
|
758
|
* @return
|
759
|
*/
|
760
|
public static Map<MarkerType, Boolean> getEditMarkerTypePreferences() {
|
761
|
List<MarkerType> markerTypes = CdmStore.getTermManager()
|
762
|
.getPreferredTerms(MarkerType.class);
|
763
|
|
764
|
Map<MarkerType, Boolean> result = new HashMap<MarkerType, Boolean>();
|
765
|
|
766
|
for (MarkerType markerType : markerTypes) {
|
767
|
String name = getMarkerTypeEditingPreferenceKey(markerType);
|
768
|
Boolean value = getPreferenceStore().getBoolean(name);
|
769
|
|
770
|
result.put(markerType, value);
|
771
|
}
|
772
|
|
773
|
return result;
|
774
|
}
|
775
|
|
776
|
/**
|
777
|
* @param markerTypeEditingMap
|
778
|
*/
|
779
|
public static void setEditMarkerTypePreferences(
|
780
|
Map<MarkerType, Boolean> markerTypeEditingMap) {
|
781
|
for (MarkerType markerType : markerTypeEditingMap.keySet()) {
|
782
|
String name = getMarkerTypeEditingPreferenceKey(markerType);
|
783
|
getPreferenceStore().setValue(name,
|
784
|
markerTypeEditingMap.get(markerType));
|
785
|
}
|
786
|
|
787
|
}
|
788
|
|
789
|
private static String getMarkerTypeEditingPreferenceKey(
|
790
|
MarkerType markerType) {
|
791
|
markerType = HibernateProxyHelper.deproxy(markerType);
|
792
|
return markerType.getClass().getName() + EDIT_MARKER_TYPE_PREFIX;
|
793
|
}
|
794
|
|
795
|
/**
|
796
|
* <p>
|
797
|
* setEditMarkerTypePreference
|
798
|
* </p>
|
799
|
*
|
800
|
* @param input
|
801
|
* a {@link org.eclipse.ui.IEditorInput} object.
|
802
|
* @param markerType
|
803
|
* a {@link eu.etaxonomy.cdm.model.common.MarkerType} object.
|
804
|
* @param edit
|
805
|
* a boolean.
|
806
|
*/
|
807
|
public static void setEditMarkerTypePreference(MarkerType markerType,
|
808
|
boolean edit) {
|
809
|
getPreferenceStore().setValue(
|
810
|
getMarkerTypeEditingPreferenceKey(markerType), edit);
|
811
|
}
|
812
|
|
813
|
/**
|
814
|
* @return
|
815
|
*/
|
816
|
public static DerivedUnitFacadeConfigurator getDerivedUnitConfigurator() {
|
817
|
DerivedUnitFacadeConfigurator configurator = DerivedUnitFacadeConfigurator
|
818
|
.NewInstance();
|
819
|
configurator.setMoveDerivedUnitMediaToGallery(true);
|
820
|
configurator.setMoveFieldObjectMediaToGallery(true);
|
821
|
return configurator;
|
822
|
}
|
823
|
|
824
|
/**
|
825
|
* This method will write language properties to the config.ini located in the configuration folder
|
826
|
* of the Taxonomic Ediitor. <b>This method is only used to set the default language for Taxonomic Editor.</b>
|
827
|
*
|
828
|
* @param setLanguage 0 is for german and 1 for english.
|
829
|
* @throws IOException
|
830
|
*/
|
831
|
public void writePropertyToConfigFile(int setLanguage) throws IOException {
|
832
|
File file = org.eclipse.core.runtime.preferences.ConfigurationScope.INSTANCE.getLocation().toFile();
|
833
|
//give warning to user if the directory has no write access
|
834
|
if(file == null){
|
835
|
throw new IOException();
|
836
|
}
|
837
|
Properties properties = load(file.getAbsolutePath()+"/config.ini");
|
838
|
switch(setLanguage){
|
839
|
case 0:
|
840
|
properties.setProperty("osgi.nl", "de");
|
841
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "de");
|
842
|
break;
|
843
|
case 1:
|
844
|
properties.setProperty("osgi.nl", "en");
|
845
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "en");
|
846
|
break;
|
847
|
default:
|
848
|
break;
|
849
|
}
|
850
|
save(file+"/config.ini", properties);
|
851
|
}
|
852
|
|
853
|
/**
|
854
|
* This method loads a property from a given file and returns it.
|
855
|
*
|
856
|
* @param filename
|
857
|
* @return
|
858
|
* @throws IOException
|
859
|
*/
|
860
|
private Properties load(String filename) throws IOException {
|
861
|
FileInputStream in = new FileInputStream(filename);
|
862
|
Properties prop = new Properties();
|
863
|
prop.load(in);
|
864
|
in.close();
|
865
|
return prop;
|
866
|
}
|
867
|
|
868
|
/**
|
869
|
* This method saves a property to the specified file.
|
870
|
*
|
871
|
* @param filename
|
872
|
* @param properties
|
873
|
* @throws IOException
|
874
|
*/
|
875
|
private void save(String filename, Properties properties) throws IOException{
|
876
|
FileOutputStream fos = new FileOutputStream(filename);
|
877
|
properties.store(fos, "");
|
878
|
fos.close();
|
879
|
}
|
880
|
|
881
|
/**
|
882
|
* Saves a list of P2 Metadata Repositories as string with specified delimiters
|
883
|
*
|
884
|
* @param p2Repos
|
885
|
*/
|
886
|
public static void setP2Repositories(List<MetadataRepositoryElement> p2Repos) {
|
887
|
StringBuilder sb = new StringBuilder();
|
888
|
for(MetadataRepositoryElement p2Repo : p2Repos) {
|
889
|
sb.append(P2_REPOSITORIES_DELIM);
|
890
|
if(p2Repo.getName() == null || p2Repo.getName().isEmpty()) {
|
891
|
sb.append("-");
|
892
|
} else {
|
893
|
sb.append(p2Repo.getName());
|
894
|
}
|
895
|
sb.append(P2_REPOSITORY_FIELDS_DELIM);
|
896
|
sb.append(p2Repo.getLocation().toString());
|
897
|
sb.append(P2_REPOSITORY_FIELDS_DELIM);
|
898
|
sb.append(String.valueOf(p2Repo.isEnabled()));
|
899
|
}
|
900
|
getPreferenceStore().setValue(P2_REPOSITORY_LIST, sb.toString());
|
901
|
}
|
902
|
|
903
|
|
904
|
/**
|
905
|
* Retrieves a list of previously saved P2 repositories
|
906
|
*
|
907
|
* @return
|
908
|
*/
|
909
|
public static List<MetadataRepositoryElement> getP2Repositories() {
|
910
|
List<MetadataRepositoryElement> p2Repos = new ArrayList<MetadataRepositoryElement>();
|
911
|
String p2ReposPref = getPreferenceStore().getString(P2_REPOSITORY_LIST);
|
912
|
if(p2ReposPref != null && !p2ReposPref.isEmpty()) {
|
913
|
StringTokenizer p2ReposPrefST = new StringTokenizer(p2ReposPref,P2_REPOSITORIES_DELIM);
|
914
|
|
915
|
while(p2ReposPrefST.hasMoreTokens()) {
|
916
|
String p2RepoStr = p2ReposPrefST.nextToken();
|
917
|
StringTokenizer p2ReposStrST = new StringTokenizer(p2RepoStr,P2_REPOSITORY_FIELDS_DELIM);
|
918
|
if(p2ReposStrST.countTokens()==3) {
|
919
|
String nickname = p2ReposStrST.nextToken();
|
920
|
URI uri = null;
|
921
|
try {
|
922
|
uri = new URI(p2ReposStrST.nextToken());
|
923
|
} catch (URISyntaxException e) {
|
924
|
continue;
|
925
|
}
|
926
|
boolean enabled = Boolean.parseBoolean(p2ReposStrST.nextToken());
|
927
|
MetadataRepositoryElement mre = new MetadataRepositoryElement(null, uri, true);
|
928
|
mre.setNickname(nickname);
|
929
|
mre.setEnabled(enabled);
|
930
|
p2Repos.add(mre);
|
931
|
}
|
932
|
}
|
933
|
}
|
934
|
|
935
|
return p2Repos;
|
936
|
}
|
937
|
|
938
|
/**
|
939
|
* enables/disables nested composite. <br>
|
940
|
*
|
941
|
* @param ctrl - Composite to be en-/disabeld
|
942
|
* @param enabled - boolean
|
943
|
*/
|
944
|
public static void recursiveSetEnabled(Control ctrl, boolean enabled) {
|
945
|
if (ctrl instanceof Composite) {
|
946
|
Composite comp = (Composite) ctrl;
|
947
|
for (Control c : comp.getChildren()) {
|
948
|
recursiveSetEnabled(c, enabled);
|
949
|
}
|
950
|
} else {
|
951
|
ctrl.setEnabled(enabled);
|
952
|
}
|
953
|
}
|
954
|
|
955
|
/**
|
956
|
* <p>
|
957
|
* getSortRanksNaturally
|
958
|
* </p>
|
959
|
*
|
960
|
* @return a boolean.
|
961
|
*/
|
962
|
public static boolean getSortNodesNaturally() {
|
963
|
return getPreferenceStore().getBoolean(SORT_NODES_NATURALLY);
|
964
|
}
|
965
|
|
966
|
/**
|
967
|
* <p>
|
968
|
* setSortRanksNaturally
|
969
|
* </p>
|
970
|
*
|
971
|
* @param selection
|
972
|
* a boolean.
|
973
|
*/
|
974
|
public static void setSortNodesNaturally(boolean selection) {
|
975
|
getPreferenceStore().setValue(SORT_NODES_NATURALLY, selection);
|
976
|
}
|
977
|
|
978
|
|
979
|
/**
|
980
|
* <p>
|
981
|
* getSortRanksNaturally
|
982
|
* </p>
|
983
|
*
|
984
|
* @return a boolean.
|
985
|
*/
|
986
|
public static boolean getSortNodesStrictlyAlphabetically() {
|
987
|
return getPreferenceStore().getBoolean(SORT_NODES_ALPHABETICALLY);
|
988
|
}
|
989
|
|
990
|
/**
|
991
|
* <p>
|
992
|
* setSortRanksNaturally
|
993
|
* </p>
|
994
|
*
|
995
|
* @param selection
|
996
|
* a boolean.
|
997
|
*/
|
998
|
public static void setSortNodesStrictlyAlphabetically(boolean selection) {
|
999
|
getPreferenceStore().setValue(SORT_NODES_ALPHABETICALLY, selection);
|
1000
|
}
|
1001
|
|
1002
|
/**
|
1003
|
* <p>
|
1004
|
* setStoreNavigatorState
|
1005
|
* </p>
|
1006
|
*
|
1007
|
* @param selection
|
1008
|
* a boolean.
|
1009
|
*/
|
1010
|
public static boolean isStoreNavigatorState() {
|
1011
|
return getPreferenceStore().getBoolean(RESTORE_NAVIGATOR_STATE);
|
1012
|
|
1013
|
}
|
1014
|
|
1015
|
/**
|
1016
|
* <p>
|
1017
|
* setStoreNavigatorState
|
1018
|
* </p>
|
1019
|
*
|
1020
|
* @param selection
|
1021
|
* a boolean.
|
1022
|
*/
|
1023
|
public static void setStoreNavigatorState(boolean selection) {
|
1024
|
getPreferenceStore().setValue(RESTORE_NAVIGATOR_STATE, selection);
|
1025
|
|
1026
|
}
|
1027
|
|
1028
|
/**
|
1029
|
* @return
|
1030
|
*/
|
1031
|
public static boolean isShowUpWidgetIsDisposedMessages() {
|
1032
|
return getPreferenceStore().getBoolean(IS_SHOW_UP_WIDGET_IS_DISPOSED);
|
1033
|
}
|
1034
|
public static void setShowUpWidgetIsDisposedMessages(boolean selection) {
|
1035
|
getPreferenceStore().setValue(IS_SHOW_UP_WIDGET_IS_DISPOSED, selection);
|
1036
|
}
|
1037
|
|
1038
|
/**
|
1039
|
* @return
|
1040
|
*/
|
1041
|
public static boolean isShowIdInVocabularyInChecklistEditor() {
|
1042
|
return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_ID_IN_VOCABULARY);
|
1043
|
}
|
1044
|
public static void setShowIdInVocabularyInChecklistEditor(boolean selection) {
|
1045
|
getPreferenceStore().setValue(CHECKLIST_ID_IN_VOCABULARY, selection);
|
1046
|
}
|
1047
|
|
1048
|
/**
|
1049
|
* @return
|
1050
|
*/
|
1051
|
public static boolean isShowSymbolInChecklistEditor() {
|
1052
|
return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_SYMBOL);
|
1053
|
}
|
1054
|
public static void setShowSymbolInChecklistEditor(boolean selection) {
|
1055
|
getPreferenceStore().setValue(CHECKLIST_SYMBOL, selection);
|
1056
|
}
|
1057
|
|
1058
|
/**
|
1059
|
* @return
|
1060
|
*/
|
1061
|
public static boolean isShowRankInChecklistEditor() {
|
1062
|
return getPreferenceStore().getBoolean(IPreferenceKeys.CHECKLIST_SHOW_RANK);
|
1063
|
}
|
1064
|
public static void setShowRankInChecklistEditor(boolean selection) {
|
1065
|
getPreferenceStore().setValue(CHECKLIST_SHOW_RANK, selection);
|
1066
|
}
|
1067
|
|
1068
|
/**
|
1069
|
* @param object
|
1070
|
* @param b
|
1071
|
* @return
|
1072
|
*/
|
1073
|
public static NameDetailsConfigurator setPreferredNameDetailsConfiguration( boolean local) {
|
1074
|
NameDetailsConfigurator config = new NameDetailsConfigurator(true);
|
1075
|
|
1076
|
CdmPreference preference = null;
|
1077
|
|
1078
|
if (!local) {
|
1079
|
preference = getPreferenceFromDB(PreferencePredicate.NameDetailsView);
|
1080
|
if (preference == null){
|
1081
|
return null;
|
1082
|
}
|
1083
|
|
1084
|
getPreferenceStore().setValue(ALLOW_OVERRIDE_NAME_DETAILS, preference.isAllowOverride());
|
1085
|
|
1086
|
//the preference value is build like this:
|
1087
|
//<section1>:true;<section2>:false....
|
1088
|
|
1089
|
String value = preference.getValue();
|
1090
|
String [] sections = value.split(";");
|
1091
|
Map<String, Boolean> sectionMap = new HashMap<String, Boolean>();
|
1092
|
String[] sectionValues;
|
1093
|
for (String sectionValue: sections){
|
1094
|
sectionValues = sectionValue.split(":");
|
1095
|
sectionMap.put(sectionValues[0], Boolean.valueOf(sectionValues[1]));
|
1096
|
}
|
1097
|
config.setAllowOverride(preference.isAllowOverride());
|
1098
|
config.setSimpleDetailsViewActivated(getValue(sectionMap, "simpleViewActivated"));
|
1099
|
|
1100
|
// getPreferenceStore().setValue(SHOW_SIMPLE_NAME_DETAILS_TAXON,
|
1101
|
// (getValue(sectionMap, "taxon")));
|
1102
|
config.setTaxonSectionActivated(getValue(sectionMap, "taxon"));
|
1103
|
|
1104
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_LSID,
|
1105
|
// (getValue(sectionMap, "lsid")));
|
1106
|
config.setLSIDActivated(getValue(sectionMap, "lsid"));
|
1107
|
|
1108
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
|
1109
|
// (getValue(sectionMap, "nc")));
|
1110
|
config.setNomenclaturalCodeActived(getValue(sectionMap, "nc"));
|
1111
|
|
1112
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
|
1113
|
// (getValue(sectionMap, "ap")));
|
1114
|
config.setAppendedPhraseActivated(getValue(sectionMap, "ap"));
|
1115
|
|
1116
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_RANK,
|
1117
|
// (getValue(sectionMap, "rank")));
|
1118
|
config.setRankActivated(getValue(sectionMap, "rank"));
|
1119
|
|
1120
|
|
1121
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
|
1122
|
// (getValue(sectionMap, "atomisedEpithets")));
|
1123
|
config.setAtomisedEpithetsActivated(getValue(sectionMap, "atomisedEpithets"));
|
1124
|
|
1125
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
|
1126
|
// (getValue(sectionMap,"author")));
|
1127
|
config.setAuthorshipSectionActivated(getValue(sectionMap,"author"));
|
1128
|
|
1129
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
|
1130
|
// (getValue(sectionMap, "nomRef")));
|
1131
|
config.setNomenclaturalReferenceSectionActivated(sectionMap.get("nomRef"));
|
1132
|
|
1133
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
|
1134
|
// (getValue(sectionMap, "nomStat")));
|
1135
|
config.setNomenclaturalStatusSectionActivated(getValue(sectionMap, "nomStat"));
|
1136
|
|
1137
|
|
1138
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
|
1139
|
// (getValue(sectionMap,"protologue")));
|
1140
|
config.setProtologueActivated(getValue(sectionMap,"protologue"));
|
1141
|
|
1142
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
|
1143
|
// (getValue(sectionMap,"typeDes")));
|
1144
|
config.setTypeDesignationSectionActivated(getValue(sectionMap,"typeDes"));
|
1145
|
|
1146
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
|
1147
|
// (getValue(sectionMap,"nameRelation")));
|
1148
|
config.setNameRelationsSectionActivated(getValue(sectionMap,"nameRelation"));
|
1149
|
|
1150
|
// getPreferenceStore().setValue(SHOW_NAME_DETAILS_SECTION_HYBRID,
|
1151
|
// (getValue(sectionMap, "hybrid")));
|
1152
|
config.setHybridActivated(getValue(sectionMap,"hybrid"));
|
1153
|
}else{
|
1154
|
config.setSimpleDetailsViewActivated(getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_SECTION));
|
1155
|
config.setTaxonSectionActivated(getPreferenceStore().getBoolean(SHOW_SIMPLE_NAME_DETAILS_TAXON));
|
1156
|
config.setLSIDActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_LSID));
|
1157
|
config.setNomenclaturalCodeActived(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
|
1158
|
config.setAppendedPhraseActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
|
1159
|
config.setRankActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_RANK));
|
1160
|
config.setAtomisedEpithetsActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
|
1161
|
config.setAuthorshipSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
|
1162
|
config.setNomenclaturalReferenceSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
|
1163
|
config.setNomenclaturalStatusSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
|
1164
|
config.setProtologueActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
|
1165
|
config.setTypeDesignationSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
|
1166
|
config.setNameRelationsSectionActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
|
1167
|
config.setHybridActivated(getPreferenceStore().getBoolean(SHOW_NAME_DETAILS_SECTION_HYBRID));
|
1168
|
}
|
1169
|
return config;
|
1170
|
}
|
1171
|
|
1172
|
private static Boolean getValue(Map<String, Boolean> sectionMap, String string) {
|
1173
|
if (sectionMap.containsKey(string)){
|
1174
|
return sectionMap.get(string);
|
1175
|
}else{
|
1176
|
return true;
|
1177
|
}
|
1178
|
|
1179
|
}
|
1180
|
|
1181
|
|
1182
|
|
1183
|
/**
|
1184
|
* <p>
|
1185
|
* setAbcdConfigurator
|
1186
|
* </p>
|
1187
|
*
|
1188
|
* @param preferredConfiguration
|
1189
|
* a {@link eu.etaxonomy.cdm.io.specimen.abcd206.in.Abcd206ImportConfigurator}
|
1190
|
* object.
|
1191
|
*/
|
1192
|
public static Abcd206ImportConfigurator getAbcdImportConfigurationPreference(boolean useLocal) {
|
1193
|
|
1194
|
Abcd206ImportConfigurator config = Abcd206ImportConfigurator.NewInstance(null,null);
|
1195
|
|
1196
|
if (useLocal){
|
1197
|
config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_INDIVIDUALS_ASSOCIATIONS_SUCH_AS_SPECIMEN_AND_OBSERVATIONS));
|
1198
|
|
1199
|
config.setAddMediaAsMediaSpecimen(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ADD_MEDIA_AS_MEDIASPECIMEN));
|
1200
|
|
1201
|
config.setAllowReuseOtherClassifications(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_ALLOW_REUSE_OTHER_CLASSIFICATIONS));
|
1202
|
config.setDeduplicateClassifications(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_CLASSIFICATIONS));
|
1203
|
config.setDeduplicateReferences(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DEDUPLICATE_REFERENCES));
|
1204
|
|
1205
|
config.setGetSiblings(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_DO_SIBLINGS));
|
1206
|
config.setIgnoreAuthorship(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_AUTHORSHIP));
|
1207
|
config.setIgnoreImportOfExistingSpecimen(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_IGNORE_IMPORT_OF_EXISTING_SPECIMEN));
|
1208
|
config.setMapUnitIdToAccessionNumber(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_ACCESSION_NUMBER));
|
1209
|
config.setMapUnitIdToBarcode(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TO_BARCODE));
|
1210
|
config.setMapUnitIdToCatalogNumber(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MAP_UNIT_ID_TOCATALOG_NUMBER));
|
1211
|
config.setMoveNewTaxaToDefaultClassification(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_MOVE_NEW_TAXA_TO_DEFAULT_CLASSIFICATION));
|
1212
|
config.setOverwriteExistingSpecimens(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_OVERWRITE_EXISTING_SPECIMEN));
|
1213
|
config.setReuseExistingDescriptiveGroups(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_DESCRIPTIVE_GROUPS));
|
1214
|
config.setReuseExistingMetaData(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_META_DATA));
|
1215
|
config.setReuseExistingTaxaWhenPossible(PreferencesUtil.getPreferenceStore().getBoolean(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_REUSE_EXISTING_TAXA_WHEN_POSSIBLE));
|
1216
|
config.setNomenclaturalCode(NomenclaturalCode.getByKey(PreferencesUtil.getPreferenceStore().getString(IPreferenceKeys.ABCD_IMPORT_CONFIGURATOR_NOMENCLATURAL_CODE)));
|
1217
|
return config;
|
1218
|
|
1219
|
}
|
1220
|
ICdmRepository controller;
|
1221
|
controller = CdmStore.getCurrentApplicationConfiguration();
|
1222
|
PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AbcdImportConfig);
|
1223
|
CdmPreference preference = null;
|
1224
|
if (controller == null){
|
1225
|
return null;
|
1226
|
}
|
1227
|
preference = controller.getPreferenceService().find(key);
|
1228
|
if (preference == null){
|
1229
|
return config;
|
1230
|
} else{
|
1231
|
String configString = preference.getValue();
|
1232
|
String[] configArray = configString.split(";");
|
1233
|
|
1234
|
for (String configItem: configArray){
|
1235
|
String[] keyValue = configItem.split(":");
|
1236
|
String keyString = keyValue[0];
|
1237
|
String valueString = keyValue[1];
|
1238
|
if (keyString.equals("ignoreImportOfExistingSpecimen")){
|
1239
|
config.setIgnoreImportOfExistingSpecimen(Boolean.valueOf(valueString));
|
1240
|
}else if (keyString.equals("addIndividualsAssociationsSuchAsSpecimenAndObservations")){
|
1241
|
config.setAddIndividualsAssociationsSuchAsSpecimenAndObservations(Boolean.valueOf(valueString));
|
1242
|
}else if (keyString.equals("reuseExistingTaxaWhenPossible")){
|
1243
|
config.setReuseExistingTaxaWhenPossible(Boolean.valueOf(valueString));
|
1244
|
}else if (keyString.equals("ignoreAuthorship")){
|
1245
|
config.setIgnoreAuthorship(Boolean.valueOf(valueString));
|
1246
|
}else if (keyString.equals("addMediaAsMediaSpecimen")){
|
1247
|
config.setAddMediaAsMediaSpecimen(Boolean.valueOf(valueString));
|
1248
|
}else if (keyString.equals("reuseExistingMetaData")){
|
1249
|
config.setReuseExistingMetaData(Boolean.valueOf(valueString));
|
1250
|
}else if (keyString.equals("reuseExistingDescriptiveGroups")){
|
1251
|
config.setReuseExistingDescriptiveGroups(Boolean.valueOf(valueString));
|
1252
|
}else if (keyString.equals("allowReuseOtherClassifications")){
|
1253
|
config.setAllowReuseOtherClassifications(Boolean.valueOf(valueString));
|
1254
|
}else if (keyString.equals("deduplicateReferences")){
|
1255
|
config.setDeduplicateReferences(Boolean.valueOf(valueString));
|
1256
|
}else if (keyString.equals("deduplicateClassifications")){
|
1257
|
config.setDeduplicateClassifications(Boolean.valueOf(valueString));
|
1258
|
}else if (keyString.equals("moveNewTaxaToDefaultClassification")){
|
1259
|
config.setMoveNewTaxaToDefaultClassification(Boolean.valueOf(valueString));
|
1260
|
}else if (keyString.equals("mapUnitIdToCatalogNumber")){
|
1261
|
config.setMapUnitIdToCatalogNumber(Boolean.valueOf(valueString));
|
1262
|
}else if (keyString.equals("mapUnitIdToAccessionNumber")){
|
1263
|
config.setMapUnitIdToAccessionNumber(Boolean.valueOf(valueString));
|
1264
|
}else if (keyString.equals("mapUnitIdToBarcode")){
|
1265
|
config.setMapUnitIdToBarcode(Boolean.valueOf(valueString));
|
1266
|
}else if (keyString.equals("overwriteExistingSpecimens")){
|
1267
|
config.setOverwriteExistingSpecimens(Boolean.valueOf(valueString));
|
1268
|
}else if (keyString.equals("nomenclaturalCode")){
|
1269
|
config.setNomenclaturalCode(NomenclaturalCode.fromString(valueString));
|
1270
|
}else{
|
1271
|
logger.debug("This key of the abcd configurator needs to be added to the transformer: " + keyString);
|
1272
|
}
|
1273
|
|
1274
|
}
|
1275
|
}
|
1276
|
return config;
|
1277
|
|
1278
|
|
1279
|
|
1280
|
}
|
1281
|
|
1282
|
/**
|
1283
|
*
|
1284
|
*/
|
1285
|
public NameDetailsConfigurator createLocalNameDetailsViewConfig(boolean local) {
|
1286
|
NameDetailsConfigurator config = new NameDetailsConfigurator(true);
|
1287
|
if (local){
|
1288
|
config.setSimpleDetailsViewActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION));
|
1289
|
config.setAppendedPhraseActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE));
|
1290
|
config.setAtomisedEpithetsActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS));
|
1291
|
config.setAuthorshipSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP));
|
1292
|
config.setLSIDActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID));
|
1293
|
config.setNameApprobiationActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_APPROBATION));
|
1294
|
config.setNameCacheActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_CACHE));
|
1295
|
config.setNameRelationsSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP));
|
1296
|
config.setNomenclaturalCodeActived(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE));
|
1297
|
config.setNomenclaturalStatusSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS));
|
1298
|
config.setNomenclaturalReferenceSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE));
|
1299
|
config.setProtologueActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE));
|
1300
|
config.setRankActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK));
|
1301
|
config.setTaxonSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON));
|
1302
|
config.setTypeDesignationSectionActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION));
|
1303
|
config.setHybridActivated(getPreferenceStore().getBoolean(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID));
|
1304
|
}else{
|
1305
|
|
1306
|
}
|
1307
|
|
1308
|
return config;
|
1309
|
}
|
1310
|
|
1311
|
|
1312
|
public static void saveConfigToPrefernceStore(NameDetailsConfigurator config) {
|
1313
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION,
|
1314
|
config.isSimpleDetailsViewActivated());
|
1315
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_TAXON, config.isTaxonSectionActivated());
|
1316
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_LSID, config.isLSIDActivated());
|
1317
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_CODE,
|
1318
|
config.isNomenclaturalCodeActived());
|
1319
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAMECACHE,
|
1320
|
config.isNameCacheActivated());
|
1321
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_APPENDED_PHRASE,
|
1322
|
config.isAppendedPhraseActivated());
|
1323
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_RANK, config.isRankActivated());
|
1324
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_ATOMISED_EPITHETS,
|
1325
|
config.isAtomisedEpithetsActivated());
|
1326
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP_CACHE,
|
1327
|
config.isAuthorCacheActivated());
|
1328
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_AUTHORSHIP,
|
1329
|
config.isAuthorshipSectionActivated());
|
1330
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_REFERENCE,
|
1331
|
config.isNomenclaturalReferenceSectionActivated());
|
1332
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NOMENCLATURAL_STATUS,
|
1333
|
config.isNomenclaturalStatusSectionActivated());
|
1334
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_PROTOLOGUE,
|
1335
|
config.isProtologueActivated());
|
1336
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_TYPE_DESIGNATION,
|
1337
|
config.isTypeDesignationSectionActivated());
|
1338
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_NAME_RELATIONSHIP,
|
1339
|
config.isNameRelationsSectionActivated());
|
1340
|
PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.SHOW_NAME_DETAILS_SECTION_HYBRID,
|
1341
|
config.isHybridActivated());
|
1342
|
|
1343
|
}
|
1344
|
|
1345
|
/**
|
1346
|
* @return
|
1347
|
*/
|
1348
|
public static boolean isSortTaxaByRankAndName() {
|
1349
|
|
1350
|
return getPreferenceStore().getBoolean(IPreferenceKeys.SORT_TAXA_BY_RANK_AND_NAME);
|
1351
|
}
|
1352
|
|
1353
|
/**
|
1354
|
* @return
|
1355
|
*/
|
1356
|
public static boolean isSortNamedAreaByOrderInVocabulary() {
|
1357
|
|
1358
|
return getPreferenceStore().getBoolean(IPreferenceKeys.SORT_NAMED_AREA_BY_VOCABULARY_ORDER);
|
1359
|
}
|
1360
|
|
1361
|
public static void setSortNamedAreasByOrderInVocabulary(boolean isSortByVocabularyOrder) {
|
1362
|
getPreferenceStore().setValue(IPreferenceKeys.SORT_NAMED_AREA_BY_VOCABULARY_ORDER, isSortByVocabularyOrder);
|
1363
|
|
1364
|
}
|
1365
|
|
1366
|
/**
|
1367
|
* <p>
|
1368
|
* setPreferredNamedAreasForDistributionEditor
|
1369
|
* </p>
|
1370
|
*
|
1371
|
* @param saveCheckedElements
|
1372
|
* @param saveGrayedElements
|
1373
|
*/
|
1374
|
public static void setLastSelectedReference(
|
1375
|
List<String> lastSelectedReferences) {
|
1376
|
|
1377
|
IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
|
1378
|
preferenceStore.setValue(PreferencesUtil.LAST_SELECTED_REFERENCES, lastSelectedReferences.toString());
|
1379
|
}
|
1380
|
|
1381
|
/**
|
1382
|
* <p>
|
1383
|
* setPreferredNamedAreasForDistributionEditor
|
1384
|
* </p>
|
1385
|
*
|
1386
|
* @param saveCheckedElements
|
1387
|
* @param saveGrayedElements
|
1388
|
*/
|
1389
|
public static List<String> getLastSelectedReferences() {
|
1390
|
|
1391
|
IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
|
1392
|
String lastSelected = preferenceStore.getString(PreferencesUtil.LAST_SELECTED_REFERENCES);
|
1393
|
List<String> result = new ArrayList<>();
|
1394
|
Collections.addAll(result, lastSelected.substring(1,lastSelected.length()-1).split(", "));
|
1395
|
return result;
|
1396
|
}
|
1397
|
|
1398
|
|
1399
|
/**
|
1400
|
* <p>
|
1401
|
* setPreferredNamedAreasForDistributionEditor
|
1402
|
* </p>
|
1403
|
*
|
1404
|
* @param saveCheckedElements
|
1405
|
* @param saveGrayedElements
|
1406
|
*/
|
1407
|
public static CdmPreference setPreferredNamedAreasForDistributionEditor(
|
1408
|
String saveCheckedElements, String saveGrayedElements, boolean local) {
|
1409
|
if (local){
|
1410
|
IPreferenceStore preferenceStore = PreferencesUtil.getPreferenceStore();
|
1411
|
preferenceStore.setValue(PreferencesUtil.DISTRIBUTION_AREA_OCCURENCE_STATUS, saveCheckedElements);
|
1412
|
preferenceStore.setValue(PreferencesUtil.DISTRIBUTION_AREA_OCCURENCE_STATUS_GRAYED, saveGrayedElements);
|
1413
|
|
1414
|
}
|
1415
|
else{
|
1416
|
ICdmRepository controller;
|
1417
|
|
1418
|
// PrefKey key = CdmPreference.NewKey(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaTerms);
|
1419
|
CdmPreference preference = null;
|
1420
|
|
1421
|
if (saveCheckedElements == null){
|
1422
|
preference = getPreferenceFromDB(PreferencePredicate.AvailableDistributionAreaTerms);
|
1423
|
// preference = controller.getPreferenceService().find(key);
|
1424
|
if (preference == null){
|
1425
|
return null;
|
1426
|
} else{
|
1427
|
String[] uuids = StringUtils.splitByWholeSeparator(saveCheckedElements, ",");
|
1428
|
List<UUID> uuidList = new ArrayList();
|
1429
|
for (String uuidString: uuids){
|
1430
|
uuidList.add(UUID.fromString(uuidString.trim()));
|
1431
|
}
|
1432
|
getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS,
|
1433
|
saveCheckedElements);
|
1434
|
|
1435
|
return preference;
|
1436
|
}
|
1437
|
} else{
|
1438
|
controller = CdmStore.getCurrentApplicationConfiguration();
|
1439
|
preference = CdmPreference.NewInstance(PreferenceSubject.NewDatabaseInstance(), PreferencePredicate.AvailableDistributionAreaTerms, saveCheckedElements);
|
1440
|
controller.getPreferenceService().set(preference);
|
1441
|
getPreferenceStore().setValue(DISTRIBUTION_AREA_OCCURENCE_STATUS,
|
1442
|
saveCheckedElements);
|
1443
|
|
1444
|
}
|
1445
|
}
|
1446
|
return null;
|
1447
|
|
1448
|
|
1449
|
|
1450
|
}
|
1451
|
|
1452
|
|
1453
|
|
1454
|
|
1455
|
|
1456
|
}
|