Lines 1-18
Link Here
|
1 |
/****************************************************************************** |
1 |
/****************************************************************************** |
2 |
* Copyright (c) 2002, 2003 IBM Corporation and others. |
2 |
* Copyright (c) 2002, 2005 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
6 |
* http://www.eclipse.org/legal/epl-v10.html |
7 |
* |
7 |
* |
8 |
* Contributors: |
8 |
* Contributors: |
9 |
* IBM Corporation - initial API and implementation |
9 |
* IBM Corporation - initial API and implementation |
10 |
****************************************************************************/ |
10 |
****************************************************************************/ |
11 |
|
11 |
|
12 |
package org.eclipse.gmf.runtime.diagram.core.listener; |
12 |
package org.eclipse.gmf.runtime.diagram.core.listener; |
13 |
|
13 |
|
14 |
import java.util.Collection; |
14 |
import java.util.Collection; |
15 |
import java.util.Iterator; |
|
|
16 |
import java.util.Set; |
15 |
import java.util.Set; |
17 |
|
16 |
|
18 |
import org.eclipse.emf.common.notify.Notification; |
17 |
import org.eclipse.emf.common.notify.Notification; |
Lines 27-50
Link Here
|
27 |
/** |
26 |
/** |
28 |
* A model server listener that broadcast EObject events to |
27 |
* A model server listener that broadcast EObject events to |
29 |
* all registered listeners. |
28 |
* all registered listeners. |
30 |
* |
29 |
* |
31 |
* @author melaasar, mmostafa |
30 |
* @author melaasar, mmostafa |
32 |
*/ |
31 |
*/ |
33 |
public class PresentationListener extends ModelServerListener { |
32 |
public final class PresentationListener extends ModelServerListener { |
34 |
/** The PresentationListener singleton */ |
33 |
/** The PresentationListener singleton */ |
35 |
private static PresentationListener instance; |
34 |
private static final PresentationListener instance = new PresentationListener(); |
36 |
|
35 |
|
37 |
/** |
36 |
/** |
38 |
* gives access to the <code>PresentationListener</code> singleton |
37 |
* gives access to the <code>PresentationListener</code> singleton |
39 |
* @return the <code>PresentationListener</code> singleton |
38 |
* @return the <code>PresentationListener</code> singleton |
40 |
*/ |
39 |
*/ |
41 |
public static PresentationListener getInstance() { |
40 |
public static PresentationListener getInstance() { |
42 |
if ( instance == null ) { |
|
|
43 |
instance = new PresentationListener(); |
44 |
} |
45 |
return instance; |
41 |
return instance; |
46 |
} |
42 |
} |
47 |
|
43 |
|
|
|
44 |
private PresentationListener() { |
45 |
super(); |
46 |
startListening(); |
47 |
} |
48 |
|
48 |
|
49 |
/** |
49 |
/** |
50 |
* gets a subset of all the registered listeners who are interested |
50 |
* gets a subset of all the registered listeners who are interested |
Lines 75-100
Link Here
|
75 |
private void addListenersOfNotifier(Set listenerSet, EObject notifier,Notification event) { |
75 |
private void addListenersOfNotifier(Set listenerSet, EObject notifier,Notification event) { |
76 |
if (notifier != null) { |
76 |
if (notifier != null) { |
77 |
Collection c = getNotificationListeners(notifier, event.getFeature()); |
77 |
Collection c = getNotificationListeners(notifier, event.getFeature()); |
78 |
if (c != null) { |
78 |
if (c != null && !c.isEmpty()) { |
79 |
if (listenerSet.isEmpty()) |
79 |
listenerSet.addAll(c); |
80 |
listenerSet.addAll(c); |
|
|
81 |
else { |
82 |
Iterator i = c.iterator(); |
83 |
while (i.hasNext()) { |
84 |
Object o = i.next(); |
85 |
listenerSet.add(o); |
86 |
} |
87 |
} |
88 |
} |
80 |
} |
89 |
} |
81 |
} |
90 |
} |
82 |
} |
91 |
|
83 |
|
92 |
/** |
84 |
/** |
93 |
* Forwards the event to all interested listeners. |
85 |
* Forwards the event to all interested listeners. |
94 |
* @param event the event to handle |
86 |
* @param event the event to handle |
95 |
*/ |
87 |
*/ |
96 |
protected void handleElementEvent(Notification event) { |
88 |
protected void handleElementEvent(Notification event) { |
97 |
MEditingDomain doamin = null; |
89 |
MEditingDomain doamin; |
98 |
if (!event.isTouch() |
90 |
if (!event.isTouch() |
99 |
&& !(doamin = MEditingDomainGetter.getMEditingDomain(event)) |
91 |
&& !(doamin = MEditingDomainGetter.getMEditingDomain(event)) |
100 |
.isUndoNotification(event) && !doamin.isRedoNotification(event)) { |
92 |
.isUndoNotification(event) && !doamin.isRedoNotification(event)) { |