blob: 1a4aad03bce752a0cea3eb2bd1113e20f7eb0433 (
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
|
/*******************************************************************************
* Copyright (c) 2006 - 2007 CEA LIST.
* 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
*******************************************************************************/
package org.eclipse.papyrus.views.listeners;
import org.eclipse.emf.common.notify.Adapter;
import org.eclipse.emf.common.notify.Notification;
import org.eclipse.emf.common.notify.Notifier;
import org.eclipse.papyrus.views.panels.CppAbstractPanel;
/**
* Listener for a uml element, for a given AccordCppAbstractPanel.
*/
public class UMLElementPanelListener implements Adapter {
/** element listened */
private Notifier target;
/** panel that listens to this element */
protected CppAbstractPanel panel;
/**
* Creates a new UMLElementListener for the given panel.
*
* @param panel
* the panel that describes this element
*/
public UMLElementPanelListener(CppAbstractPanel panel) {
this.panel = panel;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.emf.common.notify.Adapter#notifyChanged(org.eclipse.emf.common.notify.Notification)
*/
@Override
public void notifyChanged(Notification notification) {
if (notification.getEventType() != Notification.REMOVING_ADAPTER) {
panel.reset(); // equivalent to a refresh
}
}
/*
* (non-Javadoc)
*
* @see org.eclipse.emf.common.notify.Adapter#getTarget()
*/
@Override
public Notifier getTarget() {
return this.target;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.emf.common.notify.Adapter#setTarget(org.eclipse.emf.common.notify.Notifier)
*/
@Override
public void setTarget(Notifier newTarget) {
this.target = newTarget;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.emf.common.notify.Adapter#isAdapterForType(java.lang.Object)
*/
@Override
public boolean isAdapterForType(Object type) {
Class<? extends Notifier> class_ = target.getClass();
// if class is not null
if (class_ != null) {
return class_.equals(type);
}
// default case: it is not an adapter
return false;
}
}
|