blob: e543314e2efb870869cc616f5403564166b61d24 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
/*****************************************************************************
* Copyright (c) 2014, 2015 CEA LIST, Christian W. Damus, 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:
* CEA LIST - Initial API and implementation
* Christian W. Damus - bug 465416
*
*****************************************************************************/
package org.eclipse.papyrus.infra.sync;
import org.eclipse.emf.common.command.Command;
import org.eclipse.emf.common.command.CompoundCommand;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.ecore.EStructuralFeature;
/**
* Represents a dispatch option for an event of interest going on on the EMF command stack
*
* @author Laurent Wouters
*/
public abstract class EMFDispatch {
/**
* The current command aggregator
*/
private CompoundCommand aggregator;
/**
* Gets the notifier object of interest, or <code>null</code> if all notifiers are of interest
*
* @return The notifier object of interest
*/
public abstract EObject getNotifier();
/**
* Gets the changed feature of interest, or <code>null</code> if all features are of interest
*
* @return The changed feature of interest
*/
public abstract EStructuralFeature getFeature();
/**
* Reacts to the specified change notification
*
* @param notification
* The change notification
*/
public abstract void onChange(Notification notification);
/**
* Reacts to the clearing of the listener
*/
public abstract void onClear();
/**
* Dispatches the specified change notification
*
* @param notification
* The change notification
* @param aggregator
* The aggregated command being constructed
*
*/
public final void dispatch(Notification notification, CompoundCommand aggregator) {
this.aggregator = aggregator;
try {
onChange(notification);
} finally {
this.aggregator = null;
}
}
/**
* Reacts to a change with the specified command
*
* @param command
* A command
*/
public final void react(Command command) {
aggregator.append(command);
}
}
|