From 5d50c89a05038680c449af2787bcefe9a8e8b901 Mon Sep 17 00:00:00 2001 From: Kaveh Shahedi Date: Mon, 18 Nov 2024 11:37:12 -0500 Subject: [PATCH] server: Follow Trace Compass classic attributes for bookmarks Instead of using newly-introduced attributes for trace server bookmarks, we now use the ones that have been used in the classic Trace Compass. Signed-off-by: Kaveh Shahedi --- .../core/services/BookmarkManagerService.java | 37 ++++++++++++++++--- 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/BookmarkManagerService.java b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/BookmarkManagerService.java index d8b9f401..32a1ad75 100644 --- a/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/BookmarkManagerService.java +++ b/trace-server/org.eclipse.tracecompass.incubator.trace.server.jersey.rest.core/src/org/eclipse/tracecompass/incubator/internal/trace/server/jersey/rest/core/services/BookmarkManagerService.java @@ -41,9 +41,12 @@ import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IResource; import org.eclipse.core.runtime.CoreException; +import org.eclipse.osgi.util.NLS; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.Activator; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.BookmarkQueryParameters; import org.eclipse.tracecompass.incubator.internal.trace.server.jersey.rest.core.model.views.QueryParameters; +import org.eclipse.tracecompass.tmf.core.resources.ITmfMarker; +import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; import org.eclipse.tracecompass.tmf.core.trace.experiment.TmfExperiment; @@ -71,6 +74,8 @@ public class BookmarkManagerService { private static final String BOOKMARK_START = "start"; //$NON-NLS-1$ private static final String BOOKMARK_END = "end"; //$NON-NLS-1$ + private static final String BOOKMARK_DEFAULT_COLOR = "RGBA {255, 0, 0, 128}"; //$NON-NLS-1$ + /** * Retrieve all bookmarks for a specific experiment * @@ -343,9 +348,14 @@ private static Bookmark markerToBookmark(IMarker marker) throws CoreException { return null; } - String name = marker.getAttribute(BOOKMARK_NAME).toString(); - long start = Long.parseLong(marker.getAttribute(BOOKMARK_START).toString()); - long end = Long.parseLong(marker.getAttribute(BOOKMARK_END).toString()); + String name = marker.getAttribute(IMarker.MESSAGE).toString(); + long start = Long.parseLong(marker.getAttribute(ITmfMarker.MARKER_TIME).toString()); + + long duration = 0; + if (marker.getAttribute(ITmfMarker.MARKER_DURATION) != null) { + duration = Long.parseLong(marker.getAttribute(ITmfMarker.MARKER_DURATION).toString()); + } + long end = start + duration; return new Bookmark(UUID.fromString(uuid), name, start, end); } @@ -367,10 +377,25 @@ private static IMarker findMarkerByUUID(IMarker[] markers, UUID bookmarkUUID) { * Create a new marker with bookmark attributes */ private static void setMarkerAttributes(IMarker marker, Bookmark bookmark) throws CoreException { + Long duration = bookmark.getEnd() - bookmark.getStart(); + marker.setAttribute(BOOKMARK_UUID, bookmark.getUUID().toString()); - marker.setAttribute(BOOKMARK_NAME, bookmark.getName()); - marker.setAttribute(BOOKMARK_START, Long.toString(bookmark.getStart())); - marker.setAttribute(BOOKMARK_END, Long.toString(bookmark.getEnd())); + marker.setAttribute(IMarker.MESSAGE, bookmark.getName()); + marker.setAttribute(ITmfMarker.MARKER_TIME, Long.toString(bookmark.getStart())); + + if (duration > 0) { + marker.setAttribute(ITmfMarker.MARKER_DURATION, Long.toString(duration)); + marker.setAttribute(IMarker.LOCATION, + NLS.bind("timestamp [{0}, {1}]", //$NON-NLS-1$ + TmfTimestamp.fromNanos(bookmark.getStart()), + TmfTimestamp.fromNanos(bookmark.getEnd()))); + } else { + marker.setAttribute(IMarker.LOCATION, + NLS.bind("timestamp [{0}]", //$NON-NLS-1$ + TmfTimestamp.fromNanos(bookmark.getStart()))); + } + + marker.setAttribute(ITmfMarker.MARKER_COLOR, BOOKMARK_DEFAULT_COLOR); } /**