import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.action.IToolBarManager;
+import org.eclipse.jface.action.MenuManager;
import org.eclipse.jface.dialogs.IDialogSettings;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.swt.events.MenuDetectEvent;
+import org.eclipse.swt.events.MenuDetectListener;
+import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.widgets.Composite;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Menu;
+import org.eclipse.swt.widgets.TreeItem;
import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.Attributes;
import org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis.KernelAnalysisModule;
import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Activator;
import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Messages;
+import org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions.FollowThreadAction;
import org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.controlflow.ControlFlowColumnComparators;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
import org.eclipse.tracecompass.tmf.ui.views.timegraph.AbstractStateSystemTimeGraphView;
+import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.TimeGraphCombo;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ILinkEvent;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeEvent;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.ITimeGraphEntry;
static {
ImmutableList.Builder<Comparator<ITimeGraphEntry>> builder = ImmutableList.builder();
builder.add(ControlFlowColumnComparators.PROCESS_NAME_COLUMN_COMPARATOR)
- .add(ControlFlowColumnComparators.TID_COLUMN_COMPARATOR)
- .add(ControlFlowColumnComparators.PTID_COLUMN_COMPARATOR)
- .add(ControlFlowColumnComparators.BIRTH_TIME_COLUMN_COMPARATOR)
- .add(ControlFlowColumnComparators.TRACE_COLUMN_COMPARATOR);
+ .add(ControlFlowColumnComparators.TID_COLUMN_COMPARATOR)
+ .add(ControlFlowColumnComparators.PTID_COLUMN_COMPARATOR)
+ .add(ControlFlowColumnComparators.BIRTH_TIME_COLUMN_COMPARATOR)
+ .add(ControlFlowColumnComparators.TRACE_COLUMN_COMPARATOR);
List<Comparator<ITimeGraphEntry>> l = builder.build();
COLUMN_COMPARATORS = l.toArray(new Comparator[l.size()]);
}
+ private MenuManager fMenuMgr;
+
// ------------------------------------------------------------------------
// Constructors
// ------------------------------------------------------------------------
// add "Uncheck inactive" Button to TimeGraphFilterDialog
super.getTimeGraphCombo().addTimeGraphFilterUncheckInactiveButton(
new ControlFlowCheckActiveProvider(Messages.ControlFlowView_uncheckInactiveLabel, Messages.ControlFlowView_uncheckInactiveToolTip));
+ createContextMenu();
+ }
+
+ private void createContextMenu() {
+ fMenuMgr = new MenuManager();
+ final TimeGraphCombo timeGraphCombo = getTimeGraphCombo();
+ TreeViewer treeViewer = timeGraphCombo.getTreeViewer();
+ Control control = treeViewer.getControl();
+ Menu menu = fMenuMgr.createContextMenu(control);
+ control.setMenu(menu);
+ control.addMenuDetectListener(new MenuDetectListener() {
+ @Override
+ public void menuDetected(MenuDetectEvent event) {
+ fMenuMgr.removeAll();
+ Point point = control.toControl(event.x, event.y);
+ // this is super important, it makes zoom still work. Do not try
+ // to extend to the time graph area.
+ TreeItem item = treeViewer.getTree().getItem(point);
+
+ if (item.getData() instanceof ControlFlowEntry) {
+ ControlFlowEntry entry = (ControlFlowEntry) item.getData();
+ fMenuMgr.add(new FollowThreadAction(ControlFlowView.this, entry.getName(), entry.getThreadId(), entry.getTrace()));
+ }
+ }
+ });
+
}
@Override
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions;
+
+import org.eclipse.jdt.annotation.NonNullByDefault;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.jface.action.Action;
+import org.eclipse.tracecompass.analysis.os.linux.core.signals.TmfThreadSelectedSignal;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.ui.views.TmfView;
+
+/**
+ * Follow Thread Action, this action broadcasts a
+ * {@link TmfThreadSelectedSignal} when run, it sends a thread id and a trace to
+ * the signal.
+ *
+ * @author Matthew Khouzam
+ */
+@NonNullByDefault
+public class FollowThreadAction extends Action {
+
+ private final int fThreadId;
+ private final TmfView fView;
+ private final ITmfTrace fTrace;
+ private final @Nullable String fThreadName;
+
+ /**
+ * Constructor
+ *
+ * @param source
+ * the view that is generating the signal, but also shall
+ * broadcast it
+ * @param threadName
+ * the thread name, can be null
+ * @param threadId
+ * the thread id
+ * @param trace
+ * the trace containing the thread
+ */
+ public FollowThreadAction(TmfView source, @Nullable String threadName, int threadId, ITmfTrace trace) {
+ fView = source;
+ fThreadName = threadName;
+ fThreadId = threadId;
+ fTrace = trace;
+ }
+
+ @Override
+ public String getText() {
+ if (fThreadName == null) {
+ return Messages.FollowThreadAction_follow + ' ' + fThreadId;
+ }
+ return Messages.FollowThreadAction_follow + ' ' + fThreadName + '/' + fThreadId;
+ }
+
+ @Override
+ public void run() {
+ fView.broadcast(new TmfThreadSelectedSignal(fView, fThreadId, fTrace));
+ super.run();
+ }
+
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2016 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are
+ * made available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Action messages
+ *
+ * @author Matthew Khouzam
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions.messages"; //$NON-NLS-1$
+ /**
+ * Follow message
+ */
+ public static String FollowThreadAction_follow;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}