|
Lines 11-26
Link Here
|
| 11 |
package org.eclipse.gmf.runtime.diagram.ui.internal; |
11 |
package org.eclipse.gmf.runtime.diagram.ui.internal; |
| 12 |
|
12 |
|
| 13 |
import java.lang.ref.WeakReference; |
13 |
import java.lang.ref.WeakReference; |
| 14 |
import java.util.Iterator; |
|
|
| 15 |
import java.util.Set; |
| 16 |
|
14 |
|
| 17 |
import org.eclipse.emf.common.notify.Notification; |
|
|
| 18 |
import org.eclipse.emf.transaction.ResourceSetChangeEvent; |
15 |
import org.eclipse.emf.transaction.ResourceSetChangeEvent; |
| 19 |
import org.eclipse.emf.transaction.TransactionalEditingDomain; |
16 |
import org.eclipse.emf.transaction.TransactionalEditingDomain; |
| 20 |
import org.eclipse.gef.EditPartViewer; |
|
|
| 21 |
import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker; |
17 |
import org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker; |
| 22 |
import org.eclipse.gmf.runtime.diagram.ui.internal.parts.NotificationForEditPartsListener; |
|
|
| 23 |
import org.eclipse.gmf.runtime.diagram.ui.parts.DiagramGraphicalViewer; |
| 24 |
import org.eclipse.swt.widgets.Display; |
18 |
import org.eclipse.swt.widgets.Display; |
| 25 |
import org.eclipse.ui.PlatformUI; |
19 |
import org.eclipse.ui.PlatformUI; |
| 26 |
|
20 |
|
|
Lines 34-41
Link Here
|
| 34 |
* that has been exeucted with a progress meter, where the progress meter is displaying UI on the main |
28 |
* that has been exeucted with a progress meter, where the progress meter is displaying UI on the main |
| 35 |
* thread and there is a background thread that is being executed that the progress meter is monitoring. |
29 |
* thread and there is a background thread that is being executed that the progress meter is monitoring. |
| 36 |
* For this scenario, the UI updates on the diagram viewer have been disabled so as to avoid concurrency |
30 |
* For this scenario, the UI updates on the diagram viewer have been disabled so as to avoid concurrency |
| 37 |
* issues and it is desirable that the notifications continue to be handled on the worker thread so that |
31 |
* issues. When notifications are handled, they are synchronized to the main thread to avoid |
| 38 |
* the progress meter doesn't lock up. |
32 |
* SWTExceptions when UI tries to access SWT resources when updating figures or other UI. |
| 39 |
* |
33 |
* |
| 40 |
* The second scenario is for when a job has been executed on a worker thread, but has not been executed |
34 |
* The second scenario is for when a job has been executed on a worker thread, but has not been executed |
| 41 |
* through the OperationHistory. Consequently, there is no hook for turning off display updates. This |
35 |
* through the OperationHistory. Consequently, there is no hook for turning off display updates. This |
|
Lines 60-103
Link Here
|
| 60 |
* @see org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker#resourceSetChanged(org.eclipse.emf.transaction.ResourceSetChangeEvent) |
54 |
* @see org.eclipse.gmf.runtime.diagram.core.listener.DiagramEventBroker#resourceSetChanged(org.eclipse.emf.transaction.ResourceSetChangeEvent) |
| 61 |
*/ |
55 |
*/ |
| 62 |
public void resourceSetChanged(ResourceSetChangeEvent event) { |
56 |
public void resourceSetChanged(ResourceSetChangeEvent event) { |
| 63 |
if (Display.getCurrent() == null) { |
57 |
if (shouldSynchronizeWithMainThread(event)) { |
| 64 |
if (shouldSynchronizeWithMainThread(event)) { |
58 |
// force synchronization with the main thread |
| 65 |
// force synchronization with the main thread |
59 |
final ResourceSetChangeEvent eventToHandle = event; |
| 66 |
final ResourceSetChangeEvent eventToHandle = event; |
60 |
TransactionalEditingDomain editingDomain = (TransactionalEditingDomain)editingDomainRef.get(); |
| 67 |
TransactionalEditingDomain editingDomain = (TransactionalEditingDomain)editingDomainRef.get(); |
61 |
if (editingDomain != null) { |
| 68 |
if (editingDomain != null) { |
62 |
PlatformUI.getWorkbench().getDisplay().syncExec(editingDomain.createPrivilegedRunnable(new Runnable() { |
| 69 |
PlatformUI.getWorkbench().getDisplay().syncExec(editingDomain.createPrivilegedRunnable(new Runnable() { |
63 |
public void run() { |
| 70 |
public void run() { |
64 |
internal_resourceSetChanged(eventToHandle); |
| 71 |
internal_resourceSetChanged(eventToHandle); |
65 |
} |
| 72 |
} |
66 |
})); |
| 73 |
})); |
|
|
| 74 |
|
67 |
|
| 75 |
return; |
68 |
return; |
| 76 |
} |
69 |
} |
| 77 |
} |
|
|
| 78 |
} |
70 |
} |
| 79 |
|
71 |
|
| 80 |
super.resourceSetChanged(event); |
72 |
super.resourceSetChanged(event); |
| 81 |
} |
73 |
} |
| 82 |
|
74 |
|
| 83 |
private boolean shouldSynchronizeWithMainThread(ResourceSetChangeEvent event) { |
75 |
private boolean shouldSynchronizeWithMainThread(ResourceSetChangeEvent event) { |
| 84 |
|
76 |
if (Display.getCurrent() == null) |
| 85 |
for (Iterator i = event.getNotifications().iterator(); i.hasNext();) { |
77 |
return true; |
| 86 |
final Notification notification = (Notification) i.next(); |
|
|
| 87 |
Set nlSet = getInterestedNotificationListeners(notification, false); |
| 88 |
Iterator iter = nlSet.iterator(); |
| 89 |
while (iter.hasNext()) { |
| 90 |
Object listener = iter.next(); |
| 91 |
if (listener instanceof NotificationForEditPartsListener) { |
| 92 |
EditPartViewer viewer = ((NotificationForEditPartsListener)listener).getViewer(); |
| 93 |
if (viewer instanceof DiagramGraphicalViewer) { |
| 94 |
if (!((DiagramGraphicalViewer)viewer).areUpdatesDisabled()) { |
| 95 |
return true; |
| 96 |
} |
| 97 |
} |
| 98 |
} |
| 99 |
} |
| 100 |
} |
| 101 |
|
78 |
|
| 102 |
return false; |
79 |
return false; |
| 103 |
} |
80 |
} |