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
.TraceDomainType
;
24 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ITraceLogLevel
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
26 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
27 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.ControlView
;
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 session and default channel 'channel0'
35 * (which will be created if doesn't exist).
38 * @author Bernd Hufmann
40 public class EnableEventOnSessionHandler
extends BaseEnableEventHandler
{
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
46 //-------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
51 public void enableEvents(CommandParameter param
, List
<String
> eventNames
, TraceDomainType domain
, String filterExpression
, List
<String
> excludedEvents
, IProgressMonitor monitor
) throws ExecutionException
{
52 param
.getSession().enableEvents(eventNames
, domain
, filterExpression
, excludedEvents
, monitor
);
56 public void enableSyscalls(CommandParameter param
, List
<String
> syscallNames
, IProgressMonitor monitor
) throws ExecutionException
{
57 param
.getSession().enableSyscalls(syscallNames
, monitor
);
61 public void enableProbe(CommandParameter param
, String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
62 param
.getSession().enableProbe(eventName
, isFunction
, probe
, monitor
);
66 public void enableLogLevel(CommandParameter param
, List
<String
> eventNames
, LogLevelType logLevelType
, ITraceLogLevel level
, String filterExpression
, TraceDomainType domain
, IProgressMonitor monitor
) throws ExecutionException
{
67 param
.getSession().enableLogLevel(eventNames
, logLevelType
, level
, filterExpression
, domain
, monitor
);
71 public TraceDomainComponent
getDomain(CommandParameter param
) {
76 public boolean isEnabled() {
77 // Get workbench page for the Control View
78 IWorkbenchPage page
= getWorkbenchPage();
83 TraceSessionComponent session
= null;
84 // Check if one session is selected
85 ISelection selection
= page
.getSelection(ControlView
.ID
);
86 if (selection
instanceof StructuredSelection
) {
87 StructuredSelection structered
= ((StructuredSelection
) selection
);
88 for (Iterator
<?
> iterator
= structered
.iterator(); iterator
.hasNext();) {
89 Object element
= iterator
.next();
90 if (element
instanceof TraceSessionComponent
) {
91 // Add only if corresponding TraceSessionComponents is inactive and not destroyed
92 TraceSessionComponent tmpSession
= (TraceSessionComponent
) element
;
93 if(tmpSession
.getSessionState() == TraceSessionState
.INACTIVE
&& !tmpSession
.isDestroyed()) {
99 boolean isEnabled
= (session
!= null);
104 fParam
= new CommandParameter(NonNullUtils
.checkNotNull(session
));