Search in sources :

Example 1 with NamedTimeEvent

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

the class ResourcesView method fillTimeEventContextMenu.

@Override
protected void fillTimeEventContextMenu(@NonNull IMenuManager menuManager) {
    ISelection selection = getSite().getSelectionProvider().getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection sSel = (IStructuredSelection) selection;
        if (sSel.getFirstElement() instanceof TimeGraphEntry) {
            TimeGraphEntry resourcesEntry = (TimeGraphEntry) sSel.getFirstElement();
            ITmfTreeDataModel model = resourcesEntry.getEntryModel();
            if (sSel.toArray()[1] instanceof NamedTimeEvent && ((ResourcesEntryModel) model).getType() == Type.CURRENT_THREAD) {
                ITmfTrace trace = getTrace(resourcesEntry);
                NamedTimeEvent event = (NamedTimeEvent) sSel.toArray()[1];
                TmfTraceContext ctx = TmfTraceManager.getInstance().getCurrentTraceContext();
                HostThread data = (HostThread) ctx.getData(HostThread.SELECTED_HOST_THREAD_KEY);
                if (data != null) {
                    menuManager.add(new UnfollowThreadAction(ResourcesView.this));
                } else {
                    menuManager.add(new FollowThreadAction(ResourcesView.this, null, event.getValue(), trace));
                }
            }
        }
    }
    super.fillTimeEventContextMenu(menuManager);
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) HostThread(org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) TmfTraceContext(org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext) FollowThreadAction(org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions.FollowThreadAction) ISelection(org.eclipse.jface.viewers.ISelection) UnfollowThreadAction(org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions.UnfollowThreadAction) ResourcesEntryModel(org.eclipse.tracecompass.internal.analysis.os.linux.core.resourcesstatus.ResourcesEntryModel) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) NamedTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NamedTimeEvent)

Example 2 with NamedTimeEvent

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

the class FlameChartView method createPartControl.

// ------------------------------------------------------------------------
// ViewPart
// ------------------------------------------------------------------------
@Override
public void createPartControl(@Nullable Composite parent) {
    super.createPartControl(parent);
    getTimeGraphViewer().addTimeListener(event -> synchingToTime(event.getBeginTime()));
    getTimeGraphViewer().getTimeGraphControl().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(@Nullable MouseEvent event) {
            ITimeGraphEntry selection = getTimeGraphViewer().getSelection();
            if (!(selection instanceof TimeGraphEntry)) {
                // also null checks
                return;
            }
            ITimeGraphState function = fFunctions.get(((TimeGraphEntry) selection).getEntryModel().getId());
            if (function != null) {
                long entryTime = function.getStartTime();
                long exitTime = entryTime + function.getDuration();
                TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromNanos(entryTime), TmfTimestamp.fromNanos(exitTime));
                broadcast(new TmfWindowRangeUpdatedSignal(FlameChartView.this, range, getTrace()));
                getTimeGraphViewer().setStartFinishTime(entryTime, exitTime);
                startZoomThread(entryTime, exitTime);
            }
        }
    });
    getTimeGraphViewer().getTimeGraphControl().addMouseListener(new MouseAdapter() {

        @Override
        public void mouseDoubleClick(@Nullable MouseEvent e) {
            TimeGraphControl timeGraphControl = getTimeGraphViewer().getTimeGraphControl();
            ISelection selection = timeGraphControl.getSelection();
            if (selection instanceof IStructuredSelection) {
                for (Object object : ((IStructuredSelection) selection).toList()) {
                    if (object instanceof NamedTimeEvent) {
                        NamedTimeEvent event = (NamedTimeEvent) object;
                        long startTime = event.getTime();
                        long endTime = startTime + event.getDuration();
                        TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromNanos(startTime), TmfTimestamp.fromNanos(endTime));
                        broadcast(new TmfWindowRangeUpdatedSignal(FlameChartView.this, range, getTrace()));
                        getTimeGraphViewer().setStartFinishTime(startTime, endTime);
                        startZoomThread(startTime, endTime);
                        break;
                    }
                }
            }
        }
    });
    IEditorPart editor = getSite().getPage().getActiveEditor();
    if (editor instanceof ITmfTraceEditor) {
        ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
        if (trace != null) {
            traceSelected(new TmfTraceSelectedSignal(this, trace));
        }
    }
}
Also used : MouseEvent(org.eclipse.swt.events.MouseEvent) MouseAdapter(org.eclipse.swt.events.MouseAdapter) TmfWindowRangeUpdatedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) IEditorPart(org.eclipse.ui.IEditorPart) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange) ITimeGraphState(org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphState) NamedTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NamedTimeEvent) ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) ISelection(org.eclipse.jface.viewers.ISelection) TmfTraceSelectedSignal(org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal) TimeGraphControl(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl) ITmfTraceEditor(org.eclipse.tracecompass.tmf.ui.editors.ITmfTraceEditor)

Aggregations

ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)2 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)2 NamedTimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NamedTimeEvent)2 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)2 MouseAdapter (org.eclipse.swt.events.MouseAdapter)1 MouseEvent (org.eclipse.swt.events.MouseEvent)1 HostThread (org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread)1 ResourcesEntryModel (org.eclipse.tracecompass.internal.analysis.os.linux.core.resourcesstatus.ResourcesEntryModel)1 FollowThreadAction (org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions.FollowThreadAction)1 UnfollowThreadAction (org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions.UnfollowThreadAction)1 ITimeGraphState (org.eclipse.tracecompass.tmf.core.model.timegraph.ITimeGraphState)1 ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)1 TmfTraceSelectedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal)1 TmfWindowRangeUpdatedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfWindowRangeUpdatedSignal)1 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)1 TmfTraceContext (org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext)1 ITmfTraceEditor (org.eclipse.tracecompass.tmf.ui.editors.ITmfTraceEditor)1 TimeGraphControl (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl)1