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