Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Tasse2014-06-02 18:04:21 +0000
committerPatrick Tasse2014-06-04 11:50:40 +0000
commit671ac2131c879eba57ca86ab80ee86e5b0c5c554 (patch)
tree68d098b418bf2071e0883f4fd76f959dae2e052c
parentc97ab50940658a66f74cf880a07fb26ee3c6cfd9 (diff)
downloadorg.eclipse.linuxtools-671ac2131c879eba57ca86ab80ee86e5b0c5c554.tar.gz
org.eclipse.linuxtools-671ac2131c879eba57ca86ab80ee86e5b0c5c554.tar.xz
org.eclipse.linuxtools-671ac2131c879eba57ca86ab80ee86e5b0c5c554.zip
tmf: Bug 436258: Bookmark icon disappears on deletion even if there is
The TmfEventsTable now supports many bookmarks for the same rank by use of a multimap. The tool tip is updated to show multiple bookmarks. The remove and toggle bookmark actions now remove all bookmarks. Change-Id: Ic22430ed642190e0c7dc58516d7f6759390329ca Signed-off-by: Patrick Tasse <patrick.tasse@gmail.com> Reviewed-on: https://git.eclipse.org/r/27746 Tested-by: Hudson CI
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF3
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java2
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties1
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java46
4 files changed, 33 insertions, 19 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF b/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
index c778fc2267..6b9d537f5f 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/META-INF/MANIFEST.MF
@@ -73,6 +73,7 @@ Export-Package: org.eclipse.linuxtools.internal.tmf.ui;x-friends:="org.eclipse.l
org.eclipse.linuxtools.tmf.ui.widgets.timegraph.model,
org.eclipse.linuxtools.tmf.ui.widgets.timegraph.widgets,
org.eclipse.linuxtools.tmf.ui.widgets.virtualtable
-Import-Package: com.google.common.collect,
+Import-Package: com.google.common.base,
+ com.google.common.collect,
org.eclipse.emf.common.util,
org.eclipse.emf.ecore
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java
index 39a06b174e..04d7a6a1fa 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/Messages.java
@@ -40,11 +40,11 @@ public class Messages extends NLS {
public static String TmfEventsTable_ApplyPresetFilterMenuName;
public static String TmfEventsTable_ClearFiltersActionText;
public static String TmfEventsTable_ContentColumnHeader;
-
public static String TmfEventsTable_Export_to_text;
public static String TmfEventsTable_FilterHint;
public static String TmfEventsTable_HideRawActionText;
public static String TmfEventsTable_HideTableActionText;
+ public static String TmfEventsTable_MultipleBookmarksToolTip;
public static String TmfEventsTable_OpenSourceCodeActionText;
public static String TmfEventsTable_OpenSourceCodeNotFound;
public static String TmfEventsTable_OpenSourceCodeSelectFileDialogTitle;
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties
index b325b0819d..ac612a1d8e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/internal/tmf/ui/messages.properties
@@ -37,6 +37,7 @@ TmfEventsTable_Export_to_text=Export To Text...
TmfEventsTable_FilterHint=<filter>
TmfEventsTable_HideRawActionText=Hide Raw
TmfEventsTable_HideTableActionText=Hide Table
+TmfEventsTable_MultipleBookmarksToolTip=Multiple bookmarks at this location
TmfEventsTable_OpenSourceCodeActionText=Open Source Code
TmfEventsTable_OpenSourceCodeNotFound=can not be found in the workspace.
TmfEventsTable_OpenSourceCodeSelectFileDialogTitle=Select source file for the call site
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java
index d57a0aee24..e762d54cca 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java
@@ -20,9 +20,9 @@ package org.eclipse.linuxtools.tmf.ui.viewers.events;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.Collection;
import java.util.HashMap;
import java.util.List;
-import java.util.Map;
import java.util.Map.Entry;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
@@ -146,6 +146,10 @@ import org.eclipse.ui.ide.IDE;
import org.eclipse.ui.ide.IGotoMarker;
import org.eclipse.ui.themes.ColorUtil;
+import com.google.common.base.Joiner;
+import com.google.common.collect.HashMultimap;
+import com.google.common.collect.Multimap;
+
/**
* The generic TMF Events table
*
@@ -263,7 +267,7 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
private ListenerList selectionChangedListeners = new ListenerList();
// Bookmark map <Rank, MarkerId>
- private Map<Long, Long> fBookmarksMap = new HashMap<>();
+ private Multimap<Long, Long> fBookmarksMap = HashMultimap.create();
private IFile fBookmarksFile;
private long fPendingGotoRank = -1;
@@ -1012,16 +1016,22 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
item.setData(Key.TIMESTAMP, new TmfTimestamp(event.getTimestamp()));
item.setData(Key.RANK, rank);
- boolean bookmark = false;
- final Long markerId = fBookmarksMap.get(rank);
- if (markerId != null) {
- bookmark = true;
+ final Collection<Long> markerIds = fBookmarksMap.get(rank);
+ if (!markerIds.isEmpty()) {
+ Joiner joiner = Joiner.on("\n -").skipNulls(); //$NON-NLS-1$
+ List<Object> parts = new ArrayList<>();
+ if (markerIds.size() > 1) {
+ parts.add(Messages.TmfEventsTable_MultipleBookmarksToolTip);
+ }
try {
- final IMarker marker = fBookmarksFile.findMarker(markerId);
- item.setData(Key.BOOKMARK, marker.getAttribute(IMarker.MESSAGE));
- } catch (final CoreException e) {
+ for (long markerId : markerIds) {
+ final IMarker marker = fBookmarksFile.findMarker(markerId);
+ parts.add(marker.getAttribute(IMarker.MESSAGE));
+ }
+ } catch (CoreException e) {
displayException(e);
}
+ item.setData(Key.BOOKMARK, joiner.join(parts));
} else {
item.setData(Key.BOOKMARK, null);
}
@@ -1047,12 +1057,12 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
}
if (searchMatch) {
- if (bookmark) {
+ if (!markerIds.isEmpty()) {
item.setImage(SEARCH_MATCH_BOOKMARK_IMAGE);
} else {
item.setImage(SEARCH_MATCH_IMAGE);
}
- } else if (bookmark) {
+ } else if (!markerIds.isEmpty()) {
item.setImage(BOOKMARK_IMAGE);
} else {
item.setImage((Image) null);
@@ -2119,9 +2129,9 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
* The bookmark to remove
*/
public void removeBookmark(final IMarker bookmark) {
- for (final Entry<Long, Long> entry : fBookmarksMap.entrySet()) {
+ for (final Entry<Long, Long> entry : fBookmarksMap.entries()) {
if (entry.getValue().equals(bookmark.getId())) {
- fBookmarksMap.remove(entry.getKey());
+ fBookmarksMap.remove(entry.getKey(), entry.getValue());
fTable.refresh();
return;
}
@@ -2133,12 +2143,14 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
return;
}
if (fBookmarksMap.containsKey(rank)) {
- final Long markerId = fBookmarksMap.remove(rank);
+ final Collection<Long> markerIds = fBookmarksMap.removeAll(rank);
fTable.refresh();
try {
- final IMarker bookmark = fBookmarksFile.findMarker(markerId);
- if (bookmark != null) {
- bookmark.delete();
+ for (long markerId : markerIds) {
+ final IMarker bookmark = fBookmarksFile.findMarker(markerId);
+ if (bookmark != null) {
+ bookmark.delete();
+ }
}
} catch (final CoreException e) {
displayException(e);

Back to the top