1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
|
/*******************************************************************************
* 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.model.HostThread;
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 static final String TID = " TID "; //$NON-NLS-1$
private final TmfView fView;
private final HostThread fHostThread;
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) {
this(source, threadName, new HostThread(trace.getHostId(), threadId));
}
/**
* Constructor
*
* @param source
* the view that is generating the signal, but also shall broadcast
* it
* @param threadName
* the thread name, can be null
* @param ht
* The HostThread to follow
*/
public FollowThreadAction(TmfView source, @Nullable String threadName, HostThread ht) {
fView = source;
fThreadName = threadName;
fHostThread = ht;
}
@Override
public String getText() {
if (fThreadName == null) {
return Messages.FollowThreadAction_follow + TID + fHostThread.getTid();
}
return Messages.FollowThreadAction_follow + ' ' + fThreadName + '/' + fHostThread.getTid();
}
@Override
public void run() {
fView.broadcast(new TmfThreadSelectedSignal(fView, fHostThread));
super.run();
}
}
|