public static String ManageCustomParsersDialog_NewButtonLabel;
public static String ManageCustomParsersDialog_TextButtonLabel;
- public static String MarkerEvent_Bookmark;
+ public static String MarkerEvent_Bookmarks;
public static String TmfEventsTable_AddBookmarkActionText;
public static String TmfEventsTable_ApplyPresetFilterMenuName;
public static String TmfTimeGraphViewer_BookmarkActionRemoveText;
public static String TmfTimeGraphViewer_NextMarkerActionText;
public static String TmfTimeGraphViewer_PreviousMarkerActionText;
+ public static String TmfTimeGraphViewer_ShowMarkersMenuText;
public static String Utils_ClockCyclesUnit;
TmfTimeFilterDialog_UNCHECK_SUBTREE=Uncheck subtree
# org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model
-MarkerEvent_Bookmark=Bookmark
+MarkerEvent_Bookmarks=Bookmarks
# org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets
TmfTimeTipHandler_DURATION=Duration
TmfTimeGraphViewer_BookmarkActionRemoveText=Remove Bookmark
TmfTimeGraphViewer_NextMarkerActionText=Next Marker
TmfTimeGraphViewer_PreviousMarkerActionText=Previous Marker
+TmfTimeGraphViewer_ShowMarkersMenuText=Show Markers
Utils_ClockCyclesUnit=\u0020cc
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuManager;
import org.eclipse.jface.action.IStatusLineManager;
import org.eclipse.jface.action.IToolBarManager;
import org.eclipse.jface.action.Separator;
int alpha = Integer.valueOf(matcher.group(4));
Color color = new Color(Display.getDefault(), red, green, blue, alpha);
fColors.add(color);
- bookmarks.add(new MarkerEvent(null, Long.valueOf(time), Long.valueOf(duration), IMarkerEvent.BOOKMARK, color, label, true));
+ bookmarks.add(new MarkerEvent(null, Long.valueOf(time), Long.valueOf(duration), IMarkerEvent.BOOKMARKS, color, label, true));
} catch (NumberFormatException e) {
Activator.getDefault().logError(e.getMessage());
}
return new ArrayList<>();
}
+ /**
+ * Gets the list of view-specific marker categories. Default implementation
+ * returns an empty list.
+ *
+ * @return The list of marker categories
+ * @since 2.0
+ */
+ protected @NonNull List<String> getViewMarkerCategories() {
+ return new ArrayList<>();
+ }
+
/**
* Gets the list of view-specific markers for a trace in a given time range.
* Default implementation returns an empty list.
return markers;
}
+ /**
+ * Get the list of current marker categories.
+ *
+ * @return The list of marker categories
+ * @since 2.0
+ */
+ private @NonNull List<String> getMarkerCategories() {
+ Set<String> categories = new HashSet<>(getViewMarkerCategories());
+ for (IMarkerEventSource markerEventSource : getMarkerEventSources(fTrace)) {
+ categories.addAll(markerEventSource.getMarkerCategories());
+ }
+ return new ArrayList<>(categories);
+ }
+
/**
* Gets the list of marker event sources for a given trace.
*
* @return The list of marker event sources
* @since 2.0
*/
- protected @NonNull List<IMarkerEventSource> getMarkerEventSources(ITmfTrace trace) {
+ private @NonNull List<IMarkerEventSource> getMarkerEventSources(ITmfTrace trace) {
List<IMarkerEventSource> markerEventSources = fMarkerEventSourcesMap.get(trace);
if (markerEventSources == null) {
markerEventSources = checkNotNull(Collections.<IMarkerEventSource>emptyList());
fTimeGraphWrapper.setFilters(fFiltersMap.get(fTrace));
fTimeGraphWrapper.getTimeGraphViewer().setLinks(null);
fTimeGraphWrapper.getTimeGraphViewer().setBookmarks(refreshBookmarks(fEditorFile));
+ fTimeGraphWrapper.getTimeGraphViewer().setMarkerCategories(getMarkerCategories());
} else {
fTimeGraphWrapper.refresh();
}
private void contributeToActionBars() {
IActionBars bars = getViewSite().getActionBars();
fillLocalToolBar(bars.getToolBarManager());
+ fillLocalMenu(bars.getMenuManager());
}
/**
manager.add(fTimeGraphWrapper.getTimeGraphViewer().getResetScaleAction());
manager.add(fTimeGraphWrapper.getTimeGraphViewer().getPreviousEventAction());
manager.add(fTimeGraphWrapper.getTimeGraphViewer().getNextEventAction());
+ manager.add(new Separator());
manager.add(fTimeGraphWrapper.getTimeGraphViewer().getToggleBookmarkAction());
manager.add(fTimeGraphWrapper.getTimeGraphViewer().getPreviousMarkerAction());
manager.add(fTimeGraphWrapper.getTimeGraphViewer().getNextMarkerAction());
+ manager.add(new Separator());
manager.add(fPreviousResourceAction);
manager.add(fNextResourceAction);
manager.add(fTimeGraphWrapper.getTimeGraphViewer().getZoomInAction());
manager.add(new Separator());
}
+ /**
+ * Add actions to local menu manager
+ *
+ * @param manager the tool bar manager
+ * @since 2.0
+ */
+ protected void fillLocalMenu(IMenuManager manager) {
+ manager.add(fTimeGraphWrapper.getTimeGraphViewer().getMarkersMenu());
+ }
+
/**
* @since 1.0
*/
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.HashSet;
import java.util.List;
+import java.util.Set;
import org.eclipse.jface.action.Action;
import org.eclipse.jface.action.IAction;
+import org.eclipse.jface.action.IMenuListener;
+import org.eclipse.jface.action.IMenuManager;
+import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.dialogs.IDialogSettings;
import org.eclipse.jface.resource.ImageDescriptor;
import org.eclipse.jface.viewers.AbstractTreeViewer;
private Action fToggleBookmarkAction;
private Action fNextMarkerAction;
private Action fPreviousMarkerAction;
+ private MenuManager fMarkersMenu;
/** The list of bookmarks */
private final List<IMarkerEvent> fBookmarks = new ArrayList<>();
+ /** The list of marker categories */
+ private final List<String> fMarkerCategories = new ArrayList<>();
+
+ /** The set of hidden marker categories */
+ private final Set<String> fHiddenMarkerCategories = new HashSet<>();
+
/** The list of markers */
private final List<IMarkerEvent> fMarkers = new ArrayList<>();
for (Color color : fColors) {
color.dispose();
}
+ if (fMarkersMenu != null) {
+ fMarkersMenu.dispose();
+ }
}
});
GridLayout gl = new GridLayout(2, false);
return Collections.unmodifiableList(fBookmarks);
}
+ /**
+ * Set the list of marker categories.
+ *
+ * @param categories
+ * The list of marker categories, or null
+ * @since 2.0
+ */
+ public void setMarkerCategories(List<String> categories) {
+ fMarkerCategories.clear();
+ fMarkerCategories.add(IMarkerEvent.BOOKMARKS);
+ if (categories != null) {
+ fMarkerCategories.addAll(categories);
+ }
+ Collections.sort(fMarkerCategories);
+ }
+
/**
* Set the markers list.
*
final RGBA rgba = dialog.getColorValue();
Color color = new Color(Display.getDefault(), rgba.rgb.red, rgba.rgb.green, rgba.rgb.blue, rgba.alpha);
fColors.add(color);
- IMarkerEvent bookmark = new MarkerEvent(null, time, duration, IMarkerEvent.BOOKMARK, color, label, true);
+ IMarkerEvent bookmark = new MarkerEvent(null, time, duration, IMarkerEvent.BOOKMARKS, color, label, true);
fBookmarks.add(bookmark);
updateMarkerList();
+ updateMarkerActions();
getControl().redraw();
fireBookmarkAdded(bookmark);
}
checkDisposeColor(selectedBookmark.getColor());
fBookmarks.remove(selectedBookmark);
updateMarkerList();
+ updateMarkerActions();
getControl().redraw();
fireBookmarkRemoved(selectedBookmark);
}
- updateMarkerActions();
}
};
fToggleBookmarkAction.setText(Messages.TmfTimeGraphViewer_BookmarkActionAddText);
return fPreviousMarkerAction;
}
+ /**
+ * Get the show markers menu.
+ *
+ * @return The menu manager object
+ * @since 2.0
+ */
+ public MenuManager getMarkersMenu() {
+ if (fMarkersMenu == null) {
+ fMarkersMenu = new MenuManager(Messages.TmfTimeGraphViewer_ShowMarkersMenuText);
+ fMarkersMenu.setRemoveAllWhenShown(true);
+ fMarkersMenu.addMenuListener(new IMenuListener() {
+ @Override
+ public void menuAboutToShow(IMenuManager manager) {
+ for (String category : fMarkerCategories) {
+ final Action action = new Action(category, IAction.AS_CHECK_BOX) {
+ @Override
+ public void runWithEvent(Event event) {
+ if (isChecked()) {
+ fHiddenMarkerCategories.remove(getText());
+ } else {
+ fHiddenMarkerCategories.add(getText());
+ }
+ updateMarkerList();
+ updateMarkerActions();
+ getControl().redraw();
+ }
+ };
+ action.setChecked(!fHiddenMarkerCategories.contains(category));
+ manager.add(action);
+ }
+ }
+ });
+ }
+ return fMarkersMenu;
+ }
+
private IMarkerEvent getBookmarkAtSelection() {
final long time = Math.min(fSelectionBegin, fSelectionEnd);
final long duration = Math.max(fSelectionBegin, fSelectionEnd) - time;
}
private void updateMarkerList() {
- List<IMarkerEvent> markers = new ArrayList<>(fMarkers);
- markers.addAll(fBookmarks);
+ List<IMarkerEvent> markers = new ArrayList<>();
+ for (IMarkerEvent marker : fMarkers) {
+ if (!fHiddenMarkerCategories.contains(marker.getCategory())) {
+ markers.add(marker);
+ }
+ }
+ if (!fHiddenMarkerCategories.contains(IMarkerEvent.BOOKMARKS)) {
+ markers.addAll(fBookmarks);
+ }
Collections.sort(markers, new MarkerComparator());
getTimeGraphControl().setMarkers(markers);
}
*/
public interface IMarkerEvent extends ITimeEvent {
- /** Bookmark marker category */
- @NonNull String BOOKMARK = checkNotNull(Messages.MarkerEvent_Bookmark);
+ /** Bookmarks marker category */
+ @NonNull String BOOKMARKS = checkNotNull(Messages.MarkerEvent_Bookmarks);
/**
* Get this marker's category.