Bug 327842: Key bindings broken in editor when showing status
diff --git a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EncodingChangeTests.java b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EncodingChangeTests.java
index 1de880a..94f7b39 100644
--- a/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EncodingChangeTests.java
+++ b/org.eclipse.ui.editors.tests/src/org/eclipse/ui/editors/tests/EncodingChangeTests.java
@@ -16,8 +16,8 @@
 import junit.framework.TestSuite;
 
 import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.custom.StyledText;
 import org.eclipse.swt.widgets.Composite;
-import org.eclipse.swt.widgets.Text;
 
 import org.eclipse.core.runtime.CoreException;
 
@@ -172,7 +172,7 @@
 				String expected= encodingSupport.getStatusMessage(fileBuffer.getStatus());
 				Composite composite= (Composite)accessor.get("fStatusControl");
 				ScrolledComposite scrolledComposite= (ScrolledComposite)composite.getChildren()[0];
-				Text statusText= (Text)((Composite)scrolledComposite.getContent()).getChildren()[5];
+				StyledText statusText= (StyledText)((Composite)scrolledComposite.getContent()).getChildren()[5];
 				String actual= statusText.getText();
 				assertEquals(expected, actual);
 			} else
diff --git a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/DefaultEncodingSupport.java b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/DefaultEncodingSupport.java
index a8e681e..930c432 100644
--- a/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/DefaultEncodingSupport.java
+++ b/org.eclipse.ui.editors/src/org/eclipse/ui/editors/text/DefaultEncodingSupport.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2008 IBM Corporation and others.
+ * Copyright (c) 2000, 2010 IBM Corporation 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
@@ -27,9 +27,9 @@
 
 import org.eclipse.core.runtime.IStatus;
 import org.eclipse.core.runtime.preferences.IEclipsePreferences;
-import org.eclipse.core.runtime.preferences.InstanceScope;
 import org.eclipse.core.runtime.preferences.IEclipsePreferences.IPreferenceChangeListener;
 import org.eclipse.core.runtime.preferences.IEclipsePreferences.PreferenceChangeEvent;
+import org.eclipse.core.runtime.preferences.InstanceScope;
 
 import org.eclipse.core.resources.ResourcesPlugin;
 
@@ -301,6 +301,7 @@
 				action.run();
 			}
 		});
+		button.setFocus();
 
 		Label filler= new Label(parent, SWT.NONE);
 		filler.setLayoutData(new GridData(GridData.FILL_BOTH));
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java
index fb07bd0..3b1310b 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/InfoForm.java
@@ -15,6 +15,7 @@
 
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.custom.ScrolledComposite;
+import org.eclipse.swt.custom.StyledText;
 import org.eclipse.swt.events.DisposeEvent;
 import org.eclipse.swt.events.DisposeListener;
 import org.eclipse.swt.graphics.Color;
@@ -24,7 +25,6 @@
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Display;
 import org.eclipse.swt.widgets.Label;
-import org.eclipse.swt.widgets.Text;
 
 import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.jface.util.IPropertyChangeListener;
@@ -53,7 +53,7 @@
 	/** The form banner */
 	private Label fBanner;
 	/** The form text */
-	private Text fText;
+	private StyledText fText;
 	/** The preference change listener */
 	private IPropertyChangeListener fPropertyChangeListener;
 
@@ -207,8 +207,8 @@
 		return label;
 	}
 	
-	private Text createText(Composite parent, String text) {
-		Text widget = new Text(parent, SWT.READ_ONLY | SWT.MULTI);
+	private StyledText createText(Composite parent, String text) {
+		StyledText widget = new StyledText(parent, SWT.READ_ONLY | SWT.MULTI);
 		GridData data= new GridData(GridData.FILL_HORIZONTAL);
 		widget.setLayoutData(data);
 
@@ -216,6 +216,7 @@
 			widget.setText(text);
 		widget.setBackground(fBackgroundColor);
 		widget.setForeground(fForegroundColor);
+		widget.setCaret(null);
 		return widget;
 	}
 
diff --git a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusTextEditor.java b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusTextEditor.java
index 5a7706a..dd3c3f5 100644
--- a/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusTextEditor.java
+++ b/org.eclipse.ui.workbench.texteditor/src/org/eclipse/ui/texteditor/StatusTextEditor.java
@@ -67,11 +67,7 @@
 		
 		if (fStatusControl != null) {
 			if (!fStatusControl.isDisposed()) {
-				Control focusControl= fStatusControl.getDisplay().getFocusControl();
-				while (focusControl != fParent && focusControl != null && !(focusControl instanceof Shell)) {
-					focusControl= focusControl.getParent();
-				}
-				restoreFocus= focusControl == fParent;
+				restoreFocus= containsFocus(fStatusControl);
 			}
 			fStatusControl.dispose();
 			fStatusControl= null;
@@ -97,10 +93,21 @@
 			updateStatusFields();
 		}
 
-		if (restoreFocus) {
+		if (restoreFocus && fStatusControl != null && !containsFocus(fStatusControl)) {
 			fParent.setFocus();
 		}
 	}
+
+	private boolean containsFocus(Control control) {
+		Control focusControl= control.getDisplay().getFocusControl();
+		if (focusControl != null) {
+			focusControl= focusControl.getParent();
+			while (focusControl != fParent && focusControl != null && !(focusControl instanceof Shell)) {
+				focusControl= focusControl.getParent();
+			}
+		}
+		return focusControl == fParent;
+	}
 	
 	/*
 	 * @see org.eclipse.ui.texteditor.AbstractTextEditor#setFocus()