List of usage examples for com.google.gwt.user.client IncrementalCommand execute
boolean execute();
IncrementalCommand to execute its encapsulated behavior. From source file:gov.lbl.glamm.client.experiment.util.DelayConfigCommandExecutor.java
License:Apache License
/** * This method will dispatch commands from the command queue. It will dispatch * commands until one of the following conditions is <code>true</code>: * <ul>//from ww w. j a v a 2 s . c om * <li>It consumed its dispatching time slice * {@value #DEFAULT_TIME_SLICE_MILLIS}</li> * <li>It encounters a <code>null</code> in the command queue</li> * <li>All commands which were present at the start of the dispatching have * been removed from the command queue</li> * <li>The command that it was processing was canceled due to a false * cancellation -- in this case we exit without updating any state</li> * </ul> * * @param startTimeMillis the time when this method started */ protected void doExecuteCommands(double startTimeMillis) { assert (!isExecutionTimerPending()); boolean wasCanceled = false; try { setExecuting(true); iterator.setEnd(commands.size()); cancellationTimer.schedule(DEFAULT_CANCELLATION_TIMEOUT_MILLIS); while (iterator.hasNext()) { Object element = iterator.next(); boolean removeCommand = true; try { if (element == null) { // null forces a yield or pause in execution return; } if (element instanceof Command) { Command command = (Command) element; command.execute(); } else if (element instanceof IncrementalCommand) { IncrementalCommand incrementalCommand = (IncrementalCommand) element; removeCommand = !incrementalCommand.execute(); } } finally { wasCanceled = iterator.wasRemoved(); if (wasCanceled) { /* * The iterator may have already had its remove method called, if it * has, then we need to exit without updating any state */ return; } if (removeCommand) { iterator.remove(); } } if (hasTimeSliceExpired(Duration.currentTimeMillis(), startTimeMillis)) { // the time slice has expired return; } } } finally { if (!wasCanceled) { cancellationTimer.cancel(); setExecuting(false); maybeStartExecutionTimer(); } } }