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