Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 143198 | Differences between
and this patch

Collapse All | Expand All

(-)src/org/eclipse/gmf/runtime/diagram/ui/internal/DiagramEventBrokerThreadSafe.java (-39 / +16 lines)
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
    }
(-)src/org/eclipse/gmf/runtime/diagram/ui/internal/parts/NotificationForEditPartsListener.java (-30 lines)
Removed Link Here
1
/******************************************************************************
2
 * Copyright (c) 2006 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *    IBM Corporation - initial API and implementation 
10
 ****************************************************************************/
11
12
package org.eclipse.gmf.runtime.diagram.ui.internal.parts;
13
14
import org.eclipse.gef.EditPartViewer;
15
import org.eclipse.gmf.runtime.diagram.core.listener.NotificationListener;
16
17
/**
18
 * This class is an extension of the <code>NotificationListener</code> interface to allow clients
19
 * handling the listener to determine which viewer the notification is relevant for.
20
 * 
21
 * @author sshaw
22
 *
23
 */
24
public interface NotificationForEditPartsListener extends NotificationListener {
25
	
26
	/**
27
	 * @return
28
	 */
29
	public EditPartViewer getViewer();
30
}
(-)src/org/eclipse/gmf/runtime/diagram/ui/editpolicies/CanonicalEditPolicy.java (-2 / +1 lines)
Lines 63-69 Link Here
63
import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIDebugOptions;
63
import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIDebugOptions;
64
import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIPlugin;
64
import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIPlugin;
65
import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIStatusCodes;
65
import org.eclipse.gmf.runtime.diagram.ui.internal.DiagramUIStatusCodes;
66
import org.eclipse.gmf.runtime.diagram.ui.internal.parts.NotificationForEditPartsListener;
67
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
66
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramUIMessages;
68
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
67
import org.eclipse.gmf.runtime.diagram.ui.requests.CreateViewRequest;
69
import org.eclipse.gmf.runtime.diagram.ui.util.EditPartUtil;
68
import org.eclipse.gmf.runtime.diagram.ui.util.EditPartUtil;
Lines 98-104 Link Here
98
 * @author mhanner
97
 * @author mhanner
99
 */
98
 */
100
public abstract class CanonicalEditPolicy extends AbstractEditPolicy 
99
public abstract class CanonicalEditPolicy extends AbstractEditPolicy 
101
implements NotificationForEditPartsListener {
100
implements NotificationListener {
102
	
101
	
103
	/** Runs the supplied commands asyncronously. */
102
	/** Runs the supplied commands asyncronously. */
104
	private static class AsyncCommand extends Command {
103
	private static class AsyncCommand extends Command {
(-)src/org/eclipse/gmf/runtime/diagram/ui/editparts/GraphicalEditPart.java (-2 / +1 lines)
Lines 69-75 Link Here
69
import org.eclipse.gmf.runtime.diagram.ui.internal.editparts.DummyEditPart;
69
import org.eclipse.gmf.runtime.diagram.ui.internal.editparts.DummyEditPart;
70
import org.eclipse.gmf.runtime.diagram.ui.internal.editparts.IEditableEditPart;
70
import org.eclipse.gmf.runtime.diagram.ui.internal.editparts.IEditableEditPart;
71
import org.eclipse.gmf.runtime.diagram.ui.internal.l10n.DiagramFontRegistry;
71
import org.eclipse.gmf.runtime.diagram.ui.internal.l10n.DiagramFontRegistry;
72
import org.eclipse.gmf.runtime.diagram.ui.internal.parts.NotificationForEditPartsListener;
73
import org.eclipse.gmf.runtime.diagram.ui.internal.services.editpolicy.EditPolicyService;
72
import org.eclipse.gmf.runtime.diagram.ui.internal.services.editpolicy.EditPolicyService;
74
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
73
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
75
import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramEditDomain;
74
import org.eclipse.gmf.runtime.diagram.ui.parts.IDiagramEditDomain;
Lines 107-113 Link Here
107
 */
106
 */
108
public abstract class GraphicalEditPart
107
public abstract class GraphicalEditPart
109
	extends AbstractGraphicalEditPart
108
	extends AbstractGraphicalEditPart
110
	implements IGraphicalEditPart, IAdaptableSelection, NotificationForEditPartsListener {
109
	implements IGraphicalEditPart, IAdaptableSelection, NotificationListener {
111
  
110
  
112
    /** A map of listener filters ids to filter data */
111
    /** A map of listener filters ids to filter data */
113
	private Map listenerFilters;
112
	private Map listenerFilters;
(-)src/org/eclipse/gmf/runtime/diagram/ui/editparts/ConnectionEditPart.java (-2 / +1 lines)
Lines 76-82 Link Here
76
import org.eclipse.gmf.runtime.diagram.ui.internal.editpolicies.ConnectionLineSegEditPolicy;
76
import org.eclipse.gmf.runtime.diagram.ui.internal.editpolicies.ConnectionLineSegEditPolicy;
77
import org.eclipse.gmf.runtime.diagram.ui.internal.editpolicies.TreeConnectionBendpointEditPolicy;
77
import org.eclipse.gmf.runtime.diagram.ui.internal.editpolicies.TreeConnectionBendpointEditPolicy;
78
import org.eclipse.gmf.runtime.diagram.ui.internal.l10n.DiagramFontRegistry;
78
import org.eclipse.gmf.runtime.diagram.ui.internal.l10n.DiagramFontRegistry;
79
import org.eclipse.gmf.runtime.diagram.ui.internal.parts.NotificationForEditPartsListener;
80
import org.eclipse.gmf.runtime.diagram.ui.internal.properties.Properties;
79
import org.eclipse.gmf.runtime.diagram.ui.internal.properties.Properties;
81
import org.eclipse.gmf.runtime.diagram.ui.internal.services.editpolicy.EditPolicyService;
80
import org.eclipse.gmf.runtime.diagram.ui.internal.services.editpolicy.EditPolicyService;
82
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
81
import org.eclipse.gmf.runtime.diagram.ui.l10n.DiagramColorRegistry;
Lines 125-131 Link Here
125
abstract public class ConnectionEditPart
124
abstract public class ConnectionEditPart
126
	extends AbstractConnectionEditPart
125
	extends AbstractConnectionEditPart
127
	implements IGraphicalEditPart, PropertyChangeListener, IContainedEditPart,
126
	implements IGraphicalEditPart, PropertyChangeListener, IContainedEditPart,
128
	IPrimaryEditPart, NotificationForEditPartsListener {
127
	IPrimaryEditPart, NotificationListener {
129
128
130
	/** A map of listener filters ids to filter data */
129
	/** A map of listener filters ids to filter data */
131
	private Map listenerFilters;
130
	private Map listenerFilters;

Return to bug 143198