+ /**
+ * Select the next marker that begins at or after the current selection
+ * begin time. Markers that begin at the same time are ordered by end time.
+ */
+ private void selectNextMarker() {
+ List<IMarkerEvent> markers = getTimeGraphControl().getMarkers();
+ if (markers == null) {
+ return;
+ }
+ for (IMarkerEvent marker : markers) {
+ final long time = Math.min(fSelectionBegin, fSelectionEnd);
+ final long duration = Math.max(fSelectionBegin, fSelectionEnd) - time;
+ if ((marker.getTime() > time ||
+ (marker.getTime() == time && marker.getDuration() > duration))
+ && !fSkippedMarkerCategories.contains(marker.getCategory())) {
+ setSelectionRangeNotify(marker.getTime(), marker.getTime() + marker.getDuration());
+ fTimeGraphCtrl.updateStatusLine();
+ return;
+ }
+ }
+ }
+
+ /**
+ * Select the previous marker that begins at or before the current selection
+ * begin time. Markers that begin at the same time are ordered by end time.
+ */
+ private void selectPrevMarker() {
+ List<IMarkerEvent> markers = getTimeGraphControl().getMarkers();
+ if (markers == null) {
+ return;
+ }
+ final long time = Math.min(fSelectionBegin, fSelectionEnd);
+ final long duration = Math.max(fSelectionBegin, fSelectionEnd) - time;
+ for (int i = markers.size() - 1; i >= 0; i--) {
+ IMarkerEvent marker = markers.get(i);
+ if ((marker.getTime() < time ||
+ (marker.getTime() == time && marker.getDuration() < duration))
+ && !fSkippedMarkerCategories.contains(marker.getCategory())) {
+ setSelectionRangeNotify(marker.getTime(), marker.getTime() + marker.getDuration());
+ fTimeGraphCtrl.updateStatusLine();
+ return;
+ }
+ }
+ }
+
+ /**
+ * Extend the selection to the closest next marker end time.
+ */
+ private void extendToNextMarker() {
+ List<IMarkerEvent> markers = getTimeGraphControl().getMarkers();
+ if (markers == null) {
+ return;
+ }
+ IMarkerEvent nextMarker = null;
+ for (IMarkerEvent marker : markers) {
+ if (marker.getTime() + marker.getDuration() > fSelectionEnd
+ && !fSkippedMarkerCategories.contains(marker.getCategory())
+ && (nextMarker == null || marker.getTime() + marker.getDuration() < nextMarker.getTime() + nextMarker.getDuration())) {
+ nextMarker = marker;
+ }
+ }
+ if (nextMarker != null) {
+ setSelectionRangeNotify(fSelectionBegin, nextMarker.getTime() + nextMarker.getDuration());
+ fTimeGraphCtrl.updateStatusLine();
+ }
+ }
+
+ /**
+ * Extend the selection to the closest previous marker start time.
+ */
+ private void extendToPrevMarker() {
+ List<IMarkerEvent> markers = getTimeGraphControl().getMarkers();
+ if (markers == null) {
+ return;
+ }
+ for (int i = markers.size() - 1; i >= 0; i--) {
+ IMarkerEvent marker = markers.get(i);
+ if (marker.getTime() < fSelectionEnd
+ && !fSkippedMarkerCategories.contains(marker.getCategory())) {
+ setSelectionRangeNotify(fSelectionBegin, marker.getTime());
+ fTimeGraphCtrl.updateStatusLine();
+ return;
+ }
+ }
+ }
+