Search in sources :

Example 16 with TmfTraceContext

use of org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext in project tracecompass by tracecompass.

the class AbstractTimeGraphView method isDirty.

/**
 * Returns whether or not the time graph view is dirty. The time graph view is
 * considered dirty if it has yet to completely update its model.
 *
 * This method is meant to be used by tests in order to know when it is safe to
 * proceed.
 *
 * Note: If a trace is smaller than the initial window range (see
 * {@link ITmfTrace#getInitialRangeOffset}) this method will return true
 * forever.
 *
 * @return true if the time graph view has yet to completely update its model,
 *         false otherwise
 * @since 2.0
 */
public boolean isDirty() {
    if (fTrace == null) {
        return false;
    }
    TmfTraceContext ctx = TmfTraceManager.getInstance().getCurrentTraceContext();
    long startTime = ctx.getWindowRange().getStartTime().toNanos();
    long endTime = ctx.getWindowRange().getEndTime().toNanos();
    // the window range then it's dirty. A refresh should happen later.
    if (fTimeGraphViewer.getTime0() != startTime || fTimeGraphViewer.getTime1() != endTime) {
        return true;
    }
    if (fZoomThread == null) {
        // (refresh called).
        return fDirty.get() != 0;
    }
    // be a subsequent zoom thread that will be triggered.
    return fDirty.get() != 0 || fZoomThread.getZoomStartTime() != startTime || fZoomThread.getZoomEndTime() != endTime;
}
Also used : TmfTraceContext(org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext)

Example 17 with TmfTraceContext

use of org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext in project tracecompass by tracecompass.

the class AbstractTimeGraphView method windowRangeUpdated.

/**
 * Handler for the window range signal.
 *
 * @param signal
 *            The signal that's received
 * @since 1.0
 */
@TmfSignalHandler
public void windowRangeUpdated(final TmfWindowRangeUpdatedSignal signal) {
    if (signal.getSource() == this || fTrace == null) {
        return;
    }
    TmfTraceContext ctx = TmfTraceManager.getInstance().getTraceContext(checkNotNull(fTrace));
    final long startTime = ctx.getWindowRange().getStartTime().toNanos();
    final long endTime = ctx.getWindowRange().getEndTime().toNanos();
    Display.getDefault().asyncExec(() -> {
        if (fTimeGraphViewer.getControl().isDisposed()) {
            return;
        }
        if (startTime == fTimeGraphViewer.getTime0() && endTime == fTimeGraphViewer.getTime1()) {
            return;
        }
        fTimeGraphViewer.setStartFinishTime(startTime, endTime);
        startZoomThread(startTime, endTime);
    });
}
Also used : TmfTraceContext(org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 18 with TmfTraceContext

use of org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext in project tracecompass by tracecompass.

the class HistogramView method initializeHistograms.

// ------------------------------------------------------------------------
// Helper functions
// ------------------------------------------------------------------------
private void initializeHistograms() {
    TmfTimeRange fullRange = updateTraceTimeRange();
    TmfTraceContext ctx = TmfTraceManager.getInstance().getCurrentTraceContext();
    long selectionBeginTime = ctx.getSelectionRange().getStartTime().toNanos();
    long selectionEndTime = ctx.getSelectionRange().getEndTime().toNanos();
    long startTime = ctx.getWindowRange().getStartTime().toNanos();
    long duration = ctx.getWindowRange().getEndTime().toNanos() - startTime;
    if ((fTimeRangeRequest != null) && !fTimeRangeRequest.isCompleted()) {
        fTimeRangeRequest.cancel();
    }
    fTimeRangeHistogram.clear();
    fTimeRangeHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
    fTimeRangeHistogram.setTimeRange(startTime, duration);
    fTimeRangeHistogram.setSelection(selectionBeginTime, selectionEndTime);
    fTimeRangeHistogram.fDataModel.setTrace(fTrace);
    if ((fFullTraceRequest != null) && !fFullTraceRequest.isCompleted()) {
        fFullTraceRequest.cancel();
    }
    fFullTraceHistogram.clear();
    fFullTraceHistogram.setFullRange(fTraceStartTime, fTraceEndTime);
    fFullTraceHistogram.setTimeRange(startTime, duration);
    fFullTraceHistogram.setSelection(selectionBeginTime, selectionEndTime);
    fFullTraceHistogram.fDataModel.setTrace(fTrace);
    fWindowStartTime = startTime;
    fWindowSpan = duration;
    fWindowEndTime = startTime + duration;
    fSelectionBeginTime = selectionBeginTime;
    fSelectionEndTime = selectionEndTime;
    fSelectionStartControl.setValue(fSelectionBeginTime);
    fSelectionEndControl.setValue(fSelectionEndTime);
    // make sure that the scrollbar is setup properly
    fScrollComposite.setMinSize(fTimeControlsComposite.computeSize(SWT.DEFAULT, SWT.DEFAULT));
    fTimeSpanControl.setValue(duration);
    Collection<ITmfTrace> traces = TmfTraceManager.getTraceSet(fTrace);
    if (!traces.isEmpty()) {
        this.showTraceAction.setEnabled(traces.size() < fFullTraceHistogram.getMaxNbTraces());
    }
    updateLegendArea();
    if (!fullRange.equals(TmfTimeRange.NULL_RANGE)) {
        sendTimeRangeRequest(startTime, startTime + duration);
        sendFullRangeRequest(fullRange);
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceContext(org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)

Example 19 with TmfTraceContext

use of org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext in project tracecompass by tracecompass.

the class AbstractTimeGraphView method selectionRangeUpdated.

/**
 * Handler for the selection range signal.
 *
 * @param signal
 *            The signal that's received
 * @since 1.0
 */
@TmfSignalHandler
public void selectionRangeUpdated(final TmfSelectionRangeUpdatedSignal signal) {
    final ITmfTrace trace = fTrace;
    if (signal.getSource() == this || trace == null) {
        return;
    }
    ITmfTrace signalTrace = signal.getTrace();
    if (signalTrace != null && !TmfTraceManager.getInstance().isSynchronized(trace, signalTrace)) {
        return;
    }
    TmfTraceContext ctx = TmfTraceManager.getInstance().getTraceContext(trace);
    long beginTime = ctx.getSelectionRange().getStartTime().toNanos();
    long endTime = ctx.getSelectionRange().getEndTime().toNanos();
    Display.getDefault().asyncExec(() -> {
        if (fTimeGraphViewer.getControl().isDisposed()) {
            return;
        }
        if (beginTime == endTime) {
            fTimeGraphViewer.setSelectedTime(beginTime, true);
        } else {
            fTimeGraphViewer.setSelectionRange(beginTime, endTime, true);
        }
        synchingToTime(fTimeGraphViewer.getSelectionBegin());
    });
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceContext(org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Aggregations

TmfTraceContext (org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext)19 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)11 TmfSignalHandler (org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)7 TmfTimeRange (org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)6 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)3 ArrayList (java.util.ArrayList)2 ISelection (org.eclipse.jface.viewers.ISelection)2 IStructuredSelection (org.eclipse.jface.viewers.IStructuredSelection)2 FlowScopeLog (org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLog)2 FlowScopeLogBuilder (org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLogBuilder)2 ResourcesEntryModel (org.eclipse.tracecompass.internal.analysis.os.linux.core.resourcesstatus.ResourcesEntryModel)2 ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)2 ITmfTimestamp (org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp)2 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1