diff --git a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/DecoratingIntegerFieldEditor.java b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/DecoratingIntegerFieldEditor.java
new file mode 100644
index 00000000000..a44fe7e17fa
--- /dev/null
+++ b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/DecoratingIntegerFieldEditor.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.dd.dsf.debug.internal.ui.preferences;
+
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * An {@link IntegerFieldEditor} with field decoration.
+ *
+ * @since 1.1
+ */
+public class DecoratingIntegerFieldEditor extends IntegerFieldEditor {
+
+ private ControlDecoration fDecoration;
+
+ protected DecoratingIntegerFieldEditor() {
+ }
+
+ /**
+ * Creates an integer field editor.
+ *
+ * @param name the name of the preference this field editor works on
+ * @param labelText the label text of the field editor
+ * @param parent the parent of the field editor's control
+ */
+ public DecoratingIntegerFieldEditor(String name, String labelText, Composite parent) {
+ super(name, labelText, parent);
+ }
+
+ /**
+ * Creates an integer field editor.
+ *
+ * @param name the name of the preference this field editor works on
+ * @param labelText the label text of the field editor
+ * @param parent the parent of the field editor's control
+ * @param textLimit the maximum number of characters in the text.
+ */
+ public DecoratingIntegerFieldEditor(String name, String labelText, Composite parent, int textLimit) {
+ super(name, labelText, parent, textLimit);
+ }
+
+ @Override
+ public Text getTextControl(Composite parent) {
+ Text control = super.getTextControl(parent);
+ if (fDecoration == null) {
+ fDecoration = new ControlDecoration(control, SWT.LEFT | SWT.TOP);
+ FieldDecoration errorDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
+ fDecoration.setImage(errorDecoration.getImage());
+ fDecoration.setDescriptionText(getErrorMessage());
+
+ // validate on focus gain
+ control.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ refreshValidState();
+ }
+ });
+ }
+ return control;
+ }
+
+ @Override
+ protected void showErrorMessage(String msg) {
+ super.showErrorMessage(msg);
+ if (fDecoration != null) {
+ fDecoration.setDescriptionText(msg);
+ fDecoration.show();
+ }
+ }
+
+ @Override
+ protected void clearErrorMessage() {
+ super.clearErrorMessage();
+ if (fDecoration != null) {
+ fDecoration.hide();
+ }
+ }
+
+}
diff --git a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/DecoratingStringFieldEditor.java b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/DecoratingStringFieldEditor.java
new file mode 100644
index 00000000000..3a61538193f
--- /dev/null
+++ b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/DecoratingStringFieldEditor.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2008 Wind River Systems, Inc. and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.dd.dsf.debug.internal.ui.preferences;
+
+import org.eclipse.jface.fieldassist.ControlDecoration;
+import org.eclipse.jface.fieldassist.FieldDecoration;
+import org.eclipse.jface.fieldassist.FieldDecorationRegistry;
+import org.eclipse.jface.preference.StringFieldEditor;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.events.FocusAdapter;
+import org.eclipse.swt.events.FocusEvent;
+import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Text;
+
+/**
+ * A {@link StringFieldEditor} with field decoration.
+ * @since 1.1
+ */
+public class DecoratingStringFieldEditor extends StringFieldEditor {
+
+ private ControlDecoration fDecoration;
+
+ protected DecoratingStringFieldEditor() {
+ }
+
+ /**
+ * Creates a string field editor of unlimited width.
+ * Use the method setTextLimit
to limit the text.
+ *
+ * @param name the name of the preference this field editor works on
+ * @param labelText the label text of the field editor
+ * @param parent the parent of the field editor's control
+ */
+ public DecoratingStringFieldEditor(String name, String labelText, Composite parent) {
+ super(name, labelText, parent);
+ }
+
+ /**
+ * Creates a string field editor.
+ * Use the method setTextLimit
to limit the text.
+ *
+ * @param name the name of the preference this field editor works on
+ * @param labelText the label text of the field editor
+ * @param width the width of the text input field in characters,
+ * or UNLIMITED
for no limit
+ * @param parent the parent of the field editor's control
+ */
+ public DecoratingStringFieldEditor(String name, String labelText, int width, Composite parent) {
+ super(name, labelText, width, parent);
+ }
+
+ /**
+ * Creates a string field editor.
+ * Use the method setTextLimit
to limit the text.
+ *
+ * @param name the name of the preference this field editor works on
+ * @param labelText the label text of the field editor
+ * @param width the width of the text input field in characters,
+ * or UNLIMITED
for no limit
+ * @param strategy either VALIDATE_ON_KEY_STROKE
to perform
+ * on the fly checking (the default), or VALIDATE_ON_FOCUS_LOST
to
+ * perform validation only after the text has been typed in
+ * @param parent the parent of the field editor's control
+ */
+ public DecoratingStringFieldEditor(String name, String labelText, int width, int strategy, Composite parent) {
+ super(name, labelText, width, strategy, parent);
+ }
+
+ @Override
+ public Text getTextControl(Composite parent) {
+ Text control = super.getTextControl(parent);
+ if (fDecoration == null) {
+ fDecoration = new ControlDecoration(control, SWT.LEFT | SWT.TOP);
+ FieldDecoration errorDecoration = FieldDecorationRegistry.getDefault().getFieldDecoration(FieldDecorationRegistry.DEC_ERROR);
+ fDecoration.setImage(errorDecoration.getImage());
+ fDecoration.setDescriptionText(getErrorMessage());
+
+ // validate on focus gain
+ control.addFocusListener(new FocusAdapter() {
+ @Override
+ public void focusGained(FocusEvent e) {
+ refreshValidState();
+ }
+ });
+ }
+ return control;
+ }
+
+ @Override
+ protected void showErrorMessage(String msg) {
+ super.showErrorMessage(msg);
+ if (fDecoration != null) {
+ fDecoration.setDescriptionText(msg);
+ fDecoration.show();
+ }
+ }
+
+ @Override
+ protected void clearErrorMessage() {
+ super.clearErrorMessage();
+ if (fDecoration != null) {
+ fDecoration.hide();
+ }
+ }
+}
diff --git a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/DsfDebugPreferencePage.java b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/DsfDebugPreferencePage.java
index 7859c2d6d0a..77170380945 100644
--- a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/DsfDebugPreferencePage.java
+++ b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/DsfDebugPreferencePage.java
@@ -16,6 +16,7 @@ import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.jface.preference.IntegerFieldEditor;
+import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
@@ -73,6 +74,7 @@ public class DsfDebugPreferencePage extends FieldEditorPreferencePage implements
performanceGroup);
limitEditor.setValidRange(1, Integer.MAX_VALUE);
+ limitEditor.setValidateStrategy(StringFieldEditor.VALIDATE_ON_FOCUS_LOST);
limitEditor.fillIntoGrid(performanceGroup, 3);
addField(limitEditor);
@@ -86,7 +88,7 @@ public class DsfDebugPreferencePage extends FieldEditorPreferencePage implements
addField(syncSteppingEditor);
// minimum step interval
- IntegerFieldEditor minIntervalEditor= new IntegerFieldEditor(
+ IntegerFieldEditor minIntervalEditor= new DecoratingIntegerFieldEditor(
IDsfDebugUIConstants.PREF_MIN_STEP_INTERVAL,
MessagesForPreferences.DsfDebugPreferencePage_minStepInterval_label,
performanceGroup);
diff --git a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/IntegerWithBooleanFieldEditor.java b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/IntegerWithBooleanFieldEditor.java
index b53cdf1d1e4..071e43552b6 100644
--- a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/IntegerWithBooleanFieldEditor.java
+++ b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/IntegerWithBooleanFieldEditor.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.dd.dsf.debug.internal.ui.preferences;
-import org.eclipse.jface.preference.IntegerFieldEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -22,7 +21,7 @@ import org.eclipse.swt.widgets.Label;
/**
* An integer field editor with an enablement check box.
*/
-public class IntegerWithBooleanFieldEditor extends IntegerFieldEditor {
+public class IntegerWithBooleanFieldEditor extends DecoratingIntegerFieldEditor {
private final String fEnableKey;
private Button fCheckbox;
@@ -83,8 +82,8 @@ public class IntegerWithBooleanFieldEditor extends IntegerFieldEditor {
}
protected void valueChanged(boolean oldValue, boolean newValue) {
- setPresentsDefaultValue(false);
if (oldValue != newValue) {
+ valueChanged();
fireStateChanged(VALUE, oldValue, newValue);
getTextControl().setEnabled(newValue);
getLabelControl().setEnabled(newValue);
@@ -94,6 +93,7 @@ public class IntegerWithBooleanFieldEditor extends IntegerFieldEditor {
@Override
protected boolean checkState() {
if (fCheckbox != null && !fCheckbox.getSelection()) {
+ clearErrorMessage();
return true;
}
return super.checkState();
diff --git a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/StringWithBooleanFieldEditor.java b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/StringWithBooleanFieldEditor.java
index 4f9edd0ae0f..9ed0707acfe 100644
--- a/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/StringWithBooleanFieldEditor.java
+++ b/plugins/org.eclipse.dd.dsf.debug.ui/src/org/eclipse/dd/dsf/debug/internal/ui/preferences/StringWithBooleanFieldEditor.java
@@ -10,7 +10,6 @@
*******************************************************************************/
package org.eclipse.dd.dsf.debug.internal.ui.preferences;
-import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;
@@ -22,7 +21,7 @@ import org.eclipse.swt.widgets.Label;
/**
* A string field editor with an enablement check box.
*/
-public class StringWithBooleanFieldEditor extends StringFieldEditor {
+public class StringWithBooleanFieldEditor extends DecoratingStringFieldEditor {
private final String fEnableKey;
private Button fCheckbox;
@@ -88,8 +87,8 @@ public class StringWithBooleanFieldEditor extends StringFieldEditor {
}
protected void valueChanged(boolean oldValue, boolean newValue) {
- setPresentsDefaultValue(false);
if (oldValue != newValue) {
+ valueChanged();
fireStateChanged(VALUE, oldValue, newValue);
getTextControl().setEnabled(newValue);
getLabelControl().setEnabled(newValue);
@@ -99,6 +98,7 @@ public class StringWithBooleanFieldEditor extends StringFieldEditor {
@Override
protected boolean checkState() {
if (fCheckbox != null && !fCheckbox.getSelection()) {
+ clearErrorMessage();
return true;
}
return super.checkState();