Search in sources :

Example 1 with TmfTraceContext

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

the class TmfStatisticsViewer method traceRangeUpdated.

// ------------------------------------------------------------------------
// Signal handlers
// ------------------------------------------------------------------------
/**
 * Handles the signal about new trace range.
 *
 * @param signal
 *            The trace range updated signal
 */
@TmfSignalHandler
public void traceRangeUpdated(TmfTraceRangeUpdatedSignal signal) {
    ITmfTrace trace = signal.getTrace();
    // validate
    if (!isListeningTo(trace)) {
        return;
    }
    synchronized (fStatisticsRangeUpdateSyncObj) {
        // Sends the time range request only once from this method.
        if (fSendRangeRequest) {
            fSendRangeRequest = false;
            TmfTraceContext ctx = TmfTraceManager.getInstance().getCurrentTraceContext();
            TmfTimeRange timeRange = ctx.getSelectionRange();
            requestTimeRangeData(trace, timeRange);
        }
    }
    requestData(trace, signal.getRange());
}
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) TmfSignalHandler(org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler)

Example 2 with TmfTraceContext

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

the class TmfTimeViewer method loadTrace.

// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
/**
 * A Method to load a trace into the viewer.
 *
 * @param trace
 *            A trace to apply in the viewer
 */
public void loadTrace(ITmfTrace trace) {
    fTrace = trace;
    if (trace == null) {
        return;
    }
    TmfTraceContext ctx = TmfTraceManager.getInstance().getTraceContext(trace);
    long selectionStart = ctx.getSelectionRange().getStartTime().toNanos();
    long selectionEnd = ctx.getSelectionRange().getEndTime().toNanos();
    TmfTimeRange windowRange = ctx.getWindowRange();
    long windowStartTime = windowRange.getStartTime().toNanos();
    long windowEndTime = windowRange.getEndTime().toNanos();
    long startTime = fTrace.getStartTime().toNanos();
    long endTime = fTrace.getEndTime().toNanos();
    setSelectionRange(selectionStart, selectionEnd);
    setStartTime(startTime);
    setWindowRange(windowStartTime, windowEndTime);
    setEndTime(endTime);
}
Also used : TmfTraceContext(org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext) TmfTimeRange(org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange)

Example 3 with TmfTraceContext

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

the class AbstractSelectTreeViewer2 method contentChanged.

/**
 * Select previously checked entries when going back to trace.
 */
