blob: 7e477a778fd239f42b1cb124c8c7d440fc1c2a00 (
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
|
/*******************************************************************************
* Copyright (c) 2009, 2012 Oracle. 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:
* Oracle - initial API and implementation
******************************************************************************/
package org.eclipse.jpt.common.utility.internal.model.value;
import org.eclipse.jpt.common.utility.model.Model;
import org.eclipse.jpt.common.utility.model.event.ChangeEvent;
import org.eclipse.jpt.common.utility.model.listener.ChangeListener;
import org.eclipse.jpt.common.utility.model.listener.AbstractChangeListener;
import org.eclipse.jpt.common.utility.model.value.ModifiablePropertyValueModel;
/**
* Extend {@link ValueAspectAdapter} to listen to all the aspects
* of the value in the wrapped value model.
*/
public class ValueChangeAdapter<V extends Model>
extends ValueAspectAdapter<V>
{
/** Listener that listens to the value. */
protected final ChangeListener valueAspectListener;
// ********** constructors **********
/**
* Construct a change adapter for the specified value.
*/
public ValueChangeAdapter(ModifiablePropertyValueModel<V> valueHolder) {
super(valueHolder);
this.valueAspectListener = this.buildValueAspectListener();
}
// ********** initialization **********
protected ChangeListener buildValueAspectListener() {
return new ValueAspectListener();
}
protected class ValueAspectListener
extends AbstractChangeListener
{
@Override
protected void modelChanged(ChangeEvent event) {
ValueChangeAdapter.this.valueAspectChanged(event);
}
}
// ********** ValueAspectAdapter implementation **********
@Override
protected void engageValue_() {
this.value.addChangeListener(this.valueAspectListener);
}
@Override
protected void disengageValue_() {
this.value.removeChangeListener(this.valueAspectListener);
}
// ********** change events **********
protected void valueAspectChanged(@SuppressWarnings("unused") ChangeEvent event) {
this.valueAspectChanged();
}
}
|