Skip to content

Commit e8f4c6e

Browse files
lttng2.control.ui:Synchronize the start/stop LTTng trace action in Control view with the external trace
1 parent 9bd0937 commit e8f4c6e

8 files changed

Lines changed: 302 additions & 2 deletions

File tree

lttng/org.eclipse.tracecompass.lttng2.control.ui/META-INF/MANIFEST.MF

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
22
Bundle-ManifestVersion: 2
33
Bundle-Name: %Bundle-Name
44
Bundle-Vendor: %Bundle-Vendor
5-
Bundle-Version: 1.4.1.qualifier
5+
Bundle-Version: 1.5.0.qualifier
66
Bundle-Localization: plugin
77
Bundle-SymbolicName: org.eclipse.tracecompass.lttng2.control.ui;singleton:=true
88
Bundle-Activator: org.eclipse.tracecompass.internal.lttng2.control.ui.Activator
@@ -42,6 +42,7 @@ Export-Package: org.eclipse.tracecompass.internal.lttng2.control.ui;x-friends:="
4242
org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl;x-friends:="org.eclipse.tracecompass.lttng2.control.ui.tests,org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests",
4343
org.eclipse.tracecompass.internal.lttng2.control.ui.views.preferences;x-friends:="org.eclipse.tracecompass.lttng2.control.ui.tests",
4444
org.eclipse.tracecompass.internal.lttng2.control.ui.views.property;x-friends:="org.eclipse.tracecompass.lttng2.control.ui.tests",
45-
org.eclipse.tracecompass.internal.lttng2.control.ui.views.service;x-friends:="org.eclipse.tracecompass.lttng2.control.ui.tests,org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests"
45+
org.eclipse.tracecompass.internal.lttng2.control.ui.views.service;x-friends:="org.eclipse.tracecompass.lttng2.control.ui.tests,org.eclipse.tracecompass.lttng2.control.ui.swtbot.tests",
46+
org.eclipse.tracecompass.lttng2.control.ui.views.signals
4647
Import-Package: com.google.common.collect
4748
Automatic-Module-Name: org.eclipse.tracecompass.lttng2.control.ui

lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/StartHandler.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@
1515

1616
import org.eclipse.core.commands.ExecutionException;
1717
import org.eclipse.core.runtime.IProgressMonitor;
18+
import org.eclipse.swt.widgets.Display;
1819
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
20+
import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
1921
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent;
22+
import org.eclipse.tracecompass.lttng2.control.ui.views.signals.ExternalTraceStartSignal;
23+
import org.eclipse.tracecompass.lttng2.control.ui.views.signals.LTTngSessionStartSignal;
24+
import org.eclipse.tracecompass.lttng2.control.ui.views.signals.LTTngSessionStopSignal;
25+
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
26+
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
2027

