tmf: Bug 494790: Time Chart view does not update when adding bookmarks
authorPatrick Tasse <patrick.tasse@gmail.com>
Mon, 30 May 2016 15:17:41 +0000 (11:17 -0400)
committerPatrick Tasse <patrick.tasse@gmail.com>
Tue, 31 May 2016 15:26:29 +0000 (11:26 -0400)
The Time Chart view now properly shows the bookmark decorations.

Change-Id: I5e25171f61afea79fdd0e2206ef3254731ecb497
Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com>
Reviewed-on: https://git.eclipse.org/r/73956
Reviewed-by: Hudson CI
Reviewed-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
Tested-by: Bernd Hufmann <bernd.hufmann@ericsson.com>
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartDecorationProvider.java
tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/views/timechart/TimeChartView.java

index 8d7a33472494435674fdaa312dde71b02ffa3599..a11d0e1233f5dc8f11b320266707b4b3cf842d80 100644 (file)
@@ -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);
                 }
             }
index 571c19840f9b28c91457538789c15da04ecc7bd6..ff31a99cb40b53dede9df71731adaad99e983569 100644 (file)
@@ -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();
                     }
                 }
This page took 0.026879 seconds and 5 git commands to generate.