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 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
.common
.core
.NonNullUtils
;
23 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
24 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
26 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.ControlView
;
27 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceDomainComponent
;
28 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceSessionComponent
;
29 import org
.eclipse
.ui
.IWorkbenchPage
;
33 * Command handler implementation to enable events for a known session and default channel 'channel0'
34 * (which will be created if doesn't exist).
37 * @author Bernd Hufmann
39 public class EnableEventOnSessionHandler
extends BaseEnableEventHandler
{
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
45 //-------------------------------------------------------------------------
47 // ------------------------------------------------------------------------
50 public void enableEvents(CommandParameter param
, List
<String
> eventNames
, boolean isKernel
, String filterExpression
, IProgressMonitor monitor
) throws ExecutionException
{
51 param
.getSession().enableEvents(eventNames
, isKernel
, filterExpression
, monitor
);
55 public void enableSyscalls(CommandParameter param
, IProgressMonitor monitor
) throws ExecutionException
{
56 param
.getSession().enableSyscalls(monitor
);
60 public void enableProbe(CommandParameter param
, String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
61 param
.getSession().enableProbe(eventName
, isFunction
, probe
, monitor
);
65 public void enableLogLevel(CommandParameter param
, String eventName
, LogLevelType logLevelType
, TraceLogLevel level
, String filterExpression
, IProgressMonitor monitor
) throws ExecutionException
{
66 param
.getSession().enableLogLevel(eventName
, logLevelType
, level
, filterExpression
, monitor
);
70 public TraceDomainComponent
getDomain(CommandParameter param
) {
75 public boolean isEnabled() {
76 // Get workbench page for the Control View
77 IWorkbenchPage page
= getWorkbenchPage();
82 TraceSessionComponent session
= null;
83 // Check if one session is selected
84 ISelection selection
= page
.getSelection(ControlView
.ID
);
85 if (selection
instanceof StructuredSelection
) {
86 StructuredSelection structered
= ((StructuredSelection
) selection
);
87 for (Iterator
<?
> iterator
= structered
.iterator(); iterator
.hasNext();) {
88 Object element
= iterator
.next();
89 if (element
instanceof TraceSessionComponent
) {
90 // Add only if corresponding TraceSessionComponents is inactive and not destroyed
91 TraceSessionComponent tmpSession
= (TraceSessionComponent
) element
;
92 if(tmpSession
.getSessionState() == TraceSessionState
.INACTIVE
&& !tmpSession
.isDestroyed()) {
98 boolean isEnabled
= (session
!= null);
103 fParam
= new CommandParameter(NonNullUtils
.checkNotNull(session
));