tmf: Support markers in abstract time graph views
authorPatrick Tasse <patrick.tasse@gmail.com>
Fri, 25 Sep 2015 22:41:06 +0000 (18:41 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Wed, 30 Sep 2015 22:48:29 +0000 (18:48 -0400)
Change-Id: Iadbe8cd42681fec05ca295b095b60e333edb6865
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/56753
Reviewed-by: Hudson CI
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractStateSystemTimeGraphView.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timegraph/AbstractTimeGraphView.java

index 5cd5fcc0ad749aa1f7927dec44c628954ce4bbcc..a44374d9a412c3e570e68fa9f8bf050c0f6a818c 100644 (file)
@@ -31,6 +31,7 @@ import org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal;
 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphPresentationProvider;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent;
+import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry;
@@ -99,6 +100,7 @@ public abstract class AbstractStateSystemTimeGraphView extends AbstractTimeGraph
         @Override
         public void run() {
             final List<ILinkEvent> links = new ArrayList<>();
+            final List<IMarkerEvent> markers = new ArrayList<>();
             if (fClearZoomedLists) {
                 clearZoomedLists();
             }
@@ -108,11 +110,12 @@ public abstract class AbstractStateSystemTimeGraphView extends AbstractTimeGraph
                     entryList = fSSEntryListMap.get(ss);
                 }
                 if (entryList != null) {
-                    zoomByTime(ss, entryList, links, getZoomStartTime(), getZoomEndTime(), getResolution(), getMonitor());
+                    zoomByTime(ss, entryList, links, markers, getZoomStartTime(), getZoomEndTime(), getResolution(), getMonitor());
                 }
             }
             if (!getMonitor().isCanceled()) {
                 getTimeGraphViewer().setLinks(links);
+                getTimeGraphViewer().getTimeGraphControl().setMarkers(markers);
             }
         }
 
@@ -124,7 +127,7 @@ public abstract class AbstractStateSystemTimeGraphView extends AbstractTimeGraph
             }
         }
 
-        private void zoomByTime(final ITmfStateSystem ss, final List<TimeGraphEntry> entryList, final List<ILinkEvent> links,
+        private void zoomByTime(final ITmfStateSystem ss, final List<TimeGraphEntry> entryList, final List<ILinkEvent> links, final List<IMarkerEvent> markers,
                 long startTime, long endTime, long resolution, final @NonNull IProgressMonitor monitor) {
             final long start = Math.max(startTime, ss.getStartTime());
             final long end = Math.min(endTime, ss.getCurrentEndTime());
@@ -145,6 +148,8 @@ public abstract class AbstractStateSystemTimeGraphView extends AbstractTimeGraph
                     }
                     /* Refresh the arrows when zooming */
                     links.addAll(getLinkList(ss, fullStates, monitor));
+                    /* Refresh the markers when zooming */
+                    markers.addAll(getMarkerList(ss, fullStates, monitor));
                 }
             });
             refresh();
@@ -388,6 +393,23 @@ public abstract class AbstractStateSystemTimeGraphView extends AbstractTimeGraph
         return new ArrayList<>();
     }
 
+    /**
+     * Gets the list of markers for a given list of full
+     * states. The default implementation returns an empty list.
+     *
+     * @param ss
+     *            The state system
+     * @param fullStates
+     *            A list of full states
+     * @param monitor
+     *            A progress monitor
+     * @return The list of marker events
+     */
+    protected @NonNull List<IMarkerEvent> getMarkerList(ITmfStateSystem ss,
+            @NonNull List<List<ITmfStateInterval>> fullStates, @NonNull IProgressMonitor monitor) {
+        return new ArrayList<>();
+    }
+
     /**
      * @deprecated The subclass should call {@link #getEntryList(ITmfStateSystem)} instead.
      */
@@ -442,6 +464,15 @@ public abstract class AbstractStateSystemTimeGraphView extends AbstractTimeGraph
         throw new UnsupportedOperationException();
     }
 
+    /**
+     * @deprecated The subclass should implement {@link #getMarkerList(ITmfStateSystem, List, IProgressMonitor)} instead.
+     */
+    @Deprecated
+    @Override
+    protected final List<IMarkerEvent> getMarkerList(long startTime, long endTime, long resolution, IProgressMonitor monitor) {
+        throw new UnsupportedOperationException();
+    }
+
     // ------------------------------------------------------------------------
     // Signal handlers
     // ------------------------------------------------------------------------
index 3951a17c95c1cc297d3f9b6cb549460627e0694e..ee0b2c0fa9927c36539c15005e3574439a5034f3 100644 (file)
@@ -75,6 +75,7 @@ import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphRangeUpdateEve
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphTimeEvent;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphViewer;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent;
+import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
 import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry;
@@ -634,6 +635,12 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
                 fTimeGraphWrapper.getTimeGraphViewer().setLinks(events);
                 redraw();
             }
+            /* Refresh the markers when zooming */
+            List<IMarkerEvent> markers = getMarkerList(getZoomStartTime(), getZoomEndTime(), getResolution(), getMonitor());
+            if (markers != null) {
+                fTimeGraphWrapper.getTimeGraphViewer().getTimeGraphControl().setMarkers(markers);
+                redraw();
+            }
         }
 
         private void zoom(@NonNull TimeGraphEntry entry, @NonNull IProgressMonitor monitor) {
@@ -1304,6 +1311,25 @@ public abstract class AbstractTimeGraphView extends TmfView implements ITmfTimeA
         return new ArrayList<>();
     }
 
+    /**
+     * Gets the list of markers for a trace in a given time range. Default
+     * implementation returns an empty list.
+     *
+     * @param startTime
+     *            Start of the time range
+     * @param endTime
+     *            End of the time range
+     * @param resolution
+     *            The resolution
+     * @param monitor
+     *            The progress monitor object
+     * @return The list of marker events
+     * @since 2.0
+     */
+    protected @Nullable List<IMarkerEvent> getMarkerList(long startTime, long endTime,
+            long resolution, @NonNull IProgressMonitor monitor) {
+        return new ArrayList<>();
+    }
 
     /**
      * Refresh the display
This page took 0.036712 seconds and 5 git commands to generate.