package votorola.g.web.gwt.event; // Copyright 2011, Michael Allan. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Votorola Software"), to deal in the Votorola Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicence, and/or sell copies of the Votorola Software, and to permit persons to whom the Votorola Software is furnished to do so, subject to the following conditions: The preceding copyright notice and this permission notice shall be included in all copies or substantial portions of the Votorola Software. THE VOTOROLA SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE VOTOROLA SOFTWARE OR THE USE OR OTHER DEALINGS IN THE VOTOROLA SOFTWARE. import com.google.gwt.core.client.Scheduler; /** A coalescing scheduler that works with a repeating command. */ public final class CoalescingSchedulerR extends CoalescingScheduler { /** Constructs a CoalescingSchedulerR based on the {@linkplain Scheduler#get() default * scheduler}. * * @see #phaser() * @see #command() */ public CoalescingSchedulerR( Phaser _phaser, Scheduler.RepeatingCommand _command ) { this( Scheduler.get(), _phaser, _command ); } /** Constructs a CoalescingSchedulerR. * * @see #baseScheduler() * @see #phaser() * @see #command() */ public CoalescingSchedulerR( Scheduler _baseScheduler, Phaser _phaser, Scheduler.RepeatingCommand _command ) { super( _baseScheduler ); command = _command; phaser = _phaser; } /** Partially constructs a CoalescingSchedulerS, to be completed by calling * {@linkplain #init(Scheduler.RepeatingCommand) init}(command). * * @see #baseScheduler() * @see #phaser() */ protected CoalescingSchedulerR( Scheduler _baseScheduler, Phaser _phaser ) { super( _baseScheduler ); phaser = _phaser; } /** Completes the construction of this coalescing scheduler. Call once only. * * @see #command() */ protected final void init( Scheduler.RepeatingCommand _command ) { command = _command; } // ------------------------------------------------------------------------------------ /** The command to be scheduled. */ public Scheduler.RepeatingCommand command() { return command; } private Scheduler.RepeatingCommand command; /** A phaser that schedules commands to run in the event loop prior to * GWT-generated code. * * @see Scheduler#scheduleEntry(Scheduler.RepeatingCommand) */ public static final Phaser ENTRY = new Phaser() { public void schedule( final Scheduler s, final Scheduler.RepeatingCommand c ) { s.scheduleEntry( c ); } }; /** A phaser that schedules commands to run in the event loop subsequent to * GWT-generated code. * * @see Scheduler#scheduleFinally(Scheduler.RepeatingCommand) */ public static final Phaser FINALLY = new Phaser() { public void schedule( final Scheduler s, final Scheduler.RepeatingCommand c ) { s.scheduleFinally( c ); } }; /** A phaser that schedules commands to perform incremental work. * * @see Scheduler#scheduleIncremental(Scheduler.RepeatingCommand) */ public static final Phaser INCREMENTAL = new Phaser() { public void schedule( final Scheduler s, final Scheduler.RepeatingCommand c ) { s.scheduleIncremental( c ); } }; /** The scheduling phaser, one of: