Search in sources :

Example 16 with ITmfTreeDataModel

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));
                    }
                }
            }
        }
    }
}
Also used : ITmfTrace(org.eclipse.tracecompass.tmf.core.trace.ITmfTrace) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) Type(org.eclipse.tracecompass.internal.analysis.os.linux.core.resourcesstatus.ResourcesEntryModel.Type) TmfTraceContext(org.eclipse.tracecompass.tmf.core.trace.TmfTraceContext) FollowCpuAction(org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions.FollowCpuAction) ISelection(org.eclipse.jface.viewers.ISelection) ResourcesEntryModel(org.eclipse.tracecompass.internal.analysis.os.linux.core.resourcesstatus.ResourcesEntryModel) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) UnfollowCpuAction(org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions.UnfollowCpuAction)

Example 17 with ITmfTreeDataModel

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();
    }
}
Also used : ImmutableList(com.google.common.collect.ImmutableList) ITmfStateInterval(org.eclipse.tracecompass.statesystem.core.interval.ITmfStateInterval) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) TmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeDataModel) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) DataDrivenStateSystemPath(org.eclipse.tracecompass.internal.tmf.analysis.xml.core.fsm.model.DataDrivenStateSystemPath) StateSystemDisposedException(org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) AtomicLong(java.util.concurrent.atomic.AtomicLong) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)

Example 18 with ITmfTreeDataModel

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();
    }
}
Also used : ArrayList(java.util.ArrayList) TmfModelResponse(org.eclipse.tracecompass.tmf.core.response.TmfModelResponse) ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) TimeGraphEntryModel(org.eclipse.tracecompass.tmf.core.model.timegraph.TimeGraphEntryModel) TmfTreeModel(org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel) ITmfStateSystem(org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)

Example 19 with ITmfTreeDataModel

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;
}
Also used : ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) ModuleEntryModel(org.eclipse.tracecompass.internal.tmf.core.statesystem.provider.StateSystemDataProvider.ModuleEntryModel) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) StateSystemEntryModel(org.eclipse.tracecompass.internal.tmf.core.statesystem.provider.StateSystemDataProvider.StateSystemEntryModel) TimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent) ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) TmfAbstractAnalysisModule(org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisModule) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) LinkedHashMap(java.util.LinkedHashMap) ITmfAnalysisModuleWithStateSystems(org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems)

Example 20 with ITmfTreeDataModel

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);
            }
        }
    });
}
Also used : ITmfTreeDataModel(org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel) ModuleEntryModel(org.eclipse.tracecompass.internal.tmf.core.statesystem.provider.StateSystemDataProvider.ModuleEntryModel) MouseEvent(org.eclipse.swt.events.MouseEvent) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) MouseAdapter(org.eclipse.swt.events.MouseAdapter) TimeGraphControl(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry) ITmfAnalysisModuleWithStateSystems(org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems)

Aggregations

ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)20 ITmfTrace (org.eclipse.tracecompass.tmf.core.trace.ITmfTrace)9 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)8 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)7 ArrayList (java.util.ArrayList)4 TmfTreeModel (org.eclipse.tracecompass.tmf.core.model.tree.TmfTreeModel)4 Test (org.junit.Test)4 ISelection (org.eclipse.jface.viewers.ISelection)3 ResourcesEntryModel (org.eclipse.tracecompass.internal.analysis.os.linux.core.resourcesstatus.ResourcesEntryModel)3 ModuleEntryModel (org.eclipse.tracecompass.internal.tmf.core.statesystem.provider.StateSystemDataProvider.ModuleEntryModel)3 ITmfStateSystem (org.eclipse.tracecompass.statesystem.core.ITmfStateSystem)3 ITmfTreeXYDataProvider (org.eclipse.tracecompass.tmf.core.model.xy.ITmfTreeXYDataProvider)3 TmfTraceClosedSignal (org.eclipse.tracecompass.tmf.core.signal.TmfTraceClosedSignal)3 ITmfAnalysisModuleWithStateSystems (org.eclipse.tracecompass.tmf.core.statesystem.ITmfAnalysisModuleWithStateSystems)3 ITimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent)3 TimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent)3 Element (org.w3c.dom.Element)3 HashMap (java.util.HashMap)2 NonNull (org.eclipse.jdt.annotation.NonNull)2 Nullable (org.eclipse.jdt.annotation.Nullable)2