Revision 0a1dde23
Added by Patrick Plitzner over 7 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/ui/dialog/selection/NamedAreaSelectionDialog.java | ||
---|---|---|
34 | 34 |
import eu.etaxonomy.cdm.persistence.dto.UuidAndTitleCache; |
35 | 35 |
import eu.etaxonomy.taxeditor.model.MessagingUtils; |
36 | 36 |
import eu.etaxonomy.taxeditor.newWizard.AbstractNewEntityWizard; |
37 |
import eu.etaxonomy.taxeditor.preference.PreferencesUtil; |
|
37 | 38 |
import eu.etaxonomy.taxeditor.store.CdmStore; |
38 | 39 |
|
39 | 40 |
/** |
... | ... | |
62 | 63 |
}else{ |
63 | 64 |
selectedVocabularies.remove(vocabulary); |
64 | 65 |
} |
66 |
PreferencesUtil.getPreferenceStore().setValue(getPrefKey(vocabulary), isChecked()); |
|
65 | 67 |
initModel(); |
66 | 68 |
} |
67 | 69 |
} |
... | ... | |
89 | 91 |
|
90 | 92 |
protected NamedAreaSelectionDialog(Shell shell, ConversationHolder conversation, String title, boolean multi, NamedArea namedArea, UUID... preselectedVocabularyUuids) { |
91 | 93 |
super(shell, conversation, title, multi, NamedAreaSelectionDialog.class.getCanonicalName(), namedArea); |
92 |
if(preselectedVocabularyUuids.length>0){ |
|
93 |
preselectedVocabularies = new ArrayList<TermVocabulary>(); |
|
94 |
for(int i=0;i<preselectedVocabularyUuids.length;i++){ |
|
95 |
TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]); |
|
96 |
preselectedVocabularies.add(preselectedVocabulary); |
|
97 |
} |
|
98 |
selectedVocabularies.retainAll(preselectedVocabularies); |
|
99 |
initModel();//re-init to consider pre-selected vocabularies |
|
94 |
preselectedVocabularies = new ArrayList<TermVocabulary>(); |
|
95 |
for(int i=0;i<preselectedVocabularyUuids.length;i++){ |
|
96 |
TermVocabulary preselectedVocabulary = CdmStore.getService(IVocabularyService.class).find(preselectedVocabularyUuids[i]); |
|
97 |
preselectedVocabularies.add(preselectedVocabulary); |
|
100 | 98 |
} |
99 |
Collection<TermVocabulary> tempSelectedVocabularies = new HashSet<>(); |
|
100 |
for(TermVocabulary vocabulary:selectedVocabularies){ |
|
101 |
if(preselectedVocabularies.contains(vocabulary) |
|
102 |
|| PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary))){ |
|
103 |
tempSelectedVocabularies.add(vocabulary); |
|
104 |
} |
|
105 |
} |
|
106 |
selectedVocabularies = tempSelectedVocabularies; |
|
107 |
initModel();//re-init to consider pre-selected vocabularies |
|
101 | 108 |
} |
102 | 109 |
|
103 | 110 |
/** {@inheritDoc} */ |
... | ... | |
109 | 116 |
for(TermVocabulary<NamedArea> vocabulary : getAvailableVocabularies()){ |
110 | 117 |
IncludeNamedAreaVocabulary action = new IncludeNamedAreaVocabulary(vocabulary); |
111 | 118 |
menuManager.add(action); |
112 |
if(preselectedVocabularies==null || preselectedVocabularies.isEmpty() || preselectedVocabularies.contains(vocabulary)) {
|
|
119 |
if(preselectedVocabularies.contains(vocabulary)) { |
|
113 | 120 |
action.setChecked(true); |
114 | 121 |
} |
122 |
else{ |
|
123 |
action.setChecked(PreferencesUtil.getPreferenceStore().getBoolean(getPrefKey(vocabulary))); |
|
124 |
} |
|
115 | 125 |
} |
116 | 126 |
} |
127 |
|
|
128 |
private String getPrefKey(TermVocabulary vocabulary){ |
|
129 |
return NamedAreaSelectionDialog.class.toString()+vocabulary.getUuid(); |
|
130 |
} |
|
117 | 131 |
|
118 | 132 |
/** {@inheritDoc} */ |
119 | 133 |
@Override |
... | ... | |
133 | 147 |
@Override |
134 | 148 |
protected void init() { |
135 | 149 |
selectedVocabularies = getAvailableVocabularies(); |
150 |
for(TermVocabulary vocabulary:selectedVocabularies){ |
|
151 |
PreferencesUtil.getPreferenceStore().setDefault(getPrefKey(vocabulary), true); |
|
152 |
} |
|
136 | 153 |
} |
137 | 154 |
|
138 | 155 |
private List<TermVocabulary> getAvailableVocabularies(){ |
Also available in: Unified diff
fix #6049 Store vocabulary filters for NamedArea selection dialogs in
preferences