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

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

Introduction

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

Prototype

public void setPropertyChangeListener(IPropertyChangeListener listener) 

Source Link

Document

Sets or removes the property change listener for this field editor.

Usage

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

License:Open Source License

/**
 * <p>/*  www .  ja  v  a 2 s .c  o  m*/
 * Sets or removes the property change listener for this field editor.
 * </p>
 * <p>
 * Note that field editors can support only a single listener.
 * </p>
 * 
 * @author manbaum
 * @since Oct 22, 2014
 * @param listener a property change listener, or <code>null</code> to remove.
 * @see org.eclipse.jface.preference.FieldEditor#setPropertyChangeListener(org.eclipse.jface.util.IPropertyChangeListener)
 */
@Override
public void setPropertyChangeListener(IPropertyChangeListener listener) {
    super.setPropertyChangeListener(listener);
    if (fields != null) {
        for (FieldEditor f : fields) {
            f.setPropertyChangeListener(listener);
        }
    }
}

From source file:com.safi.workshop.sqlexplorer.preferences.OverlaidPreferencePage.java

License:Open Source License

@Override
protected void addField(final FieldEditor editor) {
    // Make sure that FieldEditors automatically write their changes straight to the store
    editor.setPropertyChangeListener(new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            editor.store();//from   w  w w  .  ja  v  a  2s. c  o  m
        }
    });
    super.addField(editor);
}

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.ja  v  a2s . 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./*from  w  w  w  .j  a  v  a  2s.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:gov.redhawk.internal.ui.preferences.PlotPreferencePage.java

License:Open Source License

@Override
protected void initialize() {
    super.initialize();
    if (blockPreferenceStore != null) {
        Iterator<FieldEditor> e = blockPreferences.iterator();
        while (e.hasNext()) {
            FieldEditor pe = e.next();
            pe.setPage(this);
            pe.setPropertyChangeListener(this);
            pe.setPreferenceStore(blockPreferenceStore);
            pe.load();//from  www. j av a 2s . c  o m
        }
    }
}

From source file:mpj_express_debugger.JavaMPJConnectTab.java

License:Open Source License

/**
 * Update the argument area to show the selected connector's arguments
 *//* ww  w .j  a va2  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 keys = vm.getArgumentOrder().iterator();
    while (keys.hasNext()) {
        String key = (String) keys.next();
        Connector.Argument arg = (Connector.Argument) 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 choices = ((Connector.SelectedArgument) arg).choices();
            String[][] namesAndValues = new String[choices.size()][2];
            Iterator iter = choices.iterator();
            int count = 0;
            while (iter.hasNext()) {
                String choice = (String) 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:net.sourceforge.sqlexplorer.preferences.OverlaidPreferencePage.java

License:Open Source License

protected void addField(final FieldEditor editor) {
    // Make sure that FieldEditors automatically write their changes straight to the store
    editor.setPropertyChangeListener(new IPropertyChangeListener() {
        public void propertyChange(PropertyChangeEvent event) {
            editor.store();//from w ww. j  a v  a  2 s  .co  m
        }
    });
    super.addField(editor);
}

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
 *//*from  w w  w  . j  av a 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());
            }/*from  w  ww .  j  ava2 s .c om*/
            pe.load();
        }
    }

}

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 w  w  w  . j  av  a2s  . 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;
    }

}