Example usage for org.eclipse.jface.preference FieldEditor getPreferenceName

List of usage examples for org.eclipse.jface.preference FieldEditor getPreferenceName

Introduction

In this page you can find the example usage for org.eclipse.jface.preference FieldEditor getPreferenceName.

Prototype

public String getPreferenceName() 

Source Link

Document

Returns the name of the preference this field editor operates on.

Usage

From source file:org.eclipse.xtext.ui.editor.preferences.AbstractPreferencePage.java

License:Open Source License

/**
 * Saves the 'use project settings' as a preference in the store using the
 * {@link #useProjectSettingsPreferenceName()} as the key. If not project specific, all affected keys are removed
 * from the project preferences.//from w  w  w.j a  v  a  2 s  . co  m
 * 
 * @throws IOException
 */
private void saveUseProjectSettings(boolean isProjectSpecific) throws IOException {
    final FixedScopedPreferenceStore store = (FixedScopedPreferenceStore) getPreferenceStore();
    if (!isProjectSpecific) {
        // remove all the keys (written by various field editors)
        IEclipsePreferences storePreferences = store.getStorePreferences();
        for (FieldEditor field : editors) {
            storePreferences.remove(field.getPreferenceName());
        }
        // Also remove the master key (i.e. use default/default == false when later reading).
        storePreferences.remove(useProjectSettingsPreferenceName());
    } else {
        store.setValue(useProjectSettingsPreferenceName(), Boolean.toString(isProjectSpecific));
    }
    store.save();
}

From source file:org.eclipse.xtext.ui.editor.preferences.AbstractPreferencePage.java

License:Open Source License

/**
 * Copies all the project specific values (except master key) to the values of the instance preference store.
 *//*from   w  ww  .  j  a  v  a  2 s .  c o  m*/
private void setProjectSpecificValues() {
    FixedScopedPreferenceStore store = (FixedScopedPreferenceStore) getPreferenceStore();
    IEclipsePreferences storePreferences = store.getStorePreferences();
    for (FieldEditor field : editors) {
        String key = field.getPreferenceName();
        storePreferences.put(key, store.getString(key));
    }
}

From source file:org.eclipse.xtext.ui.editor.syntaxcoloring.SyntaxColoringPreferencePage.java

License:Open Source License

/**
 * TODO: better use unqualified names in preference store. Left this workaround not to break API.
 *///from  w  ww  .  ja v a 2s .co  m
@Override
protected void addField(FieldEditor editor) {
    editor.setPreferenceName(qualifiedName() + "." + editor.getPreferenceName());
    super.addField(editor);
}

From source file:org.embl.cca.utils.ui.view.filenavigator.preference.FileNavigatorPreferencePage.java

License:Apache License

/**
 * Adds the given field editor to this page.
 *
 * @param editor the field editor//from   www  . java 2  s  .co  m
 */
protected void addField(final FieldEditor editor) {
    if (editor.getPreferenceName().equals(FileNavigatorPreferenceConstants.SHOW_INDEXRANGE_COLUMN))
        editor.setLabelText("Show index range column");
    super.addField(editor);
}

From source file:org.hpccsystems.internal.ECLLaunchConfigurationTab.java

License:Open Source License

protected void addField(Group parent, FieldEditor field) {
    fieldMap.put(field.getPreferenceName(), new FieldEditorRef(parent, field));
}

From source file:org.jsweet.plugin.preferences.FieldEditorProjectPreferencePage.java

License:Apache License

@Override
protected void addField(FieldEditor editor) {
    this.fields.add(editor);
    this.fieldMap.put(editor.getPreferenceName(), editor);
    super.addField(editor);
}

From source file:org.robotframework.ide.eclipse.main.plugin.preferences.AutoDiscoveringPreferencePageTest.java

License:Apache License

@Test
public void checkIfEditorForRecursiveModulesAdditionIsDefined() throws Exception {
    final AutoDiscoveringPreferencePage page = new AutoDiscoveringPreferencePage();
    page.createControl(shellProvider.getShell());

    final List<FieldEditor> editors = FieldEditorPreferencePageHelper.getEditors(page);
    assertThat(editors).hasSize(1);/*from w  w w.  j  a  va 2s .c  om*/

    final FieldEditor editor = editors.get(0);
    assertThat(editor).isInstanceOf(BooleanFieldEditor.class);
    assertThat(editor.getPreferenceName())
            .isEqualTo(RedPreferences.PROJECT_MODULES_RECURSIVE_ADDITION_ON_VIRTUALENV_ENABLED);
}

