Skip to main content
summaryrefslogtreecommitdiffstats
path: root/codan
diff options
context:
space:
mode:
authorSergey Prigogin2011-03-23 02:47:21 +0000
committerSergey Prigogin2011-03-23 02:47:21 +0000
commitb7f9782106cba4c872494650f733ec1471f6546d (patch)
tree516ba9302d4b0958977b48388e14778062c08e7a /codan
parentba7cd25db13a8445fc032dc35c998e7970a83eac (diff)
downloadorg.eclipse.cdt-b7f9782106cba4c872494650f733ec1471f6546d.tar.gz
org.eclipse.cdt-b7f9782106cba4c872494650f733ec1471f6546d.tar.xz
org.eclipse.cdt-b7f9782106cba4c872494650f733ec1471f6546d.zip
Bug 339294 - Message Pattern should not be user-configurable. Patch by Alex Ruiz.
Diffstat (limited to 'codan')
-rw-r--r--codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java27
1 files changed, 26 insertions, 1 deletions
diff --git a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java
index bfb70b42de4..99b9a6ba1ef 100644
--- a/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java
+++ b/codan/org.eclipse.cdt.codan.ui/src/org/eclipse/cdt/codan/internal/ui/widgets/ParametersComposite.java
@@ -31,11 +31,13 @@ import org.eclipse.jface.preference.PreferenceStore;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.jface.window.Window;
import org.eclipse.swt.SWT;
+import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Label;
+import org.eclipse.swt.widgets.Text;
/**
* Composite to show problem preferences
@@ -74,11 +76,34 @@ public class ParametersComposite extends Composite {
{ NO_CHANGE, NO_CHANGE }, //
};
addField(new ComboFieldEditor(PREF_SEVERITY, CodanUIMessages.ParametersComposite_Severity, entries, getFieldEditorParent()));
- addField(new StringFieldEditor(PREF_MESSAGE, CodanUIMessages.ParametersComposite_MessagePattern, getFieldEditorParent()));
+ StringFieldEditor messagePatternEditor = new StringFieldEditor(PREF_MESSAGE,
+ CodanUIMessages.ParametersComposite_MessagePattern, getFieldEditorParent());
+ // We are using read-only text field for message pattern to allow copy to clipboard.
+ makeUneditable(messagePatternEditor);
+ addField(messagePatternEditor);
IProblemPreference pref = problem.getPreference();
createFieldEditorsForParameters(pref);
}
+ private void makeUneditable(StringFieldEditor editor) {
+ /*
+ * Here we are doing 2 things to make a text control "uneditable":
+ * 1. 'setUneditable(false)' the problem with with just doing this is that
+ * the background of the text control doesn't change, and it looks like
+ * an editable one. This is confusing to the user.
+ * 2. Getting the background of a label control and applying it
+ * to the "uneditable" text control. This way it is easier to figure out that
+ * the contents of the text control cannot be changed.
+ * Why not just setEnable(false)? Because it changes the text of the text control
+ * to light gray, making it difficult to read. Also, users cannot select and copy
+ * text from a disabled text field.
+ */
+ Color background = editor.getLabelControl(getFieldEditorParent()).getBackground();
+ Text text = editor.getTextControl(getFieldEditorParent());
+ text.setBackground(background);
+ text.setEditable(false);
+ }
+
@Override
protected Control createContents(Composite parent) {
return super.createContents(parent);

Back to the top