use of com.google.gwt.core.client.Scheduler.RepeatingCommand in project gwt-test-utils by gwt-test-utils.
the class BrowserSimulatorImpl method executeReaptingCommnand.
private void executeReaptingCommnand(List<RepeatingCommand> commands) {
List<RepeatingCommand> toRemove = new ArrayList<RepeatingCommand>();
int i = 0;
while (i < commands.size()) {
RepeatingCommand current = commands.get(i);
if (!current.execute()) {
toRemove.add(current);
}
i++;
}
for (RepeatingCommand rc : toRemove) {
commands.remove(rc);
}
}
use of com.google.gwt.core.client.Scheduler.RepeatingCommand in project gwt-test-utils by gwt-test-utils.
the class SchedulerTest method scheduledRepeatingCommandOrder.
@Test
public void scheduledRepeatingCommandOrder() {
// Given
i = j = 0;
final StringBuilder sb = new StringBuilder();
Scheduler.get().scheduleEntry(new RepeatingCommand() {
public boolean execute() {
sb.append("entry").append(i).append(" ");
return 3 > i++;
}
});
Scheduler.get().scheduleFinally(new RepeatingCommand() {
public boolean execute() {
sb.append("finally").append(j).append(" ");
Scheduler.get().scheduleEntry(new RepeatingCommand() {
public boolean execute() {
sb.append("subentry").append(j).append(" ");
return false;
}
});
Scheduler.get().scheduleFinally(new RepeatingCommand() {
public boolean execute() {
sb.append("subfinally").append(j).append(" ");
return false;
}
});
return 3 > j++;
}
});
// When
getBrowserSimulator().fireLoopEnd();
// Then
assertThat(sb.toString()).isEqualTo("finally0 subfinally1 entry0 subentry1 finally1 subfinally2 entry1 subentry2 finally2 subfinally3 entry2 subentry3 finally3 subfinally4 entry3 subentry4 ");
}
use of com.google.gwt.core.client.Scheduler.RepeatingCommand in project rstudio by rstudio.
the class ExternalJavaScriptLoader method onLoaded.
private void onLoaded() {
state_ = State.Loaded;
Scheduler.get().scheduleIncremental(new RepeatingCommand() {
public boolean execute() {
if (!callbacks_.isEmpty())
callbacks_.remove().onLoaded();
return !callbacks_.isEmpty();
}
});
}
use of com.google.gwt.core.client.Scheduler.RepeatingCommand in project rstudio by rstudio.
the class RmdOutputPanel method createFrame.
@Override
protected AnchorableFrame createFrame(String url) {
AnchorableFrame frame = new AnchorableFrame();
// allow full screen
Element el = frame.getElement();
el.setAttribute("webkitallowfullscreen", "");
el.setAttribute("mozallowfullscreen", "");
el.setAttribute("allowfullscreen", "");
frame.navigate(url);
final Operation initSlides = new Operation() {
@Override
public void execute() {
if (getNavigationMenu().isVisible()) {
fireSlideIndexChanged();
slideChangeMonitor_.scheduleRepeating(100);
}
}
};
if (isShiny_) {
shinyFrame_.initialize(url, new Operation() {
@Override
public void execute() {
shinyFrame_.setScrollPosition(scrollPosition_);
initSlides.execute();
}
});
} else {
// poll for document availability then perform initialization
// tasks once it's available (addLoadHandler wasn't always
// getting called at least under Cocoa WebKit)
Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
@Override
public boolean execute() {
// see if the document is ready
AnchorableFrame frame = getFrame();
if (frame == null)
return true;
IFrameElementEx iframe = frame.getIFrame();
if (iframe == null)
return true;
Document doc = iframe.getContentDocument();
if (doc == null)
return true;
initSlides.execute();
// Even though the document exists, it may not have rendered all
// its content yet
ScrollUtil.setScrollPositionOnLoad(frame, scrollPosition_);
return false;
}
}, 50);
}
return frame;
}
use of com.google.gwt.core.client.Scheduler.RepeatingCommand in project rstudio by rstudio.
the class NewRSConnectAuthPage method pollForAuthCompleted.
private void pollForAuthCompleted() {
Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
@Override
public boolean execute() {
// don't keep polling once auth is complete or window is closed
if (!waitingForAuth_.getValue())
return false;
// returned for some reason, just wait for it to finish
if (runningAuthCompleteCheck_)
return true;
runningAuthCompleteCheck_ = true;
server_.getUserFromToken(result_.getServerInfo().getUrl(), result_.getPreAuthToken(), new ServerRequestCallback<RSConnectAuthUser>() {
@Override
public void onResponseReceived(RSConnectAuthUser user) {
runningAuthCompleteCheck_ = false;
// just wait and try again
if (!user.isValidUser())
return;
// user is valid--cache account info and close the
// window
result_.setAuthUser(user);
waitingForAuth_.setValue(false, true);
if (Desktop.isDesktop()) {
// on the desktop, we can close the window by name
Desktop.getFrame().closeNamedWindow(AUTH_WINDOW_NAME);
}
onUserAuthVerified();
}
@Override
public void onError(ServerError error) {
// ignore this error
runningAuthCompleteCheck_ = false;
}
});
return true;
}
}, 1000);
}
Aggregations