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 44643 Details for
Bug 143198
SWTExceptions occurring when handling notifications from worker thread transactions
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]
update patch
progress meter synchronize.txt (text/plain), 17.61 KB, created by
Steven R. Shaw
on 2006-06-16 10:32:21 EDT
(
hide
)
Description:
update patch
Filename:
MIME Type:
Creator:
Steven R. Shaw
Created:
2006-06-16 10:32:21 EDT
Size:
17.61 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.gmf.runtime.diagram.ui >Index: src/org/eclipse/gmf/runtime/diagram/ui/internal/DiagramEventBrokerThreadSafe.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/internal/DiagramEventBrokerThreadSafe.java,v >retrieving revision 1.1 >diff -u -r1.1 DiagramEventBrokerThreadSafe.java >--- src/org/eclipse/gmf/runtime/diagram/ui/internal/DiagramEventBrokerThreadSafe.java 31 May 2006 16:26:07 -0000 1.1 >+++ src/org/eclipse/gmf/runtime/diagram/ui/internal/DiagramEventBrokerThreadSafe.java 16 Jun 2006 14:27:19 -0000 >@@ -11,16 +11,10 @@ > package org.eclipse.gmf.runtime.diagram.ui.internal; > > import java.lang.ref.WeakReference; >-import java.util.Iterator; >-import java.util.Set; > >-import org.eclipse.emf.common.notify.Notification; > import org.eclipse.emf.transaction.ResourceSetChangeEvent; > import org.eclipse.emf.transaction.TransactionalEditingDomain; >-import org.eclipse.gef.EditPartViewer; > import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker; >-import org.eclipse.gmf.runtime.diagram.ui.internal.parts.NotificationForEditPartsListener; >-import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer; > import org.eclipse.swt.widgets.Display; > import org.eclipse.ui.PlatformUI; > >@@ -34,8 +28,8 @@ > * that has been exeucted with a progress meter, where the progress meter is displaying UI on the main > * thread and there is a background thread that is being executed that the progress meter is monitoring. > * For this scenario, the UI updates on the diagram viewer have been disabled so as to avoid concurrency >- * issues and it is desirable that the notifications continue to be handled on the worker thread so that >- * the progress meter doesn't lock up. >+ * issues. When notifications are handled, they are synchronized to the main thread to avoid >+ * SWTExceptions when UI tries to access SWT resources when updating figures or other UI. > * > * The second scenario is for when a job has been executed on a worker thread, but has not been executed > * through the OperationHistory. Consequently, there is no hook for turning off display updates. This >@@ -60,44 +54,27 @@ > * @see org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker#resourceSetChanged(org.eclipse.emf.transaction.ResourceSetChangeEvent) > */ > public void resourceSetChanged(ResourceSetChangeEvent event) { >- if (Display.getCurrent() == null) { >- if (shouldSynchronizeWithMainThread(event)) { >- // force synchronization with the main thread >- final ResourceSetChangeEvent eventToHandle = event; >- TransactionalEditingDomain editingDomain = (TransactionalEditingDomain)editingDomainRef.get(); >- if (editingDomain != null) { >- PlatformUI.getWorkbench().getDisplay().syncExec(editingDomain.createPrivilegedRunnable(new Runnable() { >- public void run() { >- internal_resourceSetChanged(eventToHandle); >- } >- })); >+ if (shouldSynchronizeWithMainThread(event)) { >+ // force synchronization with the main thread >+ final ResourceSetChangeEvent eventToHandle = event; >+ TransactionalEditingDomain editingDomain = (TransactionalEditingDomain)editingDomainRef.get(); >+ if (editingDomain != null) { >+ PlatformUI.getWorkbench().getDisplay().syncExec(editingDomain.createPrivilegedRunnable(new Runnable() { >+ public void run() { >+ internal_resourceSetChanged(eventToHandle); >+ } >+ })); > >- return; >- } >- } >+ return; >+ } > } > > super.resourceSetChanged(event); > } > > private boolean shouldSynchronizeWithMainThread(ResourceSetChangeEvent event) { >- >- for (Iterator i = event.getNotifications().iterator(); i.hasNext();) { >- final Notification notification = (Notification) i.next(); >- Set nlSet = getInterestedNotificationListeners(notification, false); >- Iterator iter = nlSet.iterator(); >- while (iter.hasNext()) { >- Object listener = iter.next(); >- if (listener instanceof NotificationForEditPartsListener) { >- EditPartViewer viewer = ((NotificationForEditPartsListener)listener).getViewer(); >- if (viewer instanceof DiagramGraphicalViewer) { >- if (!((DiagramGraphicalViewer)viewer).areUpdatesDisabled()) { >- return true; >- } >- } >- } >- } >- } >+ if (Display.getCurrent() == null) >+ return true; > > return false; > } >Index: src/org/eclipse/gmf/runtime/diagram/ui/commands/DeferredLayoutCommand.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/commands/DeferredLayoutCommand.java,v >retrieving revision 1.10 >diff -u -r1.10 DeferredLayoutCommand.java >--- src/org/eclipse/gmf/runtime/diagram/ui/commands/DeferredLayoutCommand.java 13 Jun 2006 20:21:04 -0000 1.10 >+++ src/org/eclipse/gmf/runtime/diagram/ui/commands/DeferredLayoutCommand.java 16 Jun 2006 14:27:18 -0000 >@@ -23,7 +23,9 @@ > import org.eclipse.core.resources.IFile; > import org.eclipse.core.runtime.IAdaptable; > import org.eclipse.core.runtime.IProgressMonitor; >+import org.eclipse.core.runtime.IStatus; > import org.eclipse.draw2d.IFigure; >+import org.eclipse.emf.transaction.RunnableWithResult; > import org.eclipse.emf.transaction.TransactionalEditingDomain; > import org.eclipse.emf.workspace.util.WorkspaceSynchronizer; > import org.eclipse.gef.commands.Command; >@@ -33,6 +35,7 @@ > import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; > import org.eclipse.gmf.runtime.diagram.ui.requests.ArrangeRequest; > import org.eclipse.gmf.runtime.diagram.ui.services.layout.LayoutType; >+import org.eclipse.gmf.runtime.diagram.ui.util.EditPartUtil; > import org.eclipse.gmf.runtime.emf.commands.core.command.AbstractTransactionalCommand; > import org.eclipse.gmf.runtime.notation.View; > >@@ -121,39 +124,68 @@ > IProgressMonitor progressMonitor, IAdaptable info) > throws ExecutionException { > >- containerEP.refresh(); >- >- // The layout command requires that the figure world is updated. >- getContainerFigure().invalidate(); >- getContainerFigure().validate(); >- >- List editParts = new ArrayList(viewAdapters.size()); >- Map epRegistry = containerEP.getRoot().getViewer() >- .getEditPartRegistry(); >- for (Iterator iter = viewAdapters.iterator(); iter.hasNext();) { >- IAdaptable ad = (IAdaptable) iter.next(); >- View view = (View) ad.getAdapter(View.class); >- Object ep = epRegistry.get(view); >- if (ep != null) { >- editParts.add(ep); >+ RunnableWithResult refreshRunnable = new RunnableWithResult() { >+ >+ private IStatus status; >+ private Object result; >+ >+ public Object getResult() { >+ return result; >+ } >+ >+ public void setStatus(IStatus status) { >+ this.status = status; >+ } >+ >+ public IStatus getStatus() { >+ return status; >+ } >+ >+ public void run() { >+ containerEP.refresh(); >+ >+ // The layout command requires that the figure world is updated. >+ getContainerFigure().invalidate(); >+ getContainerFigure().validate(); >+ >+ List editParts = new ArrayList(viewAdapters.size()); >+ Map epRegistry = containerEP.getRoot().getViewer() >+ .getEditPartRegistry(); >+ for (Iterator iter = viewAdapters.iterator(); iter.hasNext();) { >+ IAdaptable ad = (IAdaptable) iter.next(); >+ View view = (View) ad.getAdapter(View.class); >+ Object ep = epRegistry.get(view); >+ if (ep != null) { >+ editParts.add(ep); >+ } >+ } >+ >+ if (editParts.isEmpty()) { >+ result = editParts; >+ return; >+ } >+ >+ Set layoutSet = new HashSet(editParts.size()); >+ layoutSet.addAll(editParts); >+ >+ // refresh source and target connections of any shapes in the container not being considered for layout >+ Iterator iter = containerEP.getChildren().iterator(); >+ while (iter.hasNext()) { >+ Object obj = iter.next(); >+ if (!layoutSet.contains(obj) && obj instanceof IGraphicalEditPart) { >+ IGraphicalEditPart ep = (IGraphicalEditPart)obj; >+ ep.refresh(); >+ } >+ } >+ >+ result = editParts; > } >- } >- >- if (editParts.isEmpty()) { >- return CommandResult.newOKCommandResult(); >- } >- >- Set layoutSet = new HashSet(editParts.size()); >- layoutSet.addAll(editParts); >+ }; > >- // refresh source and target connections of any shapes in the container not being considered for layout >- Iterator iter = containerEP.getChildren().iterator(); >- while (iter.hasNext()) { >- Object obj = iter.next(); >- if (!layoutSet.contains(obj) && obj instanceof IGraphicalEditPart) { >- IGraphicalEditPart ep = (IGraphicalEditPart)obj; >- ep.refresh(); >- } >+ EditPartUtil.synchronizeRunnableToMainThread(containerEP, refreshRunnable); >+ List editParts = (List)refreshRunnable.getResult(); >+ if (editParts == null || editParts.isEmpty()) { >+ return CommandResult.newOKCommandResult(); > } > > // add an arrange command, to layout the related shapes >Index: src/org/eclipse/gmf/runtime/diagram/ui/internal/parts/NotificationForEditPartsListener.java >=================================================================== >RCS file: src/org/eclipse/gmf/runtime/diagram/ui/internal/parts/NotificationForEditPartsListener.java >diff -N src/org/eclipse/gmf/runtime/diagram/ui/internal/parts/NotificationForEditPartsListener.java >--- src/org/eclipse/gmf/runtime/diagram/ui/internal/parts/NotificationForEditPartsListener.java 31 May 2006 16:26:07 -0000 1.1 >+++ /dev/null 1 Jan 1970 00:00:00 -0000 >@@ -1,30 +0,0 @@ >-/****************************************************************************** >- * Copyright (c) 2006 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.gmf.runtime.diagram.ui.internal.parts; >- >-import org.eclipse.gef.EditPartViewer; >-import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener; >- >-/** >- * This class is an extension of the <code>NotificationListener</code> interface to allow clients >- * handling the listener to determine which viewer the notification is relevant for. >- * >- * @author sshaw >- * >- */ >-public interface NotificationForEditPartsListener extends NotificationListener { >- >- /** >- * @return >- */ >- public EditPartViewer getViewer(); >-} >Index: src/org/eclipse/gmf/runtime/diagram/ui/util/EditPartUtil.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/util/EditPartUtil.java,v >retrieving revision 1.5 >diff -u -r1.5 EditPartUtil.java >--- src/org/eclipse/gmf/runtime/diagram/ui/util/EditPartUtil.java 2 Jun 2006 13:15:59 -0000 1.5 >+++ src/org/eclipse/gmf/runtime/diagram/ui/util/EditPartUtil.java 16 Jun 2006 14:27:19 -0000 >@@ -60,21 +60,13 @@ > */ > public static void synchronizeRunnableToMainThread(IGraphicalEditPart editPart, Runnable runThreadSafe) { > if (Display.getCurrent() == null) { >- EditPartViewer viewer = editPart.getViewer(); >- if (viewer instanceof DiagramGraphicalViewer) { >- if (!((DiagramGraphicalViewer)viewer).areUpdatesDisabled()) { >- TransactionalEditingDomain editingDomain = (TransactionalEditingDomain)editPart.getEditingDomain(); >- if (editingDomain != null) { >- PlatformUI.getWorkbench().getDisplay().syncExec(editingDomain.createPrivilegedRunnable(runThreadSafe)); >- return; >- } >- } >- else { >- PlatformUI.getWorkbench().getDisplay().asyncExec(runThreadSafe); >- } >+ TransactionalEditingDomain editingDomain = (TransactionalEditingDomain)editPart.getEditingDomain(); >+ if (editingDomain != null) { >+ PlatformUI.getWorkbench().getDisplay().syncExec(editingDomain.createPrivilegedRunnable(runThreadSafe)); >+ return; > } >- else { >- PlatformUI.getWorkbench().getDisplay().asyncExec(runThreadSafe); >+ else { >+ PlatformUI.getWorkbench().getDisplay().asyncExec(runThreadSafe); > } > } > else { >Index: src/org/eclipse/gmf/runtime/diagram/ui/editpolicies/CanonicalEditPolicy.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/editpolicies/CanonicalEditPolicy.java,v >retrieving revision 1.22 >diff -u -r1.22 CanonicalEditPolicy.java >--- src/org/eclipse/gmf/runtime/diagram/ui/editpolicies/CanonicalEditPolicy.java 14 Jun 2006 18:39:49 -0000 1.22 >+++ src/org/eclipse/gmf/runtime/diagram/ui/editpolicies/CanonicalEditPolicy.java 16 Jun 2006 14:27:19 -0000 >@@ -63,7 +63,6 @@ > import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIDebugOptions; > import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIPlugin; > import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIStatusCodes; >-import org.eclipse.gmf.runtime.diagram.ui.internal.parts.NotificationForEditPartsListener; > import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages; > import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest; > import org.eclipse.gmf.runtime.diagram.ui.util.EditPartUtil; >@@ -98,7 +97,7 @@ > * @author mhanner > */ > public abstract class CanonicalEditPolicy extends AbstractEditPolicy >-implements NotificationForEditPartsListener { >+implements NotificationListener { > > /** Runs the supplied commands asyncronously. */ > private static class AsyncCommand extends Command { >Index: src/org/eclipse/gmf/runtime/diagram/ui/editparts/GraphicalEditPart.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/editparts/GraphicalEditPart.java,v >retrieving revision 1.41 >diff -u -r1.41 GraphicalEditPart.java >--- src/org/eclipse/gmf/runtime/diagram/ui/editparts/GraphicalEditPart.java 2 Jun 2006 13:15:59 -0000 1.41 >+++ src/org/eclipse/gmf/runtime/diagram/ui/editparts/GraphicalEditPart.java 16 Jun 2006 14:27:19 -0000 >@@ -69,7 +69,6 @@ > import org.eclipse.gmf.runtime.diagram.ui.internal.editparts.DummyEditPart; > import org.eclipse.gmf.runtime.diagram.ui.internal.editparts.IEditableEditPart; > import org.eclipse.gmf.runtime.diagram.ui.internal.l10n.DiagramFontRegistry; >-import org.eclipse.gmf.runtime.diagram.ui.internal.parts.NotificationForEditPartsListener; > import org.eclipse.gmf.runtime.diagram.ui.internal.services.editpolicy.EditPolicyService; > import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; > import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramEditDomain; >@@ -107,7 +106,7 @@ > */ > public abstract class GraphicalEditPart > extends AbstractGraphicalEditPart >- implements IGraphicalEditPart, IAdaptableSelection, NotificationForEditPartsListener { >+ implements IGraphicalEditPart, IAdaptableSelection, NotificationListener { > > /** A map of listener filters ids to filter data */ > private Map listenerFilters; >Index: src/org/eclipse/gmf/runtime/diagram/ui/editparts/ConnectionEditPart.java >=================================================================== >RCS file: /cvsroot/technology/org.eclipse.gmf/plugins/org.eclipse.gmf.runtime.diagram.ui/src/org/eclipse/gmf/runtime/diagram/ui/editparts/ConnectionEditPart.java,v >retrieving revision 1.34 >diff -u -r1.34 ConnectionEditPart.java >--- src/org/eclipse/gmf/runtime/diagram/ui/editparts/ConnectionEditPart.java 5 Jun 2006 20:30:20 -0000 1.34 >+++ src/org/eclipse/gmf/runtime/diagram/ui/editparts/ConnectionEditPart.java 16 Jun 2006 14:27:19 -0000 >@@ -76,7 +76,6 @@ > import org.eclipse.gmf.runtime.diagram.ui.internal.editpolicies.ConnectionLineSegEditPolicy; > import org.eclipse.gmf.runtime.diagram.ui.internal.editpolicies.TreeConnectionBendpointEditPolicy; > import org.eclipse.gmf.runtime.diagram.ui.internal.l10n.DiagramFontRegistry; >-import org.eclipse.gmf.runtime.diagram.ui.internal.parts.NotificationForEditPartsListener; > import org.eclipse.gmf.runtime.diagram.ui.internal.properties.Properties; > import org.eclipse.gmf.runtime.diagram.ui.internal.services.editpolicy.EditPolicyService; > import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry; >@@ -125,7 +124,7 @@ > abstract public class ConnectionEditPart > extends AbstractConnectionEditPart > implements IGraphicalEditPart, PropertyChangeListener, IContainedEditPart, >- IPrimaryEditPart, NotificationForEditPartsListener { >+ IPrimaryEditPart, NotificationListener { > > /** A map of listener filters ids to filter data */ > private Map listenerFilters;
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 143198
:
44444
| 44643