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

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

Introduction

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

Prototype

public void setPage(DialogPage dialogPage) 

Source Link

Document

Set the page to be the receiver.

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();/*from  w  ww.  ja  v  a 2  s  .co  m*/
    editor.fillIntoGrid(composite, MAX_FIELD_EDITOR_COLUMNS);
}

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

License:Open Source License

/**
 * Set the page to be the receiver.//  w w w  . j a  va 2 s. c  o m
 * 
 * @author manbaum
 * @since Oct 22, 2014
 * @param dialogPage the dialog page.
 * @see org.eclipse.jface.preference.FieldEditor#setPage(org.eclipse.jface.dialogs.DialogPage)
 */
@Override
public void setPage(DialogPage dialogPage) {
    super.setPage(dialogPage);
    if (fields != null) {
        for (FieldEditor f : fields) {
            f.setPage(dialogPage);
        }
    }
}

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  . ja v  a 2s.  com
        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/*from w w w  .j a va2 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 != 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  ww  . j  a  v  a  2  s  . com
        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 .ja  va  2s  . co 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.swtdesigner.FieldLayoutPreferencePage.java

License:Open Source License

/**   
 * The field editor preference page implementation of an <code>IDialogPage</code>
 * method disposes of this page's controls and images.
 * Subclasses may override to release their own allocated SWT
 * resources, but must call <code>super.dispose</code>.
 *//*  w  w  w .j a  v  a 2s  .c  o  m*/
public void dispose() {
    super.dispose();
    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(null);
            pe.setPreferenceStore(null);
        }
    }
}

From source file:com.swtdesigner.FieldLayoutPreferencePage.java

License:Open Source License

/**
 * Initializes all field editors./*  w  w  w.ja  v a  2s  .com*/
 */
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());/*w  w  w  .j a v a2s. c o  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 www.  java 2  s  .c  o m
 * @param fieldEditor
 *        The field editor
 */
protected void addFieldEditor(FieldEditor fieldEditor) {
    fieldEditors.add(fieldEditor);
    fieldEditor.setPage(this);
    fieldEditor.setPreferenceStore(getPreferenceStore());
    fieldEditor.load();
}