Search in sources :

Example 1 with IMarkerEvent

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent in project tracecompass by tracecompass.

the class TimeGraphViewer method updateMarkerList.

private void updateMarkerList() {
    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());
    fTimeGraphCtrl.setMarkers(markers);
    fMarkerAxisCtrl.setMarkers(markers);
}
Also used : ArrayList(java.util.ArrayList) IMarkerEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent)

Example 2 with IMarkerEvent

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent in project tracecompass by tracecompass.

the class TimeGraphViewer method getBookmarkAtSelection.

private IMarkerEvent getBookmarkAtSelection() {
    final long time = Math.min(fSelectionBegin, fSelectionEnd);
    final long duration = Math.max(fSelectionBegin, fSelectionEnd) - time;
    for (IMarkerEvent bookmark : fBookmarks) {
        if (bookmark.getTime() == time && bookmark.getDuration() == duration) {
            return bookmark;
        }
    }
    return null;
}
Also used : IMarkerEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent)

Example 3 with IMarkerEvent

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent in project tracecompass by tracecompass.

the class TimeGraphViewer method selectNextMarker.

/**
 * Select the next marker that begins at or after the current selection
 * begin time. Markers that begin at the same time are ordered by end time.
 */
private void selectNextMarker() {
    List<IMarkerEvent> markers = getTimeGraphControl().getMarkers();
    if (markers == null) {
        return;
    }
    for (IMarkerEvent marker : markers) {
        final long time = Math.min(fSelectionBegin, fSelectionEnd);
        final long duration = Math.max(fSelectionBegin, fSelectionEnd) - time;
        if ((marker.getTime() > time || (marker.getTime() == time && marker.getDuration() > duration)) && !fSkippedMarkerCategories.contains(marker.getCategory())) {
            setSelectionRangeNotify(marker.getTime(), marker.getTime() + marker.getDuration(), false);
            ensureVisible(marker.getTime());
            notifyRangeListeners();
            fTimeGraphCtrl.updateStatusLine();
            return;
        }
    }
}
Also used : IMarkerEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent)

Example 4 with IMarkerEvent

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent in project tracecompass by tracecompass.

the class TimeGraphViewer method getToggleBookmarkAction.

/**
 * Get the toggle bookmark action.
 *
 * @return The Action object
 * @since 2.0
 */
public Action getToggleBookmarkAction() {
    if (fToggleBookmarkAction == null) {
        fToggleBookmarkAction = new Action() {

            @Override
            public void runWithEvent(Event event) {
                IMarkerEvent selectedBookmark = getBookmarkAtSelection();
                if (selectedBookmark == null) {
                    final long time = Math.min(fSelectionBegin, fSelectionEnd);
                    final long duration = Math.max(fSelectionBegin, fSelectionEnd) - time;
                    final AddBookmarkDialog dialog = new AddBookmarkDialog(PlatformUI.getWorkbench().getActiveWorkbenchWindow().getShell(), null);
                    if (dialog.open() == Window.OK) {
                        final String label = dialog.getValue();
                        final RGBA rgba = dialog.getColorValue();
                        IMarkerEvent bookmark = new MarkerEvent(null, time, duration, IMarkerEvent.BOOKMARKS, rgba, label, true);
                        fBookmarks.add(bookmark);
                        updateMarkerList();
                        updateMarkerActions();
                        getControl().redraw();
                        fireBookmarkAdded(bookmark);
                    }
                } else {
                    fBookmarks.remove(selectedBookmark);
                    updateMarkerList();
                    updateMarkerActions();
                    getControl().redraw();
                    fireBookmarkRemoved(selectedBookmark);
                }
            }
        };
        fToggleBookmarkAction.setText(Messages.TmfTimeGraphViewer_BookmarkActionAddText);
        fToggleBookmarkAction.setToolTipText(Messages.TmfTimeGraphViewer_BookmarkActionAddText);
        fToggleBookmarkAction.setImageDescriptor(ADD_BOOKMARK);
    }
    return fToggleBookmarkAction;
}
Also used : AddBookmarkDialog(org.eclipse.tracecompass.internal.tmf.ui.dialogs.AddBookmarkDialog) IAction(org.eclipse.jface.action.IAction) ShowFilterDialogAction(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.dialogs.ShowFilterDialogAction) Action(org.eclipse.jface.action.Action) RGBA(org.eclipse.swt.graphics.RGBA) IMarkerEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent) MarkerEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.MarkerEvent) IMarkerEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent) PaintEvent(org.eclipse.swt.events.PaintEvent) KeyEvent(org.eclipse.swt.events.KeyEvent) ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) ILinkEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent) SelectionChangedEvent(org.eclipse.jface.viewers.SelectionChangedEvent) MarkerEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.MarkerEvent) Event(org.eclipse.swt.widgets.Event) ControlEvent(org.eclipse.swt.events.ControlEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) IMarkerEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent)

Example 5 with IMarkerEvent

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent in project tracecompass by tracecompass.

the class TimeGraphViewer method extendToPrevMarker.

/**
 * Extend the selection to the closest previous marker start time.
 */
private void extendToPrevMarker() {
    List<IMarkerEvent> markers = getTimeGraphControl().getMarkers();
    if (markers == null) {
        return;
    }
    for (int i = markers.size() - 1; i >= 0; i--) {
        IMarkerEvent marker = markers.get(i);
        if (marker.getTime() < fSelectionEnd && !fSkippedMarkerCategories.contains(marker.getCategory())) {
            setSelectionRangeNotify(fSelectionBegin, marker.getTime(), true);
            fTimeGraphCtrl.updateStatusLine();
            return;
        }
    }
}
Also used : IMarkerEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent) Point(org.eclipse.swt.graphics.Point)

Aggregations

IMarkerEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEvent)30 MarkerEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.MarkerEvent)15 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)10 Point (org.eclipse.swt.graphics.Point)9 PeriodicMarkerEventSource (org.eclipse.tracecompass.tmf.ui.markers.PeriodicMarkerEventSource)9 IMarkerEventSource (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.IMarkerEventSource)9 Test (org.junit.Test)9 ArrayList (java.util.ArrayList)6 RGBA (org.eclipse.swt.graphics.RGBA)5 NonNull (org.eclipse.jdt.annotation.NonNull)4 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)3 IMarker (org.eclipse.core.resources.IMarker)2 CoreException (org.eclipse.core.runtime.CoreException)2 Action (org.eclipse.jface.action.Action)2 IAction (org.eclipse.jface.action.IAction)2 PaintEvent (org.eclipse.swt.events.PaintEvent)2 Rectangle (org.eclipse.swt.graphics.Rectangle)2 ILinkEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Collection (java.util.Collection)1