Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 10079 Details for
Bug 51996
Blocked UI warning occurs multiple times simultaneously
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
Patch to org.eclipse.ui.workbench
workbench.diff (text/plain), 13.15 KB, created by
John Arthorne
on 2004-04-28 17:02:37 EDT
(
hide
)
Description:
Patch to org.eclipse.ui.workbench
Filename:
MIME Type:
Creator:
John Arthorne
Created:
2004-04-28 17:02:37 EDT
Size:
13.15 KB
patch
obsolete
>Index: Eclipse UI/org/eclipse/ui/internal/dialogs/EventLoopProgressMonitor.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/EventLoopProgressMonitor.java,v >retrieving revision 1.14 >diff -u -r1.14 EventLoopProgressMonitor.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/EventLoopProgressMonitor.java 23 Apr 2004 16:00:48 -0000 1.14 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/EventLoopProgressMonitor.java 28 Apr 2004 20:50:33 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2003 IBM Corporation and others. >+ * Copyright (c) 2000, 2004 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Common Public License v1.0 > * which accompanies this distribution, and is available at >@@ -9,18 +9,10 @@ > * IBM Corporation - initial API and implementation > *******************************************************************************/ > package org.eclipse.ui.internal.dialogs; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.IProgressMonitorWithBlocking; >-import org.eclipse.core.runtime.IStatus; >-import org.eclipse.core.runtime.ProgressMonitorWrapper; >-import org.eclipse.core.runtime.Status; >+import org.eclipse.core.runtime.*; > import org.eclipse.swt.widgets.Display; >-import org.eclipse.ui.PlatformUI; > import org.eclipse.ui.internal.ExceptionHandler; >-import org.eclipse.ui.internal.WorkbenchMessages; > import org.eclipse.ui.internal.progress.BlockedJobsDialog; >-import org.eclipse.ui.internal.progress.ProgressManagerUtil; >-import org.eclipse.ui.progress.WorkbenchJob; > /** > * Used to run an event loop whenever progress monitor methods > * are invoked. <p> >@@ -40,10 +32,13 @@ > * Maximum amount of time to spend processing events, in ms. > */ > private static int T_MAX = 50; >+ > /** >- * The dialog that is shown when the operation is blocked >+ * The dialog that is shown when the operation is blocked, or null when no >+ * operation in the UI thread is blocked. > */ >- private BlockedJobsDialog dialog; >+ protected BlockedJobsDialog dialog; >+ > /** > * Last time the event loop was spun. > */ >@@ -65,12 +60,9 @@ > * @see org.eclipse.core.runtime.IProgressMonitorWithBlocking#clearBlocked() > */ > public void clearBlocked() { >- //the UI operation is no longer blocked so get rid of the progress dialog >- if (dialog == null || dialog.getShell() == null || dialog.getShell().isDisposed()){ >- dialog = null; >- return; >- } >- dialog.close(); >+ //dismiss the dialog that was reporting the blockage >+ if (dialog != null) >+ dialog.close(this); > dialog = null; > } > /** >@@ -91,6 +83,16 @@ > * @see IProgressMonitor#isCanceled > */ > public boolean isCanceled() { >+ if (dialog != null) { >+ IProgressMonitor blockedMonitor = dialog.getProgressMonitor(); >+ // If the blocked dialog already exists, and is associated with a different >+ // progress monitor, then this is a recursive blockage. Respond to the cancelation >+ // in the progress monitor that is associated with the dialog rather than this one. >+ // This will allow cancelation in the dialog to cancel all event loop monitors in >+ // the stack. >+ if (blockedMonitor != null && blockedMonitor != this) >+ return blockedMonitor.isCanceled(); >+ } > runEventLoop(); > return super.isCanceled(); > } >@@ -135,33 +137,7 @@ > * @see org.eclipse.core.runtime.IProgressMonitorWithBlocking#setBlocked(org.eclipse.core.runtime.IStatus) > */ > public void setBlocked(IStatus reason) { >- >- //The UI operation has been blocked. Open a progress dialog >- //to report the situation and give the user an opportunity to cancel. >- >- dialog = new BlockedJobsDialog(null, EventLoopProgressMonitor.this,reason); >- dialog.setBlockOnOpen(false); >- >- WorkbenchJob dialogJob = new WorkbenchJob(WorkbenchMessages.getString("EventLoopProgressMonitor.OpenDialogJobName")){ //$NON-NLS-1$ >- /* (non-Javadoc) >- * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) >- */ >- public IStatus runInUIThread(IProgressMonitor monitor) { >- >- if(dialog == null) >- return Status.CANCEL_STATUS; >- if(ProgressManagerUtil.rescheduleIfModalShellOpen(this)) >- return Status.CANCEL_STATUS; >- dialog.open(); >- return Status.OK_STATUS; >- } >- }; >- >- //Wait for long operation time to prevent a proliferation >- //of dialogs >- dialogJob.setSystem(true); >- dialogJob.schedule(PlatformUI.getWorkbench().getProgressService().getLongOperationTime()); >- >+ dialog = BlockedJobsDialog.createBlockedDialog(null, this, reason); > } > /** > * @see IProgressMonitor#setCanceled >Index: Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchWizardBlockedHandler.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/dialogs/Attic/WorkbenchWizardBlockedHandler.java,v >retrieving revision 1.1 >diff -u -r1.1 WorkbenchWizardBlockedHandler.java >--- Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchWizardBlockedHandler.java 15 Apr 2004 21:34:13 -0000 1.1 >+++ Eclipse UI/org/eclipse/ui/internal/dialogs/WorkbenchWizardBlockedHandler.java 28 Apr 2004 20:50:34 -0000 >@@ -19,7 +19,14 @@ > * implements the blocked handler for the workbench. > */ > public class WorkbenchWizardBlockedHandler implements IWizardBlockedHandler { >+ /** >+ * The dialog that reports blockage to the user. >+ */ > BlockedJobsDialog blockedDialog; >+ /** >+ * The progress monitor that is blocked. >+ */ >+ IProgressMonitor blockingMonitor; > > /** > * Create a new instance of the receiver. >@@ -33,8 +40,9 @@ > public void clearBlocked() { > if (blockedDialog == null) > return; >- blockedDialog.close(); >+ blockedDialog.close(blockingMonitor); > blockedDialog = null; >+ blockingMonitor = null; > } > /* (non-Javadoc) > * @see org.eclipse.jface.wizard.IWizardBlockedHandler#showBlocked(org.eclipse.swt.widgets.Shell, org.eclipse.core.runtime.IProgressMonitor, org.eclipse.core.runtime.IStatus, java.lang.String) >@@ -42,10 +50,10 @@ > public void showBlocked(Shell parentShell, IProgressMonitor blockingMonitor, > IStatus blockingStatus, String blockedName) { > //Try to get a name as best as possible >+ this.blockingMonitor = blockingMonitor; > if (blockedName == null) > blockedName = parentShell.getText(); >- blockedDialog = new BlockedJobsDialog(parentShell, blockingMonitor, blockingStatus); >+ blockedDialog = BlockedJobsDialog.createBlockedDialog(parentShell, blockingMonitor, blockingStatus); > blockedDialog.setBlockedTaskName(blockedName); >- blockedDialog.open(); > } > } >Index: Eclipse UI/org/eclipse/ui/internal/progress/BlockedJobsDialog.java >=================================================================== >RCS file: /home/eclipse/org.eclipse.ui.workbench/Eclipse UI/org/eclipse/ui/internal/progress/BlockedJobsDialog.java,v >retrieving revision 1.16 >diff -u -r1.16 BlockedJobsDialog.java >--- Eclipse UI/org/eclipse/ui/internal/progress/BlockedJobsDialog.java 27 Apr 2004 19:53:49 -0000 1.16 >+++ Eclipse UI/org/eclipse/ui/internal/progress/BlockedJobsDialog.java 28 Apr 2004 20:50:34 -0000 >@@ -9,34 +9,35 @@ > * IBM Corporation - initial API and implementation > *******************************************************************************/ > package org.eclipse.ui.internal.progress; >-import org.eclipse.core.runtime.IProgressMonitor; >-import org.eclipse.core.runtime.IStatus; >+import org.eclipse.core.runtime.*; > import org.eclipse.jface.dialogs.Dialog; > import org.eclipse.jface.dialogs.IconAndMessageDialog; > import org.eclipse.jface.resource.JFaceResources; >-import org.eclipse.jface.viewers.IContentProvider; >-import org.eclipse.jface.viewers.Viewer; >-import org.eclipse.jface.viewers.ViewerSorter; >+import org.eclipse.jface.viewers.*; > import org.eclipse.swt.SWT; > import org.eclipse.swt.graphics.Cursor; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.layout.GridData; >-import org.eclipse.swt.widgets.Button; >-import org.eclipse.swt.widgets.Composite; >-import org.eclipse.swt.widgets.Control; >-import org.eclipse.swt.widgets.Shell; >-import org.eclipse.swt.widgets.TreeItem; >+import org.eclipse.swt.widgets.*; >+import org.eclipse.ui.PlatformUI; >+import org.eclipse.ui.internal.WorkbenchMessages; >+import org.eclipse.ui.progress.WorkbenchJob; > /** > * The BlockedJobsDialog class displays a dialog that provides information on > * the running jobs. > */ > public class BlockedJobsDialog extends IconAndMessageDialog { > /** >+ * The singleton dialog instance. A singleton avoids the possibility >+ * of recursive dialogs being created. The singleton is created >+ * when a dialog is requested, and cleared when the dialog is disposed. >+ */ >+ protected static BlockedJobsDialog singleton; >+ >+ /** > * The running jobs progress tree. > * >- * @see /org.eclipse.ui.workbench/Eclipse >- * UI/org/eclipse/ui/internal/progress/ProgressTreeViewer.java >- * (org.eclipse.ui.internal.progress) >+ * @see org.eclipse.ui.internal.progress.ProgressTreeViewer > */ > private ProgressTreeViewer viewer; > /** >@@ -141,6 +142,47 @@ > } > /** > * Creates a progress monitor dialog under the given shell. It also sets the >+ * dialog's message. The dialog is opened automatically after a reasonable delay. >+ * When no longer needed, the dialog must be closed by calling >+ * <code>close(IProgressMonitor)</code>, where the supplied monitor is the >+ * same monitor passed to this factory method. >+ * >+ * @param parentShell >+ * The parent shell, or <code>null</code> to create a top-level shell. >+ * @param monitor >+ * The monitor that is currently blocked >+ * @param reason >+ * A status describing why the monitor is blocked >+ */ >+ public static BlockedJobsDialog createBlockedDialog(Shell parentShell, IProgressMonitor monitor, IStatus reason) { >+ //use an existing dialog if available >+ if (singleton != null) >+ return singleton; >+ singleton = new BlockedJobsDialog(parentShell, monitor, reason); >+ >+ //create the job that will open the dialog after a delay. >+ WorkbenchJob dialogJob = new WorkbenchJob(WorkbenchMessages.getString("EventLoopProgressMonitor.OpenDialogJobName")){ //$NON-NLS-1$ >+ /* (non-Javadoc) >+ * @see org.eclipse.ui.progress.UIJob#runInUIThread(org.eclipse.core.runtime.IProgressMonitor) >+ */ >+ public IStatus runInUIThread(IProgressMonitor monitor) { >+ if(singleton == null) >+ return Status.CANCEL_STATUS; >+ if(ProgressManagerUtil.rescheduleIfModalShellOpen(this)) >+ return Status.CANCEL_STATUS; >+ singleton.open(); >+ return Status.OK_STATUS; >+ } >+ }; >+ >+ //Wait for long operation time to prevent a proliferation >+ //of dialogs >+ dialogJob.setSystem(true); >+ dialogJob.schedule(PlatformUI.getWorkbench().getProgressService().getLongOperationTime()); >+ return singleton; >+ } >+ /** >+ * Creates a progress monitor dialog under the given shell. It also sets the > * dialog's\ message. <code>open</code> is non-blocking. > * > * @param parentShell >@@ -148,8 +190,10 @@ > * shell. > * @param blocking > * The monitor that is blocking the job >+ * @param blockingStatus >+ * A status describing why the monitor is blocked > */ >- public BlockedJobsDialog(Shell parentShell, IProgressMonitor blocking, >+ private BlockedJobsDialog(Shell parentShell, IProgressMonitor blocking, > IStatus blockingStatus) { > super(parentShell == null > ? ProgressManagerUtil.getDefaultParent() >@@ -242,7 +286,6 @@ > } > }; > } >- > /** > * Clear the cursors in the dialog. > */ >@@ -300,14 +343,29 @@ > protected Image getImage() { > return JFaceResources.getImageRegistry().get(Dialog.DLG_IMG_INFO); > } >- /* >- * (non-Javadoc) >- * >- * @see org.eclipse.jface.dialogs.Dialog#close() >+ /** >+ * Returns the progress monitor being used for this dialog. This allows recursive >+ * blockages to also respond to cancelation. >+ * @return > */ >- public boolean close() { >- clearCursors(); >- return super.close(); >+ public IProgressMonitor getProgressMonitor() { >+ return blockingMonitor; >+ } >+ /** >+ * Requests that the blocked jobs dialog be closed. The supplied monitor >+ * must be the same one that was passed to the createBlockedDialog method. >+ */ >+ public boolean close(IProgressMonitor monitor) { >+ //ignore requests to close the dialog from all but the first monitor >+ if (blockingMonitor != monitor) >+ return false; >+ try { >+ clearCursors(); >+ return super.close(); >+ } finally { >+ //make sure the singleton is discarded, even in case of failure >+ singleton = null; >+ } > } > /** > * Set the name of the task being blocked. If this value is not set then the >@@ -325,5 +383,4 @@ > protected Control createButtonBar(Composite parent) { > // Do nothing here as we want no buttons > return parent; >- } >-} >\ No newline at end of file >+}} >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 51996
:
7901
| 10079