1 /**********************************************************************
2 * Copyright (c) 2012, 2014 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 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
.tracecompass
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
23 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
24 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.ControlView
;
26 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceDomainComponent
;
27 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceSessionComponent
;
28 import org
.eclipse
.ui
.IWorkbenchPage
;
32 * Command handler implementation to enable events for a known session and default channel 'channel0'
33 * (which will be created if doesn't exist).
36 * @author Bernd Hufmann
38 public class EnableEventOnSessionHandler
extends BaseEnableEventHandler
{
40 // ------------------------------------------------------------------------
42 // ------------------------------------------------------------------------
44 //-------------------------------------------------------------------------
46 // ------------------------------------------------------------------------
49 public void enableEvents(CommandParameter param
, List
<String
> eventNames
, boolean isKernel
, String filterExpression
, IProgressMonitor monitor
) throws ExecutionException
{
50 param
.getSession().enableEvents(eventNames
, isKernel
, filterExpression
, monitor
);
54 public void enableSyscalls(CommandParameter param
, IProgressMonitor monitor
) throws ExecutionException
{
55 param
.getSession().enableSyscalls(monitor
);
59 public void enableProbe(CommandParameter param
, String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
60 param
.getSession().enableProbe(eventName
, isFunction
, probe
, monitor
);
64 public void enableLogLevel(CommandParameter param
, String eventName
, LogLevelType logLevelType
, TraceLogLevel level
, String filterExpression
, IProgressMonitor monitor
) throws ExecutionException
{
65 param
.getSession().enableLogLevel(eventName
, logLevelType
, level
, filterExpression
, monitor
);
69 public TraceDomainComponent
getDomain(CommandParameter param
) {
74 public boolean isEnabled() {
75 // Get workbench page for the Control View
76 IWorkbenchPage page
= getWorkbenchPage();
81 TraceSessionComponent session
= null;
82 // Check if one session is selected
83 ISelection selection
= page
.getSelection(ControlView
.ID
);
84 if (selection
instanceof StructuredSelection
) {
85 StructuredSelection structered
= ((StructuredSelection
) selection
);
86 for (Iterator
<?
> iterator
= structered
.iterator(); iterator
.hasNext();) {
87 Object element
= iterator
.next();
88 if (element
instanceof TraceSessionComponent
) {
89 // Add only if corresponding TraceSessionComponents is inactive and not destroyed
90 TraceSessionComponent tmpSession
= (TraceSessionComponent
) element
;
91 if(tmpSession
.getSessionState() == TraceSessionState
.INACTIVE
&& !tmpSession
.isDestroyed()) {
97 boolean isEnabled
= (session
!= null);
102 fParam
= new CommandParameter(session
);