Search in sources :

Example 1 with TimeEvent

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent in project tracecompass by tracecompass.

the class ITimeGraphPresentationProvider method getEventStyle.

/**
 * Get the style map of a given ITimeEvent
 *
 * @param event
 *            the time event
 * @return the style map, as detailed in {@link ITimeEventStyleStrings}
 * @since 3.0
 */
default Map<String, Object> getEventStyle(ITimeEvent event) {
    if (event instanceof TimeEvent) {
        TimeEvent timeEvent = (TimeEvent) event;
        OutputElementStyle style = timeEvent.getModel().getStyle();
        if (style != null) {
            Map<@NonNull String, @NonNull Object> styleValues = style.getStyleValues();
            if (!styleValues.isEmpty()) {
                return styleValues;
            }
        }
    }
    StateItem stateItem = null;
    int index = getStateTableIndex(event);
    StateItem[] stateTable = getStateTable();
    if (index >= 0 && index < stateTable.length) {
        stateItem = stateTable[index];
    }
    Map<String, Object> styleMap = stateItem == null ? Collections.emptyMap() : stateItem.getStyleMap();
    Map<String, Object> specificEventStyles = getSpecificEventStyle(event);
    if (specificEventStyles.isEmpty()) {
        return styleMap;
    }
    if (styleMap.isEmpty()) {
        return specificEventStyles;
    }
    styleMap = new HashMap<>(styleMap);
    styleMap.putAll(specificEventStyles);
    return styleMap;
}
Also used : OutputElementStyle(org.eclipse.tracecompass.tmf.core.model.OutputElementStyle) ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) TimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent)

Example 2 with TimeEvent

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent in project tracecompass by tracecompass.

the class StateSystemPresentationProvider method getStateTableIndex.

@Override
public int getStateTableIndex(ITimeEvent event) {
    if (event instanceof TimeEvent) {
        TimeEvent timeEvent = (TimeEvent) event;
        Object value = timeEvent.getLabel();
        if (value != null) {
            return Math.floorMod(value.hashCode(), NUM_COLORS);
        }
        ITimeGraphEntry entry = event.getEntry();
        if (entry != null) {
            ITmfTreeDataModel model = ((TimeGraphEntry) entry).getEntryModel();
            if (model instanceof StateSystemEntryModel || model instanceof ModuleEntryModel) {
                // tooltip
                return INVISIBLE;
            }
        }
        // grey
        return NUM_COLORS;
    }
    return INVISIBLE;
}
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) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)

Example 3 with TimeEvent

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent in project tracecompass by tracecompass.

the class BaseDataProviderTimeGraphView method createTimeEventContextMenu.

private void createTimeEventContextMenu() {
    MenuManager eventMenuManager = new MenuManager();
    eventMenuManager.setRemoveAllWhenShown(true);
    TimeGraphControl timeGraphControl = getTimeGraphViewer().getTimeGraphControl();
    final Menu timeEventMenu = eventMenuManager.createContextMenu(timeGraphControl);
    timeGraphControl.addTimeEventMenuListener(event -> {
        Menu menu = timeEventMenu;
        if (event.data instanceof TimeEvent) {
            timeGraphControl.setMenu(menu);
            return;
        }
        timeGraphControl.setMenu(null);
        event.doit = false;
    });
    eventMenuManager.addMenuListener(manager -> {
        fillTimeEventContextMenu(eventMenuManager);
        eventMenuManager.add(new GroupMarker(IWorkbenchActionConstants.MB_ADDITIONS));
    });
    getSite().registerContextMenu(eventMenuManager, getTimeGraphViewer().getSelectionProvider());
}
Also used : MenuManager(org.eclipse.jface.action.MenuManager) IMenuManager(org.eclipse.jface.action.IMenuManager) NamedTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NamedTimeEvent) TimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent) ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) NullTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent) TimeGraphControl(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.TimeGraphControl) GroupMarker(org.eclipse.jface.action.GroupMarker) Menu(org.eclipse.swt.widgets.Menu)

Example 4 with TimeEvent

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent in project tracecompass by tracecompass.

the class BaseDataProviderTimeGraphView method fillTimeEventContextMenu.

/**
 * Fill context menu
 *
 * @param menuManager
 *            a menuManager to fill
 * @since 5.2
 */
