Revision 8a7e7d33
Added by Katja Luther over 4 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/menu/SpecimenTypeDesignationStatusMenuPreferences.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.taxeditor.preference.menu; |
11 | 11 |
|
12 |
import java.util.ArrayList; |
|
13 |
import java.util.List; |
|
14 |
import java.util.UUID; |
|
15 |
|
|
16 |
import org.apache.commons.lang.StringUtils; |
|
17 |
|
|
18 |
import eu.etaxonomy.cdm.api.service.ITermService; |
|
19 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; |
|
20 |
import eu.etaxonomy.cdm.model.term.DefinedTermBase; |
|
12 | 21 |
import eu.etaxonomy.cdm.model.term.TermType; |
13 |
import eu.etaxonomy.cdm.model.name.SpecimenTypeDesignationStatus; |
|
14 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
|
22 |
import eu.etaxonomy.cdm.persistence.dto.TermDto; |
|
23 |
import eu.etaxonomy.cdm.persistence.dto.TermVocabularyDto; |
|
24 |
import eu.etaxonomy.taxeditor.preference.GeneralTermPreference; |
|
25 |
import eu.etaxonomy.taxeditor.preference.LocalOrDefaultEnum; |
|
26 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
27 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
|
15 | 28 |
|
16 | 29 |
/** |
17 | 30 |
* <p>SpecimenTypeDesignationStatusMenuPreferences class.</p> |
... | ... | |
21 | 34 |
* @version 1.0 |
22 | 35 |
*/ |
23 | 36 |
public class SpecimenTypeDesignationStatusMenuPreferences extends |
24 |
AbstractMenuPreferences<SpecimenTypeDesignationStatus> { |
|
25 |
/** |
|
26 |
* <p>Constructor for SpecimenTypeDesignationStatusMenuPreferences.</p> |
|
27 |
*/ |
|
28 |
public SpecimenTypeDesignationStatusMenuPreferences() { |
|
29 |
super("Specimen Type Designation Status Preferences", //$NON-NLS-1$ |
|
30 |
Messages.SpecimenTypeDesignationStatusMenuPreferences_configure, |
|
31 |
false); |
|
32 |
} |
|
33 |
|
|
34 |
/* (non-Javadoc) |
|
35 |
* @see eu.etaxonomy.taxeditor.preference.menu.AbstractMenuPreferences#getTermClass() |
|
36 |
*/ |
|
37 |
/** {@inheritDoc} */ |
|
38 |
@Override |
|
39 |
protected TermType getTermType() { |
|
40 |
return TermType.SpecimenTypeDesignationStatus; |
|
41 |
} |
|
37 |
GeneralTermPreference { |
|
38 |
/** |
|
39 |
* <p>Constructor for SpecimenTypeDesignationStatusMenuPreferences.</p> |
|
40 |
*/ |
|
41 |
public SpecimenTypeDesignationStatusMenuPreferences() { |
|
42 |
super(); |
|
43 |
setLocalPref(true); |
|
44 |
setPredicate(PreferencePredicate.SpecimenTypeDesignationStatus); |
|
45 |
type = TermType.SpecimenTypeDesignationStatus; |
|
46 |
} |
|
47 |
|
|
48 |
|
|
49 |
|
|
50 |
/** |
|
51 |
* {@inheritDoc} |
|
52 |
*/ |
|
53 |
@Override |
|
54 |
protected List<TermVocabularyDto> getVocabulariesFromPreference() { |
|
55 |
// TODO Auto-generated method stub |
|
56 |
return null; |
|
57 |
} |
|
58 |
|
|
59 |
|
|
60 |
@Override |
|
61 |
public boolean performOk() { |
|
62 |
if (!isApply()){ |
|
63 |
return true; |
|
64 |
} |
|
65 |
Object[] checkedElements = treeComposite.getViewer().getCheckedElements(); |
|
66 |
List<UUID> listUIIDChecked = new ArrayList<>(); |
|
67 |
List<DefinedTermBase> preferredTerms = new ArrayList<>(); |
|
68 |
for (Object o : checkedElements) { |
|
69 |
if(o instanceof TermDto){ |
|
70 |
TermDto termDto = (TermDto) o; |
|
71 |
listUIIDChecked.add(termDto.getUuid()); |
|
72 |
preferredTerms.add(CdmStore.getService(ITermService.class).load(termDto.getUuid())); |
|
73 |
} |
|
74 |
} |
|
75 |
String saveCheckedElements = StringUtils.join(listUIIDChecked, ";"); //$NON-NLS-1$ |
|
76 |
|
|
77 |
PreferencesUtil.setStringValue(PreferencePredicate.SpecimenTypeDesignationStatus.getKey(), saveCheckedElements); |
|
78 |
String text = this.useLocalOrAdmin.getText(); |
|
79 |
if (text.equals(LocalOrDefaultEnum.Database.getLabel()) || text.equals(LocalOrDefaultEnum.Default.getLabel())){ |
|
80 |
PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.SpecimenTypeDesignationStatus.getKey()), false); |
|
81 |
}else if (text.equals(LocalOrDefaultEnum.Local.getLabel())){ |
|
82 |
PreferencesUtil.setBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.SpecimenTypeDesignationStatus.getKey()), true); |
|
83 |
} |
|
84 |
|
|
85 |
CdmStore.getTermManager().setPreferredTermsByType(preferredTerms, TermType.SpecimenTypeDesignationStatus); |
|
86 |
PreferencesUtil.firePreferencesChanged(this.getClass()); |
|
87 |
return true; |
|
42 | 88 |
|
89 |
} |
|
43 | 90 |
} |
Also available in: Unified diff
fix preferences and term issues