import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
-import java.util.HashSet;
+import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
* @since 2.0
*/
private @NonNull List<String> getMarkerCategories() {
- Set<String> categories = new HashSet<>(getViewMarkerCategories());
+ Set<String> categories = new LinkedHashSet<>(getViewMarkerCategories());
for (IMarkerEventSource markerEventSource : getMarkerEventSources(fTrace)) {
categories.addAll(markerEventSource.getMarkerCategories());
}
package org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets;
+import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent;
import com.google.common.collect.LinkedHashMultimap;
-import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
/**
private @NonNull ITimeDataProvider fTimeProvider;
private Multimap<String, IMarkerEvent> fMarkers = LinkedHashMultimap.create();
- private List<String> fCategories = Collections.EMPTY_LIST;
+ private @NonNull List<String> fCategories = Collections.EMPTY_LIST;
/**
* Contructor
fTimeProvider = timeProvider;
}
+ /**
+ * Set the list of marker categories.
+ *
+ * @param categories
+ * The list of marker categories, or null
+ */
+ public void setMarkerCategories(List<String> categories) {
+ if (categories == null) {
+ fCategories = Collections.EMPTY_LIST;
+ } else {
+ fCategories = categories;
+ }
+ }
+
/**
* Set the markers list.
*
for (IMarkerEvent marker : markers) {
map.put(marker.getCategory(), marker);
}
- List<String> categories = Lists.newArrayList(map.keySet());
- Collections.sort(categories);
Display.getDefault().asyncExec(() -> {
fMarkers = map;
- fCategories = categories;
getParent().layout();
redraw();
});
gc.fillRectangle(bounds);
Rectangle rect = new Rectangle(bounds.x, bounds.y + TOP_MARGIN, bounds.width, HEIGHT);
- for (String category : fCategories) {
+ List<String> categories = new ArrayList<>(fCategories);
+ categories.retainAll(fMarkers.keySet());
+ for (String category : categories) {
rect.x = bounds.x;
rect.width = nameSpace;
drawMarkerCategory(category, rect, gc);
(double) (timeSpace - RIGHT_MARGIN) / (time1 - time0);
int categoryIndex = Math.max((event.y - TOP_MARGIN) / HEIGHT, 0);
- String category = fCategories.get(categoryIndex);
+ List<String> categories = new ArrayList<>(fCategories);
+ categories.retainAll(fMarkers.keySet());
+ String category = categories.get(categoryIndex);
IMarkerEvent marker = null;
GC gc = new GC(Display.getDefault());