protected void fillTimeEventContextMenu(@NonNull IMenuManager menuManager) {
    ISelection selection = getSite().getSelectionProvider().getSelection();
    if (selection instanceof IStructuredSelection) {
        IStructuredSelection sSel = (IStructuredSelection) selection;
        for (Object element : sSel.toArray()) {
            if (element instanceof TimeEvent) {
                TimeEvent event = (TimeEvent) element;
                IContributionItem contribItem = createOpenSourceCodeAction(getPresentationProvider().getEventHoverToolTipInfo(event, getTimeGraphViewer().getSelectionBegin()));
                if (contribItem != null) {
                    menuManager.add(contribItem);
                    break;
                }
            }
        }
    }
}
Also used : IContributionItem(org.eclipse.jface.action.IContributionItem) ISelection(org.eclipse.jface.viewers.ISelection) NamedTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NamedTimeEvent) TimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent) ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) NullTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent) IStructuredSelection(org.eclipse.jface.viewers.IStructuredSelection)

Example 5 with TimeEvent

use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent in project tracecompass by tracecompass.

the class ResourcesPresentationProvider method getSpecificEventStyle.

@Override
public Map<String, Object> getSpecificEventStyle(ITimeEvent event) {
    Map<String, Object> map = new HashMap<>(super.getSpecificEventStyle(event));
    if (isType(event.getEntry(), Type.CURRENT_THREAD) && event instanceof TimeEvent) {
        if (event instanceof MarkerEvent) {
            TimeEvent timeEvent = (TimeEvent) event;
            OutputElementStyle style = timeEvent.getModel().getStyle();
            if (style != null) {
                return style.getStyleValues();
            }
        } else {
            int threadEventValue = ((TimeEvent) event).getValue();
            RGBAColor color = PALETTE.get(Math.floorMod(threadEventValue + COLOR_DIFFERENCIATION_FACTOR, NUM_COLORS));
            map.put(StyleProperties.BACKGROUND_COLOR, ColorUtils.toHexColor(color.getRed(), color.getGreen(), color.getBlue()));
            map.put(StyleProperties.STYLE_NAME, String.valueOf(threadEventValue));
        }
    } else if (event.getEntry() instanceof TimeGraphEntry && ((TimeGraphEntry) event.getEntry()).getEntryModel() instanceof ITimeGraphEntryModelWeighted) {
        ITimeGraphEntryModelWeighted model = (ITimeGraphEntryModelWeighted) ((TimeGraphEntry) event.getEntry()).getEntryModel();
        int eventValue = ((TimeEvent) event).getValue();
        map.put(StyleProperties.HEIGHT, (float) model.getWeight(eventValue));
    }
    return map;
}
Also used : OutputElementStyle(org.eclipse.tracecompass.tmf.core.model.OutputElementStyle) HashMap(java.util.HashMap) LinkedHashMap(java.util.LinkedHashMap) ITimeGraphEntryModelWeighted(org.eclipse.tracecompass.internal.provisional.tmf.core.model.timegraph.ITimeGraphEntryModelWeighted) MarkerEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.MarkerEvent) RGBAColor(org.eclipse.tracecompass.tmf.core.presentation.RGBAColor) NullTimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent) TimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent) ITimeEvent(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent) TimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry) ITimeGraphEntry(org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)

Aggregations

ITimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent)24 TimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent)24 NullTimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NullTimeEvent)21 TimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeGraphEntry)17 Test (org.junit.Test)10 ITimeGraphEntry (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry)6 NamedTimeEvent (org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NamedTimeEvent)5 LinkedHashMap (java.util.LinkedHashMap)4 ITmfTreeDataModel (org.eclipse.tracecompass.tmf.core.model.tree.ITmfTreeDataModel)4 OutputElementStyle (org.eclipse.tracecompass.tmf.core.model.OutputElementStyle)3 ArrayList (java.util.ArrayList)2 Map (java.util.Map)2 NonNull (org.eclipse.jdt.annotation.NonNull)2 Nullable (org.eclipse.jdt.annotation.Nullable)2 DataDrivenOutputEntryModel (org.eclipse.tracecompass.internal.tmf.analysis.xml.core.output.DataDrivenOutputEntryModel)2 ModuleEntryModel (org.eclipse.tracecompass.internal.tmf.core.statesystem.provider.StateSystemDataProvider.ModuleEntryModel)2 StateSystemEntryModel (org.eclipse.tracecompass.internal.tmf.core.statesystem.provider.StateSystemDataProvider.StateSystemEntryModel)2 SelectionTimeQueryFilter (org.eclipse.tracecompass.tmf.core.model.filters.SelectionTimeQueryFilter)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 HashMap (java.util.HashMap)1