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