1 /**********************************************************************
2 * Copyright (c) 2012, 2015 Ericsson
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
10 * Bernd Hufmann - Initial API and implementation
11 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
12 **********************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.handlers
;
15 import static org
.eclipse
.tracecompass
.common
.core
.NonNullUtils
.checkNotNull
;
17 import java
.util
.Iterator
;
18 import java
.util
.List
;
20 import org
.eclipse
.core
.commands
.ExecutionException
;
21 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
22 import org
.eclipse
.jface
.viewers
.ISelection
;
23 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
24 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
26 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.ControlView
;
27 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceChannelComponent
;
28 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceDomainComponent
;
29 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceSessionComponent
;
30 import org
.eclipse
.ui
.IWorkbenchPage
;
34 * Command handler implementation to enable events for a known channel.
37 * @author Bernd Hufmann
39 public class EnableEventOnChannelHandler
extends BaseEnableEventHandler
{
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
45 // ------------------------------------------------------------------------
47 // ------------------------------------------------------------------------
50 public void enableEvents(CommandParameter param
, List
<String
> eventNames
, boolean isKernel
, String filterExression
, List
<String
> excludedEvents
, IProgressMonitor monitor
) throws ExecutionException
{
51 if (param
instanceof ChannelCommandParameter
) {
52 ((ChannelCommandParameter
)param
).getChannel().enableEvents(eventNames
, filterExression
, excludedEvents
, monitor
);
57 public void enableSyscalls(CommandParameter param
, IProgressMonitor monitor
) throws ExecutionException
{
58 if (param
instanceof ChannelCommandParameter
) {
59 ((ChannelCommandParameter
)param
).getChannel().enableSyscalls(monitor
);
64 public void enableProbe(CommandParameter param
, String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
65 if (param
instanceof ChannelCommandParameter
) {
66 ((ChannelCommandParameter
)param
).getChannel().enableProbe(eventName
, isFunction
, probe
, monitor
);
71 public void enableLogLevel(CommandParameter param
, String eventName
, LogLevelType logLevelType
, TraceLogLevel level
, String filterExression
, IProgressMonitor monitor
) throws ExecutionException
{
72 if (param
instanceof ChannelCommandParameter
) {
73 ((ChannelCommandParameter
)param
).getChannel().enableLogLevel(eventName
, logLevelType
, level
, filterExression
, monitor
);
78 public TraceDomainComponent
getDomain(CommandParameter param
) {
79 if (param
instanceof ChannelCommandParameter
) {
80 return (TraceDomainComponent
) ((ChannelCommandParameter
)param
).getChannel().getParent();
86 public boolean isEnabled() {
87 // Get workbench page for the Control View
88 IWorkbenchPage page
= getWorkbenchPage();
93 TraceChannelComponent channel
= null;
94 TraceSessionComponent session
= null;
95 ISelection selection
= page
.getSelection(ControlView
.ID
);
96 if (selection
instanceof StructuredSelection
) {
97 StructuredSelection structered
= ((StructuredSelection
) selection
);
98 for (Iterator
<?
> iterator
= structered
.iterator(); iterator
.hasNext();) {
99 Object element
= iterator
.next();
100 if (element
instanceof TraceChannelComponent
) {
101 // Add only if corresponding TraceSessionComponents is inactive and not destroyed
102 TraceChannelComponent tmpChannel
= (TraceChannelComponent
) element
;
103 session
= tmpChannel
.getSession();
104 if(!session
.isDestroyed()) {
105 channel
= tmpChannel
;
111 boolean isEnabled
= (channel
!= null);
116 fParam
= new ChannelCommandParameter(checkNotNull(session
), checkNotNull(channel
));