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

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

Introduction

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

Prototype

public void setPreferenceStore(IPreferenceStore store) 

Source Link

Document

Sets the preference store used by this field editor.

Usage

From source file:net.sourceforge.eclipseccase.ui.preferences.UcmPreferencePage.java

License:Open Source License

private void addFieldEditor(FieldEditor fieldEditor) {

    fieldEditor.setPreferencePage(this);
    fieldEditor.setPreferenceStore(getPreferenceStore());
    fieldEditor.load();/*from  w w  w.  j  av a2  s .com*/
}

From source file:org.apache.felix.sigil.eclipse.ui.wizard.repository.RepositoryWizardPage.java

License:Apache License

public void createControl(Composite parent) {
    Composite control = new Composite(parent, SWT.NONE);
    setControl(control);//from   w  ww. j a va2  s .  c o  m

    if (getModel().getType().isDynamic()) {
        nameEditor = new StringFieldEditor("name", "Name:", control);
        nameEditor.setEmptyStringAllowed(false);
        addField(nameEditor);
    }

    createFieldEditors();

    int cols = 0;
    for (FieldEditor e : editors) {
        cols = Math.max(cols, e.getNumberOfControls());
    }

    control.setLayout(new GridLayout(cols, false));

    for (FieldEditor e : editors) {
        if (e instanceof StringFieldEditor) {
            StringFieldEditor sfe = (StringFieldEditor) e;
            sfe.getTextControl(getFieldEditorParent()).addModifyListener(new ModifyListener() {
                public void modifyText(ModifyEvent e) {
                    checkPageComplete();
                }
            });
        }
        e.fillIntoGrid(getFieldEditorParent(), cols);
        e.setPreferenceStore(getStore());
        e.load();
    }

    checkPageComplete();
}

From source file:org.bc.eclipse.hadoop.debug.JavaRetryConnectTab.java

License:Open Source License

/**
 * Update the argument area to show the selected connector's arguments
 *///  www .j ava  2  s .  co  m
private void handleConnectorComboModified() {
    int index = fConnectorCombo.getSelectionIndex();
    if ((index < 0) || (index >= fConnectors.length)) {
        return;
    }
    IVMConnector vm = fConnectors[index];
    if (vm.equals(fConnector)) {
        return; // selection did not change
    }
    fConnector = vm;
    try {
        fArgumentMap = vm.getDefaultArguments();
    } catch (CoreException e) {
        JDIDebugUIPlugin.statusDialog(LauncherMessages.JavaConnectTab_Unable_to_display_connection_arguments__2,
                e.getStatus());
        return;
    }

    // Dispose of any current child widgets in the tab holder area
    Control[] children = fArgumentComposite.getChildren();
    for (int i = 0; i < children.length; i++) {
        children[i].dispose();
    }
    fFieldEditorMap.clear();
    PreferenceStore store = new PreferenceStore();
    // create editors
    Iterator<String> keys = vm.getArgumentOrder().iterator();
    while (keys.hasNext()) {
        String key = keys.next();
        Connector.Argument arg = fArgumentMap.get(key);
        FieldEditor field = null;
        if (arg instanceof Connector.IntegerArgument) {
            store.setDefault(arg.name(), ((Connector.IntegerArgument) arg).intValue());
            field = new IntegerFieldEditor(arg.name(), arg.label(), fArgumentComposite);
        } else if (arg instanceof Connector.SelectedArgument) {
            List<String> choices = ((Connector.SelectedArgument) arg).choices();
            String[][] namesAndValues = new String[choices.size()][2];
            Iterator<String> iter = choices.iterator();
            int count = 0;
            while (iter.hasNext()) {
                String choice = iter.next();
                namesAndValues[count][0] = choice;
                namesAndValues[count][1] = choice;
                count++;
            }
            store.setDefault(arg.name(), arg.value());
            field = new ComboFieldEditor(arg.name(), arg.label(), namesAndValues, fArgumentComposite);
        } else if (arg instanceof Connector.StringArgument) {
            store.setDefault(arg.name(), arg.value());
            field = new StringFieldEditor(arg.name(), arg.label(), fArgumentComposite);
        } else if (arg instanceof Connector.BooleanArgument) {
            store.setDefault(arg.name(), ((Connector.BooleanArgument) arg).booleanValue());
            field = new BooleanFieldEditor(arg.name(), arg.label(), fArgumentComposite);
        }
        if (field != null) {
            field.setPreferenceStore(store);
            field.loadDefault();
            field.setPropertyChangeListener(this);
            fFieldEditorMap.put(key, field);
        }
    }
    fArgumentComposite.getParent().getParent().layout();
    fArgumentComposite.layout(true);
    updateLaunchConfigurationDialog();
}

