Revision 9c128421
Added by Katja Luther over 4 years ago
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/SearchDialogPreferences.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.taxeditor.preference; |
10 | 10 |
|
11 |
import org.eclipse.jface.preference.BooleanFieldEditor; |
|
11 |
import org.eclipse.swt.SWT; |
|
12 |
import org.eclipse.swt.events.SelectionAdapter; |
|
13 |
import org.eclipse.swt.events.SelectionEvent; |
|
14 |
import org.eclipse.swt.events.SelectionListener; |
|
15 |
import org.eclipse.swt.layout.GridData; |
|
16 |
import org.eclipse.swt.widgets.Button; |
|
17 |
import org.eclipse.swt.widgets.Combo; |
|
18 |
import org.eclipse.swt.widgets.Composite; |
|
19 |
import org.eclipse.swt.widgets.Control; |
|
20 |
import org.eclipse.swt.widgets.Label; |
|
12 | 21 |
|
22 |
import eu.etaxonomy.cdm.model.metadata.CdmPreference; |
|
23 |
import eu.etaxonomy.cdm.model.metadata.PreferencePredicate; |
|
13 | 24 |
import eu.etaxonomy.taxeditor.l10n.Messages; |
14 |
import eu.etaxonomy.taxeditor.preference.menu.FieldEditorPreferencePageE4;
|
|
25 |
import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
|
|
15 | 26 |
|
16 | 27 |
/** |
17 | 28 |
* @author k.luther |
18 | 29 |
* @since 16.10.2018 |
19 | 30 |
* |
20 | 31 |
*/ |
21 |
public class SearchDialogPreferences extends FieldEditorPreferencePageE4 { |
|
32 |
public class SearchDialogPreferences extends CdmPreferencePage implements SelectionListener { |
|
33 |
|
|
34 |
protected CdmPreference showIdInSelectionDialogPref; |
|
35 |
protected CdmPreference searchForIdentifierAsDefaultPref; |
|
36 |
protected CdmPreference searchForIdentifierAndTitleCachePref; |
|
37 |
protected CdmPreference sortTaxaByRankAndNamePref; |
|
38 |
protected CdmPreference filterCommonNameReferencesPref; |
|
39 |
|
|
40 |
|
|
41 |
protected Boolean showIdInSelectionDialog; |
|
42 |
protected Boolean searchForIdentifierAsDefault; |
|
43 |
protected Boolean searchForIdentifierAndTitleCache; |
|
44 |
protected Boolean sortTaxaByRankAndName; |
|
45 |
protected Boolean filterCommonNameReferences; |
|
46 |
|
|
47 |
private boolean overrideShowIdInSelectionDialog; |
|
48 |
private boolean overrideSearchForIdentifierAsDefault; |
|
49 |
private boolean overrideSearchForIdentifierAndTitleCache; |
|
50 |
private boolean overrideSortTaxaByRankAndName; |
|
51 |
private boolean overrideFilterCommonNameReferences; |
|
52 |
|
|
53 |
protected Combo showIdInSelectionDialogButton; |
|
54 |
protected Button allowOverrideIsShowIdInSelectionDialogButton; |
|
55 |
protected Combo searchForIdentifierAsDefaultButton; |
|
56 |
protected Button allowOverrideSearchForIdentifierAsDefaultButton; |
|
57 |
protected Combo searchForIdentifierAndTitleCacheButton; |
|
58 |
protected Button allowOverridesSearchForIdentifierAndTitleCacheButton; |
|
59 |
protected Combo sortTaxaByRankAndNameButton; |
|
60 |
protected Button allowOverrideIsSortTaxaByRankAndNameButton; |
|
61 |
protected Combo filterCommonNameReferenceButton; |
|
62 |
protected Button allowOverrideFilterCommonNameReferencesButton; |
|
63 |
|
|
64 |
|
|
65 |
|
|
66 |
@Override |
|
67 |
public void getValues(){ |
|
68 |
|
|
69 |
showIdInSelectionDialogPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowIdInSelectionDialog); |
|
70 |
searchForIdentifierAsDefaultPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.SearchForIdentifierAsDefault); |
|
71 |
searchForIdentifierAndTitleCachePref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.SearchForIdentifierAndTitleCache); |
|
72 |
sortTaxaByRankAndNamePref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.SortTaxaByRankAndName); |
|
73 |
filterCommonNameReferencesPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.CommonNameReferencesWithMarker); |
|
74 |
|
|
75 |
overrideShowIdInSelectionDialog = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.ShowIdInSelectionDialog.getKey())); |
|
76 |
overrideSearchForIdentifierAsDefault = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.SearchForIdentifierAsDefault.getKey())); |
|
77 |
overrideSearchForIdentifierAndTitleCache = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.SearchForIdentifierAndTitleCache.getKey())); |
|
78 |
overrideSortTaxaByRankAndName = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.SortTaxaByRankAndName.getKey())); |
|
79 |
overrideFilterCommonNameReferences = PreferencesUtil.getBooleanValue(PreferencesUtil.createOverridePreferenceString(PreferencePredicate.CommonNameReferencesWithMarker.getKey())); |
|
80 |
|
|
81 |
showIdInSelectionDialog = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSelectionDialog.getKey()); |
|
82 |
searchForIdentifierAsDefault = PreferencesUtil.getBooleanValue(PreferencePredicate.SearchForIdentifierAsDefault.getKey()); |
|
83 |
searchForIdentifierAndTitleCache = PreferencesUtil.getBooleanValue(PreferencePredicate.SearchForIdentifierAndTitleCache.getKey()); |
|
84 |
sortTaxaByRankAndName = PreferencesUtil.getBooleanValue(PreferencePredicate.SortTaxaByRankAndName.getKey()); |
|
85 |
filterCommonNameReferences = PreferencesUtil.getBooleanValue(PreferencePredicate.CommonNameReferencesWithMarker.getKey()); |
|
86 |
|
|
87 |
|
|
88 |
} |
|
89 |
|
|
90 |
|
|
91 |
|
|
92 |
@Override |
|
93 |
public void widgetSelected(SelectionEvent e) { |
|
94 |
setApply(true); |
|
95 |
if (e.getSource().equals(this.showIdInSelectionDialogButton)) { |
|
96 |
String text = showIdInSelectionDialogButton.getText(); |
|
97 |
if(text.startsWith(Messages.Preference_Use_Default)){ |
|
98 |
showIdInSelectionDialog = null; |
|
99 |
if (isAdminPreference){ |
|
100 |
showIdInSelectionDialogPref.setAllowOverride(true); |
|
101 |
allowOverrideIsShowIdInSelectionDialogButton.setSelection(true); |
|
102 |
} |
|
103 |
return; |
|
104 |
} |
|
105 |
if (text.equals(Messages.GeneralPreference_yes)){ |
|
106 |
showIdInSelectionDialog = true; |
|
107 |
}else{ |
|
108 |
showIdInSelectionDialog = false; |
|
109 |
} |
|
110 |
} |
|
111 |
|
|
112 |
if (e.getSource().equals(this.searchForIdentifierAsDefaultButton)) { |
|
113 |
String text = searchForIdentifierAsDefaultButton.getText(); |
|
114 |
if(text.startsWith(Messages.Preference_Use_Default)){ |
|
115 |
searchForIdentifierAsDefault = null; |
|
116 |
if (isAdminPreference){ |
|
117 |
searchForIdentifierAsDefaultPref.setAllowOverride(true); |
|
118 |
allowOverrideSearchForIdentifierAsDefaultButton.setSelection(true); |
|
119 |
} |
|
120 |
return; |
|
121 |
} |
|
122 |
if (text.equals(Messages.GeneralPreference_yes)){ |
|
123 |
searchForIdentifierAsDefault = true; |
|
124 |
}else{ |
|
125 |
searchForIdentifierAsDefault = false; |
|
126 |
} |
|
127 |
} |
|
128 |
|
|
129 |
if (e.getSource().equals(this.searchForIdentifierAndTitleCacheButton)) { |
|
130 |
String text = searchForIdentifierAndTitleCacheButton.getText(); |
|
131 |
if(text.startsWith(Messages.Preference_Use_Default)){ |
|
132 |
searchForIdentifierAndTitleCache = null; |
|
133 |
if (isAdminPreference){ |
|
134 |
searchForIdentifierAndTitleCachePref.setAllowOverride(true); |
|
135 |
allowOverridesSearchForIdentifierAndTitleCacheButton.setSelection(true); |
|
136 |
} |
|
137 |
return; |
|
138 |
} |
|
139 |
if (text.equals(Messages.GeneralPreference_yes)){ |
|
140 |
searchForIdentifierAndTitleCache = true; |
|
141 |
}else{ |
|
142 |
searchForIdentifierAndTitleCache = false; |
|
143 |
} |
|
144 |
} |
|
145 |
|
|
146 |
if (e.getSource().equals(this.sortTaxaByRankAndNameButton)) { |
|
147 |
String text = sortTaxaByRankAndNameButton.getText(); |
|
148 |
if(text.startsWith(Messages.Preference_Use_Default)){ |
|
149 |
sortTaxaByRankAndName = null; |
|
150 |
if (isAdminPreference){ |
|
151 |
sortTaxaByRankAndNamePref.setAllowOverride(true); |
|
152 |
allowOverrideIsSortTaxaByRankAndNameButton.setSelection(true); |
|
153 |
} |
|
154 |
return; |
|
155 |
} |
|
156 |
if (text.equals(Messages.GeneralPreference_yes)){ |
|
157 |
sortTaxaByRankAndName = true; |
|
158 |
}else{ |
|
159 |
sortTaxaByRankAndName = false; |
|
160 |
} |
|
161 |
} |
|
162 |
|
|
163 |
if (e.getSource().equals(this.filterCommonNameReferenceButton)) { |
|
164 |
String text = filterCommonNameReferenceButton.getText(); |
|
165 |
if(text.startsWith(Messages.Preference_Use_Default)){ |
|
166 |
filterCommonNameReferences = null; |
|
167 |
if (isAdminPreference){ |
|
168 |
filterCommonNameReferencesPref.setAllowOverride(true); |
|
169 |
allowOverrideFilterCommonNameReferencesButton.setSelection(true); |
|
170 |
} |
|
171 |
return; |
|
172 |
} |
|
173 |
if (text.equals(Messages.GeneralPreference_yes)){ |
|
174 |
filterCommonNameReferences = true; |
|
175 |
}else{ |
|
176 |
filterCommonNameReferences = false; |
|
177 |
} |
|
178 |
} |
|
179 |
|
|
180 |
|
|
181 |
} |
|
182 |
|
|
183 |
@Override |
|
184 |
public void widgetDefaultSelected(SelectionEvent e) { |
|
185 |
// TODO Auto-generated method stub |
|
186 |
|
|
187 |
} |
|
22 | 188 |
|
23 |
/** |
|
24 |
* {@inheritDoc} |
|
25 |
*/ |
|
26 | 189 |
@Override |
27 |
protected void createFieldEditors() { |
|
28 |
addField(new BooleanFieldEditor(PreferencesUtil.createPreferenceString(IPreferenceKeys.SHOW_ID_IN_ENTITY_SELECTION_DIAOLOG), |
|
29 |
Messages.SearchDialogPreferences_0, |
|
30 |
getFieldEditorParent())); |
|
31 |
addField(new BooleanFieldEditor(PreferencesUtil.createPreferenceString(IPreferenceKeys.IS_SEARCH_FOR_IDENTIFIER_AS_DEFAULT), |
|
32 |
Messages.SearchDialogPreferences_1, |
|
33 |
getFieldEditorParent())); |
|
34 |
addField(new BooleanFieldEditor(PreferencesUtil.createPreferenceString(IPreferenceKeys.SEARCH_FOR_IDENTIFIER_AND_TITLECACHE), |
|
35 |
Messages.SearchDialogPreferences_2, |
|
36 |
getFieldEditorParent())); |
|
37 |
addField(new BooleanFieldEditor(PreferencesUtil.createPreferenceString(IPreferenceKeys.SORT_TAXA_BY_RANK_AND_NAME), |
|
38 |
Messages.SearchDialogPreferences_3, |
|
39 |
getFieldEditorParent())); |
|
40 |
addField(new BooleanFieldEditor(PreferencesUtil.createPreferenceString( |
|
41 |
IPreferenceKeys.FILTER_COMMON_NAME_REFERENCES), |
|
42 |
Messages.SearchDialogPreferences_4, getFieldEditorParent())); |
|
190 |
protected Control createContents(Composite parent) { |
|
191 |
getValues(); |
|
43 | 192 |
|
193 |
Composite titleComp = createComposite(parent); |
|
194 |
GridData gridData = createTextGridData(); |
|
44 | 195 |
|
196 |
Label separator= new Label(titleComp, SWT.HORIZONTAL | SWT.SEPARATOR); |
|
197 |
separator.setLayoutData(gridData); |
|
198 |
separator.setVisible(false); |
|
199 |
showIdInSelectionDialogButton = createBooleanCombo(titleComp, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowIdInSelectionDialog, Messages.DatabasePreferncesPage_Show_Id_In_SelectionDialog, isAdminPreference); |
|
45 | 200 |
|
201 |
showIdInSelectionDialogButton.addSelectionListener(this); |
|
202 |
int index = 0; |
|
203 |
for (String itemLabel : showIdInSelectionDialogButton.getItems()) { |
|
204 |
if (itemLabel.startsWith(Messages.Preference_Use_Default) && showIdInSelectionDialog == null) { |
|
205 |
showIdInSelectionDialogButton.select(index); |
|
206 |
break; |
|
207 |
} |
|
208 |
if (itemLabel.equals(Messages.GeneralPreference_yes) && showIdInSelectionDialog){ |
|
209 |
showIdInSelectionDialogButton.select(index); |
|
210 |
break; |
|
211 |
} |
|
212 |
if (itemLabel.equals(Messages.GeneralPreference_no) && !showIdInSelectionDialog){ |
|
213 |
showIdInSelectionDialogButton.select(index); |
|
214 |
break; |
|
215 |
} |
|
216 |
index++; |
|
217 |
} |
|
218 |
if (!isAdminPreference && showIdInSelectionDialogPref != null){ |
|
219 |
showIdInSelectionDialogButton.setEnabled(showIdInSelectionDialogPref.isAllowOverride()); |
|
220 |
} |
|
46 | 221 |
|
222 |
if (isAdminPreference){ |
|
223 |
allowOverrideIsShowIdInSelectionDialogButton = createAllowOverrideButton(titleComp); |
|
224 |
allowOverrideIsShowIdInSelectionDialogButton.setSelection(showIdInSelectionDialogPref != null? showIdInSelectionDialogPref.isAllowOverride(): true); |
|
225 |
allowOverrideIsShowIdInSelectionDialogButton.addSelectionListener(new SelectionAdapter(){ |
|
226 |
@Override |
|
227 |
public void widgetSelected(SelectionEvent e) { |
|
228 |
setApply(true); |
|
229 |
if (showIdInSelectionDialogPref == null){ |
|
230 |
showIdInSelectionDialogPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowIdInSelectionDialog, null); |
|
231 |
} |
|
232 |
showIdInSelectionDialogPref.setAllowOverride(allowOverrideIsShowIdInSelectionDialogButton.getSelection()); |
|
233 |
} |
|
234 |
}); |
|
235 |
} |
|
236 |
|
|
237 |
Composite composite = createComposite(parent); |
|
238 |
//composite.setEnabled(isShowSpecimenRelatedIssues); |
|
239 |
gridData = createTextGridData(); |
|
240 |
|
|
241 |
separator= new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR); |
|
242 |
separator.setLayoutData(gridData); |
|
243 |
|
|
244 |
searchForIdentifierAsDefaultButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.SearchForIdentifierAsDefault, Messages.DatabasePreferncesPage_Search_for_identifier_as_default, isAdminPreference); |
|
245 |
|
|
246 |
searchForIdentifierAsDefaultButton.addSelectionListener(this); |
|
247 |
index = 0; |
|
248 |
for (String itemLabel : searchForIdentifierAsDefaultButton.getItems()) { |
|
249 |
if (searchForIdentifierAsDefault == null && itemLabel.startsWith(Messages.Preference_Use_Default)) { |
|
250 |
searchForIdentifierAsDefaultButton.select(index); |
|
251 |
break; |
|
252 |
} |
|
253 |
if (searchForIdentifierAsDefault != null && itemLabel.equals(Messages.GeneralPreference_yes) && searchForIdentifierAsDefault){ |
|
254 |
searchForIdentifierAsDefaultButton.select(index); |
|
255 |
break; |
|
256 |
} |
|
257 |
if (searchForIdentifierAsDefault != null && itemLabel.equals(Messages.GeneralPreference_no) && !searchForIdentifierAsDefault){ |
|
258 |
searchForIdentifierAsDefaultButton.select(index); |
|
259 |
break; |
|
260 |
} |
|
261 |
index++; |
|
262 |
} |
|
263 |
if (isAdminPreference){ |
|
264 |
allowOverrideSearchForIdentifierAsDefaultButton = createAllowOverrideButton(composite); |
|
265 |
allowOverrideSearchForIdentifierAsDefaultButton.setSelection(searchForIdentifierAsDefaultPref != null?searchForIdentifierAsDefaultPref.isAllowOverride(): true); |
|
266 |
allowOverrideSearchForIdentifierAsDefaultButton.addSelectionListener(new SelectionAdapter(){ |
|
267 |
@Override |
|
268 |
public void widgetSelected(SelectionEvent e) { |
|
269 |
setApply(true); |
|
270 |
if (searchForIdentifierAsDefaultPref == null){ |
|
271 |
searchForIdentifierAsDefaultPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAsDefault, null); |
|
272 |
} |
|
273 |
searchForIdentifierAsDefaultPref.setAllowOverride(allowOverrideSearchForIdentifierAsDefaultButton.getSelection()); |
|
274 |
} |
|
275 |
}); |
|
276 |
} |
|
277 |
if(!isAdminPreference && searchForIdentifierAsDefaultPref != null){ |
|
278 |
searchForIdentifierAsDefaultButton.setEnabled(searchForIdentifierAsDefaultPref.isAllowOverride()); |
|
279 |
} |
|
280 |
|
|
281 |
searchForIdentifierAndTitleCacheButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.SearchForIdentifierAndTitleCache, Messages.DatabasePreferncesPage_search_for_identifier_and_titleCache, isAdminPreference); |
|
282 |
searchForIdentifierAndTitleCacheButton.addSelectionListener(this); |
|
283 |
index = 0; |
|
284 |
for (String itemLabel : searchForIdentifierAndTitleCacheButton.getItems()) { |
|
285 |
if (searchForIdentifierAndTitleCache == null && itemLabel.startsWith(Messages.Preference_Use_Default)) { |
|
286 |
searchForIdentifierAndTitleCacheButton.select(index); |
|
287 |
break; |
|
288 |
} |
|
289 |
if (searchForIdentifierAndTitleCache != null && itemLabel.equals(Messages.GeneralPreference_yes) && searchForIdentifierAndTitleCache){ |
|
290 |
searchForIdentifierAndTitleCacheButton.select(index); |
|
291 |
break; |
|
292 |
} |
|
293 |
if (searchForIdentifierAndTitleCache != null && itemLabel.equals(Messages.GeneralPreference_no) && !searchForIdentifierAndTitleCache){ |
|
294 |
searchForIdentifierAndTitleCacheButton.select(index); |
|
295 |
break; |
|
296 |
} |
|
297 |
index++; |
|
298 |
} |
|
299 |
if(!isAdminPreference && searchForIdentifierAndTitleCachePref != null){ |
|
300 |
searchForIdentifierAndTitleCacheButton.setEnabled(searchForIdentifierAndTitleCachePref.isAllowOverride()); |
|
301 |
} |
|
302 |
|
|
303 |
if (isAdminPreference){ |
|
304 |
allowOverridesSearchForIdentifierAndTitleCacheButton = createAllowOverrideButton(composite); |
|
305 |
allowOverridesSearchForIdentifierAndTitleCacheButton.setSelection(searchForIdentifierAndTitleCachePref != null?searchForIdentifierAndTitleCachePref.isAllowOverride():true); |
|
306 |
allowOverridesSearchForIdentifierAndTitleCacheButton.addSelectionListener(new SelectionAdapter(){ |
|
307 |
@Override |
|
308 |
public void widgetSelected(SelectionEvent e) { |
|
309 |
setApply(true); |
|
310 |
if (searchForIdentifierAndTitleCachePref == null){ |
|
311 |
searchForIdentifierAndTitleCachePref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAndTitleCache, null); |
|
312 |
} |
|
313 |
searchForIdentifierAndTitleCachePref.setAllowOverride(allowOverridesSearchForIdentifierAndTitleCacheButton.getSelection()); |
|
314 |
} |
|
315 |
}); |
|
316 |
} |
|
317 |
|
|
318 |
sortTaxaByRankAndNameButton =createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.SortTaxaByRankAndName, Messages.DatabasePreferncesPage_Sort_Taxa_By_Name_And_Rank, isAdminPreference); |
|
319 |
|
|
320 |
|
|
321 |
sortTaxaByRankAndNameButton.addSelectionListener(this); |
|
322 |
index = 0; |
|
323 |
for (String itemLabel : sortTaxaByRankAndNameButton.getItems()) { |
|
324 |
if (sortTaxaByRankAndName == null && itemLabel.startsWith(Messages.Preference_Use_Default)) { |
|
325 |
sortTaxaByRankAndNameButton.select(index); |
|
326 |
break; |
|
327 |
} |
|
328 |
if (sortTaxaByRankAndName != null && itemLabel.equals(Messages.GeneralPreference_yes) && sortTaxaByRankAndName){ |
|
329 |
sortTaxaByRankAndNameButton.select(index); |
|
330 |
break; |
|
331 |
} |
|
332 |
if (sortTaxaByRankAndName != null && itemLabel.equals(Messages.GeneralPreference_no) && !sortTaxaByRankAndName){ |
|
333 |
sortTaxaByRankAndNameButton.select(index); |
|
334 |
break; |
|
335 |
} |
|
336 |
index++; |
|
337 |
} |
|
338 |
if ( !isAdminPreference && sortTaxaByRankAndNamePref != null){ |
|
339 |
sortTaxaByRankAndNameButton.setEnabled(sortTaxaByRankAndNamePref.isAllowOverride()); |
|
340 |
} |
|
341 |
|
|
342 |
if (isAdminPreference){ |
|
343 |
allowOverrideIsSortTaxaByRankAndNameButton = createAllowOverrideButton(composite); |
|
344 |
allowOverrideIsSortTaxaByRankAndNameButton.setSelection(sortTaxaByRankAndNamePref != null? sortTaxaByRankAndNamePref.isAllowOverride(): true); |
|
345 |
allowOverrideIsSortTaxaByRankAndNameButton.addSelectionListener(new SelectionAdapter(){ |
|
346 |
@Override |
|
347 |
public void widgetSelected(SelectionEvent e) { |
|
348 |
setApply(true); |
|
349 |
if (sortTaxaByRankAndNamePref == null){ |
|
350 |
sortTaxaByRankAndNamePref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SortTaxaByRankAndName, null); |
|
351 |
} |
|
352 |
sortTaxaByRankAndNamePref.setAllowOverride(allowOverrideIsSortTaxaByRankAndNameButton.getSelection()); |
|
353 |
} |
|
354 |
}); |
|
355 |
} |
|
356 |
|
|
357 |
filterCommonNameReferenceButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.CommonNameReferencesWithMarker, Messages.DatabasePreferncesPage_CommonNameFilter, isAdminPreference); |
|
358 |
filterCommonNameReferenceButton.addSelectionListener(this); |
|
359 |
|
|
360 |
index = 0; |
|
361 |
for (String itemLabel: filterCommonNameReferenceButton.getItems()) { |
|
362 |
if (filterCommonNameReferences == null && itemLabel.startsWith(Messages.Preference_Use_Default)) { |
|
363 |
filterCommonNameReferenceButton.select(index); |
|
364 |
break; |
|
365 |
} |
|
366 |
if (filterCommonNameReferences != null && itemLabel.equals(Messages.GeneralPreference_yes) && filterCommonNameReferences){ |
|
367 |
filterCommonNameReferenceButton.select(index); |
|
368 |
break; |
|
369 |
} |
|
370 |
if (filterCommonNameReferences != null && itemLabel.equals(Messages.GeneralPreference_no) && !filterCommonNameReferences){ |
|
371 |
filterCommonNameReferenceButton.select(index); |
|
372 |
break; |
|
373 |
} |
|
374 |
index++; |
|
375 |
} |
|
376 |
if (!isAdminPreference && filterCommonNameReferencesPref != null){ |
|
377 |
filterCommonNameReferenceButton.setEnabled(filterCommonNameReferencesPref.isAllowOverride()); |
|
378 |
} |
|
379 |
|
|
380 |
if (isAdminPreference){ |
|
381 |
allowOverrideFilterCommonNameReferencesButton = createAllowOverrideButton(composite); |
|
382 |
allowOverrideFilterCommonNameReferencesButton.setSelection(filterCommonNameReferencesPref != null? filterCommonNameReferencesPref.isAllowOverride():true); |
|
383 |
allowOverrideFilterCommonNameReferencesButton.addSelectionListener(new SelectionAdapter(){ |
|
384 |
@Override |
|
385 |
public void widgetSelected(SelectionEvent e) { |
|
386 |
setApply(true); |
|
387 |
if (filterCommonNameReferencesPref == null){ |
|
388 |
filterCommonNameReferencesPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.CommonNameReferencesWithMarker, null); |
|
389 |
} |
|
390 |
filterCommonNameReferencesPref.setAllowOverride(allowOverrideFilterCommonNameReferencesButton.getSelection()); |
|
391 |
} |
|
392 |
}); |
|
393 |
} |
|
394 |
|
|
395 |
|
|
396 |
|
|
397 |
return composite; |
|
398 |
} |
|
399 |
|
|
400 |
@Override |
|
401 |
protected void performDefaults() { |
|
402 |
//TODO |
|
403 |
super.performDefaults(); |
|
47 | 404 |
} |
48 | 405 |
|
406 |
@Override |
|
407 |
public boolean performOk(){ |
|
408 |
if (!isApply()){ |
|
409 |
return true; |
|
410 |
} |
|
411 |
boolean override = false; |
|
412 |
if (showIdInSelectionDialog != null ) { |
|
413 |
override = true; |
|
414 |
PreferencesUtil.setStringValue(PreferencePredicate.ShowIdInSelectionDialog.getKey(), showIdInSelectionDialog.toString()); |
|
415 |
} |
|
416 |
PreferencesUtil.setBooleanValue( |
|
417 |
PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowIdInSelectionDialog.getKey()), |
|
418 |
override); |
|
419 |
|
|
420 |
override = false; |
|
421 |
|
|
422 |
if(searchForIdentifierAsDefault != null){ |
|
423 |
override = true; |
|
424 |
PreferencesUtil.setStringValue(PreferencePredicate.SearchForIdentifierAsDefault.getKey(), searchForIdentifierAsDefault.toString()); |
|
425 |
} |
|
426 |
PreferencesUtil.setBooleanValue( |
|
427 |
PreferencesUtil.prefOverrideKey(PreferencePredicate.SearchForIdentifierAsDefault.getKey()), |
|
428 |
override); |
|
429 |
override = false; |
|
430 |
|
|
431 |
if(searchForIdentifierAndTitleCache != null){ |
|
432 |
override = true; |
|
433 |
PreferencesUtil.setStringValue(PreferencePredicate.SearchForIdentifierAndTitleCache.getKey(), searchForIdentifierAndTitleCache.toString()); |
|
434 |
} |
|
435 |
PreferencesUtil.setBooleanValue( |
|
436 |
PreferencesUtil.prefOverrideKey(PreferencePredicate.SearchForIdentifierAndTitleCache.getKey()), |
|
437 |
override); |
|
438 |
override = false; |
|
439 |
|
|
440 |
if(sortTaxaByRankAndName != null){ |
|
441 |
override = true; |
|
442 |
PreferencesUtil.setStringValue(PreferencePredicate.SortTaxaByRankAndName.getKey(), sortTaxaByRankAndName.toString()); |
|
443 |
} |
|
444 |
PreferencesUtil.setBooleanValue( |
|
445 |
PreferencesUtil.prefOverrideKey(PreferencePredicate.SortTaxaByRankAndName.getKey()), |
|
446 |
override); |
|
447 |
override = false; |
|
448 |
|
|
449 |
|
|
450 |
if(filterCommonNameReferences != null){ |
|
451 |
override = true; |
|
452 |
PreferencesUtil.setStringValue(PreferencePredicate.CommonNameReferencesWithMarker.getKey(), filterCommonNameReferences.toString()); |
|
453 |
} |
|
454 |
PreferencesUtil.setBooleanValue( |
|
455 |
PreferencesUtil.prefOverrideKey(PreferencePredicate.CommonNameReferencesWithMarker.getKey()), |
|
456 |
override); |
|
457 |
override = false; |
|
458 |
|
|
459 |
return true; |
|
460 |
} |
|
461 |
|
|
462 |
|
|
49 | 463 |
} |
Also available in: Unified diff
ref #8385: adapt local and db preference pages