*/
package eu.etaxonomy.taxeditor.preference;
-import org.eclipse.jface.preference.BooleanFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.SelectionAdapter;
+import org.eclipse.swt.events.SelectionEvent;
+import org.eclipse.swt.events.SelectionListener;
+import org.eclipse.swt.layout.GridData;
+import org.eclipse.swt.widgets.Button;
+import org.eclipse.swt.widgets.Combo;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Label;
+import eu.etaxonomy.cdm.model.metadata.CdmPreference;
+import eu.etaxonomy.cdm.model.metadata.NamedAreaSearchField;
+import eu.etaxonomy.cdm.model.metadata.PreferencePredicate;
import eu.etaxonomy.taxeditor.l10n.Messages;
-import eu.etaxonomy.taxeditor.preference.menu.FieldEditorPreferencePageE4;
+import eu.etaxonomy.taxeditor.preference.menu.CdmPreferencePage;
/**
* @author k.luther
* @since 16.10.2018
*
*/
-public class SearchDialogPreferences extends FieldEditorPreferencePageE4 {
+public class SearchDialogPreferences extends CdmPreferencePage implements SelectionListener {
+
+ protected CdmPreference showIdInSelectionDialogPref;
+ protected CdmPreference searchForIdentifierAsDefaultPref;
+ protected CdmPreference searchForIdentifierAndTitleCachePref;
+ protected CdmPreference sortTaxaByRankAndNamePref;
+ protected CdmPreference filterCommonNameReferencesPref;
+ protected CdmPreference searchNamedAreasByAbbrevPref;
+
+
+ protected Boolean showIdInSelectionDialog;
+ protected Boolean searchForIdentifierAsDefault;
+ protected Boolean searchForIdentifierAndTitleCache;
+ protected Boolean sortTaxaByRankAndName;
+ protected Boolean filterCommonNameReferences;
+ protected NamedAreaSearchField searchNamedAreasByAbbrev;
+
+ private boolean overrideShowIdInSelectionDialog = true;
+ private boolean overrideSearchForIdentifierAsDefault = true;
+ private boolean overrideSearchForIdentifierAndTitleCache = true;
+ private boolean overrideSortTaxaByRankAndName = true;
+ private boolean overrideFilterCommonNameReferences = true;
+ private boolean overrideSearchNamedAreasByAbbrev = true;
+
+ protected Combo showIdInSelectionDialogButton;
+ protected Button allowOverrideIsShowIdInSelectionDialogButton;
+ protected Combo searchForIdentifierAsDefaultButton;
+ protected Button allowOverrideSearchForIdentifierAsDefaultButton;
+ protected Combo searchForIdentifierAndTitleCacheButton;
+ protected Button allowOverridesSearchForIdentifierAndTitleCacheButton;
+ protected Combo sortTaxaByRankAndNameButton;
+ protected Button allowOverrideIsSortTaxaByRankAndNameButton;
+ protected Combo filterCommonNameReferenceButton;
+ protected Button allowOverrideFilterCommonNameReferencesButton;
+ protected Combo searchNamedAreasByAbbrevButton;
+ protected Button allowOverridesearchNamedAreasByAbbrevButton;
+
+
+
+ @Override
+ public void getValues(){
+
+ showIdInSelectionDialogPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.ShowIdInSelectionDialog);
+ searchForIdentifierAsDefaultPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.SearchForIdentifierAsDefault);
+ searchForIdentifierAndTitleCachePref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.SearchForIdentifierAndTitleCache);
+ sortTaxaByRankAndNamePref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.SortTaxaByRankAndName);
+ filterCommonNameReferencesPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.CommonNameReferencesWithMarker);
+ searchNamedAreasByAbbrevPref = PreferencesUtil.getPreferenceFromDB(PreferencePredicate.NamedAreaSearchForAbbrev);
+
+ overrideShowIdInSelectionDialog = PreferencesUtil.getOverrideForPreference(PreferencePredicate.ShowIdInSelectionDialog.getKey());
+ overrideSearchForIdentifierAsDefault = PreferencesUtil.getOverrideForPreference(PreferencePredicate.SearchForIdentifierAsDefault.getKey());
+ overrideSearchForIdentifierAndTitleCache = PreferencesUtil.getOverrideForPreference(PreferencePredicate.SearchForIdentifierAndTitleCache.getKey());
+ overrideSortTaxaByRankAndName = PreferencesUtil.getOverrideForPreference(PreferencePredicate.SortTaxaByRankAndName.getKey());
+ overrideFilterCommonNameReferences = PreferencesUtil.getOverrideForPreference(PreferencePredicate.CommonNameReferencesWithMarker.getKey());
+ overrideSearchNamedAreasByAbbrev = PreferencesUtil.getOverrideForPreference(PreferencePredicate.NamedAreaSearchForAbbrev.getKey());
+
+ if(overrideShowIdInSelectionDialog){
+ showIdInSelectionDialog = PreferencesUtil.getBooleanValue(PreferencePredicate.ShowIdInSelectionDialog.getKey(), true);
+ }
+ if(overrideSearchForIdentifierAsDefault){
+ searchForIdentifierAsDefault = PreferencesUtil.getBooleanValue(PreferencePredicate.SearchForIdentifierAsDefault.getKey(), true);
+ }
+ if(overrideSearchForIdentifierAndTitleCache){
+ searchForIdentifierAndTitleCache = PreferencesUtil.getBooleanValue(PreferencePredicate.SearchForIdentifierAndTitleCache.getKey(), true);
+ }
+ if(overrideSortTaxaByRankAndName){
+ sortTaxaByRankAndName = PreferencesUtil.getBooleanValue(PreferencePredicate.SortTaxaByRankAndName.getKey(), true);
+ }
+ if(overrideFilterCommonNameReferences){
+ filterCommonNameReferences = PreferencesUtil.getBooleanValue(PreferencePredicate.CommonNameReferencesWithMarker.getKey(), true);
+ }
+ if(overrideSearchNamedAreasByAbbrev){
+ String stringValue = PreferencesUtil.getStringValue(PreferencePredicate.NamedAreaSearchForAbbrev.getKey(), true);
+ searchNamedAreasByAbbrev = stringValue != null? NamedAreaSearchField.byKey(stringValue):null;
+ }
+
+
+
+ }
+
+
+
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setApply(true);
+ if (e.getSource().equals(this.showIdInSelectionDialogButton)) {
+ String text = showIdInSelectionDialogButton.getText();
+ if(text.startsWith(Messages.Preference_Use_Default)){
+ showIdInSelectionDialog = null;
+ return;
+ }
+
+ if (text.equals(Messages.GeneralPreference_yes)){
+ showIdInSelectionDialog = true;
+ }else{
+ showIdInSelectionDialog = false;
+ }
+ }
+
+ if (e.getSource().equals(this.searchForIdentifierAsDefaultButton)) {
+ String text = searchForIdentifierAsDefaultButton.getText();
+ if(text.startsWith(Messages.Preference_Use_Default)){
+ searchForIdentifierAsDefault = null;
+ return;
+ }
+
+ if (text.equals(Messages.GeneralPreference_yes)){
+ searchForIdentifierAsDefault = true;
+ }else{
+ searchForIdentifierAsDefault = false;
+ }
+ }
+
+ if (e.getSource().equals(this.searchForIdentifierAndTitleCacheButton)) {
+ String text = searchForIdentifierAndTitleCacheButton.getText();
+ if(text.startsWith(Messages.Preference_Use_Default)){
+ searchForIdentifierAndTitleCache = null;
+ return;
+ }
+
+ if (text.equals(Messages.GeneralPreference_yes)){
+ searchForIdentifierAndTitleCache = true;
+ }else{
+ searchForIdentifierAndTitleCache = false;
+ }
+ }
+
+ if (e.getSource().equals(this.sortTaxaByRankAndNameButton)) {
+ String text = sortTaxaByRankAndNameButton.getText();
+ if(text.startsWith(Messages.Preference_Use_Default)){
+ sortTaxaByRankAndName = null;
+ return;
+ }
+
+ if (text.equals(Messages.GeneralPreference_yes)){
+ sortTaxaByRankAndName = true;
+ }else{
+ sortTaxaByRankAndName = false;
+ }
+ }
+
+ if (e.getSource().equals(this.filterCommonNameReferenceButton)) {
+ String text = filterCommonNameReferenceButton.getText();
+ if(text.startsWith(Messages.Preference_Use_Default)){
+ filterCommonNameReferences = null;
+ return;
+ }
+
+ if (text.equals(Messages.GeneralPreference_yes)){
+ filterCommonNameReferences = true;
+ }else{
+ filterCommonNameReferences = false;
+ }
+ }
+
+ if (e.getSource().equals(this.searchNamedAreasByAbbrevButton)) {
+ String text = searchNamedAreasByAbbrevButton.getText();
+ if(text.startsWith(Messages.Preference_Use_Default)){
+ searchNamedAreasByAbbrev = null;
+ return;
+ }
+ searchNamedAreasByAbbrev = (NamedAreaSearchField) searchNamedAreasByAbbrevButton.getData(text);
+
+ }
+
+
+
+ }
+
+ @Override
+ public void widgetDefaultSelected(SelectionEvent e) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected Control createContents(Composite parent) {
+ getValues();
+
+ Composite titleComp = createComposite(parent);
+ GridData gridData = createTextGridData();
+
+ Label separator= new Label(titleComp, SWT.HORIZONTAL | SWT.SEPARATOR);
+ separator.setLayoutData(gridData);
+ separator.setVisible(false);
+ showIdInSelectionDialogButton = createBooleanCombo(titleComp, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.ShowIdInSelectionDialog, Messages.DatabasePreferncesPage_Show_Id_In_SelectionDialog, isAdminPreference);
+
+ showIdInSelectionDialogButton.addSelectionListener(this);
+
+ if (!isAdminPreference && showIdInSelectionDialogPref != null){
+ showIdInSelectionDialogButton.setEnabled(showIdInSelectionDialogPref.isAllowOverride());
+ }
+
+ if (isAdminPreference){
+ allowOverrideIsShowIdInSelectionDialogButton = createAllowOverrideButton(titleComp);
+ allowOverrideIsShowIdInSelectionDialogButton.setSelection(showIdInSelectionDialogPref != null? showIdInSelectionDialogPref.isAllowOverride(): true);
+ allowOverrideIsShowIdInSelectionDialogButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setApply(true);
+ if (showIdInSelectionDialogPref == null){
+ showIdInSelectionDialogPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.ShowIdInSelectionDialog, null);
+ }
+ showIdInSelectionDialogPref.setAllowOverride(allowOverrideIsShowIdInSelectionDialogButton.getSelection());
+ }
+ });
+ }
+
+ Composite composite = createComposite(parent);
+ //composite.setEnabled(isShowSpecimenRelatedIssues);
+ gridData = createTextGridData();
+
+ separator= new Label(composite, SWT.HORIZONTAL | SWT.SEPARATOR);
+ separator.setLayoutData(gridData);
+
+ searchForIdentifierAsDefaultButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.SearchForIdentifierAsDefault, Messages.DatabasePreferncesPage_Search_for_identifier_as_default, isAdminPreference);
+
+ searchForIdentifierAsDefaultButton.addSelectionListener(this);
+
+ if (isAdminPreference){
+ allowOverrideSearchForIdentifierAsDefaultButton = createAllowOverrideButton(composite);
+ allowOverrideSearchForIdentifierAsDefaultButton.setSelection(searchForIdentifierAsDefaultPref != null?searchForIdentifierAsDefaultPref.isAllowOverride(): true);
+ allowOverrideSearchForIdentifierAsDefaultButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setApply(true);
+ if (searchForIdentifierAsDefaultPref == null && !allowOverrideSearchForIdentifierAsDefaultButton.getSelection()){
+ searchForIdentifierAsDefaultPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAsDefault, null);
+ }
+ searchForIdentifierAsDefaultPref.setAllowOverride(allowOverrideSearchForIdentifierAsDefaultButton.getSelection());
+ }
+ });
+ }
+ if(!isAdminPreference && searchForIdentifierAsDefaultPref != null){
+ searchForIdentifierAsDefaultButton.setEnabled(searchForIdentifierAsDefaultPref.isAllowOverride());
+ }
+
+ searchForIdentifierAndTitleCacheButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.SearchForIdentifierAndTitleCache, Messages.DatabasePreferncesPage_search_for_identifier_and_titleCache, isAdminPreference);
+ searchForIdentifierAndTitleCacheButton.addSelectionListener(this);
+
+ if(!isAdminPreference && searchForIdentifierAndTitleCachePref != null){
+ searchForIdentifierAndTitleCacheButton.setEnabled(searchForIdentifierAndTitleCachePref.isAllowOverride());
+ }
+
+ if (isAdminPreference){
+ allowOverridesSearchForIdentifierAndTitleCacheButton = createAllowOverrideButton(composite);
+ allowOverridesSearchForIdentifierAndTitleCacheButton.setSelection(searchForIdentifierAndTitleCachePref != null?searchForIdentifierAndTitleCachePref.isAllowOverride():true);
+ allowOverridesSearchForIdentifierAndTitleCacheButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setApply(true);
+ if (searchForIdentifierAndTitleCachePref == null && !allowOverridesSearchForIdentifierAndTitleCacheButton.getSelection()){
+ searchForIdentifierAndTitleCachePref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SearchForIdentifierAndTitleCache, null);
+ }
+ searchForIdentifierAndTitleCachePref.setAllowOverride(allowOverridesSearchForIdentifierAndTitleCacheButton.getSelection());
+ }
+ });
+ }
+
+ sortTaxaByRankAndNameButton =createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.SortTaxaByRankAndName, Messages.DatabasePreferncesPage_Sort_Taxa_By_Name_And_Rank, isAdminPreference);
+
+
+ sortTaxaByRankAndNameButton.addSelectionListener(this);
+
+ if ( !isAdminPreference && sortTaxaByRankAndNamePref != null){
+ sortTaxaByRankAndNameButton.setEnabled(sortTaxaByRankAndNamePref.isAllowOverride());
+ }
+
+ if (isAdminPreference){
+ allowOverrideIsSortTaxaByRankAndNameButton = createAllowOverrideButton(composite);
+ allowOverrideIsSortTaxaByRankAndNameButton.setSelection(sortTaxaByRankAndNamePref != null? sortTaxaByRankAndNamePref.isAllowOverride(): true);
+ allowOverrideIsSortTaxaByRankAndNameButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setApply(true);
+ if (sortTaxaByRankAndNamePref == null && !allowOverrideIsSortTaxaByRankAndNameButton.getSelection()){
+ sortTaxaByRankAndNamePref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.SortTaxaByRankAndName, null);
+ }
+ sortTaxaByRankAndNamePref.setAllowOverride(allowOverrideIsSortTaxaByRankAndNameButton.getSelection());
+ }
+ });
+ }
+
+ filterCommonNameReferenceButton = createBooleanCombo(composite, Messages.GeneralPreference_yes, Messages.GeneralPreference_no, PreferencePredicate.CommonNameReferencesWithMarker, Messages.DatabasePreferncesPage_CommonNameFilter, isAdminPreference);
+ filterCommonNameReferenceButton.addSelectionListener(this);
+
+
+ if (!isAdminPreference && filterCommonNameReferencesPref != null){
+ filterCommonNameReferenceButton.setEnabled(filterCommonNameReferencesPref.isAllowOverride());
+ }
+
+ if (isAdminPreference){
+ allowOverrideFilterCommonNameReferencesButton = createAllowOverrideButton(composite);
+ allowOverrideFilterCommonNameReferencesButton.setSelection(filterCommonNameReferencesPref != null? filterCommonNameReferencesPref.isAllowOverride():true);
+ allowOverrideFilterCommonNameReferencesButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setApply(true);
+ if (filterCommonNameReferencesPref == null && !allowOverrideFilterCommonNameReferencesButton.getSelection()){
+ filterCommonNameReferencesPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.CommonNameReferencesWithMarker, null);
+ }
+ filterCommonNameReferencesPref.setAllowOverride(allowOverrideFilterCommonNameReferencesButton.getSelection());
+ }
+ });
+ }
+
+ searchNamedAreasByAbbrevButton = createCombo(composite, NamedAreaSearchField.values(), PreferencePredicate.NamedAreaSearchForAbbrev, Messages.DatabasePreferncesPage_NamedAreaSearchField, isAdminPreference);
+ searchNamedAreasByAbbrevButton.addSelectionListener(this);
+
+
+ if (!isAdminPreference && searchNamedAreasByAbbrevPref != null){
+ searchNamedAreasByAbbrevButton.setEnabled(searchNamedAreasByAbbrevPref.isAllowOverride());
+ }
+
+ if (isAdminPreference){
+ allowOverridesearchNamedAreasByAbbrevButton = createAllowOverrideButton(composite);
+ allowOverridesearchNamedAreasByAbbrevButton.setSelection(searchNamedAreasByAbbrevPref != null? searchNamedAreasByAbbrevPref.isAllowOverride():true);
+ allowOverridesearchNamedAreasByAbbrevButton.addSelectionListener(new SelectionAdapter(){
+ @Override
+ public void widgetSelected(SelectionEvent e) {
+ setApply(true);
+ if (searchNamedAreasByAbbrevPref == null && !allowOverridesearchNamedAreasByAbbrevButton.getSelection()){
+ searchNamedAreasByAbbrevPref = CdmPreference.NewTaxEditorInstance(PreferencePredicate.NamedAreaSearchForAbbrev, null);
+ }
+ searchNamedAreasByAbbrevPref.setAllowOverride(allowOverridesearchNamedAreasByAbbrevButton.getSelection());
+ }
+ });
+ }
+
+ setSelections();
+
+ return composite;
+ }
+
+ @Override
+ protected void performDefaults() {
+ showIdInSelectionDialogButton.select(0);
+ showIdInSelectionDialog = null;
+ if (isAdminPreference){
+ allowOverrideIsShowIdInSelectionDialogButton.setSelection(true);
+ showIdInSelectionDialogPref.setAllowOverride(true);
+ }
+ searchForIdentifierAsDefaultButton.select(0);
+ searchForIdentifierAsDefault = null;
+ if (isAdminPreference){
+ allowOverrideSearchForIdentifierAsDefaultButton.setSelection(true);
+ searchForIdentifierAsDefaultPref.setAllowOverride(true);
+ }
+ searchForIdentifierAndTitleCacheButton.select(0);
+ searchForIdentifierAndTitleCache = null;
+ if (isAdminPreference){
+ allowOverridesSearchForIdentifierAndTitleCacheButton.setSelection(true);
+ searchForIdentifierAndTitleCachePref.setAllowOverride(true);
+ }
+ sortTaxaByRankAndNameButton.select(0);
+ sortTaxaByRankAndName = null;
+ if (isAdminPreference){
+ allowOverrideIsSortTaxaByRankAndNameButton.setSelection(true);
+ sortTaxaByRankAndNamePref.setAllowOverride(true);
+ }
+ filterCommonNameReferenceButton.select(0);
+ filterCommonNameReferences = null;
+ if (isAdminPreference){
+ allowOverrideFilterCommonNameReferencesButton.setSelection(true);
+ filterCommonNameReferencesPref.setAllowOverride(true);
+ }
+ searchNamedAreasByAbbrevButton.select(0);
+ searchNamedAreasByAbbrev = null;
+ if (isAdminPreference){
+ allowOverridesearchNamedAreasByAbbrevButton.setSelection(true);
+ searchNamedAreasByAbbrevPref.setAllowOverride(true);
+ }
+ setApply(true);
+ }
- /**
- * {@inheritDoc}
- */
@Override
- protected void createFieldEditors() {
- addField(new BooleanFieldEditor(PreferencesUtil.createPreferenceString(IPreferenceKeys.SHOW_ID_IN_ENTITY_SELECTION_DIAOLOG),
- Messages.SearchDialogPreferences_0,
- getFieldEditorParent()));
- addField(new BooleanFieldEditor(PreferencesUtil.createPreferenceString(IPreferenceKeys.IS_SEARCH_FOR_IDENTIFIER_AS_DEFAULT),
- Messages.SearchDialogPreferences_1,
- getFieldEditorParent()));
- addField(new BooleanFieldEditor(PreferencesUtil.createPreferenceString(IPreferenceKeys.SEARCH_FOR_IDENTIFIER_AND_TITLECACHE),
- Messages.SearchDialogPreferences_2,
- getFieldEditorParent()));
- addField(new BooleanFieldEditor(PreferencesUtil.createPreferenceString(IPreferenceKeys.SORT_TAXA_BY_RANK_AND_NAME),
- Messages.SearchDialogPreferences_3,
- getFieldEditorParent()));
- addField(new BooleanFieldEditor(PreferencesUtil.createPreferenceString(
- IPreferenceKeys.FILTER_COMMON_NAME_REFERENCES),
- Messages.SearchDialogPreferences_4, getFieldEditorParent()));
+ public boolean performOk(){
+ if (!isApply()){
+ return true;
+ }
+ boolean override = false;
+ if (showIdInSelectionDialog != null ) {
+ override = true;
+ PreferencesUtil.setStringValue(PreferencePredicate.ShowIdInSelectionDialog.getKey(), showIdInSelectionDialog.toString());
+ }
+ PreferencesUtil.setBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.ShowIdInSelectionDialog.getKey()),
+ override);
+
+ override = false;
+
+ if(searchForIdentifierAsDefault != null){
+ override = true;
+ PreferencesUtil.setStringValue(PreferencePredicate.SearchForIdentifierAsDefault.getKey(), searchForIdentifierAsDefault.toString());
+ }
+ PreferencesUtil.setBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.SearchForIdentifierAsDefault.getKey()),
+ override);
+ override = false;
+
+ if(searchForIdentifierAndTitleCache != null){
+ override = true;
+ PreferencesUtil.setStringValue(PreferencePredicate.SearchForIdentifierAndTitleCache.getKey(), searchForIdentifierAndTitleCache.toString());
+ }
+ PreferencesUtil.setBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.SearchForIdentifierAndTitleCache.getKey()),
+ override);
+ override = false;
+
+ if(sortTaxaByRankAndName != null){
+ override = true;
+ PreferencesUtil.setStringValue(PreferencePredicate.SortTaxaByRankAndName.getKey(), sortTaxaByRankAndName.toString());
+ }
+ PreferencesUtil.setBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.SortTaxaByRankAndName.getKey()),
+ override);
+ override = false;
+
+
+ if(filterCommonNameReferences != null){
+ override = true;
+ PreferencesUtil.setStringValue(PreferencePredicate.CommonNameReferencesWithMarker.getKey(), filterCommonNameReferences.toString());
+ }
+ PreferencesUtil.setBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.CommonNameReferencesWithMarker.getKey()),
+ override);
+ override = false;
+ if(searchNamedAreasByAbbrev != null){
+ override = true;
+ PreferencesUtil.setStringValue(PreferencePredicate.NamedAreaSearchForAbbrev.getKey(), searchNamedAreasByAbbrev.getKey());
+ }
+ PreferencesUtil.setBooleanValue(
+ PreferencesUtil.prefOverrideKey(PreferencePredicate.NamedAreaSearchForAbbrev.getKey()),
+ override);
+ return true;
}
+ protected void setSelections(){
+
+ int index = 0;
+ for (String itemLabel : showIdInSelectionDialogButton.getItems()) {
+ if (itemLabel.startsWith(Messages.Preference_Use_Default) && (showIdInSelectionDialog == null || (!overrideShowIdInSelectionDialog && !isAdminPreference))) {
+ showIdInSelectionDialogButton.select(index);
+ break;
+ }
+ if (itemLabel.equals(Messages.GeneralPreference_yes) && showIdInSelectionDialog){
+ showIdInSelectionDialogButton.select(index);
+ break;
+ }
+ if (itemLabel.equals(Messages.GeneralPreference_no) && !showIdInSelectionDialog){
+ showIdInSelectionDialogButton.select(index);
+ break;
+ }
+ index++;
+ }
+
+ index = 0;
+ for (String itemLabel : searchForIdentifierAsDefaultButton.getItems()) {
+ if ((searchForIdentifierAsDefault == null || (!overrideSearchForIdentifierAsDefault && !isAdminPreference)) && itemLabel.startsWith(Messages.Preference_Use_Default)) {
+ searchForIdentifierAsDefaultButton.select(index);
+ break;
+ }
+ if (searchForIdentifierAsDefault != null && itemLabel.equals(Messages.GeneralPreference_yes) && searchForIdentifierAsDefault){
+ searchForIdentifierAsDefaultButton.select(index);
+ break;
+ }
+ if (searchForIdentifierAsDefault != null && itemLabel.equals(Messages.GeneralPreference_no) && !searchForIdentifierAsDefault){
+ searchForIdentifierAsDefaultButton.select(index);
+ break;
+ }
+ index++;
+ }
+
+ index = 0;
+ for (String itemLabel : searchForIdentifierAndTitleCacheButton.getItems()) {
+ if ((searchForIdentifierAndTitleCache == null || (!overrideSearchForIdentifierAndTitleCache && !isAdminPreference))&& itemLabel.startsWith(Messages.Preference_Use_Default)) {
+ searchForIdentifierAndTitleCacheButton.select(index);
+ break;
+ }
+ if (searchForIdentifierAndTitleCache != null && itemLabel.equals(Messages.GeneralPreference_yes) && searchForIdentifierAndTitleCache){
+ searchForIdentifierAndTitleCacheButton.select(index);
+ break;
+ }
+ if (searchForIdentifierAndTitleCache != null && itemLabel.equals(Messages.GeneralPreference_no) && !searchForIdentifierAndTitleCache){
+ searchForIdentifierAndTitleCacheButton.select(index);
+ break;
+ }
+ index++;
+ }
+
+ index = 0;
+ for (String itemLabel : sortTaxaByRankAndNameButton.getItems()) {
+ if ((sortTaxaByRankAndName == null || (!overrideSortTaxaByRankAndName && !isAdminPreference))&& itemLabel.startsWith(Messages.Preference_Use_Default)) {
+ sortTaxaByRankAndNameButton.select(index);
+ break;
+ }
+ if (sortTaxaByRankAndName != null && itemLabel.equals(Messages.GeneralPreference_yes) && sortTaxaByRankAndName){
+ sortTaxaByRankAndNameButton.select(index);
+ break;
+ }
+ if (sortTaxaByRankAndName != null && itemLabel.equals(Messages.GeneralPreference_no) && !sortTaxaByRankAndName){
+ sortTaxaByRankAndNameButton.select(index);
+ break;
+ }
+ index++;
+ }
+
+ index = 0;
+ for (String itemLabel: filterCommonNameReferenceButton.getItems()) {
+ if ((filterCommonNameReferences == null || (!overrideFilterCommonNameReferences && !isAdminPreference)) && itemLabel.startsWith(Messages.Preference_Use_Default)) {
+ filterCommonNameReferenceButton.select(index);
+ break;
+ }
+ if (filterCommonNameReferences != null && itemLabel.equals(Messages.GeneralPreference_yes) && filterCommonNameReferences){
+ filterCommonNameReferenceButton.select(index);
+ break;
+ }
+ if (filterCommonNameReferences != null && itemLabel.equals(Messages.GeneralPreference_no) && !filterCommonNameReferences){
+ filterCommonNameReferenceButton.select(index);
+ break;
+ }
+ index++;
+ }
+ index = 0;
+ for (String itemLabel: searchNamedAreasByAbbrevButton.getItems()) {
+ if ((searchNamedAreasByAbbrev == null || (!overrideSearchNamedAreasByAbbrev && !isAdminPreference)) && itemLabel.startsWith(Messages.Preference_Use_Default)) {
+ searchNamedAreasByAbbrevButton.select(index);
+ break;
+ }
+
+
+ if (searchNamedAreasByAbbrev != null && itemLabel.equals(searchNamedAreasByAbbrev.getLabel())){
+ searchNamedAreasByAbbrevButton.select(index);
+ break;
+ }
+
+ index++;
+ }
+ }
+
+
}