@Override
protected void contentChanged(ITmfTreeViewerEntry rootEntry) {
    try (FlowScopeLog refreshTree = new FlowScopeLogBuilder(LOGGER, Level.FINE, getClass().getSimpleName() + "#contentChanged()").setCategory("contentChanged").build()) {
        // $NON-NLS-1$ //$NON-NLS-2$
        ITmfTrace trace = getTrace();
        if (trace == null) {
            return;
        }
        TmfTraceContext ctx = TmfTraceManager.getInstance().getTraceContext(trace);
        Set<Long> ids = (Set<Long>) ctx.getData(getDataContextId(CHECKED_ELEMENTS));
        if (ids != null && rootEntry != null) {
            List<ITmfTreeViewerEntry> checkedElements = new ArrayList<>();
            checkEntries(ids, rootEntry, checkedElements);
            internalSetCheckedElements(checkedElements.toArray());
        }
        Object filterString = ctx.getData(getDataContextId(FILTER_STRING));
        if (filterString instanceof String) {
            fCheckboxTree.setFilterText((String) filterString);
        } else {
            // $NON-NLS-1$
            fCheckboxTree.setFilterText("");
        }
        refreshTree(refreshTree);
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceContext(org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext) Set(java.util.Set) HashSet(java.util.HashSet) ArrayList(java.util.ArrayList) FlowScopeLog(org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLog) FlowScopeLogBuilder(org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLogBuilder)

Example 4 with TmfTraceContext

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

the class AbstractSelectTreeViewer2 method restorePatternFilter.

private void restorePatternFilter(ITmfTrace trace) {
    if (trace == null) {
        fCheckboxTree.getPatternFilter().setPattern(null);
        return;
    }
    TmfTraceContext ctx = TmfTraceManager.getInstance().getTraceContext(trace);
    Object filterString = ctx.getData(getDataContextId(FILTER_STRING));
    if (filterString instanceof String) {
        fCheckboxTree.getPatternFilter().setPattern((String) filterString);
    } else {
        fCheckboxTree.getPatternFilter().setPattern(null);
    }
}
Also used : TmfTraceContext(org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext)

Example 5 with TmfTraceContext

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

the class AbstractTimeGraphView method refresh.

/**
 * Refresh the display
 */
protected void refresh() {
    try (FlowScopeLog parentLogger = new FlowScopeLogBuilder(LOGGER, Level.FINE, "RefreshRequested").setCategory(getViewId()).build()) {
        // $NON-NLS-1$
        final boolean isZoomThread = Thread.currentThread() instanceof ZoomThread;
        TmfUiRefreshHandler.getInstance().queueUpdate(this, () -> {
            try (FlowScopeLog log = new FlowScopeLogBuilder(LOGGER, Level.FINE, "TimeGraphView:Refresh").setParentScope(parentLogger).build()) {
                // $NON-NLS-1$
                if (fTimeGraphViewer.getControl().isDisposed()) {
                    return;
                }
                fDirty.incrementAndGet();
                try {
                    synchronized (fEntryListMap) {
                        fEntryList = fEntryListMap.get(fTrace);
                        if (fEntryList == null) {
                            fEntryList = new CopyOnWriteArrayList<>();
                        } else if (fEntryComparator != null) {
                            List<TimeGraphEntry> list = new ArrayList<>(fEntryList);
                            Collections.sort(list, fEntryComparator);
                            for (ITimeGraphEntry entry : list) {
                                sortChildren(entry, fEntryComparator);
                            }
                            fEntryList.clear();
                            fEntryList.addAll(list);
                        }
                    }
                    boolean inputChanged = fEntryList != fTimeGraphViewer.getInput();
                    if (inputChanged) {
                        fTimeGraphViewer.setInput(fEntryList);
                        /*
                             * restore the previously saved filters, if any
                             */
                        fTimeGraphViewer.setFilters(fFiltersMap.get(fTrace));
                        fTimeGraphViewer.setLinks(null);
                        fTimeGraphViewer.setBookmarks(refreshBookmarks(fEditorFile));
                        fTimeGraphViewer.setMarkerCategories(getMarkerCategories());
                        fTimeGraphViewer.setMarkers(null);
                        applyViewContext();
                    } else {
                        fTimeGraphViewer.refresh();
                    }
                    // reveal selection
                    if (fIsRevealSelection) {
                        fIsRevealSelection = false;
                        fTimeGraphViewer.setSelection(fTimeGraphViewer.getSelection(), true);
                    }
                    long startBound = (fStartTime == Long.MAX_VALUE ? SWT.DEFAULT : fStartTime);
                    long endBound = (fEndTime == Long.MIN_VALUE ? SWT.DEFAULT : fEndTime);
                    fTimeGraphViewer.setTimeBounds(startBound, endBound);
                    ITmfTrace trace = fTrace;
                    TmfTraceContext ctx = (trace == null) ? null : TmfTraceManager.getInstance().getTraceContext(trace);
                    long selectionBeginTime = ctx == null ? SWT.DEFAULT : ctx.getSelectionRange().getStartTime().toNanos();
                    long selectionEndTime = ctx == null ? SWT.DEFAULT : ctx.getSelectionRange().getEndTime().toNanos();
                    long startTime = ctx == null ? SWT.DEFAULT : ctx.getWindowRange().getStartTime().toNanos();
                    long endTime = ctx == null ? SWT.DEFAULT : ctx.getWindowRange().getEndTime().toNanos();
                    if (fStartTime > fEndTime) {
                        startTime = SWT.DEFAULT;
                        endTime = SWT.DEFAULT;
                    } else {
                        startTime = Math.min(Math.max(startTime, fStartTime), fEndTime);
                        endTime = Math.min(Math.max(endTime, fStartTime), fEndTime);
                    }
                    fTimeGraphViewer.setSelectionRange(selectionBeginTime, selectionEndTime, false);
                    fTimeGraphViewer.setStartFinishTime(startTime, endTime);
                    if (inputChanged && selectionBeginTime != SWT.DEFAULT) {
                        synchingToTime(selectionBeginTime);
                    }
                    ZoomThread zoomThread = fZoomThread;
                    if (!isZoomThread || (zoomThread != null && (zoomThread.getZoomStartTime() != startTime || zoomThread.getZoomEndTime() != endTime))) {
                        startZoomThread(startTime, endTime);
                    }
                } finally {
                    if (fDirty.decrementAndGet() < 0) {
                        Activator.getDefault().logError(DIRTY_UNDERFLOW_ERROR, new Throwable());
                    }
                }
            }
        });
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) TmfTraceContext(org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) FlowScopeLog(org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLog) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) ArrayList(java.util.ArrayList) List(java.util.List) FlowScopeLogBuilder(org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.FlowScopeLogBuilder)

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