private void fireEventLoop(Queue<ScheduledCommand> deferredToExecuteInLoop, Queue<Command> asyncCallbackToExecuteInLoop) { while (!finallyScheduledCommands.isEmpty()) { finallyScheduledCommands.poll().execute(); } executeReaptingCommnand(finallyRepeatingCommands); while (!entryScheduledCommands.isEmpty()) { entryScheduledCommands.poll().execute(); } executeReaptingCommnand(entryRepeatingCommands); while (!deferredToExecuteInLoop.isEmpty()) { deferredToExecuteInLoop.poll().execute(); } while (!asyncCallbackToExecuteInLoop.isEmpty()) { asyncCallbackToExecuteInLoop.poll().execute(); } }
@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; } }
/** * Simulates a click event on a particular MenuItem of a SuggestBox. * * @param suggestBox The targeted suggest box. * @param clickedItem The child widget to click inside the suggest box. */ public static void click(SuggestBox suggestBox, MenuItem clickedItem) { BrowserSimulatorImpl.get().fireLoopEnd(); Event onClick = EventBuilder.create(Event.ONCLICK).setTarget(clickedItem).build(); if (canApplyEvent(suggestBox, onClick)) { clickedItem.getScheduledCommand().execute(); } BrowserSimulatorImpl.get().fireLoopEnd(); }
@Test public void checkOnDelete() { final PlaceRequest placeRequest = mock(PlaceRequest.class); presenter.editorPlaceRequest = placeRequest; presenter.onDelete(); final ArgumentCaptor<Scheduler.ScheduledCommand> commandCaptor = ArgumentCaptor.forClass(Scheduler.ScheduledCommand.class); verify(presenter, times(1)).scheduleClosure(commandCaptor.capture()); final Scheduler.ScheduledCommand command = commandCaptor.getValue(); assertNotNull(command); command.execute(); verify(placeManager, times(1)).forceClosePlace(eq(placeRequest)); }
public static Callback<Void, Exception> voidCallback(ScheduledCommand onLoaded) { return new LoggingCallback<>((v)->onLoaded.execute()); }
public void executeScheduled() { getScheduled().execute(); }
public void executeScheduled() { getScheduled().execute(); }
/** * Simulates a click event on a particular MenuItem of a SuggestBox. * * @param suggestBox The targeted suggest box. * @param clickedItem The child widget to click inside the suggest box. */ public static void click(SuggestBox suggestBox, MenuItem clickedItem) { BrowserSimulatorImpl.get().fireLoopEnd(); Event onClick = EventBuilder.create(Event.ONCLICK).setTarget(clickedItem).build(); if (canApplyEvent(suggestBox, onClick)) { clickedItem.getScheduledCommand().execute(); } BrowserSimulatorImpl.get().fireLoopEnd(); }
public void executeScheduled() { getScheduled().execute(); }
@Test public void checkRemoveDocumentClosesEditor() { final PlaceRequest placeRequest = mock(PlaceRequest.class); final GuidedDecisionTableView.Presenter dtPresenter = mock(GuidedDecisionTableView.Presenter.class); presenter.editorPlaceRequest = placeRequest; presenter.removeDocument(dtPresenter); final ArgumentCaptor<Scheduler.ScheduledCommand> commandCaptor = ArgumentCaptor.forClass(Scheduler.ScheduledCommand.class); verify(presenter, times(1)).scheduleClosure(commandCaptor.capture()); final Scheduler.ScheduledCommand command = commandCaptor.getValue(); assertNotNull(command); command.execute(); verify(placeManager, times(1)).forceClosePlace(eq(placeRequest)); }
@Override public void scheduleFinally(final ScheduledCommand cmd) { if (executeImmediately()) { cmd.execute(); } else { deferred.add(cmd); } }
@Override public void scheduleDeferred(final ScheduledCommand cmd) { if (executeImmediately()) { cmd.execute(); } else { deferred.add(cmd); } }
private void assertThrowsNpe(ScheduledCommand command) { try { command.execute(); fail("expected NullPointerException"); } catch (NullPointerException e) { /* pass */ } }
@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 scheduleDeferred(ScheduledCommand cmd) { cmd.execute(); } }
/** * Reset focus on an element. * * @param command the command to execute when resetting focus */ public void resetFocus(ScheduledCommand command) { command.execute(); }
@Before @SuppressWarnings("unchecked") public void init() { this.tested = spy(new TextEditorSingleLineBoxView(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)); }
/** * 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; } }