Bug 334093 [RCP] RCP application without a status line is completely
crippled when trying to use the workbench window as an IRunnableContext

If the status line manager does not actually have a status line
because it has not or will not be created, a null progress
monitor should be returned instead so that the client calling
methods on the progress monitor will not receive runtime
exceptions for invoking methods on a disposed or null control.
diff --git a/bundles/org.eclipse.jface/src/org/eclipse/jface/action/StatusLineManager.java b/bundles/org.eclipse.jface/src/org/eclipse/jface/action/StatusLineManager.java
index a17e0fc..7eed699 100644
--- a/bundles/org.eclipse.jface/src/org/eclipse/jface/action/StatusLineManager.java
+++ b/bundles/org.eclipse.jface/src/org/eclipse/jface/action/StatusLineManager.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -13,6 +13,7 @@
 import org.eclipse.core.runtime.IProgressMonitor;
 import org.eclipse.core.runtime.IProgressMonitorWithBlocking;
 import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.NullProgressMonitor;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.widgets.Composite;
@@ -145,11 +146,11 @@
      * Method declared on IStatusLineManager
      */
     public IProgressMonitor getProgressMonitor() {
+		final IProgressMonitor progressDelegate = statusLineExist() ? getProgressMonitorDelegate()
+				: new NullProgressMonitor();
 
         return new IProgressMonitorWithBlocking() {
 
-            IProgressMonitor progressDelegate = getProgressMonitorDelegate();
-
             /* (non-Javadoc)
              * @see org.eclipse.core.runtime.IProgressMonitor#beginTask(java.lang.String, int)
              */
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/AllTests.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/AllTests.java
index 6857c14..d738b2c 100644
--- a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/AllTests.java
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/AllTests.java
@@ -1,5 +1,5 @@
 /*******************************************************************************
- * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * Copyright (c) 2000, 2011 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
@@ -33,5 +33,6 @@
         addTest(new org.eclipse.jface.tests.wizards.WizardTestSuite());
         addTest(new org.eclipse.jface.tests.labelProviders.DecoratingLabelProviderTests());
         addTest(new org.eclipse.jface.tests.fieldassist.FieldAssistTestSuite());
+        addTest(new org.eclipse.jface.tests.window.AllTests());
     }
 }
diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/window/AllTests.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/window/AllTests.java
new file mode 100644
index 0000000..d60d1ff
--- /dev/null
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/window/AllTests.java
@@ -0,0 +1,31 @@
+/*******************************************************************************

+ * Copyright (c) 2011 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

+ * http://www.eclipse.org/legal/epl-v10.html

+ *

+ * Contributors:

+ *     IBM Corporation - initial API and implementation

+ ******************************************************************************/

+

+package org.eclipse.jface.tests.window;

+

+import junit.framework.Test;

+import junit.framework.TestSuite;

+

+public class AllTests extends TestSuite {

+

+	public static void main(String[] args) {

+		junit.textui.TestRunner.run(suite());

+	}

+

+	public static Test suite() {

+		return new AllTests();

+	}

+

+	public AllTests() {

+		addTestSuite(ApplicationWindowTest.class);

+	}

+

+}

diff --git a/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/window/ApplicationWindowTest.java b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/window/ApplicationWindowTest.java
new file mode 100644
index 0000000..cb68d34
--- /dev/null
+++ b/tests/org.eclipse.ui.tests/Eclipse JFace Tests/org/eclipse/jface/tests/window/ApplicationWindowTest.java
@@ -0,0 +1,85 @@
+/*******************************************************************************

+ * Copyright (c) 2011 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

+ * http://www.eclipse.org/legal/epl-v10.html

+ *

+ * Contributors:

+ *     IBM Corporation - initial API and implementation

+ ******************************************************************************/

+package org.eclipse.jface.tests.window;

+

+import junit.framework.TestCase;

+

+import org.eclipse.core.runtime.IProgressMonitor;

+import org.eclipse.core.runtime.IProgressMonitorWithBlocking;

+import org.eclipse.core.runtime.Status;

+import org.eclipse.jface.operation.IRunnableWithProgress;

+import org.eclipse.jface.window.ApplicationWindow;

+import org.eclipse.swt.widgets.Shell;

+

+public class ApplicationWindowTest extends TestCase {

+

+	private ApplicationWindow window;

+

+	protected void tearDown() throws Exception {

+		if (window != null) {

+			// close the window

+			window.close();

+			window = null;

+		}

+		super.tearDown();

+	}

+

+	private void testBug334093(boolean fork, boolean cancelable)

+			throws Exception {

+		window = new ApplicationWindow(null) {

+			public void create() {

+				addStatusLine();

+				super.create();

+			}

+

+			protected void createTrimWidgets(Shell shell) {

+				// don't actually create the status line controls

+			}

+		};

+		window.create();

+		window.run(fork, cancelable, new IRunnableWithProgress() {

+			public void run(IProgressMonitor monitor) {

+				monitor.beginTask("beginTask", 10);

+				monitor.setTaskName("setTaskName");

+				monitor.subTask("subTask");

+

+				if (monitor instanceof IProgressMonitorWithBlocking) {

+					IProgressMonitorWithBlocking blockingMonitor = (IProgressMonitorWithBlocking) monitor;

+					blockingMonitor.setBlocked(Status.CANCEL_STATUS);

+					blockingMonitor.clearBlocked();

+				}

+

+				monitor.worked(1);

+				monitor.setCanceled(true);

+				monitor.isCanceled();

+				monitor.setCanceled(false);

+				monitor.done();

+			}

+		});

+	}

+

+	public void testBug334093_TrueTrue() throws Exception {

+		testBug334093(true, true);

+	}

+

+	public void testBug334093_TrueFalse() throws Exception {

+		testBug334093(true, false);

+	}

+

+	public void testBug334093_FalseTrue() throws Exception {

+		testBug334093(false, true);

+	}

+

+	public void testBug334093_FalseFalse() throws Exception {

+		testBug334093(false, false);

+	}

+

+}