Search in sources :

Example 1 with SafeMap

use of org.rstudio.core.client.container.SafeMap in project rstudio by rstudio.

the class AceEditorBackgroundLinkHighlighter method onDocumentChanged.

@Override
public void onDocumentChanged(DocumentChangedEvent event) {
    // clear markers within the delete range
    clearMarkers(event.getEvent().getRange());
    // prepare highlighter
    int row = event.getEvent().getRange().getStart().getRow();
    nextHighlightStart_ = Math.min(nextHighlightStart_, row);
    timer_.schedule(700);
    // update marker positions (deferred so that anchors update)
    Scheduler.get().scheduleDeferred(new ScheduledCommand() {

        @Override
        public void execute() {
            final SafeMap<Integer, List<MarkerRegistration>> newMarkers = new SafeMap<Integer, List<MarkerRegistration>>();
            MapUtil.forEach(activeMarkers_, new ForEachCommand<Integer, List<MarkerRegistration>>() {

                @Override
                public void execute(Integer oldRow, List<MarkerRegistration> markers) {
                    if (markers == null || markers.isEmpty())
                        return;
                    // all markers here should have same row
                    int newRow = markers.get(0).getRange().getStart().getRow();
                    newMarkers.put(newRow, markers);
                }
            });
            activeMarkers_.clear();
            activeMarkers_ = newMarkers;
        }
    });
}
Also used : ScheduledCommand(com.google.gwt.core.client.Scheduler.ScheduledCommand) SafeMap(org.rstudio.core.client.container.SafeMap) ForEachCommand(org.rstudio.core.client.MapUtil.ForEachCommand) List(java.util.List) ArrayList(java.util.ArrayList)

Aggregations

ScheduledCommand (com.google.gwt.core.client.Scheduler.ScheduledCommand)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ForEachCommand (org.rstudio.core.client.MapUtil.ForEachCommand)1 SafeMap (org.rstudio.core.client.container.SafeMap)1