From source file:org.bonitasoft.studio.preferences.pages.BonitaAppearancePreferencePage.java

License:Open Source License

@Override
protected void initialize() {

    if (fieldEditors != null) {
        Iterator<FieldEditor> e = fieldEditors.iterator();
        while (e.hasNext()) {
            FieldEditor pe = e.next();
            pe.setPage(this);
            pe.setPropertyChangeListener(this);
            if (pe.getPreferenceStore() == null) {
                pe.setPreferenceStore(getPreferenceStore());
            }/*w w  w .  j  a v  a  2 s.  c  o m*/
            pe.load();
        }
    }

}

From source file:org.cs3.prolog.connector.internal.preferences.PreferencePage.java

License:Open Source License

private void changePreferenceStore(PreferenceStore store) {
    setPreferenceStore(store);//from   ww  w . j  ava  2s  .co m
    for (FieldEditor editor : editors) {
        editor.setPreferenceStore(store);
        editor.load();
    }
    updateExecuteablePreviewLabelText();
}

From source file:org.csstudio.diirt.util.preferences.BasePreferencePage.java

License:Open Source License

/**
 * Add the given {@code editor} field to this page. The editor's
 * caption foreground will be updated when the editor's value changes.
 *
 * @param fieldEditor The {@link FieldEditor} to be added and updated.
 * @param parent The {@link Composite} owning the given {@code editor}.
 * @param canBeDefaulted {@code true} if the given {@code editor} can be
 *            restored to its default value.
 * @param defaultGetter The {@link Supplier} of the editor's default value.
 *            Can be {@code null} if the editor's caption foreground
 *            should not be updated when the editor's value changes.
 * @param storedGetter The {@link Supplier} of the editor's stored value.
 *            Can be {@code null} if the editor's caption foreground
 *            should not be initially updated.
 * @param listener Called when a field editor fires a value property change.
 *///from   www .jav  a  2 s . c  o m
protected void addField(FieldEditor fieldEditor, Composite parent, boolean canBeDefaulted,
        Supplier<Object> defaultGetter, Supplier<Object> storedGetter, IPropertyChangeListener listener) {

    final IPreferenceStore store = getPreferenceStore();
    final Editor editor = new Editor(fieldEditor, parent, canBeDefaulted, defaultGetter, storedGetter);

    fieldEditor.getLabelControl(parent).setLayoutData(new GridData(SWT.RIGHT, SWT.CENTER, false, false));
    fieldEditor.setPage(this);
    fieldEditor.setPreferenceStore(store);
    fieldEditor.load();
    fieldEditor.setPropertyChangeListener(e -> {
        if (FieldEditor.VALUE.equals(e.getProperty())) {

            if (storedGetter != null) {
                editor.setRestartRequired(!Objects.equals(e.getNewValue(), storedGetter.get()));
            }

            editor.updateCaptionColor(e.getNewValue());

            if (listener != null) {
                listener.propertyChange(e);
            }

        }
    });

    editor.updateCaptionColor();
    editors.put(fieldEditor, editor);

    if (PREF_CONFIGURATION_DIRECTORY.equals(fieldEditor.getPreferenceName())) {
        directoryEditor = editor;
    }

}

From source file:org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointPropertyPage.java

License:Open Source License

void cleanEditorsFromComposite() {
    if (fEventArgsFEs != null) {
        for (FieldEditor editor : fEventArgsFEs) {
            editor.setPreferenceStore(null);
            editor.setPage(null);/*from  w  ww .ja  va 2 s .  co  m*/
        }
    }
}

