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

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

Introduction

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

Prototype

public void load() 

Source Link

Document

Initializes this field editor with the preference value from the preference store.

Usage

From source file:com.amazonaws.eclipse.dynamodb.preferences.TestToolPreferencePage.java

License:Apache License

private void customizeEditor(final Composite composite, final FieldEditor editor) {
    editor.setPage(this);
    editor.setPreferenceStore(getPreferenceStore());
    editor.load();
    editor.fillIntoGrid(composite, MAX_FIELD_EDITOR_COLUMNS);
}

From source file:com.dnw.plugin.preference.GroupFieldEditor.java

License:Open Source License

/**
 * Initializes this field editor with the preference value from the preference store.
 * // w ww  .ja v a2 s .  co  m
 * @author manbaum
 * @since Oct 22, 2014
 * @see org.eclipse.jface.preference.FieldEditor#doLoad()
 */
@Override
protected void doLoad() {
    if (fields != null) {
        for (FieldEditor f : fields) {
            f.load();
        }
    }
}

From source file:com.ge.research.sadl.ui.preferences.ReasonerConfigurationDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    editors = new ArrayList<FieldEditor>();
    messageArea = new DialogMessageArea();

    page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) {
        @Override/*  ww  w .  jav a2 s . c o  m*/
        public void createControl(Composite parentComposite) {
            noDefaultAndApplyButton();
            super.createControl(parentComposite);
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void createFieldEditors() {
            rcps = this.doGetPreferenceStore();
            if (rcps == null) {
                rcps = new PreferenceStore();
            }
            FieldEditor editor;
            if (config != null) {
                for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) {
                    String key = entry.getKey();
                    ConfigurationOption option = entry.getValue();
                    if (key.equalsIgnoreCase("builtin")) {
                        continue;
                    }
                    String optionDescription = option.getDescription();
                    Object currentValue = currentConfig.get(key);
                    Object optionValue = option.getValue();
                    if (currentValue != null) {
                        optionValue = currentValue;
                    }
                    logger.debug(key + " class = " + optionValue.getClass().getName());
                    Object[] optionPossibleValues = option.getPossibleValues();
                    if (optionPossibleValues != null && optionPossibleValues.length > 0) {
                        // Option has a list of values so create a dropdown box
                        String[][] nv = new String[optionPossibleValues.length][2];
                        for (int i = 0; i < optionPossibleValues.length; i++) {
                            nv[i][0] = optionPossibleValues[i].toString();
                            nv[i][1] = optionPossibleValues[i].toString();
                        }
                        editor = new ComboFieldEditor(key, optionDescription, nv, getFieldEditorParent());
                        rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                        editor.setPreferenceStore(rcps);
                        addField(editor);
                        editor.load();
                        editors.add(editor);
                    } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) {
                        editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent());
                        rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                        editor.setPreferenceStore(rcps);
                        addField(editor);
                        editor.load();
                        editors.add(editor);
                    } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) {
                        editor = new BooleanFieldEditor(key, optionDescription,
                                BooleanFieldEditor.SEPARATE_LABEL, getFieldEditorParent());
                        rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                        editor.setPreferenceStore(rcps);
                        addField(editor);
                        editor.load();
                        editors.add(editor);
                    } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) {
                        editor = new IntegerFieldEditor(key, optionDescription, getFieldEditorParent());
                        rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                        editor.setPreferenceStore(rcps);
                        addField(editor);
                        editor.setPage(page);
                        editor.load();
                        editors.add(editor);
                    } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) {
                        editor = new DoubleFieldEditor(key, optionDescription, getFieldEditorParent());
                        rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                        editor.setPreferenceStore(rcps);
                        addField(editor);
                        editor.load();
                        editors.add(editor);
                    }
                }
            } else {
                logger.info("No configuration options available");
            }
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void updateApplyButton() {
            updateButtons(isValid());
            super.updateApplyButton();
        }

    };

    messageArea.createContents(composite);
    messageArea.showTitle(reasonerCategory + " Configuration Options", null);
    messageArea.setMessageLayoutData(new GridData(GridData.FILL_BOTH));
    page.createControl(composite);
    for (FieldEditor editor : editors) {
        editor.setPreferenceStore(rcps);
    }
    Control pageControl = page.getControl();
    pageControl.setLayoutData(new GridData(GridData.FILL_BOTH));
    return pageControl;
}

