import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache;
import eu.etaxonomy.taxeditor.model.MessagingUtils;
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard;
+import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
import eu.etaxonomy.taxeditor.store.CdmStore;
/**
}else{
selectedVocabularies.remove(vocabulary);
}
+ PreferencesUtil.getPreferenceStore().setValue(getPrefKey(vocabulary), isChecked());
initModel();
}
}
protected NamedAreaSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, NamedArea namedArea, UUID... preselectedVocabularyUuids) {
super(shell, conversation, title, multi, NamedAreaSelectionDialog.class.getCanonicalName(), namedArea);
- if(preselectedVocabularyUuids.length>0){
- preselectedVocabularies = new ArrayList<TermVocabulary>();
- for(int i=0;i<preselectedVocabularyUuids.length;i++){
- TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]);
- preselectedVocabularies.add(preselectedVocabulary);
- }
- selectedVocabularies.retainAll(preselectedVocabularies);
- initModel();//re-init to consider pre-selected vocabularies
+ preselectedVocabularies = new ArrayList<TermVocabulary>();
+ for(int i=0;i<preselectedVocabularyUuids.length;i++){
+ TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]);
+ preselectedVocabularies.add(preselectedVocabulary);
}
+ Collection<TermVocabulary> tempSelectedVocabularies = new HashSet<>();
+ for(TermVocabulary vocabulary:selectedVocabularies){
+ if(preselectedVocabularies.contains(vocabulary)
+ || PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary))){
+ tempSelectedVocabularies.add(vocabulary);
+ }
+ }
+ selectedVocabularies = tempSelectedVocabularies;
+ initModel();//re-init to consider pre-selected vocabularies
}
/** {@inheritDoc} */
for(TermVocabulary<NamedArea> vocabulary : getAvailableVocabularies()){
IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary);
menuManager.add(action);
- if(preselectedVocabularies==null || preselectedVocabularies.isEmpty() || preselectedVocabularies.contains(vocabulary)) {
+ if(preselectedVocabularies.contains(vocabulary)) {
action.setChecked(true);
}
+ else{
+ action.setChecked(PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary)));
+ }
}
}
+
+ private String getPrefKey(TermVocabulary vocabulary){
+ return NamedAreaSelectionDialog.class.toString()+vocabulary.getUuid();
+ }
/** {@inheritDoc} */
@Override
@Override
protected void init() {
selectedVocabularies = getAvailableVocabularies();
+ for(TermVocabulary vocabulary:selectedVocabularies){
+ PreferencesUtil.getPreferenceStore().setDefault(getPrefKey(vocabulary), true);
+ }
}
private List<TermVocabulary> getAvailableVocabularies(){
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
import eu.etaxonomy.taxeditor.ui.element.IEntityElement;
import eu.etaxonomy.taxeditor.ui.section.agent.TeamMemberElement;
-import eu.etaxonomy.taxeditor.ui.section.description.detail.DistributionDetailElement;
import eu.etaxonomy.taxeditor.ui.section.name.AuthorshipDetailElement;
import eu.etaxonomy.taxeditor.ui.section.reference.NomenclaturalReferenceDetailElement;
return (T) SpecimenOrObservationBaseSelectionDialog.select(shell, conversation, (SpecimenOrObservationBase) currentSelection);
}
if(clazz.equals(NamedArea.class)){
- if(parentElement instanceof DistributionDetailElement){
-// return (T) NamedAreaSelectionForDistributionDialog.select(shell, conversation, (NamedArea) currentSelection, CdmStore.getTermManager().getPreferredVocabulary(TermType.NamedArea));
- return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection, Country.uuidCountryVocabulary);
- }else if(parentElement instanceof IEntityElement && ((IEntityElement) parentElement).getEntity() instanceof DerivedUnitFacade){
+ if(parentElement instanceof IEntityElement && ((IEntityElement) parentElement).getEntity() instanceof DerivedUnitFacade){
return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection, Country.uuidCountryVocabulary);
}
else{