2128
/**
2229
* <p>
@@ -27,6 +34,20 @@
2734
*/
2835
public class StartHandler extends ChangeSessionStateHandler {
2936

37+
/**
38+
* Constructor
39+
*/
40+
public StartHandler() {
41+
super();
42+
TmfSignalManager.register(this);
43+
}
44+
45+
@Override
46+
public void dispose() {
47+
TmfSignalManager.deregister(this);
48+
super.dispose();
49+
}
50+
3051
// ------------------------------------------------------------------------
3152
// Accessors
3253
// ------------------------------------------------------------------------
@@ -43,5 +64,35 @@ public TraceSessionState getNewState() {
4364
@Override
4465
public void changeState(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException {
4566
session.startSession(monitor);
67+
TmfSignalManager.dispatchSignal(
68+
new LTTngSessionStartSignal(session));
69+
}
70+
71+
/**
72+
* Handle the external trace start signal
73+
* @param signal contains the information of the start external trace
74+
*/
75+
@TmfSignalHandler
76+
public void handle(ExternalTraceStartSignal signal) {
77+
Display.getDefault().asyncExec(() -> {
78+
try {
79+
execute(null);
80+
} catch (ExecutionException e) {
81+
Activator.getDefault().logError("Failed to synchronize with the external trace start signal", e); //$NON-NLS-1$
82+
}
83+
});
84+
}
85+
86+
/**
87+
* Handle the LTTng session stop signal
88+
* @param signal contains the information of the stop LTTng session
89+
*/
90+
@TmfSignalHandler
91+
public void handle(LTTngSessionStopSignal signal) {
92+
Display.getDefault().asyncExec(() -> {
93+
if (signal.getSource() instanceof TraceSessionComponent session && !this.fSessions.contains(session)) {
94+
this.fSessions.add(session);
95+
}
96+
});
4697
}
4798
}

lttng/org.eclipse.tracecompass.lttng2.control.ui/src/org/eclipse/tracecompass/internal/lttng2/control/ui/views/handlers/StopHandler.java

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,15 @@
1515

1616
import org.eclipse.core.commands.ExecutionException;
1717
import org.eclipse.core.runtime.IProgressMonitor;
18+
import org.eclipse.swt.widgets.Display;
1819
import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
20+
import org.eclipse.tracecompass.internal.lttng2.control.ui.Activator;
1921
import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent;
22+
import org.eclipse.tracecompass.lttng2.control.ui.views.signals.ExternalTraceStopSignal;
23+
import org.eclipse.tracecompass.lttng2.control.ui.views.signals.LTTngSessionStartSignal;
24+
import org.eclipse.tracecompass.lttng2.control.ui.views.signals.LTTngSessionStopSignal;
25+
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler;
26+
import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager;
2027

2128
/**
2229
* <p>
@@ -27,6 +34,20 @@
2734
*/
2835
public class StopHandler extends ChangeSessionStateHandler {
2936

37+
/**
38+
* Constructor
39+
*/
40+
public StopHandler() {
41+
super();
42+
TmfSignalManager.register(this);
43+
}
44+
45+
@Override
46+
public void dispose() {
47+
TmfSignalManager.deregister(this);
48+
super.dispose();
49+
}
50+
3051
// ------------------------------------------------------------------------
3152
// Accessors
3253
// ------------------------------------------------------------------------
@@ -43,5 +64,35 @@ public TraceSessionState getNewState() {
4364
@Override
4465
public void changeState(TraceSessionComponent session, IProgressMonitor monitor) throws ExecutionException {
4566
session.stopSession(monitor);
67+
TmfSignalManager.dispatchSignal(
68+
new LTTngSessionStopSignal(session));
69+
}
70+
71+
/**
72+
* Handle the external trace stop signal
73+
* @param signal contains the information of the stop external trace
74+
*/
75+
@TmfSignalHandler
76+
public void handle(ExternalTraceStopSignal signal) {
77+
Display.getDefault().asyncExec(() -> {
78+
try {
79+
execute(null);
80+
} catch (ExecutionException e) {
81+
Activator.getDefault().logError("Failed to synchronize with the external trace stop signal", e); //$NON-NLS-1$
82+
}
83+
});
84+
}
85+
86+
/**
87+
* Handle the LTTng session start signal
88+
* @param signal contains the information of the start LTTng session
89+
*/
90+
@TmfSignalHandler
91+
public void handle(LTTngSessionStartSignal signal) {
92+
Display.getDefault().asyncExec(() -> {
93+
if (signal.getSource() instanceof TraceSessionComponent session && !this.fSessions.contains(session)) {
94+
this.fSessions.add(session);
95+
}
96+
});
4697
}
4798
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 Renesas Electronics Corp.
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* Tuan Can - Initial API and implementation
13+
*******************************************************************************/
14+
15+
package org.eclipse.tracecompass.lttng2.control.ui.views.signals;
16+
17+
import org.eclipse.tracecompass.tmf.core.signal.TmfSignal;
18+
19+
/**
20+
* Signal notify that the External trace have been started
21+
* @since 1.5
22+
*/
23+
public class ExternalTraceStartSignal extends TmfSignal{
24+
25+
private final String sessionName;
26+
27+
/**
28+
* Constructor
29+
* @param source input source
30+
* @param sessionName external trace
31+
*/
32+
public ExternalTraceStartSignal(Object source, String sessionName) {
33+
super(source);
34+
this.sessionName = sessionName;
35+
}
36+
37+
/**
38+
* Get the name of the external trace
39+
* @return External trace name
40+
*/
41+
public String getSessionName() {
42+
return sessionName;
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 Renesas Electronics Corp.
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* Tuan Can - Initial API and implementation
13+
*******************************************************************************/
14+
15+
package org.eclipse.tracecompass.lttng2.control.ui.views.signals;
16+
17+
import org.eclipse.tracecompass.tmf.core.signal.TmfSignal;
18+
19+
/**
20+
* Signal notify that the External trace have been stopped
21+
* @since 1.5
22+
*/
23+
public class ExternalTraceStopSignal extends TmfSignal{
24+
25+
private final String sessionName;
26+
27+
/**
28+
* Constructor
29+
* @param source input source
30+
* @param sessionName external trace
31+
*/
32+
public ExternalTraceStopSignal(Object source, String sessionName) {
33+
super(source);
34+
this.sessionName = sessionName;
35+
}
36+
37+
/**
38+
* Get the name of the external trace
39+
* @return External trace name
40+
*/
41+
public String getSessionName() {
42+
return sessionName;
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 Renesas Electronics Corp.
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* Tuan Can - Initial API and implementation
13+
*******************************************************************************/
14+
15+
package org.eclipse.tracecompass.lttng2.control.ui.views.signals;
16+
17+
import org.eclipse.tracecompass.tmf.core.signal.TmfSignal;
18+
19+
/**
20+
* Signal notify that the LTTng session have been destroyed
21+
* @since 1.5
22+
*/
23+
public class LTTngSessionDestroySignal extends TmfSignal{
24+
25+
private final String sessionName;
26+
27+
/**
28+
* Constructor
29+
* @param source input source
30+
* @param sessionName LTTng session name
31+
*/
32+
public LTTngSessionDestroySignal(Object source, String sessionName) {
33+
super(source);
34+
this.sessionName = sessionName;
35+
}
36+
37+
/**
38+
* Get the name of the LTTng session
39+
* @return LTTng session name
40+
*/
41+
public String getSessionName() {
42+
return sessionName;
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 Renesas Electronics Corp.
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* Tuan Can - Initial API and implementation
13+
*******************************************************************************/
14+
15+
package org.eclipse.tracecompass.lttng2.control.ui.views.signals;
16+
17+
import org.eclipse.tracecompass.tmf.core.signal.TmfSignal;
18+
19+
/**
20+
* Signal notify that the LTTng session have been started
21+
* @since 1.5
22+
*/
23+
public class LTTngSessionStartSignal extends TmfSignal{
24+
25+
26+
/**
27+
* Constructor
28+
* @param source input source
29+
*/
30+
public LTTngSessionStartSignal(Object source) {
31+
super(source);
32+
}
33+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2026 Renesas Electronics Corp.
3+
*
4+
* All rights reserved. This program and the accompanying materials are
5+
* made available under the terms of the Eclipse Public License 2.0 which
6+
* accompanies this distribution, and is available at
7+
* https://www.eclipse.org/legal/epl-2.0/
8+
*
9+
* SPDX-License-Identifier: EPL-2.0
10+
*
11+
* Contributors:
12+
* Tuan Can - Initial API and implementation
13+
*******************************************************************************/
14+
15+
package org.eclipse.tracecompass.lttng2.control.ui.views.signals;
16+
17+
import org.eclipse.tracecompass.tmf.core.signal.TmfSignal;
18+
19+
/**
20+
* Signal notify that the LTTng session have been stopped
21+
* @since 1.5
22+
*/
23+
public class LTTngSessionStopSignal extends TmfSignal{
24+
25+
/**
26+
* Constructor
27+
* @param source input source
28+
*/
29+
public LTTngSessionStopSignal(Object source) {
30+
super(source);
31+
}
32+
}

0 commit comments

Comments
 (0)