From: Patrick Plitzner
Date: Thu, 20 Oct 2016 15:09:19 +0000 (+0200)
Subject: ref #6058 store named area filters more individually
X-Git-Tag: 4.4.0^2~88
X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/be719c489241a9a9ed181b82338df1cd593ab999?hp=2a49546117427d9f1a17cb1dc43ab6bce2dd0017
ref #6058 store named area filters more individually
---
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 3ce780781..024bdd6db 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
@@ -63,13 +63,14 @@ public class NamedAreaSelectionDialog extends
}else{
selectedVocabularies.remove(vocabulary);
}
- PreferencesUtil.getPreferenceStore().setValue(getPrefKey(vocabulary), isChecked());
+ PreferencesUtil.getPreferenceStore().setValue(getPrefKey(vocabulary), !isChecked());
initModel();
}
}
protected Collection selectedVocabularies;
protected ArrayList preselectedVocabularies;
+ private Object preferenceID;
/**
@@ -80,17 +81,20 @@ public class NamedAreaSelectionDialog extends
* @param namedArea
* A namedArea that should be selected when the dialog opens
* @param conversation a {@link eu.etaxonomy.cdm.api.conversation.ConversationHolder} object.
+ * @param preferenceId a class which is used for generating the preference key so that every
+ * dialogs can be grouped to have their own preferences depending on this id
* @param preselectedVocabularyUuids the {@link UUID}s of the pre-selected vocabularies
* @return a {@link eu.etaxonomy.cdm.model.location.NamedArea} object.
*/
- public static NamedArea select(Shell shell, ConversationHolder conversation, NamedArea namedArea, UUID... preselectedVocabularyUuids) {
+ public static NamedArea select(Shell shell, ConversationHolder conversation, NamedArea namedArea, String preferenceId, UUID... preselectedVocabularyUuids) {
NamedAreaSelectionDialog dialog = new NamedAreaSelectionDialog(shell, conversation,
- "Choose an area", false, namedArea, preselectedVocabularyUuids);
+ "Choose an area", false, namedArea, preferenceId, preselectedVocabularyUuids);
return getSelectionFromDialog(dialog);
}
- protected NamedAreaSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, NamedArea namedArea, UUID... preselectedVocabularyUuids) {
+ protected NamedAreaSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, NamedArea namedArea, Object preferenceId, UUID... preselectedVocabularyUuids) {
super(shell, conversation, title, multi, NamedAreaSelectionDialog.class.getCanonicalName(), namedArea);
+ this.preferenceID = preferenceId;
preselectedVocabularies = new ArrayList();
for(int i=0;i tempSelectedVocabularies = new HashSet<>();
for(TermVocabulary vocabulary:selectedVocabularies){
if(preselectedVocabularies.contains(vocabulary)
- || PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary))){
+ || !PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary))){
tempSelectedVocabularies.add(vocabulary);
}
}
@@ -120,13 +124,13 @@ public class NamedAreaSelectionDialog extends
action.setChecked(true);
}
else{
- action.setChecked(PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary)));
+ action.setChecked(!PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary)));
}
}
}
private String getPrefKey(TermVocabulary vocabulary){
- return NamedAreaSelectionDialog.class.toString()+vocabulary.getUuid();
+ return "hide_"+NamedAreaSelectionDialog.class.getCanonicalName()+vocabulary.getUuid()+preferenceID;
}
/** {@inheritDoc} */
@@ -147,9 +151,6 @@ 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 b2eb36969..610334db0 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
@@ -126,10 +126,10 @@ public class SelectionDialogFactory {
}
if(clazz.equals(NamedArea.class)){
if(parentElement instanceof IEntityElement && ((IEntityElement) parentElement).getEntity() instanceof DerivedUnitFacade){
- return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection, Country.uuidCountryVocabulary);
+ return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection, DerivedUnit.class.getCanonicalName(), Country.uuidCountryVocabulary);
}
else{
- return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection);
+ return (T) NamedAreaSelectionDialog.select(shell, conversation, (NamedArea) currentSelection, parentElement.getClass().getCanonicalName());
}
}
if(clazz.equals(Collection.class)){
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectingAreasDetailSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectingAreasDetailSection.java
index ce0fc596f..3ca632399 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectingAreasDetailSection.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/CollectingAreasDetailSection.java
@@ -15,6 +15,7 @@ import java.util.Collection;
import eu.etaxonomy.cdm.api.conversation.ConversationHolder;
import eu.etaxonomy.cdm.api.facade.DerivedUnitFacade;
import eu.etaxonomy.cdm.model.location.NamedArea;
+import eu.etaxonomy.cdm.model.occurrence.FieldUnit;
import eu.etaxonomy.taxeditor.ui.dialog.selection.NamedAreaSelectionDialog;
import eu.etaxonomy.taxeditor.ui.element.CdmFormFactory;
import eu.etaxonomy.taxeditor.ui.element.ICdmFormElement;
@@ -59,7 +60,7 @@ public class CollectingAreasDetailSection extends AbstractEntityCollectionSectio
/** {@inheritDoc} */
@Override
public NamedArea createNewElement() {
- NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null);
+ NamedArea selection = NamedAreaSelectionDialog.select(getLayoutComposite().getShell(), getConversationHolder(), null, FieldUnit.class.getCanonicalName());
return selection;
}
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/GeoScopeDetailSection.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/GeoScopeDetailSection.java
index 8ce8454a5..4c159d941 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/GeoScopeDetailSection.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/section/occurrence/GeoScopeDetailSection.java
@@ -59,7 +59,7 @@ public class GeoScopeDetailSection extends AbstractEntityCollectionSection