linux.ui: Add context menu to Control Flow View to follow a thread
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.os.linux.ui / src / org / eclipse / tracecompass / internal / analysis / os / linux / ui / actions / FollowThreadAction.java
1 /*******************************************************************************
2 * Copyright (c) 2016 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *******************************************************************************/
9
10 package org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions;
11
12 import org.eclipse.jdt.annotation.NonNullByDefault;
13 import org.eclipse.jdt.annotation.Nullable;
14 import org.eclipse.jface.action.Action;
15 import org.eclipse.tracecompass.analysis.os.linux.core.signals.TmfThreadSelectedSignal;
16 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
17 import org.eclipse.tracecompass.tmf.ui.views.TmfView;
18
19 /**
20 * Follow Thread Action, this action broadcasts a
21 * {@link TmfThreadSelectedSignal} when run, it sends a thread id and a trace to
22 * the signal.
23 *
24 * @author Matthew Khouzam
25 */
26 @NonNullByDefault
27 public class FollowThreadAction extends Action {
28
29 private final int fThreadId;
30 private final TmfView fView;
31 private final ITmfTrace fTrace;
32 private final @Nullable String fThreadName;
33
34 /**
35 * Constructor
36 *
37 * @param source
38 * the view that is generating the signal, but also shall
39 * broadcast it
40 * @param threadName
41 * the thread name, can be null
42 * @param threadId
43 * the thread id
44 * @param trace
45 * the trace containing the thread
46 */
47 public FollowThreadAction(TmfView source, @Nullable String threadName, int threadId, ITmfTrace trace) {
48 fView = source;
49 fThreadName = threadName;
50 fThreadId = threadId;
51 fTrace = trace;
52 }
53
54 @Override
55 public String getText() {
56 if (fThreadName == null) {
57 return Messages.FollowThreadAction_follow + ' ' + fThreadId;
58 }
59 return Messages.FollowThreadAction_follow + ' ' + fThreadName + '/' + fThreadId;
60 }
61
62 @Override
63 public void run() {
64 fView.broadcast(new TmfThreadSelectedSignal(fView, fThreadId, fTrace));
65 super.run();
66 }
67
68 }
This page took 0.031829 seconds and 5 git commands to generate.