1 /**********************************************************************
2 * Copyright (c) 2012, 2013 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
.linuxtools
.internal
.lttng2
.ui
.views
.control
.handlers
;
15 import java
.util
.Iterator
;
16 import java
.util
.List
;
18 import org
.eclipse
.core
.commands
.ExecutionException
;
19 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
20 import org
.eclipse
.jface
.viewers
.ISelection
;
21 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.LogLevelType
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceLogLevel
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.ControlView
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceChannelComponent
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceDomainComponent
;
27 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceSessionComponent
;
28 import org
.eclipse
.ui
.IWorkbenchPage
;
32 * Command handler implementation to enable events for a known channel.
35 * @author Bernd Hufmann
37 public class EnableEventOnChannelHandler
extends BaseEnableEventHandler
{
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
45 // ------------------------------------------------------------------------
48 public void enableEvents(CommandParameter param
, List
<String
> eventNames
, boolean isKernel
, String filterExression
, IProgressMonitor monitor
) throws ExecutionException
{
49 if (param
instanceof ChannelCommandParameter
) {
50 ((ChannelCommandParameter
)param
).getChannel().enableEvents(eventNames
, filterExression
, monitor
);
55 public void enableSyscalls(CommandParameter param
, IProgressMonitor monitor
) throws ExecutionException
{
56 if (param
instanceof ChannelCommandParameter
) {
57 ((ChannelCommandParameter
)param
).getChannel().enableSyscalls(monitor
);
62 public void enableProbe(CommandParameter param
, String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
63 if (param
instanceof ChannelCommandParameter
) {
64 ((ChannelCommandParameter
)param
).getChannel().enableProbe(eventName
, isFunction
, probe
, monitor
);
69 public void enableLogLevel(CommandParameter param
, String eventName
, LogLevelType logLevelType
, TraceLogLevel level
, String filterExression
, IProgressMonitor monitor
) throws ExecutionException
{
70 if (param
instanceof ChannelCommandParameter
) {
71 ((ChannelCommandParameter
)param
).getChannel().enableLogLevel(eventName
, logLevelType
, level
, filterExression
, monitor
);
76 public TraceDomainComponent
getDomain(CommandParameter param
) {
77 if (param
instanceof ChannelCommandParameter
) {
78 return (TraceDomainComponent
) ((ChannelCommandParameter
)param
).getChannel().getParent();
84 public boolean isEnabled() {
85 // Get workbench page for the Control View
86 IWorkbenchPage page
= getWorkbenchPage();
91 TraceChannelComponent channel
= null;
92 TraceSessionComponent session
= null;
93 ISelection selection
= page
.getSelection(ControlView
.ID
);
94 if (selection
instanceof StructuredSelection
) {
95 StructuredSelection structered
= ((StructuredSelection
) selection
);
96 for (Iterator
<?
> iterator
= structered
.iterator(); iterator
.hasNext();) {
97 Object element
= iterator
.next();
98 if (element
instanceof TraceChannelComponent
) {
99 // Add only if corresponding TraceSessionComponents is inactive and not destroyed
100 TraceChannelComponent tmpChannel
= (TraceChannelComponent
) element
;
101 session
= tmpChannel
.getSession();
102 if(!session
.isDestroyed()) {
103 channel
= tmpChannel
;
109 boolean isEnabled
= (channel
!= null);
114 fParam
= new ChannelCommandParameter(session
, channel
);