use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NamedTimeEvent in project tracecompass by tracecompass.
the class ResourcesView method fillTimeEventContextMenu.
@Override
protected void fillTimeEventContextMenu(@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 (sSel.toArray()[1] instanceof NamedTimeEvent && ((ResourcesEntryModel) model).getType() == Type.CURRENT_THREAD) {
ITmfTrace trace = getTrace(resourcesEntry);
NamedTimeEvent event = (NamedTimeEvent) sSel.toArray()[1];
TmfTraceContext ctx = TmfTraceManager.getInstance().getCurrentTraceContext();
HostThread data = (HostThread) ctx.getData(HostThread.SELECTED_HOST_THREAD_KEY);
if (data != null) {
menuManager.add(new UnfollowThreadAction(ResourcesView.this));
} else {
menuManager.add(new FollowThreadAction(ResourcesView.this, null, event.getValue(), trace));
}
}
}
}
super.fillTimeEventContextMenu(menuManager);
}
use of org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.NamedTimeEvent in project tracecompass by tracecompass.
the class FlameChartView method createPartControl.
// ------------------------------------------------------------------------
// ViewPart
// ------------------------------------------------------------------------
@Override
public void createPartControl(@Nullable Composite parent) {
super.createPartControl(parent);
getTimeGraphViewer().addTimeListener(event -> synchingToTime(event.getBeginTime()));
getTimeGraphViewer().getTimeGraphControl().addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(@Nullable MouseEvent event) {
ITimeGraphEntry selection = getTimeGraphViewer().getSelection();
if (!(selection instanceof TimeGraphEntry)) {
// also null checks
return;
}
ITimeGraphState function = fFunctions.get(((TimeGraphEntry) selection).getEntryModel().getId());
if (function != null) {
long entryTime = function.getStartTime();
long exitTime = entryTime + function.getDuration();
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromNanos(entryTime), TmfTimestamp.fromNanos(exitTime));
broadcast(new TmfWindowRangeUpdatedSignal(FlameChartView.this, range, getTrace()));
getTimeGraphViewer().setStartFinishTime(entryTime, exitTime);
startZoomThread(entryTime, exitTime);
}
}
});
getTimeGraphViewer().getTimeGraphControl().addMouseListener(new MouseAdapter() {
@Override
public void mouseDoubleClick(@Nullable MouseEvent e) {
TimeGraphControl timeGraphControl = getTimeGraphViewer().getTimeGraphControl();
ISelection selection = timeGraphControl.getSelection();
if (selection instanceof IStructuredSelection) {
for (Object object : ((IStructuredSelection) selection).toList()) {
if (object instanceof NamedTimeEvent) {
NamedTimeEvent event = (NamedTimeEvent) object;
long startTime = event.getTime();
long endTime = startTime + event.getDuration();
TmfTimeRange range = new TmfTimeRange(TmfTimestamp.fromNanos(startTime), TmfTimestamp.fromNanos(endTime));
broadcast(new TmfWindowRangeUpdatedSignal(FlameChartView.this, range, getTrace()));
getTimeGraphViewer().setStartFinishTime(startTime, endTime);
startZoomThread(startTime, endTime);
break;
}
}
}
}
});
IEditorPart editor = getSite().getPage().getActiveEditor();
if (editor instanceof ITmfTraceEditor) {
ITmfTrace trace = ((ITmfTraceEditor) editor).getTrace();
if (trace != null) {
traceSelected(new TmfTraceSelectedSignal(this, trace));
}
}
}
Aggregations