Project

General

Profile

Download (2.81 KB) Statistics
| Branch: | Tag: | Revision:
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.menu;
11

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

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

    
18
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
19
import eu.etaxonomy.cdm.model.term.TermType;
20
import eu.etaxonomy.cdm.persistence.dto.TermDto;
21
import eu.etaxonomy.taxeditor.preference.GeneralTermPreferencePage;
22
import eu.etaxonomy.taxeditor.preference.LocalOrDefaultEnum;
23
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
24
import eu.etaxonomy.taxeditor.store.CdmStore;
25

    
26
/**
27
 * <p>SpecimenTypeDesignationStatusMenuPreferences class.</p>
28
 *
29
 * @author n.hoffmann
30
 * @created 25.06.2009
31
 * @version 1.0
32
 */
33
public class SpecimenTypeDesignationStatusMenuPreferences extends
34
		GeneralTermPreferencePage {
35
    /**
36
    * <p>Constructor for SpecimenTypeDesignationStatusMenuPreferences.</p>
37
    */
38
   public SpecimenTypeDesignationStatusMenuPreferences() {
39
       super();
40
       setPredicate(PreferencePredicate.SpecimenTypeDesignationStatus);
41
       type = TermType.SpecimenTypeDesignationStatus;
42
   }
43

    
44

    
45

    
46

    
47

    
48

    
49
   @Override
50
   public boolean performOk() {
51
       if (!isApply()){
52
           return true;
53
       }
54
       Object[] checkedElements = treeComposite.getViewer().getCheckedElements();
55
       List<UUID> listUIIDChecked = new ArrayList<>();
56
       List<TermDto> preferredTerms = new ArrayList<>();
57
       for (Object o : checkedElements) {
58
           if(o instanceof TermDto){
59
               TermDto termDto = (TermDto) o;
60
               listUIIDChecked.add(termDto.getUuid());
61
               preferredTerms.add(termDto);
62
           }
63
       }
64
       String saveCheckedElements = StringUtils.join(listUIIDChecked, ";"); //$NON-NLS-1$
65

    
66
       PreferencesUtil.setStringValue(PreferencePredicate.SpecimenTypeDesignationStatus.getKey(), saveCheckedElements);
67
       String text = this.useLocalOrAdmin.getText();
68
       if (text.equals(LocalOrDefaultEnum.Database.getLabel()) || text.equals(LocalOrDefaultEnum.Default.getLabel())){
69
           PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.SpecimenTypeDesignationStatus.getKey()), false);
70
       }else if (text.equals(LocalOrDefaultEnum.Local.getLabel())){
71
           PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.SpecimenTypeDesignationStatus.getKey()), true);
72
       }
73

    
74
       CdmStore.getTermManager().setPreferredTermsByType(preferredTerms, TermType.SpecimenTypeDesignationStatus);
75
       PreferencesUtil.firePreferencesChanged(this.getClass());
76
       return true;
77

    
78
   }
79
}
(19-19/21)