Search in sources :

Example 6 with RepeatingCommand

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_);
    }
}
Also used : RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand)

Example 7 with RepeatingCommand

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");
}
Also used : RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) Test(org.junit.Test)

Example 8 with RepeatingCommand

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);
}
Also used : RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand)

Example 9 with RepeatingCommand

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;
        }
    });
}
Also used : RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) Coordinates(org.opennms.features.vaadin.nodemaps.internal.gwt.client.Coordinates) JSNodeMarker(org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker)

Example 10 with RepeatingCommand

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;
        }
    });
}
Also used : RepeatingCommand(com.google.gwt.core.client.Scheduler.RepeatingCommand) Coordinates(org.opennms.features.vaadin.nodemaps.internal.gwt.client.Coordinates) JSNodeMarker(org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker)

Aggregations

RepeatingCommand (com.google.gwt.core.client.Scheduler.RepeatingCommand)21 JsArrayString (com.google.gwt.core.client.JsArrayString)3 Element (com.google.gwt.dom.client.Element)3 ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)2 ClickEvent (com.google.gwt.event.dom.client.ClickEvent)2 ClickHandler (com.google.gwt.event.dom.client.ClickHandler)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Coordinates (org.opennms.features.vaadin.nodemaps.internal.gwt.client.Coordinates)2 JSNodeMarker (org.opennms.features.vaadin.nodemaps.internal.gwt.client.JSNodeMarker)2 Breakpoint (org.rstudio.studio.client.common.debugging.model.Breakpoint)2 ServerError (org.rstudio.studio.client.server.ServerError)2 ServerRequestCallback (org.rstudio.studio.client.server.ServerRequestCallback)2 Position (org.rstudio.studio.client.workbench.views.source.editors.text.ace.Position)2 CommentInfo (com.google.gerrit.client.changes.CommentInfo)1 NativeMap (com.google.gerrit.client.rpc.NativeMap)1 JavaScriptObject (com.google.gwt.core.client.JavaScriptObject)1 JsArray (com.google.gwt.core.client.JsArray)1 DivElement (com.google.gwt.dom.client.DivElement)1 Document (com.google.gwt.dom.client.Document)1