Project

General

Profile

Download (2.04 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
 * Copyright (C) 2017 EDIT
3
 * European Distributed Institute of Taxonomy
4
 * http://www.e-taxonomy.eu
5
 *
6
 * The contents of this file are subject to the Mozilla Public License Version 1.1
7
 * See LICENSE.TXT at the top of this package for the full license terms.
8
 */
9
package eu.etaxonomy.taxeditor.navigation.search;
10

    
11
import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator;
12
import eu.etaxonomy.taxeditor.navigation.l10n.Messages;
13
import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
14
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
15

    
16
/**
17
 * @author pplitzner
18
 * @since Sep 27, 2017
19
 *
20
 */
21
public enum SearchOption {
22
    TAXON(Messages.SearchBar_6),
23
    SYNONYM(Messages.SearchBar_7),
24
    NAME(Messages.SearchBar_8),
25
    COMMON_NAME(Messages.SearchBar_9);
26

    
27
    private final String label;
28

    
29
    private SearchOption(String label) {
30
        this.label = label;
31
    }
32

    
33
    public String getLabel() {
34
        return label;
35
    }
36

    
37
    public boolean getPreference() {
38
        if (!PreferencesUtil.getPreferenceStore().contains(IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_TAXA)) {
39
            // initializes the search configurator
40
            IFindTaxaAndNamesConfigurator configurator = PreferencesUtil.initializeSearchConfigurator();
41
            PreferencesUtil.setSearchConfigurator(configurator);
42
        }
43

    
44
        switch (this) {
45
        case TAXON:
46
            boolean result = PreferencesUtil.getPreferenceStore().getBoolean(
47
                    IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_TAXA);
48
            return result;
49
        case SYNONYM:
50
            return PreferencesUtil.getPreferenceStore().getBoolean(
51
                    IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_SYNONYMS);
52
        case NAME:
53
            return PreferencesUtil.getPreferenceStore().getBoolean(
54
                    IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_NAMES);
55
        case COMMON_NAME:
56
            return PreferencesUtil.getPreferenceStore().getBoolean(
57
                    IPreferenceKeys.TAXON_SERVICE_CONFIGURATOR_COMMON_NAMES);
58
        }
59

    
60
        return true;
61
    }
62

    
63
}
(2-2/3)