Bug 578864 - remove fake job from waiting progress list

The change removes an entry for the swt display thread
"The user is waiting for background work to complete"
if no particular Job was running in display thread.

Since it is now possible to cancel exactly that job
with a dedicated cancel button the additional entry
for does not add value but is confusing.

Change-Id: I857fac569f58fb46fa0994b760b79df72a5f8da4
Signed-off-by: Joerg Kubitz <jkubitz-eclipse@gmx.de>
Reviewed-on: https://git.eclipse.org/r/c/platform/eclipse.platform.ui/+/191000
Tested-by: Platform Bot <platform-bot@eclipse.org>
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchDialogBlockedHandler.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchDialogBlockedHandler.java
index b66b3d0..dac3121 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchDialogBlockedHandler.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchDialogBlockedHandler.java
@@ -58,11 +58,7 @@
 		nestingDepth++;
 		if (outerMonitor == null) {
 			outerMonitor = blockingMonitor;
-			// Try to get a name as best as possible
-			if (blockedName == null && parentShell != null) {
-				blockedName = parentShell.getText();
-			}
-			BlockedJobsDialog.createBlockedDialog(parentShell, blockingMonitor, blockingStatus, blockedName);
+			BlockedJobsDialog.createBlockedDialog(parentShell, blockingMonitor, blockingStatus);
 		}
 
 	}
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/BlockedJobsDialog.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/BlockedJobsDialog.java
index 41eafda..d4bae0d 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/BlockedJobsDialog.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/BlockedJobsDialog.java
@@ -18,7 +18,6 @@
 import org.eclipse.core.runtime.Status;
 import org.eclipse.jface.dialogs.IDialogConstants;
 import org.eclipse.jface.dialogs.IconAndMessageDialog;
-import org.eclipse.jface.resource.JFaceResources;
 import org.eclipse.swt.SWT;
 import org.eclipse.swt.graphics.Image;
 import org.eclipse.swt.layout.GridData;
@@ -48,68 +47,12 @@
 	private DetailedProgressViewer viewer;
 
 	/**
-	 * The name of the task that is being blocked.
-	 */
-	private String blockedTaskName = ProgressMessages.SubTaskInfo_UndefinedTaskName;
-
-	/**
 	 * The Cancel button control.
 	 */
 	private Button cancelSelected;
 
 	private IProgressMonitor blockingMonitor;
 
-	private JobTreeElement blockedElement = new BlockedUIElement();
-
-	/**
-	 * The BlockedUIElement is the JobTreeElement that represents the blocked job in
-	 * the dialog.
-	 */
-	private class BlockedUIElement extends JobTreeElement {
-		@Override
-		Object[] getChildren() {
-			return ProgressManagerUtil.EMPTY_OBJECT_ARRAY;
-		}
-
-		@Override
-		String getDisplayString() {
-			if (blockedTaskName == null || blockedTaskName.isEmpty()) {
-				return ProgressMessages.BlockedJobsDialog_UserInterfaceTreeElement;
-			}
-			return blockedTaskName;
-		}
-
-		@Override
-		public Image getDisplayImage() {
-			return JFaceResources.getImage(ProgressManager.WAITING_JOB_KEY);
-		}
-
-		@Override
-		boolean hasChildren() {
-			return false;
-		}
-
-		@Override
-		boolean isActive() {
-			return true;
-		}
-
-		@Override
-		boolean isJobInfo() {
-			return false;
-		}
-
-		@Override
-		public void cancel() {
-			blockingMonitor.setCanceled(true);
-		}
-
-		@Override
-		public boolean isCancellable() {
-			return true;
-		}
-	}
-
 	/**
 	 * Creates a progress monitor dialog under the given shell. It also sets the
 	 * dialog's message. The dialog is opened automatically after a reasonable
@@ -124,23 +67,16 @@
 	 *                       until there is no modal shell blocking it.
 	 * @param blockedMonitor The monitor that is currently blocked
 	 * @param reason         A status describing why the monitor is blocked
-	 * @param taskName       A name to give the blocking task in the dialog
 	 * @return BlockedJobsDialog
 	 */
 	public static BlockedJobsDialog createBlockedDialog(Shell parentShell, IProgressMonitor blockedMonitor,
-			IStatus reason, String taskName) {
+			IStatus reason) {
 		// Use an existing dialog if available.
 		if (singleton != null) {
 			return singleton;
 		}
 		singleton = new BlockedJobsDialog(parentShell, blockedMonitor, reason);
 
-		if (taskName == null || taskName.isEmpty()) {
-			singleton.setBlockedTaskName(ProgressMessages.BlockedJobsDialog_UserInterfaceTreeElement);
-		} else {
-			singleton.setBlockedTaskName(taskName);
-		}
-
 		/**
 		 * If there is no parent shell we have not been asked for a parent so we want to
 		 * avoid blocking. If there is a parent then it is OK to open.
@@ -240,16 +176,7 @@
 	 * @return ProgressTreeContentProvider
 	 */
 	private ProgressViewerContentProvider getContentProvider() {
-		return new ProgressViewerContentProvider(viewer, true, false) {
-			@Override
-			public Object[] getElements(Object inputElement) {
-				Object[] elements = super.getElements(inputElement);
-				Object[] result = new Object[elements.length + 1];
-				System.arraycopy(elements, 0, result, 1, elements.length);
-				result[0] = blockedElement;
-				return result;
-			}
-		};
+		return new ProgressViewerContentProvider(viewer, true, false);
 	}
 
 	/**
@@ -342,11 +269,4 @@
 		blockingMonitor.clearBlocked(); // clearBlocked() results in calling close()
 		blockingMonitor.setCanceled(true);
 	}
-
-	/**
-	 * @param taskName The blockedTaskName to set.
-	 */
-	void setBlockedTaskName(String taskName) {
-		this.blockedTaskName = taskName;
-	}
 }
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressMessages.java b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressMessages.java
index 09c863a..11655f1 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressMessages.java
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/ProgressMessages.java
@@ -59,7 +59,6 @@
 	public static String ProgressMonitorJobsDialog_HideTitle;
 	public static String AnimationManager_AnimationStart;
 	public static String ProgressFloatingWindow_EllipsisValue;
-	public static String BlockedJobsDialog_UserInterfaceTreeElement;
 	public static String BlockedJobsDialog_BlockedTitle;
 	public static String BlockedJobsDialog_CancelButtonText;
 	public static String WorkbenchSiteProgressService_CursorJob;
diff --git a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/messages.properties b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/messages.properties
index f3bab92..2eb211a 100644
--- a/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/messages.properties
+++ b/bundles/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/messages.properties
@@ -55,7 +55,6 @@
 AnimationManager_AnimationStart=Animation start
 ProgressFloatingWindow_EllipsisValue=...
 
-BlockedJobsDialog_UserInterfaceTreeElement=Waiting User Operation
 BlockedJobsDialog_BlockedTitle=User Operation is Waiting
 BlockedJobsDialog_CancelButtonText=&Cancel User Operation
 WorkbenchSiteProgressService_CursorJob=Change cursor