Project

General

Profile

« Previous | Next » 

Revision 505368e5

Added by Katja Luther about 8 years ago

add simple view preference to the general preferences page

View differences:

eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/preference/TaxonomicEditorGeneralPreferences.java
13 13
import org.eclipse.jface.preference.BooleanFieldEditor;
14 14
import org.eclipse.jface.preference.FieldEditorPreferencePage;
15 15
import org.eclipse.jface.preference.StringFieldEditor;
16
import org.eclipse.swt.SWT;
17
import org.eclipse.swt.events.SelectionAdapter;
18
import org.eclipse.swt.events.SelectionEvent;
19
import org.eclipse.swt.layout.GridData;
20
import org.eclipse.swt.layout.RowLayout;
21
import org.eclipse.swt.widgets.Combo;
22
import org.eclipse.swt.widgets.Composite;
23
import org.eclipse.swt.widgets.Label;
16 24
import org.eclipse.ui.IWorkbench;
17 25
import org.eclipse.ui.IWorkbenchPreferencePage;
18 26

  
27
import eu.etaxonomy.cdm.persistence.query.MatchMode;
28

  
19 29
/**
20 30
 * <p>
21 31
 * TaxonomicEditorGeneralPreferences class.
......
60 70
		addField(new BooleanFieldEditor(IPreferenceKeys.SEARCH_OPEN_RESULTS_IN_SEPARATE_WINDOWS,
61 71
		        "Open search results in separate windows",
62 72
		        getFieldEditorParent()));
73
		addField(new BooleanFieldEditor(IPreferenceKeys.SHOW_SIMPLE_NAME_DETAILS_SECTION,
74
                "Show only a simple name details view",
75
                getFieldEditorParent()));
76

  
77
		Composite composite = new Composite(getFieldEditorParent(), SWT.NULL);
78
        composite.setLayoutData(new GridData(SWT.FILL, SWT.TOP, true, false, 2, 1));
79
        composite.setLayout(new RowLayout(1));
80

  
81
        final Label label = new Label(composite, SWT.NONE);
82
        label.setText("Choose the prefered match mode for searches.");
83

  
84
        final Combo combo_MatchMode = new Combo(composite, SWT.NONE);
85

  
86
        MatchMode[] matchModes = MatchMode.values();
87
        int currentSelectionIndex = 0;
88
        for(int i = 0; i < matchModes.length; i++){
89
            MatchMode mode = matchModes[i];
90
            combo_MatchMode.add(mode.name(),i);
91
            //TODO:the correct preselection is needed here!!
92
            if (mode.equals(PreferencesUtil.getSearchConfigurator().getMatchMode())){
93
                currentSelectionIndex = i;
94
            }
95
        }
96

  
97
        combo_MatchMode.select(currentSelectionIndex);
98

  
99
        combo_MatchMode.addSelectionListener(new SelectionAdapter() {
100
            /* (non-Javadoc)
101
             * @see org.eclipse.swt.events.SelectionAdapter#widgetSelected(org.eclipse.swt.events.SelectionEvent)
102
             */
103
            @Override
104
            public void widgetSelected(SelectionEvent e) {
105
                int selectionIndex = combo_MatchMode.getSelectionIndex();
106
                PreferencesUtil.getSearchConfigurator().setMatchMode(MatchMode.valueOf(combo_MatchMode.getItem(selectionIndex)));
107
            }
108
        });
109

  
110

  
63 111

  
64 112

  
65 113
	}

Also available in: Unified diff