Bug 109389 [JFace] API - IntegerFieldEditor does not fire property change all the time
How to reproduce : JDT must be installed. Open Run->debug... Create a new Remote Java Application. Select (Standard)Socket Attach if not already selected. Change the default port value 8000 to 800011 (this value is invalid but is does not matter). Click on the Apply button. Select another debug configuration and come back to the configuration we have just created. Select the last two figures 11 in the port value and suppress them so that the port value is 8000 again. You will then notice that the apply button is still grayed out, because the IntegerFieldEditor did not fire a propertychange event. Here is the code that should correct it from org.eclipse.jface.preference.IntegerFieldEditor: /* (non-Javadoc) * Method declared on FieldEditor. */ protected void doLoad() { Text text = getTextControl(); if (text != null) { int value = getPreferenceStore().getInt(getPreferenceName()); text.setText("" + value);//$NON-NLS-1$ oldvalue = "" + value;<----------------------- this must be added } } and oldvalue must be made protected in the StringFieldEditor. I think that should correct the bug. Sebastien.
bundles/org.eclipse.jface/src/org/eclipse/jface/preference/StringFieldEditor.java
import org.eclipse.swt.events.KeyAdapter;
import org.eclipse.swt.events.KeyEvent;
import org.eclipse.swt.graphics.GC;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Text;
/**
 * A field editor for a string type preference.
 * <p>
 * This class may be used as is, or subclassed as required.
 * </p>
 */
public class StringFieldEditor extends FieldEditor {
    /**
     * Validation strategy constant (value <code>0</code>) indicating that
     * the editor should perform validation after every key stroke.
     *
     * @see #setValidateStrategy
     */
    public static final int VALIDATE_ON_KEY_STROKE = 0;
    /**
     * Validation strategy constant (value <code>1</code>) indicating that
     * the editor should perform validation only when the text widget 
     * loses focus.
     *
     * @see #setValidateStrategy
     */
    public static final int VALIDATE_ON_FOCUS_LOST = 1;
    /**