use of com.google.gwt.core.client.Scheduler.RepeatingCommand in project rstudio by rstudio.
the class ShinyFrameHelper method sendMethod.
private void sendMethod(final ShinyFrameMethod method) {
// (every 100ms, up to 5s)
if (window_ == null) {
windowRetries_ = 0;
Scheduler.get().scheduleFixedPeriod(new RepeatingCommand() {
@Override
public boolean execute() {
if (window_ == null && windowRetries_ < MAX_WINDOW_RETRIES) {
windowRetries_++;
return true;
}
if (window_ != null) {
window_.postMessage(method, origin_);
}
return false;
}
}, WINDOW_RETRY_DELAY);
} else {
window_.postMessage(method, origin_);
}
}
use of com.google.gwt.core.client.Scheduler.RepeatingCommand in project gwt-test-utils by gwt-test-utils.
the class SchedulerTest method scheduleIncremental.
@Test
public void scheduleIncremental() {
// Given
final StringBuilder sb = new StringBuilder();
final int COUNT = 2;
RepeatingCommand command = new RepeatingCommand() {
private int index = 0;
public boolean execute() {
sb.append(index++);
return index <= COUNT;
}
};
// When
Scheduler.get().scheduleIncremental(command);
// Then
assertThat(sb.toString()).isEqualTo("012");
}
use of com.google.gwt.core.client.Scheduler.RepeatingCommand in project opennms by OpenNMS.
the class NodeMapWidget method onApplicationInitialized.
@Override
public void onApplicationInitialized(final ApplicationInitializedEvent event) {
LOG.info("NodeMapWidget.onApplicationInitialized(): triggering a backend refresh");
Scheduler.get().scheduleFixedDelay(new RepeatingCommand() {
@Override
public boolean execute() {
LOG.info("NodeMapWidget.onApplicationInitialized(): refreshing");
m_clientToServerRpc.refresh();
return false;
}
}, 5000);
}
use of com.google.gwt.core.client.Scheduler.RepeatingCommand in project opennms by OpenNMS.
the class NodeMapWidget method removeDisabledMarkers.
private void removeDisabledMarkers() {
// remove disabled markers
final List<JSNodeMarker> disabledMarkers = m_markerContainer.getDisabledMarkers();
LOG.info("NodeMapWidget.removeDisabledMarkers(): removing " + disabledMarkers.size() + " disabled markers from the map.");
Scheduler.get().scheduleIncremental(new RepeatingCommand() {
final ListIterator<JSNodeMarker> m_markerIterator = disabledMarkers.listIterator();
@Override
public boolean execute() {
if (m_markerIterator.hasNext()) {
final JSNodeMarker marker = m_markerIterator.next();
marker.closePopup();
final Coordinates coordinates = marker.getCoordinates();
if (coordinates == null) {
LOG.log(Level.WARNING, "NodeMapWidget.removeDisabledMarkers(): no coordinates found for marker! " + marker);
return true;
}
if (m_groupByState && StatesData.inUs(marker.getLatLng().lat(), marker.getLatLng().lng(), StatesData.getUsShape())) {
final int stateId = StatesData.getStateId(marker.getLatLng().lat(), marker.getLatLng().lng(), StatesData.getInstance());
m_stateClusterGroups[stateId].removeLayer(marker);
} else {
m_markerClusterGroup.removeLayer(marker);
}
return true;
}
LOG.info("NodeMapWidget.removeDisabledMarkers(): finished removing filtered markers (" + disabledMarkers.size() + " entries)");
return false;
}
});
}
use of com.google.gwt.core.client.Scheduler.RepeatingCommand in project opennms by OpenNMS.
the class NodeMapWidget method addNewMarkers.
private void addNewMarkers() {
// add new markers
LOG.info("NodeMapWidget.addNewMarkers(): adding " + m_markerContainer.size() + " markers to the map.");
Scheduler.get().scheduleIncremental(new RepeatingCommand() {
final ListIterator<JSNodeMarker> m_markerIterator = m_markerContainer.listIterator();
@Override
public boolean execute() {
if (m_markerIterator.hasNext()) {
final JSNodeMarker marker = m_markerIterator.next();
final Coordinates coordinates = marker.getCoordinates();
if (coordinates == null) {
LOG.log(Level.WARNING, "NodeMapWidget.addNewMarkers(): no coordinates found for marker! " + marker);
return true;
}
if (m_groupByState && StatesData.inUs(coordinates.latitude, coordinates.longitude, StatesData.getUsShape())) {
final int stateId = StatesData.getStateId(marker.getLatLng().lat(), marker.getLatLng().lng(), StatesData.getInstance());
if (!m_stateClusterGroups[stateId].hasLayer(marker)) {
m_stateClusterGroups[stateId].addLayer(marker);
}
} else {
if (!m_markerClusterGroup.hasLayer(marker)) {
m_markerClusterGroup.addLayer(marker);
}
}
return true;
}
LOG.info("NodeMapWidget.addNewMarkers(): finished adding visible markers (" + m_markerContainer.size() + " entries)");
return false;
}
});
}
Aggregations