From: Patrick Plitzner Date: Thu, 1 Sep 2016 15:11:37 +0000 (+0200) Subject: fix #6049 Store vocabulary filters for NamedArea selection dialogs in X-Git-Tag: 4.3.0^2~55 X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/0a1dde2393323d6754c7791d6608f2bfda97154d fix #6049 Store vocabulary filters for NamedArea selection dialogs in preferences - when passing pre-selected vocabularies programmatically these will ignore the preferences and will always be selected --- diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NamedAreaSelectionDialog.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NamedAreaSelectionDialog.java index 055fd74cb..3ce780781 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NamedAreaSelectionDialog.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NamedAreaSelectionDialog.java @@ -34,6 +34,7 @@ import eu.etaxonomy.cdm.model.location.NamedArea; 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; /** @@ -62,6 +63,7 @@ public class NamedAreaSelectionDialog extends }else{ selectedVocabularies.remove(vocabulary); } + PreferencesUtil.getPreferenceStore().setValue(getPrefKey(vocabulary), isChecked()); initModel(); } } @@ -89,15 +91,20 @@ public class NamedAreaSelectionDialog extends 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(); - for(int i=0;i(); + for(int i=0;i 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} */ @@ -109,11 +116,18 @@ public class NamedAreaSelectionDialog extends for(TermVocabulary 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 @@ -133,6 +147,9 @@ public class NamedAreaSelectionDialog extends @Override protected void init() { selectedVocabularies = getAvailableVocabularies(); + for(TermVocabulary vocabulary:selectedVocabularies){ + PreferencesUtil.getPreferenceStore().setDefault(getPrefKey(vocabulary), true); + } } private List getAvailableVocabularies(){ diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionDialogFactory.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionDialogFactory.java index f45adb155..b2eb36969 100644 --- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionDialogFactory.java +++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/SelectionDialogFactory.java @@ -45,7 +45,6 @@ import eu.etaxonomy.taxeditor.model.MessagingUtils; 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; @@ -126,10 +125,7 @@ public class SelectionDialogFactory { 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{