/** * Executes all scheduled {@link ScheduledCommand}s that have been passed to this scheduler, * then removes all commands. * * <p>After this method completes, {@link #getScheduledCommands} returns only the commands * that have been scheduled by the initial commands. * * @return whether new commands have been scheduled after the execution */ public boolean executeScheduledCommands() { List<ScheduledCommand> commands = new ArrayList<ScheduledCommand>(scheduledCommands); scheduledCommands.clear(); for (ScheduledCommand command : commands) { try { command.execute(); } catch (Throwable e) { GWT.reportUncaughtException(e); } } return !scheduledCommands.isEmpty(); }
@Override public void claimElement(Element element) { if (isFullyInitialized()) { /* * If claimElement is being called after the widget is fully initialized, * that's probably a programming error, as it's much more efficient to * build the whole tree at once. */ throw new IllegalStateException( "claimElement() cannot be called twice, or after forcing the widget to" + " render itself (e.g. after adding it to a panel)"); } setElement(element); html = null; if (wrapInitializationCallback != null) { wrapInitializationCallback.execute(); wrapInitializationCallback = null; } }
@Test public void testOnResize() { final ArgumentCaptor<Scheduler.ScheduledCommand> scheduledCommand = ArgumentCaptor.forClass(Scheduler.ScheduledCommand.class); doNothing().when(gridLienzoPanel).updatePanelSize(); doNothing().when(gridLienzoPanel).refreshScrollPosition(); doNothing().when(gridLienzoPanel).scheduleDeferred(scheduledCommand.capture()); gridLienzoPanel.onResize(); scheduledCommand.getValue().execute(); verify(gridLienzoPanel).updatePanelSize(); verify(gridLienzoPanel).refreshScrollPosition(); }
/** * Reset focus on an element. * * @param command the command to execute when resetting focus */ public void resetFocus(ScheduledCommand command) { command.execute(); }
@Override public void initializeClaimedElement() { if (detachedInitializationCallback != null) { detachedInitializationCallback.execute(); detachedInitializationCallback = null; } }
@Override public void execute() { cmd.execute(); } });
private void enterKey() { final MenuItem item = select.getSelectedItem(); if (item != null) { item.getScheduledCommand().execute(); } }
private void enterKey() { final MenuItem item = select.getSelectedItem(); if (item != null) { item.getScheduledCommand().execute(); } }
@Before @SuppressWarnings("unchecked") public void init() { this.tested = spy(new TextEditorMultiLineBoxView(translationService, editNameBox, nameField, showCommand, hideCommand, closeButton, saveButton)); this.tested.init(presenter); doAnswer(i -> { ((Scheduler.ScheduledCommand) i.getArguments()[0]).execute(); return null; }).when(tested).scheduleDeferredCommand(any(Scheduler.ScheduledCommand.class)); }
@Override public void scheduleDeferred(ScheduledCommand cmd) { callCount++; if (callCount >= threshold) { // threshold matched, execute the command. cmd.execute(); } }
@Override public void execute() { cmd.execute(); } });
@Override public void execute() { if (command != null) { command.execute(); } } };
@Override public void execute() { if (command != null) { command.execute(); } } };
/** * IE6 does not allow direct access to event handlers on the parent window, * so we must embed a script in the parent window that will set the event * handlers in the correct context. * * @param initFunc the string representation of the init function * @param cmd the command to execute the init function */ private void initHandler(String initFunc, ScheduledCommand cmd) { if (GWT.isClient()) { // Embed the init script on the page ScriptElement scriptElem = Document.get().createScriptElement(initFunc); Document.get().getBody().appendChild(scriptElem); // Initialize the handler cmd.execute(); // Remove the script element Document.get().getBody().removeChild(scriptElem); } }
public void executeScheduled() { getScheduled().execute(); }
@Override public void execute() { if (command != null) { command.execute(); } } };
@Override public void execute() { cmd.execute(); } });
@Override public void initializeClaimedElement() { if (detachedInitializationCallback != null) { detachedInitializationCallback.execute(); detachedInitializationCallback = null; } }
/** * Reset focus on an element. * * @param command the command to execute when resetting focus */ public void resetFocus(ScheduledCommand command) { command.execute(); }