From: Patrick Tasse Date: Mon, 30 May 2016 15:17:41 +0000 (-0400) Subject: tmf: Bug 494790: Time Chart view does not update when adding bookmarks X-Git-Url: http://git.efficios.com/?p=deliverable%2Ftracecompass.git;a=commitdiff_plain;h=b1ba6312a6310dadfa14adb5ab7782b3da79bc62 tmf: Bug 494790: Time Chart view does not update when adding bookmarks The Time Chart view now properly shows the bookmark decorations. Change-Id: I5e25171f61afea79fdd0e2206ef3254731ecb497 Signed-off-by: Patrick Tasse Reviewed-on: https://git.eclipse.org/r/73956 Reviewed-by: Hudson CI Reviewed-by: Bernd Hufmann Tested-by: Bernd Hufmann --- diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartDecorationProvider.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartDecorationProvider.java index 8d7a334724..a11d0e1233 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartDecorationProvider.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartDecorationProvider.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2014 Ericsson + * Copyright (c) 2010, 2016 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -22,6 +22,7 @@ import org.eclipse.core.runtime.CoreException; import org.eclipse.tracecompass.internal.tmf.ui.Activator; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; import org.eclipse.tracecompass.tmf.core.filter.ITmfFilter; +import org.eclipse.tracecompass.tmf.core.resources.ITmfMarker; /** * Provider for decorations in the time chart view @@ -78,9 +79,17 @@ public class TimeChartDecorationProvider { } for (IMarker bookmark : fBookmarksFile.findMarkers( IMarker.BOOKMARK, false, IResource.DEPTH_ZERO)) { - int location = bookmark.getAttribute(IMarker.LOCATION, -1); - if (location != -1) { - Long rank = (long) location; + /* try location as an integer for backward compatibility */ + long rank = bookmark.getAttribute(IMarker.LOCATION, -1); + if (rank == -1) { + String rankString = bookmark.getAttribute(ITmfMarker.MARKER_RANK, (String) null); + try { + rank = Long.parseLong(rankString); + } catch (NumberFormatException e) { + /* ignored */ + } + } + if (rank != -1) { fBookmarksSet.add(rank); } } diff --git a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java index 571c19840f..ff31a99cb4 100644 --- a/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java +++ b/tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2010, 2015 Ericsson + * Copyright (c) 2010, 2016 Ericsson * * All rights reserved. This program and the accompanying materials are * made available under the terms of the Eclipse Public License v1.0 which @@ -30,6 +30,7 @@ import org.eclipse.swt.SWT; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Display; import org.eclipse.tracecompass.tmf.core.event.ITmfEvent; +import org.eclipse.tracecompass.tmf.core.resources.ITmfMarker; import org.eclipse.tracecompass.tmf.core.signal.TmfEventFilterAppliedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfEventSearchAppliedSignal; import org.eclipse.tracecompass.tmf.core.signal.TmfSelectionRangeUpdatedSignal; @@ -561,9 +562,9 @@ public class TimeChartView extends TmfView implements ITimeGraphRangeListener, I for (IMarkerDelta delta : event.findMarkerDeltas(IMarker.BOOKMARK, false)) { for (TimeChartDecorationProvider provider : fDecorationProviders.values()) { if (delta.getResource().equals(provider.getBookmarksFile())) { - if (delta.getKind() == IResourceDelta.CHANGED && delta.getMarker().getAttribute(IMarker.LOCATION, -1) != -1) { - provider.refreshBookmarks(); - } else if (delta.getKind() == IResourceDelta.REMOVED) { + if (delta.getKind() == IResourceDelta.REMOVED || + delta.getMarker().getAttribute(IMarker.LOCATION, -1) != -1 || + delta.getMarker().getAttribute(ITmfMarker.MARKER_RANK, (String) null) != null) { provider.refreshBookmarks(); } }