critical path: bug 494196 reset selection when trace selected
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.kernel.ui / src / org / eclipse / tracecompass / internal / lttng2 / kernel / ui / criticalpath / CriticalPathParameterProvider.java
1 /*******************************************************************************
2 * Copyright (c) 2015 École Polytechnique de Montréal
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.lttng2.kernel.ui.criticalpath;
11
12 import org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule;
13 import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread;
14 import org.eclipse.tracecompass.analysis.os.linux.core.signals.TmfThreadSelectedSignal;
15 import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.model.LttngWorker;
16 import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule;
17 import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisParamProvider;
18 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
19 import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
20 import org.eclipse.tracecompass.tmf.core.signal.TmfTraceSelectedSignal;
21 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
22
23 /**
24 * Class that provides parameters to the critical path analysis for lttng kernel
25 * traces
26 *
27 * @author Geneviève Bastien
28 */
29 public class CriticalPathParameterProvider extends TmfAbstractAnalysisParamProvider {
30
31 private static final String NAME = "Critical Path Lttng kernel parameter provider"; //$NON-NLS-1$
32
33 private HostThread fCurrentHostThread = null;
34
35 /**
36 * Constructor
37 */
38 public CriticalPathParameterProvider() {
39 super();
40 TmfSignalManager.register(this);
41 }
42
43 @Override
44 public String getName() {
45 return NAME;
46 }
47
48 @Override
49 public Object getParameter(String name) {
50 if (name.equals(CriticalPathModule.PARAM_WORKER)) {
51 final HostThread currentHostThread = fCurrentHostThread;
52 if (currentHostThread == null) {
53 return null;
54 }
55 /* Try to find the worker for the critical path */
56 IAnalysisModule mod = getModule();
57 if ((mod != null) && (mod instanceof CriticalPathModule)) {
58 LttngWorker worker = new LttngWorker(currentHostThread, "", 0); //$NON-NLS-1$
59 return worker;
60 }
61 }
62 return null;
63 }
64
65 @Override
66 public boolean appliesToTrace(ITmfTrace trace) {
67 return true;
68 }
69
70 private void setCurrentHostThread(HostThread hostThread) {
71 if (!hostThread.equals(fCurrentHostThread)) {
72 fCurrentHostThread = hostThread;
73 notifyParameterChanged(CriticalPathModule.PARAM_WORKER);
74 }
75 }
76
77 /**
78 * Signal handler to know that a thread was selected
79 *
80 * @param signal
81 * the thread was selected
82 */
83 @TmfSignalHandler
84 public void tmfThreadSelectedSignalHander(TmfThreadSelectedSignal signal) {
85 final TmfThreadSelectedSignal threadSignal = signal;
86 if (threadSignal != null) {
87 setCurrentHostThread(new HostThread(threadSignal.getTraceHost(), threadSignal.getThreadId()));
88 }
89 }
90
91 /**
92 * Reset the selection when a new trace is selected
93 *
94 * @param signal The trace selected signal
95 */
96 @TmfSignalHandler
97 public void traceSelected(TmfTraceSelectedSignal signal) {
98 fCurrentHostThread = null;
99 }
100
101 }
This page took 0.049496 seconds and 5 git commands to generate.