use of org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.ScopeLog in project tracecompass by tracecompass.
the class StateSystem method queryFullState.
// --------------------------------------------------------------------------
// Regular query methods (sent to the back-end)
// --------------------------------------------------------------------------
@Override
public List<ITmfStateInterval> queryFullState(long t) throws TimeRangeException, StateSystemDisposedException {
if (isDisposed) {
throw new StateSystemDisposedException();
}
try (ScopeLog log = new // $NON-NLS-1$
ScopeLog(// $NON-NLS-1$
LOGGER, // $NON-NLS-1$
Level.FINER, // $NON-NLS-1$
"StateSystem:FullQuery", "ssid", getSSID(), "ts", t)) {
// $NON-NLS-1$ //$NON-NLS-2$
final int nbAttr = getNbAttributes();
List<@Nullable ITmfStateInterval> stateInfo = new ArrayList<>(nbAttr);
/*
* Bring the size of the array to the current number of attributes
*/
for (int i = 0; i < nbAttr; i++) {
stateInfo.add(null);
}
/*
* If we are currently building the history, also query the
* "ongoing" states for stuff that might not yet be written to the
* history.
*/
if (transState.isActive()) {
transState.doQuery(stateInfo, t);
}
/* Query the storage backend */
backend.doQuery(stateInfo, t);
/*
* We should have previously inserted an interval for every
* attribute.
*/
for (ITmfStateInterval interval : stateInfo) {
if (interval == null) {
// $NON-NLS-1$
throw new IllegalStateException("Incoherent interval storage");
}
}
return stateInfo;
}
}
use of org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.ScopeLog in project tracecompass by tracecompass.
the class TmfOpenTraceHelper method openTraceFromPath.
/**
* Opens a trace from a path while importing it to the destination folder.
* The trace is linked as a resource.
*
* @param destinationFolder
* The destination trace folder
* @param path
* the file to import
* @param shell
* the shell to use for dialogs
* @param tracetypeHint
* The trace type id, can be null
* @return IStatus OK if successful. In addition to the OK status, a code OK
* means the trace will be opened correctly, otherwise, a code of
* {@link IStatus#INFO} means the operation completely successfully,
* but the path won't be opened as a trace.
* @throws CoreException
* core exceptions if something is not well set up in the back
* end
*/
public static IStatus openTraceFromPath(TmfTraceFolder destinationFolder, String path, Shell shell, String tracetypeHint) throws CoreException {
final String pathToUse = checkTracePath(path);
TraceTypeHelper traceTypeToSet = null;
try (ScopeLog scopeLog = new ScopeLog(LOGGER, Level.FINE, "TmfOpenTraceHelper#openTraceFromPath", "Get trace type")) {
// $NON-NLS-1$//$NON-NLS-2$
traceTypeToSet = TmfTraceTypeUIUtils.selectTraceType(pathToUse, null, tracetypeHint);
} catch (TmfTraceImportException e) {
TraceUtils.displayErrorMsg(e);
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, e.getMessage());
}
IFolder folder = destinationFolder.getResource();
String traceName = getTraceName(pathToUse, folder);
if (traceExists(pathToUse, folder)) {
return openTraceFromFolder(destinationFolder, traceName);
}
final IPath pathString = Path.fromOSString(pathToUse);
IResource linkedTrace = TmfImportHelper.createLink(folder, pathString, traceName);
if (linkedTrace == null || !linkedTrace.exists()) {
return new Status(IStatus.ERROR, Activator.PLUGIN_ID, Messages.TmfOpenTraceHelper_LinkFailed);
}
String sourceLocation = URIUtil.toUnencodedString(pathString.toFile().toURI());
linkedTrace.setPersistentProperty(TmfCommonConstants.SOURCE_LOCATION, sourceLocation);
// No trace type was determined.
if (traceTypeToSet == null) {
return new Status(IStatus.OK, Activator.PLUGIN_ID, IStatus.INFO, Messages.TmfOpenTraceHelper_NoTraceType, null);
}
IStatus ret = TmfTraceTypeUIUtils.setTraceType(linkedTrace, traceTypeToSet);
if (ret.isOK()) {
ret = openTraceFromFolder(destinationFolder, traceName);
}
return ret;
}
use of org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.ScopeLog in project tracecompass by tracecompass.
the class AbstractTmfTreeViewer method refresh.
@Override
public void refresh() {
try (ScopeLog refreshTree = new ScopeLog(LOGGER, Level.FINE, getClass().getCanonicalName() + "#refresh()")) {
Tree tree = fTreeViewer.getTree();
tree.setRedraw(false);
fTreeViewer.refresh();
tree.setRedraw(true);
}
}
use of org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.ScopeLog in project tracecompass by tracecompass.
the class AbstractSegmentStoreTableViewer method setData.
/**
* Set the data into the viewer. It will update the model. If the provider
* is an analysis, the analysis will be scheduled.
*
* @param provider
* segment store provider
*/
public synchronized void setData(@Nullable ISegmentStoreProvider provider) {
// Set the current segment store provider
fSegmentProvider = provider;
if (provider == null) {
updateModel(null);
return;
}
createProviderColumns();
/*
* If the listener is null then the table is updated from another viewer.
* Otherwise this class is responsible to load the trace.
*/
SegmentStoreProviderProgressListener listener = fListener;
if (listener == null) {
return;
}
ISegmentStore<ISegment> segStore = provider.getSegmentStore();
// If results are not null, then the segment of the provider is ready
// and model can be updated
// FIXME Filtering should be done at the data provider level
Map<@NonNull Integer, @NonNull Predicate<@NonNull Multimap<@NonNull String, @NonNull Object>>> predicates = generateRegexPredicate();
Predicate<ISegment> predicate = (segment) -> {
// Get the filter external input data
Multimap<@NonNull String, @NonNull Object> input = ISegmentStoreProvider.getFilterInput(provider, segment);
/*
* Test each predicates and set the status of the property
* associated to the predicate
*/
boolean activateProperty = false;
for (Map.Entry<Integer, Predicate<Multimap<String, Object>>> mapEntry : predicates.entrySet()) {
Integer property = Objects.requireNonNull(mapEntry.getKey());
Predicate<Multimap<String, Object>> value = Objects.requireNonNull(mapEntry.getValue());
if (property == CoreFilterProperty.DIMMED || property == CoreFilterProperty.EXCLUDE) {
boolean status = value.test(input);
activateProperty |= status;
}
}
return activateProperty;
};
if (segStore != null) {
// Cancel the current filtering job
Job job = fFilteringJob;
if (job != null) {
job.cancel();
}
if (predicates.isEmpty()) {
updateModel(segStore);
return;
}
job = new Job(Messages.SegmentStoreTableViewer_FilteringData) {
@Override
protected IStatus run(@Nullable IProgressMonitor monitor) {
try (ScopeLog log = new ScopeLog(LOGGER, Level.FINE, "SegmentStoreTable:Filtering")) {
// $NON-NLS-1$
SubMonitor subMonitor = SubMonitor.convert(monitor);
ISegmentStore<ISegment> filteredStore = new ArrayListStore<>();
for (ISegment segment : segStore) {
if (subMonitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
if (predicate.test(segment)) {
filteredStore.add(segment);
}
}
if (subMonitor.isCanceled()) {
return Status.CANCEL_STATUS;
}
updateModel(filteredStore);
return Status.OK_STATUS;
}
}
};
fFilteringJob = job;
job.schedule();
return;
}
// If results are null, then add completion listener and if the provider
// is an analysis, run the analysis
updateModel(null);
provider.addListener(listener);
if (provider instanceof IAnalysisModule) {
((IAnalysisModule) provider).schedule();
}
}
use of org.eclipse.tracecompass.common.core.log.TraceCompassLogUtils.ScopeLog in project tracecompass by tracecompass.
the class TimeGraphControl method paint.
@Override
void paint(Rectangle bounds, PaintEvent e) {
try (ScopeLog sl = new ScopeLog(LOGGER, Level.FINE, fPaintScopeLabel)) {
GC gc = e.gc;
fPostDrawEntries.clear();
fPostDrawArrows.clear();
fLines.clear();
fPoints.clear();
fSelectedRectangles.clear();
if (bounds.width < 2 || bounds.height < 2 || null == fTimeProvider) {
return;
}
fIdealNameSpace = 0;
int nameSpace = fTimeProvider.getNameSpace();
try (ScopeLog bgScope = new ScopeLog(LOGGER, Level.FINEST, fBackgroundScopeLabel)) {
// draw the background layer
drawBackground(bounds, nameSpace, gc);
}
try (ScopeLog glScope = new ScopeLog(LOGGER, Level.FINEST, fGridLinesScopeLabel)) {
// draw the grid lines
drawGridLines(bounds, gc);
}
try (ScopeLog bgmScope = new ScopeLog(LOGGER, Level.FINEST, fBgmScopeLabel)) {
// draw the background markers
drawMarkers(bounds, fTimeProvider, fMarkers, false, nameSpace, gc);
}
try (ScopeLog itemsScope = new ScopeLog(LOGGER, Level.FINEST, fItemsScopeLabel)) {
// draw the items
drawItems(bounds, fTimeProvider, fItemData.fExpandedItems, fTopIndex, nameSpace, gc);
}
try (ScopeLog markerScope = new ScopeLog(LOGGER, Level.FINEST, fMarkersScopeLabel)) {
// draw the foreground markers
drawMarkers(bounds, fTimeProvider, fMarkers, true, nameSpace, gc);
}
try (ScopeLog linksScope = new ScopeLog(LOGGER, Level.FINEST, fLinksScopeLabel)) {
// draw the links (arrows)
drawLinks(bounds, fTimeProvider, fItemData.fLinks, nameSpace, gc);
}
gc.setAlpha(OPAQUE * 2 / 5);
long time0 = fTimeProvider.getTime0();
long time1 = fTimeProvider.getTime1();
long selectionBegin = fTimeProvider.getSelectionBegin();
long selectionEnd = fTimeProvider.getSelectionEnd();
double pixelsPerNanoSec = (bounds.width - nameSpace <= RIGHT_MARGIN) ? 0 : (double) (bounds.width - nameSpace - RIGHT_MARGIN) / (time1 - time0);
int x0 = SaturatedArithmetic.add(bounds.x + nameSpace, (int) ((selectionBegin - time0) * pixelsPerNanoSec));
int x1 = SaturatedArithmetic.add(bounds.x + nameSpace, (int) ((selectionEnd - time0) * pixelsPerNanoSec));
// draw selection lines
if (fDragState != DRAG_SELECTION) {
gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.SELECTED_TIME));
if (x0 >= nameSpace && x0 < bounds.x + bounds.width) {
gc.drawLine(x0, bounds.y, x0, bounds.y + bounds.height);
}
if (x1 != x0) {
if (x1 >= nameSpace && x1 < bounds.x + bounds.width) {
gc.drawLine(x1, bounds.y, x1, bounds.y + bounds.height);
}
}
}
// draw selection background
if (selectionBegin != 0 && selectionEnd != 0 && fDragState != DRAG_SELECTION) {
x0 = Math.max(nameSpace, Math.min(bounds.x + bounds.width, x0));
x1 = Math.max(nameSpace, Math.min(bounds.x + bounds.width, x1));
gc.setBackground(getColorScheme().getBkColor(false, false, true));
if (x1 - x0 > 1) {
gc.fillRectangle(new Rectangle(x0 + 1, bounds.y, x1 - x0 - 1, bounds.height));
} else if (x0 - x1 > 1) {
gc.fillRectangle(new Rectangle(x1 + 1, bounds.y, x0 - x1 - 1, bounds.height));
}
}
// draw drag selection background
if (fDragState == DRAG_ZOOM || fDragState == DRAG_SELECTION) {
gc.setBackground(getColorScheme().getBkColor(false, false, true));
if (fDragX0 < fDragX) {
gc.fillRectangle(new Rectangle(fDragX0, bounds.y, fDragX - fDragX0, bounds.height));
} else if (fDragX0 > fDragX) {
gc.fillRectangle(new Rectangle(fDragX, bounds.y, fDragX0 - fDragX, bounds.height));
}
}
// draw split line
if (DRAG_SPLIT_LINE == fDragState || (DRAG_NONE == fDragState && fMouseOverSplitLine && fTimeProvider.getNameSpace() > 0)) {
gc.setBackground(getColorScheme().getColor(TimeGraphColorScheme.DARK_GRAY));
} else {
gc.setBackground(getColorScheme().getColor(TimeGraphColorScheme.GRAY));
}
gc.fillRectangle(bounds.x + nameSpace - SNAP_WIDTH, bounds.y, SNAP_WIDTH, bounds.height);
if (DRAG_ZOOM == fDragState && Math.max(fDragX, fDragX0) > nameSpace) {
gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.TOOL_FOREGROUND));
gc.drawLine(fDragX0, bounds.y, fDragX0, bounds.y + bounds.height - 1);
if (fDragX != fDragX0) {
gc.drawLine(fDragX, bounds.y, fDragX, bounds.y + bounds.height - 1);
}
} else if (DRAG_SELECTION == fDragState && Math.max(fDragX, fDragX0) > nameSpace) {
gc.setForeground(getColorScheme().getColor(TimeGraphColorScheme.SELECTED_TIME));
gc.drawLine(fDragX0, bounds.y, fDragX0, bounds.y + bounds.height - 1);
if (fDragX != fDragX0) {
gc.drawLine(fDragX, bounds.y, fDragX, bounds.y + bounds.height - 1);
}
}
gc.setAlpha(OPAQUE);
for (PostDrawEvent postDrawEvent : fPostDrawArrows) {
postDrawEvent.draw(fTimeGraphProvider, gc);
}
fPostDrawEntries.clear();
fPostDrawArrows.clear();
fTimeGraphProvider.postDrawControl(bounds, gc);
}
}
Aggregations