KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > core > databinding > observable > value > ValueChangingEvent


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 package org.eclipse.core.databinding.observable.value;
13
14 import org.eclipse.core.databinding.observable.IObservablesListener;
15 import org.eclipse.core.databinding.observable.ObservableEvent;
16
17 /**
18  * Value changing event describing a pending change of an
19  * {@link IObservableValue} object's current value. Listeners can veto the
20  * pending change by setting {@link #veto} to <code>true</code>.
21  *
22  * @since 1.0
23  *
24  */

25 public class ValueChangingEvent extends ObservableEvent {
26
27     /**
28      *
29      */

30     private static final long serialVersionUID = 2305345286999701156L;
31
32     static final Object JavaDoc TYPE = new Object JavaDoc();
33
34     /**
35      * Description of the change to the source observable value. Listeners must
36      * not change this field.
37      */

38     public ValueDiff diff;
39
40     /**
41      * Flag for vetoing this change. Default value is <code>false</code>, can
42      * be set to <code>true</code> by listeners to veto this change.
43      */

44     public boolean veto = false;
45
46     /**
47      * Creates a new value changing event.
48      *
49      * @param source
50      * the source observable value
51      * @param diff
52      * the value change
53      */

54     public ValueChangingEvent(IObservableValue source, ValueDiff diff) {
55         super(source);
56         this.diff = diff;
57     }
58
59     /**
60      * @return the observable value from which this event originated
61      */

62     public IObservableValue getObservableValue() {
63         return (IObservableValue) source;
64     }
65
66     protected void dispatch(IObservablesListener listener) {
67         ((IValueChangingListener) listener).handleValueChanging(this);
68     }
69
70     protected Object JavaDoc getListenerType() {
71         return TYPE;
72     }
73
74 }
75
Popular Tags