78
|
1 /*******************************************************************************
|
|
2 * Copyright (c) 2006, 2007 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 module org.eclipse.core.databinding.observable.value.ValueChangingEvent;
|
|
13
|
|
14 import java.lang.all;
|
|
15
|
|
16 import org.eclipse.core.databinding.observable.IObservablesListener;
|
|
17 import org.eclipse.core.databinding.observable.ObservableEvent;
|
|
18
|
|
19 /**
|
|
20 * Value changing event describing a pending change of an
|
|
21 * {@link IObservableValue} object's current value. Listeners can veto the
|
|
22 * pending change by setting {@link #veto} to <code>true</code>.
|
|
23 *
|
|
24 * @since 1.0
|
|
25 *
|
|
26 */
|
|
27 public class ValueChangingEvent : ObservableEvent {
|
|
28
|
|
29 /**
|
|
30 *
|
|
31 */
|
|
32 private static final long serialVersionUID = 2305345286999701156L;
|
|
33
|
|
34 static final Object TYPE = new Object();
|
|
35
|
|
36 /**
|
|
37 * Description of the change to the source observable value. Listeners must
|
|
38 * not change this field.
|
|
39 */
|
|
40 public ValueDiff diff;
|
|
41
|
|
42 /**
|
|
43 * Flag for vetoing this change. Default value is <code>false</code>, can
|
|
44 * be set to <code>true</code> by listeners to veto this change.
|
|
45 */
|
|
46 public bool veto = false;
|
|
47
|
|
48 /**
|
|
49 * Creates a new value changing event.
|
|
50 *
|
|
51 * @param source
|
|
52 * the source observable value
|
|
53 * @param diff
|
|
54 * the value change
|
|
55 */
|
|
56 public this(IObservableValue source, ValueDiff diff) {
|
|
57 super(source);
|
|
58 this.diff = diff;
|
|
59 }
|
|
60
|
|
61 /**
|
|
62 * @return the observable value from which this event originated
|
|
63 */
|
|
64 public IObservableValue getObservableValue() {
|
|
65 return cast(IObservableValue) source;
|
|
66 }
|
|
67
|
|
68 protected void dispatch(IObservablesListener listener) {
|
|
69 (cast(IValueChangingListener) listener).handleValueChanging(this);
|
|
70 }
|
|
71
|
|
72 protected Object getListenerType() {
|
|
73 return TYPE;
|
|
74 }
|
|
75
|
|
76 }
|