Project

General

Profile

« Previous | Next » 

Revision 7f73ebf0

Added by Katja Luther over 2 years ago

add common name language pref to db preferences

View differences:

eu.etaxonomy.taxeditor.store/plugin.xml
838 838
            id="eu.etaxonomy.taxeditor.preferences.languages"
839 839
            name="%page.name.10">
840 840
      </page>
841
      <page
842
          category="eu.etaxonomy.taxeditor.preference.EmptyLanguagePage"
843
          class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.CommonNameLanguageAdminPreferences"
844
          id="eu.etaxonomy.taxeditor.preferences.commonnameAdminlanguages"
845
          name="%page.name.58">
846
      </page>
841 847
      <page
842 848
            category="eu.etaxonomy.taxeditor.preferences.description"
843 849
            class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.NameFeatureAdminMenuPreference"
......
926 932
      <page
927 933
            category="eu.etaxonomy.taxeditor.preferences.description"
928 934
            class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.CommonNameVocabularyAdminPreferencePage"
929
            id="eu.etaxonomy.taxeditor.store.vocabularyAdminPreference"
935
            id="eu.etaxonomy.taxeditor.store.commonNameAdminPreference"
930 936
            name="%page.name.47">
931 937
      </page>
932
       <page
938
      <page
933 939
            category="eu.etaxonomy.taxeditor.preferences.general"
934 940
            class="eu.etaxonomy.taxeditor.databaseAdmin.preferencePage.SpecimenAdminPreferences"
935 941
            id="eu.etaxonomy.taxeditor.store.specimenAdminPreferences"
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/databaseAdmin/preferencePage/CommonNameLanguageAdminPreferences.java
1
/**
2
* Copyright (C) 2021 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.databaseAdmin.preferencePage;
10

  
11
import java.util.ArrayList;
12
import java.util.List;
13
import java.util.UUID;
14

  
15
import org.apache.commons.lang3.StringUtils;
16

  
17
import eu.etaxonomy.cdm.model.metadata.CdmPreference;
18
import eu.etaxonomy.cdm.persistence.dto.TermDto;
19
import eu.etaxonomy.taxeditor.preference.LocalOrDefaultEnum;
20
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
21
import eu.etaxonomy.taxeditor.preference.menu.CommonNameLanguagePreferences;
22

  
23
/**
24
 * @author k.luther
25
 * @since Aug 27, 2021
26
 */
27
public class CommonNameLanguageAdminPreferences extends CommonNameLanguagePreferences {
28

  
29
    public CommonNameLanguageAdminPreferences(){
30
        super();
31
        isAdminPreference = true;
32
    }
33

  
34
    @Override
35
    public boolean performOk() {
36
        if (!isApply()){
37
            return true;
38
        }
39

  
40
        Object[] checkedElements = treeComposite.getViewer().getCheckedElements();
41

  
42
        List<UUID> listUIIDChecked = new ArrayList<>();
43

  
44
        for (Object o : checkedElements) {
45
            if(o instanceof TermDto){
46
                TermDto termDto = (TermDto) o;
47
                listUIIDChecked.add(termDto.getUuid());
48

  
49
            }
50
        }
51
        String saveCheckedElements = StringUtils.join(listUIIDChecked, ";"); //$NON-NLS-1$
52
        if (pref == null){
53
            saveCheckedElements = null;
54
        }
55
        CdmPreference savePref = CdmPreference.NewTaxEditorInstance(predicate, saveCheckedElements);
56
        String text = this.useLocalOrAdmin.getText();
57
        if (text.equals(LocalOrDefaultEnum.Database.getLabel()) ){
58
            savePref.setAllowOverride(false);
59
        }else if (text.equals(LocalOrDefaultEnum.AllowOverride.getLabel())){
60
            savePref.setAllowOverride(true);
61
        }
62

  
63
        PreferencesUtil.setPreferenceToDB(savePref);
64
        PreferencesUtil.updateDBPreferences();
65
        PreferencesUtil.firePreferencesChanged(this.getClass());
66
        return true;
67

  
68
    }
69

  
70
}

Also available in: Unified diff