Revision acd9267c
Added by Katja Luther over 4 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/menu/NameTypeDesignationStatusMenuPreferences.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.preference.menu; |
11 | 11 |
|
12 |
import java.util.ArrayList; |
|
12 | 13 |
import java.util.List; |
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import org.apache.commons.lang.StringUtils; |
|
13 | 17 |
|
14 | 18 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; |
15 | 19 |
import eu.etaxonomy.cdm.model.term.TermType; |
20 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
|
16 | 21 |
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto; |
17 | 22 |
import eu.etaxonomy.taxeditor.preference.GeneralTermPreference; |
23 |
import eu.etaxonomy.taxeditor.preference.LocalOrDefaultEnum; |
|
24 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
25 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
18 | 26 |
|
19 | 27 |
/** |
20 | 28 |
* <p>NameTypeDesignationStatusMenuPreferences class.</p> |
... | ... | |
43 | 51 |
// TODO Auto-generated method stub |
44 | 52 |
return null; |
45 | 53 |
} |
54 |
|
|
55 |
@Override |
|
56 |
public boolean performOk() { |
|
57 |
if (!isApply()){ |
|
58 |
return true; |
|
59 |
} |
|
60 |
Object[] checkedElements = treeComposite.getViewer().getCheckedElements(); |
|
61 |
List<UUID> listUIIDChecked = new ArrayList<>(); |
|
62 |
List<TermDto> preferredTerms = new ArrayList<>(); |
|
63 |
for (Object o : checkedElements) { |
|
64 |
if(o instanceof TermDto){ |
|
65 |
TermDto termDto = (TermDto) o; |
|
66 |
listUIIDChecked.add(termDto.getUuid()); |
|
67 |
preferredTerms.add(termDto); |
|
68 |
} |
|
69 |
} |
|
70 |
String saveCheckedElements = StringUtils.join(listUIIDChecked, ";"); //$NON-NLS-1$ |
|
71 |
|
|
72 |
PreferencesUtil.setStringValue(PreferencePredicate.NameTypeDesignationStatus.getKey(), saveCheckedElements); |
|
73 |
String text = this.useLocalOrAdmin.getText(); |
|
74 |
if (text.equals(LocalOrDefaultEnum.Database.getLabel()) || text.equals(LocalOrDefaultEnum.Default.getLabel())){ |
|
75 |
PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.NameTypeDesignationStatus.getKey()), false); |
|
76 |
}else if (text.equals(LocalOrDefaultEnum.Local.getLabel())){ |
|
77 |
PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.NameTypeDesignationStatus.getKey()), true); |
|
78 |
} |
|
79 |
|
|
80 |
CdmStore.getTermManager().setPreferredTermsByType(preferredTerms, TermType.NameTypeDesignationStatus); |
|
81 |
PreferencesUtil.firePreferencesChanged(this.getClass()); |
|
82 |
return true; |
|
83 |
} |
|
46 | 84 |
} |
Also available in: Unified diff
ref #8389: adapt term preference handling for nametypedesignation