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());
}
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);
}
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);
}
}
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);
}
}
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());
}
}
}
});
}
}
Aggregations