From source file:com.ge.research.sadl.ui.preferences.TranslatorConfigurationDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    editors = new ArrayList<FieldEditor>();
    messageArea = new DialogMessageArea();

    page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) {
        @Override/*ww  w  . j ava  2s . c o m*/
        public void createControl(Composite parentComposite) {
            noDefaultAndApplyButton();
            super.createControl(parentComposite);
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void createFieldEditors() {
            rcps = this.doGetPreferenceStore();
            if (rcps == null) {
                rcps = new PreferenceStore();
            }
            FieldEditor editor;
            if (config == null) {
                messageArea.updateText("No options available", IMessageProvider.NONE);
                return;
            }
            for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) {
                String key = entry.getKey();
                ConfigurationOption option = entry.getValue();
                if (key.equalsIgnoreCase("builtin")) {
                    continue;
                }
                String optionDescription = option.getDescription();
                Object currentValue = currentConfig.get(key);
                Object optionValue = option.getValue();
                if (currentValue != null) {
                    optionValue = currentValue;
                }
                logger.debug(
                        key + " class = " + (optionValue != null ? optionValue.getClass().getName() : "null"));
                Object[] optionPossibleValues = option.getPossibleValues();
                if (optionPossibleValues != null && optionPossibleValues.length > 0) {
                    // Option has a list of values so create a dropdown box
                    String[][] nv = new String[optionPossibleValues.length][2];
                    for (int i = 0; i < optionPossibleValues.length; i++) {
                        nv[i][0] = optionPossibleValues[i].toString();
                        nv[i][1] = optionPossibleValues[i].toString();
                    }
                    editor = new ComboFieldEditor(key, optionDescription, nv, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue == null) {
                    editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) {
                    editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) {
                    editor = new BooleanFieldEditor(key, optionDescription, BooleanFieldEditor.SEPARATE_LABEL,
                            getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) {
                    editor = new IntegerFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.setPage(page);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) {
                    editor = new DoubleFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                }
            }
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void updateApplyButton() {
            updateButtons(isValid());
            super.updateApplyButton();
        }

    };

    messageArea.createContents(composite);
    messageArea.showTitle(translatorCategory + " Configuration Options", null);
    messageArea.setMessageLayoutData(new GridData(GridData.FILL_BOTH));
    page.createControl(composite);
    for (FieldEditor editor : editors) {
        editor.setPreferenceStore(rcps);
    }
    Control pageControl = page.getControl();
    pageControl.setLayoutData(new GridData(GridData.FILL_BOTH));
    return pageControl;
}

From source file:com.ge.research.sadl.ui.properties.ReasonerConfigurationDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    editors = new ArrayList<FieldEditor>();
    messageArea = new DialogMessageArea();

    page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) {
        @Override/*from w  w w.java 2s .c o m*/
        public void createControl(Composite parentComposite) {
            noDefaultAndApplyButton();
            super.createControl(parentComposite);
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void createFieldEditors() {
            rcps = this.doGetPreferenceStore();
            if (rcps == null) {
                rcps = new PreferenceStore();
            }
            FieldEditor editor;
            for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) {
                String key = entry.getKey();
                ConfigurationOption option = entry.getValue();
                if (key.equalsIgnoreCase("builtin")) {
                    continue;
                }
                String optionDescription = option.getDescription();
                Object currentValue = currentConfig.get(key);
                Object optionValue = option.getValue();
                if (currentValue != null) {
                    optionValue = currentValue;
                }
                logger.debug(key + " class = " + optionValue.getClass().getName());
                Object[] optionPossibleValues = option.getPossibleValues();
                if (optionPossibleValues != null && optionPossibleValues.length > 0) {
                    // Option has a list of values so create a dropdown box
                    String[][] nv = new String[optionPossibleValues.length][2];
                    for (int i = 0; i < optionPossibleValues.length; i++) {
                        nv[i][0] = optionPossibleValues[i].toString();
                        nv[i][1] = optionPossibleValues[i].toString();
                    }
                    editor = new ComboFieldEditor(key, optionDescription, nv, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) {
                    editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) {
                    editor = new BooleanFieldEditor(key, optionDescription, BooleanFieldEditor.SEPARATE_LABEL,
                            getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) {
                    editor = new IntegerFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.setPage(page);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) {
                    editor = new DoubleFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                }
            }
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void updateApplyButton() {
            updateButtons(isValid());
            super.updateApplyButton();
        }

    };

    messageArea.createContents(composite);
    messageArea.showTitle(reasonerCategory + " Configuration Options", null);
    messageArea.setMessageLayoutData(new GridData(GridData.FILL_BOTH));
    page.createControl(composite);
    for (FieldEditor editor : editors) {
        editor.setPreferenceStore(rcps);
    }
    Control pageControl = page.getControl();
    pageControl.setLayoutData(new GridData(GridData.FILL_BOTH));
    return pageControl;
}

From source file:com.ge.research.sadl.ui.properties.TranslatorConfigurationDialog.java

License:Open Source License

@Override
protected Control createDialogArea(Composite parent) {
    Composite composite = (Composite) super.createDialogArea(parent);

    editors = new ArrayList<FieldEditor>();
    messageArea = new DialogMessageArea();

    page = new FieldEditorPreferencePage(FieldEditorPreferencePage.GRID) {
        @Override/*from   w  w w  .j a  v  a 2 s.c  o  m*/
        public void createControl(Composite parentComposite) {
            noDefaultAndApplyButton();
            super.createControl(parentComposite);
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void createFieldEditors() {
            rcps = this.doGetPreferenceStore();
            if (rcps == null) {
                rcps = new PreferenceStore();
            }
            FieldEditor editor;
            if (config == null) {
                messageArea.updateText("No options available", IMessageProvider.NONE);
                return;
            }
            for (Map.Entry<String, ConfigurationOption> entry : config.entrySet()) {
                String key = entry.getKey();
                ConfigurationOption option = entry.getValue();
                if (key.equalsIgnoreCase("builtin")) {
                    continue;
                }
                String optionDescription = option.getDescription();
                Object currentValue = currentConfig.get(key);
                Object optionValue = option.getValue();
                if (currentValue != null) {
                    optionValue = currentValue;
                }
                logger.debug(key + " class = " + optionValue.getClass().getName());
                Object[] optionPossibleValues = option.getPossibleValues();
                if (optionPossibleValues != null && optionPossibleValues.length > 0) {
                    // Option has a list of values so create a dropdown box
                    String[][] nv = new String[optionPossibleValues.length][2];
                    for (int i = 0; i < optionPossibleValues.length; i++) {
                        nv[i][0] = optionPossibleValues[i].toString();
                        nv[i][1] = optionPossibleValues[i].toString();
                    }
                    editor = new ComboFieldEditor(key, optionDescription, nv, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.String")) {
                    editor = new StringFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Boolean")) {
                    editor = new BooleanFieldEditor(key, optionDescription, BooleanFieldEditor.SEPARATE_LABEL,
                            getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Integer")) {
                    editor = new IntegerFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.setPage(page);
                    editor.load();
                    editors.add(editor);
                } else if (optionValue.getClass().getName().equalsIgnoreCase("java.lang.Double")) {
                    editor = new DoubleFieldEditor(key, optionDescription, getFieldEditorParent());
                    rcps.setValue(editor.getPreferenceName(), optionValue.toString());
                    editor.setPreferenceStore(rcps);
                    addField(editor);
                    editor.load();
                    editors.add(editor);
                }
            }
        }

        @SuppressWarnings("synthetic-access")
        @Override
        protected void updateApplyButton() {
            updateButtons(isValid());
            super.updateApplyButton();
        }

    };

    messageArea.createContents(composite);
    messageArea.showTitle(translatorCategory + " Configuration Options", null);
    messageArea.setMessageLayoutData(new GridData(GridData.FILL_BOTH));
    page.createControl(composite);
    for (FieldEditor editor : editors) {
        editor.setPreferenceStore(rcps);
    }
    Control pageControl = page.getControl();
    pageControl.setLayoutData(new GridData(GridData.FILL_BOTH));
    return pageControl;
}

From source file:com.puppetlabs.geppetto.pp.dsl.ui.preferences.editors.AbstractPreferencePage.java

License:Open Source License

/**
 * Loads values of all field editors using current search scopes in the preference store.
 * Also updates fields enabled status. (The effect is that fields show project specific values
 * when enabled, and instance scoped/default values when disabled).
 * /*from  w  w w.ja  v  a  2  s  . co m*/
 * @param enabled
 */
protected void updateFieldEditors(boolean enabled) {
    Composite parent = getFieldEditorParent();
    for (FieldEditor editor : editors) {
        editor.load();
        editor.setEnabled(enabled, parent);
    }
    getDefaultsButton().setEnabled(enabled);
}

From source file:com.swtdesigner.FieldLayoutPreferencePage.java

License:Open Source License

/**
 * Initializes all field editors./* w  w  w  .  j  av  a2 s.  c o  m*/
 */
protected void initialize() {
    if (fields != null) {
        Iterator e = fields.iterator();
        while (e.hasNext()) {
            FieldEditor pe = (FieldEditor) e.next();
            /* $codepro.preprocessor.if version >= 3.1 $ */
            pe.setPage(null);
            /* $codepro.preprocessor.elseif version < 3.0 $
            pe.setPreferencePage(null);
            $codepro.preprocessor.endif $ */
            pe.setPropertyChangeListener(this);
            pe.setPreferenceStore(getPreferenceStore());
            pe.load();
        }
    }
}

From source file:com.technophobia.substeps.editor.preferences.page.SubstepsPropertyPage.java

License:Open Source License

private void createProblemsGroup(final Composite composite) {
    final Group group = new Group(composite, SWT.NONE);
    group.setFont(composite.getFont());/*from  ww  w . j  a va2s .co  m*/
    group.setText("Problems");
    final GridData layoutData = new GridData(GridData.FILL, GridData.FILL, true, false);
    layoutData.verticalIndent = 20;
    group.setLayoutData(layoutData);

    group.setLayout(new GridLayout(1, false));

    final FieldEditor enableProblems = new BooleanFieldEditor(SubstepsPreferences.ENABLE_PROBLEMS.key(),
            "&Show substeps problems", group);
    enableProblems.setPage(this);
    enableProblems.setPreferenceStore(getPreferenceStore());
    enableProblems.load();
    addField(enableProblems, group);
}

From source file:com.threecrickets.creel.eclipse.internal.PreferencePageWithFields.java

License:LGPL

/**
 * Hooks up a field editor to performOk and performDefaults.
 * //from w w w  . ja  va  2s.c o m
 * @param fieldEditor
 *        The field editor
 */
protected void addFieldEditor(FieldEditor fieldEditor) {
    fieldEditors.add(fieldEditor);
    fieldEditor.setPage(this);
    fieldEditor.setPreferenceStore(getPreferenceStore());
    fieldEditor.load();
}