01 
02 /*
03  *  JScripter Standard 1.0 - To Script In Java
04  *  Copyright (C) 2008-2011  J.J.Liu<jianjunliu@126.com> <http://www.jscripter.org>
05  *  
06  *  This program is free software: you can redistribute it and/or modify
07  *  it under the terms of the GNU Affero General Public License as published by
08  *  the Free Software Foundation, either version 3 of the License, or
09  *  (at your option) any later version.
10  *  
11  *  This program is distributed in the hope that it will be useful,
12  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  *  GNU Affero General Public License for more details.
15  *  
16  *  You should have received a copy of the GNU Affero General Public License
17  *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 package jsx.ui.event;
21 
22 import js.Id;
23 import js.Initializer;
24 import js.Js;
25 import js.ObjectLike;
26 import jsx.ui.Widget;
27 
28 /**
29  * <p>A type of high level events that may be fired from a source widget when 
30  * the style of the element wrapped by the widget has just been changed.</p>
31  * 
32  * @author <a href="mailto:jianjunliu@126.com">J.J.Liu (Jianjun Liu)</a> at <a href="http://www.jscripter.org" target="_blank">http://www.jscripter.org</a>
33  */
34 public final class Style extends Widget.Event<OnStyle>
35 {
36     /**
37      * <p>A global identifier for a configurable property of a {@link Style} object.</p>
38      * <p>The identified configurable property of a {@link Style} object 
39      * is a referent to style object that has just been applied to the source 
40      * widget.</p>
41      * @since 1.0
42      */
43     public final static Id<ObjectLike> STYLE = new Id<ObjectLike>();
44 
45     /**
46      * <p>Constructs an event of this type.</p>
47      * <p>This constructor simply invokes the default constructor of the superclass.</p>
48      * <p>Note that, this constructor does not change the configurable property {@link jsx.Source.Event#BUBBLE}
49      * but it sets the configurable property {@link jsx.Source.Event#UPDATE} to <tt>true</tt>.</p>
50      * @since 1.0
51      */
52     public Style() {
53         ini(this).var(UPDATE, true);
54     }
55     /**
56      * <p>Constructs an event of this type.</p>
57      * <p>This constructor simply invokes the default constructor of the superclass and 
58      * applies the argument style object to the {@link #STYLE} configurable property of 
59      * this event.</p>
60      * <p>Note that, this constructor does not change the configurable properties 
61      * {@link jsx.Source.Event#BUBBLE} and {@link jsx.Source.Event#UPDATE} of this event object.</p>
62      * @param style The style object that has just been applied to the source widget.
63      * @since 1.0
64      */
65     public Style(ObjectLike style) {
66         ini(this).var(
67                 STYLE,
68                 Js.apply(
69                         new Initializer().var(),
70                         style
71                 )
72         );
73     }
74 
75     /**
76      * <p>Dispatches this event to the specified event listener to handle, by invoking the 
77      * handler method of the listener interface passing the event itself as the argument.</p>
78      * @param on The event listener that handles this event.
79      * @since 1.0
80      */
81     @Override
82     protected final void execute(OnStyle on) {
83         on.onEvent(this);
84     }
85 }