From source file:org.robotframework.ide.eclipse.main.plugin.preferences.DefaultLaunchConfigurationPreferencePageTest.java

License:Apache License

@Test
public void checkIfEditorsForAllLaunchConfigurationPreferencesAreDefined() throws Exception {
    final DefaultLaunchConfigurationPreferencePage page = new DefaultLaunchConfigurationPreferencePage();
    page.createControl(shellProvider.getShell());

    final List<String> integerPrefNames = newArrayList(RedPreferences.LAUNCH_AGENT_CONNECTION_PORT,
            RedPreferences.LAUNCH_AGENT_CONNECTION_TIMEOUT);
    final List<String> stringPrefNames = newArrayList(RedPreferences.LAUNCH_ADDITIONAL_INTERPRETER_ARGUMENTS,
            RedPreferences.LAUNCH_ADDITIONAL_ROBOT_ARGUMENTS, RedPreferences.LAUNCH_AGENT_CONNECTION_HOST,
            RedPreferences.LAUNCH_ADDITIONAL_EXECUTABLE_FILE_ARGUMENTS);

    final List<FieldEditor> editors = FieldEditorPreferencePageHelper.getEditors(page);
    assertThat(editors).hasSize(7);//from   w  ww .jav a 2 s.c  o m
    for (final FieldEditor editor : editors) {
        if (editor instanceof IntegerFieldEditor) {
            integerPrefNames.remove(editor.getPreferenceName());
        } else if (editor instanceof StringFieldEditor) {
            stringPrefNames.remove(editor.getPreferenceName());
        } else if (editor instanceof FileFieldEditor) {
            assertThat(editor.getPreferenceName()).isEqualTo(RedPreferences.LAUNCH_EXECUTABLE_FILE_PATH);
        }
    }
    assertThat(integerPrefNames).isEmpty();
    assertThat(stringPrefNames).isEmpty();
}

From source file:org.robotframework.ide.eclipse.main.plugin.preferences.FoldingPreferencePageTest.java

License:Apache License

@Test
public void thereAreBooleanEditorsForEachFoldableElementAndIntegerEditorForLinespan() throws Exception {
    final FoldingPreferencePage page = new FoldingPreferencePage();
    page.createControl(shellProvider.getShell());

    final List<String> booleanPrefNames = newArrayList(RedPreferences.FOLDABLE_SECTIONS,
            RedPreferences.FOLDABLE_CASES, RedPreferences.FOLDABLE_KEYWORDS,
            RedPreferences.FOLDABLE_DOCUMENTATION);

    final List<FieldEditor> editors = FieldEditorPreferencePageHelper.getEditors(page);
    assertThat(editors).hasSize(5);//  ww  w  .j a v a2  s .  c  o  m
    for (final FieldEditor editor : editors) {
        if (editor instanceof BooleanFieldEditor) {
            booleanPrefNames.remove(editor.getPreferenceName());
        } else if (editor instanceof IntegerFieldEditor) {
            final IntegerFieldEditor lineLimitEditor = (IntegerFieldEditor) editor;
            assertThat(lineLimitEditor.getPreferenceName()).isEqualTo(RedPreferences.FOLDING_LINE_LIMIT);
        }
    }
    assertThat(booleanPrefNames).isEmpty();
}

From source file:org.robotframework.ide.eclipse.main.plugin.preferences.LaunchingPreferencePageTest.java

License:Apache License

@Test
public void checkIfAllBooleanEditorsAreDefined() throws Exception {
    final LaunchingPreferencePage page = new LaunchingPreferencePage();
    page.createControl(shellProvider.getShell());

    final List<String> booleanPrefNames = newArrayList(RedPreferences.LAUNCH_USE_ARGUMENT_FILE,
            RedPreferences.LAUNCH_USE_SINGLE_FILE_DATA_SOURCE,
            RedPreferences.LAUNCH_USE_SINGLE_COMMAND_LINE_ARGUMENT);

    final List<FieldEditor> editors = FieldEditorPreferencePageHelper.getEditors(page);
    assertThat(editors).hasSize(3);//from  w  w w.  ja v a2 s . com
    for (final FieldEditor editor : editors) {
        if (editor instanceof BooleanFieldEditor) {
            booleanPrefNames.remove(editor.getPreferenceName());
        }
    }
    assertThat(booleanPrefNames).isEmpty();
}