Skip to content

Commit

Permalink
server: Follow Trace Compass classic attributes for bookmarks
Browse files Browse the repository at this point in the history
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 <kaveh.shahedi@ericsson.com>
  • Loading branch information
kavehshahedi committed Nov 18, 2024
1 parent 43b1ef9 commit 5d50c89
Showing 1 changed file with 31 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
*
Expand Down Expand Up @@ -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);
}
Expand All @@ -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);
}

/**
Expand Down

0 comments on commit 5d50c89

Please sign in to comment.