From source file:org.eclipse.cdt.debug.internal.ui.breakpoints.CBreakpointPropertyPage.java

License:Open Source License

private void displayEventArgs(ICBreakpoint breakpoint, Composite parent) {
    boolean result = false;
    String[] debugModelIds = getDebugModelIds();

    try {//w ww .  j a  v a  2s  .  c  o  m
        ICBreakpointsUIContribution[] cons;
        CBreakpointUIContributionFactory factory = CBreakpointUIContributionFactory.getInstance();
        IPreferenceStore prefStore = getPreferenceStore();
        if (prefStore instanceof CBreakpointPreferenceStore) {
            cons = factory.getBreakpointUIContributions(debugModelIds, breakpoint,
                    ((CBreakpointPreferenceStore) prefStore).getAttributes());
        } else {
            cons = factory.getBreakpointUIContributions(breakpoint);
        }
        for (ICBreakpointsUIContribution con : cons) {
            if (con.getMarkerType().equalsIgnoreCase(ICEventBreakpoint.C_EVENT_BREAKPOINT_MARKER)
                    && !con.getId().equals(ICEventBreakpoint.EVENT_TYPE_ID)) {
                setupArgsComposite(parent);
                FieldEditor fieldEditor = con.getFieldEditor(con.getId(), con.getLabel() + ":", //$NON-NLS-1$
                        fEventArgsComposite);
                if (fieldEditor != null) {
                    fieldEditor.setPreferenceStore(getPreferenceStore());
                    fieldEditor.setPage(this);
                    addEditorToComposite(fieldEditor);
                    addField(fieldEditor);
                    result = true;
                }
            }
        }
    } catch (CoreException ce) {
        CDebugUIPlugin.log(ce);
    }

    if (fEventArgsComposite != null && !fEventArgsComposite.isDisposed()) {
        fEventArgsComposite.setVisible(result);
        fEventArgsComposite.layout();
        fEventBPComposite.layout();
    }
}

From source file:org.eclipse.debug.internal.ui.preferences.LaunchConfigurationsPreferencePage.java

License:Open Source License

/**
 * Initializes the field editors to their values
 * @since 3.2//from  www . jav a2s . com
 */
private void initFieldEditors() {
    FieldEditor editor;
    for (int i = 0; i < fFieldEditors.size(); i++) {
        editor = (FieldEditor) fFieldEditors.get(i);
        editor.setPreferenceStore(getPreferenceStore());
        editor.load();
    }
    fDeleteConfigs.setSelection(Platform.getPreferencesService().getBoolean(DebugPlugin.getUniqueIdentifier(),
            DebugPlugin.PREF_DELETE_CONFIGS_ON_PROJECT_DELETE, true, null));
    //restore the tables' checked state
    String[] types = getPreferenceStore().getString(IInternalDebugUIConstants.PREF_FILTER_TYPE_LIST)
            .split("\\,"); //$NON-NLS-1$
    TableItem[] items = fTable.getItems();
    ILaunchConfigurationType type;
    for (int i = 0; i < types.length; i++) {
        for (int j = 0; j < items.length; j++) {
            type = (ILaunchConfigurationType) items[j].getData();
            if (type.getIdentifier().equals(types[i])) {
                items[j].setChecked(true);
            }
        }
    }
}

From source file:org.eclipse.epsilon.common.dt.preferences.EpsilonPreferencePage.java

License:Open Source License

@Override
protected Control createContents(Composite parent) {

    Composite composite = new Composite(parent, SWT.FILL);

    fieldEditors.add(//from   ww  w.  j a v a 2  s . c  om
            new BooleanFieldEditor(ENABLE_STATIC_ANALYSIS, "Enable static analysis (experimental)", composite));

    for (FieldEditor fieldEditor : fieldEditors) {
        fieldEditor.setPreferenceStore(EpsilonCommonsPlugin.getDefault().getPreferenceStore());
        fieldEditor.load();
    }

    return composite;
}