use of org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel in project tracecompass by tracecompass.
the class ResourcesView method fillTimeGraphEntryContextMenu.
/**
* @since 2.0
*/
@Override
protected void fillTimeGraphEntryContextMenu(@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 (model instanceof ResourcesEntryModel) {
ResourcesEntryModel resourcesModel = (ResourcesEntryModel) model;
Type type = resourcesModel.getType();
if (type == Type.CPU || type == Type.CURRENT_THREAD) {
ITmfTrace trace = getTrace(resourcesEntry);
TmfTraceContext ctx = TmfTraceManager.getInstance().getTraceContext(trace);
Integer data = (Integer) ctx.getData(RESOURCES_FOLLOW_CPU);
int cpu = data != null ? data.intValue() : -1;
if (cpu >= 0) {
menuManager.add(new UnfollowCpuAction(ResourcesView.this, resourcesModel.getResourceId(), trace));
} else {
menuManager.add(new FollowCpuAction(ResourcesView.this, resourcesModel.getResourceId(), trace));
}
}
}
}
}
}
use of org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel in project tracecompass by tracecompass.
the class XmlXYDataProvider method fetchTree.
/**
* @since 2.4
*/
@Override
public TmfModelResponse<TmfTreeModel<ITmfTreeDataModel>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
fLock.readLock().lock();
try {
if (fCached != null) {
return fCached;
}
} finally {
fLock.readLock().unlock();
}
ITmfStateSystem ss = fXmlEntry.getStateSystem();
DataDrivenStateSystemPath seriesNameAttrib = fSeriesNameAttrib;
boolean isComplete = ss.waitUntilBuilt(0);
// Get the quarks before the full states to ensure that the attributes will be present in the full state
List<Integer> quarks = fXmlEntry.getQuarks();
fLock.writeLock().lock();
try {
List<ITmfStateInterval> fullState = ss.queryFullState(ss.getCurrentEndTime());
ImmutableList.Builder<ITmfTreeDataModel> builder = ImmutableList.builder();
builder.add(new TmfTreeDataModel(fTraceId, -1, Collections.singletonList(getTrace().getName())));
for (int quark : quarks) {
String seriesName = ss.getAttributeName(quark);
if (seriesNameAttrib != null) {
// Use the value of the series name attribute
int seriesNameQuark = seriesNameAttrib.getQuark(quark, fXmlEntry);
Object value = fullState.get(seriesNameQuark).getValue();
if (value != null) {
seriesName = String.valueOf(value);
}
}
if (!seriesName.isEmpty()) {
String tempSeriesName = seriesName;
String uniqueName = fQuarkToString.computeIfAbsent(quark, q -> getUniqueNameFor(tempSeriesName));
// Check if an ID has already been created for this quark.
Long id = fIdToQuark.inverse().computeIfAbsent(quark, q -> ENTRY_IDS.getAndIncrement());
builder.add(new TmfTreeDataModel(id, fTraceId, Collections.singletonList(uniqueName)));
}
}
ImmutableList<ITmfTreeDataModel> list = builder.build();
if (isComplete) {
TmfModelResponse<TmfTreeModel<ITmfTreeDataModel>> tmfModelResponse = new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), list), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
fCached = tmfModelResponse;
return tmfModelResponse;
}
return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), list), ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING);
} catch (StateSystemDisposedException e) {
return new TmfModelResponse<>(null, ITmfResponse.Status.FAILED, CommonStatusMessage.STATE_SYSTEM_FAILED);
} finally {
fLock.writeLock().unlock();
}
}
use of org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel in project tracecompass by tracecompass.
the class DataDrivenXYDataProvider method fetchTree.
@Override
public TmfModelResponse<TmfTreeModel<ITmfTreeDataModel>> fetchTree(Map<String, Object> fetchParameters, @Nullable IProgressMonitor monitor) {
fLock.readLock().lock();
try {
if (fCached != null) {
return fCached;
}
} finally {
fLock.readLock().unlock();
}
List<ITmfTreeDataModel> entryList = new ArrayList<>();
boolean isComplete = true;
String traceName = String.valueOf(getTrace().getName());
fLock.writeLock().lock();
try {
for (ITmfStateSystem ss : fSs) {
isComplete &= ss.waitUntilBuilt(0);
/* Don't query empty state system */
if (ss.getNbAttributes() > 0 && ss.getStartTime() != Long.MIN_VALUE) {
long start = ss.getStartTime();
long end = ss.getCurrentEndTime();
long id = fBaseQuarkToId.row(ss).computeIfAbsent(ITmfStateSystem.ROOT_ATTRIBUTE, s -> ENTRY_IDS.getAndIncrement());
TimeGraphEntryModel ssEntry = new TimeGraphEntryModel(id, -1, traceName, start, end);
entryList.add(ssEntry);
for (DataDrivenOutputEntry entry : fEntries) {
entryList.addAll(entry.buildEntries(ss, ssEntry.getId(), getTrace(), -1, StringUtils.EMPTY, end, fIdGenerator, fQuarkCallback));
}
}
}
fIdToTitle.clear();
entryList.forEach(e -> fIdToTitle.put(e.getId(), e.getName()));
if (isComplete) {
TmfModelResponse<TmfTreeModel<ITmfTreeDataModel>> tmfModelResponse = new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), entryList), ITmfResponse.Status.COMPLETED, CommonStatusMessage.COMPLETED);
fCached = tmfModelResponse;
return tmfModelResponse;
}
return new TmfModelResponse<>(new TmfTreeModel<>(Collections.emptyList(), entryList), ITmfResponse.Status.RUNNING, CommonStatusMessage.RUNNING);
} finally {
fLock.writeLock().unlock();
}
}
use of org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel in project tracecompass by tracecompass.
the class StateSystemPresentationProvider method getEventHoverToolTipInfo.
@Override
public Map<String, String> getEventHoverToolTipInfo(ITimeEvent event) {
Map<String, String> retMap = new LinkedHashMap<>();
if (event instanceof TimeEvent) {
ITimeGraphEntry entry = event.getEntry();
ITmfTreeDataModel model = ((TimeGraphEntry) entry).getEntryModel();
if (model instanceof StateSystemEntryModel) {
TimeGraphEntry moduleEntry = (TimeGraphEntry) entry.getParent();
ModuleEntryModel moduleModel = (ModuleEntryModel) moduleEntry.getEntryModel();
ITmfAnalysisModuleWithStateSystems module = (moduleModel).getModule();
if (module instanceof TmfAbstractAnalysisModule) {
retMap.putAll(((TmfAbstractAnalysisModule) module).getProperties());
}
} else if (model instanceof ModuleEntryModel) {
ITmfAnalysisModuleWithStateSystems module = ((ModuleEntryModel) model).getModule();
retMap.put(Messages.ModuleHelpText, module.getHelpText());
retMap.put(Messages.ModuleIsAutomatic, Boolean.toString(module.isAutomatic()));
}
}
return retMap;
}
use of org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel in project tracecompass by tracecompass.
the class TmfStateSystemExplorer method createPartControl.
@Override
public void createPartControl(Composite parent) {
super.createPartControl(parent);
getTimeGraphViewer().addTimeListener(event -> synchingToTime(event.getBeginTime()));
getTimeGraphViewer().getTimeGraphControl().addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(MouseEvent event) {
ITimeGraphEntry selection = getTimeGraphViewer().getSelection();
if (selection instanceof TimeGraphEntry) {
ITmfTreeDataModel model = ((TimeGraphEntry) selection).getEntryModel();
if (model instanceof ModuleEntryModel && selection.getChildren().isEmpty()) {
/**
* Schedule the analysis if it has not run yet.
*/
ITmfAnalysisModuleWithStateSystems module = ((ModuleEntryModel) model).getModule();
module.schedule();
}
TimeGraphControl control = getTimeGraphViewer().getTimeGraphControl();
boolean expandedState = control.getExpandedState(selection);
control.setExpandedState(selection, !expandedState);
}
}
});
}
Aggregations