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
.TraceDomainType
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ITraceLogLevel
;
26 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
27 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.ControlView
;
28 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceChannelComponent
;
29 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceDomainComponent
;
30 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceSessionComponent
;
31 import org
.eclipse
.ui
.IWorkbenchPage
;
35 * Command handler implementation to enable events for a known channel.
38 * @author Bernd Hufmann
40 public class EnableEventOnChannelHandler
extends BaseEnableEventHandler
{
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
46 // ------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
51 public void enableEvents(CommandParameter param
, List
<String
> eventNames
, TraceDomainType domain
, String filterExression
, List
<String
> excludedEvents
, IProgressMonitor monitor
) throws ExecutionException
{
52 if (param
instanceof ChannelCommandParameter
) {
53 ((ChannelCommandParameter
)param
).getChannel().enableEvents(eventNames
, filterExression
, excludedEvents
, monitor
);
58 public void enableSyscalls(CommandParameter param
, List
<String
> syscallNames
, IProgressMonitor monitor
) throws ExecutionException
{
59 if (param
instanceof ChannelCommandParameter
) {
60 ((ChannelCommandParameter
)param
).getChannel().enableSyscalls(syscallNames
, monitor
);
65 public void enableProbe(CommandParameter param
, String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
66 if (param
instanceof ChannelCommandParameter
) {
67 ((ChannelCommandParameter
)param
).getChannel().enableProbe(eventName
, isFunction
, probe
, monitor
);
72 public void enableLogLevel(CommandParameter param
, List
<String
> eventNames
, LogLevelType logLevelType
, ITraceLogLevel level
, String filterExression
, TraceDomainType domain
, IProgressMonitor monitor
) throws ExecutionException
{
73 if (param
instanceof ChannelCommandParameter
) {
74 ((ChannelCommandParameter
)param
).getChannel().enableLogLevel(eventNames
, logLevelType
, level
, filterExression
, domain
, monitor
);
79 public TraceDomainComponent
getDomain(CommandParameter param
) {
80 if (param
instanceof ChannelCommandParameter
) {
81 return (TraceDomainComponent
) ((ChannelCommandParameter
)param
).getChannel().getParent();
87 public boolean isEnabled() {
88 // Get workbench page for the Control View
89 IWorkbenchPage page
= getWorkbenchPage();
94 TraceChannelComponent channel
= null;
95 TraceSessionComponent session
= null;
96 ISelection selection
= page
.getSelection(ControlView
.ID
);
97 if (selection
instanceof StructuredSelection
) {
98 StructuredSelection structered
= ((StructuredSelection
) selection
);
99 for (Iterator
<?
> iterator
= structered
.iterator(); iterator
.hasNext();) {
100 Object element
= iterator
.next();
101 if (element
instanceof TraceChannelComponent
) {
102 // Add only if corresponding TraceSessionComponents is inactive and not destroyed
103 TraceChannelComponent tmpChannel
= (TraceChannelComponent
) element
;
104 session
= tmpChannel
.getSession();
105 if (!session
.isDestroyed()) {
106 channel
= tmpChannel
;
112 boolean isEnabled
= (channel
!= null);
117 fParam
= new ChannelCommandParameter(checkNotNull(session
), checkNotNull(channel
));