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
.LogLevelType
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceLogLevel
;
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 domain and default channel 'channel0'
35 * (which will be created if doesn't exist).
38 * @author Bernd Hufmann
40 public class EnableEventOnDomainHandler
extends BaseEnableEventHandler
{
42 // ------------------------------------------------------------------------
44 // ------------------------------------------------------------------------
47 public void enableEvents(CommandParameter param
, List
<String
> eventNames
, boolean isKernel
, String filterExression
, IProgressMonitor monitor
) throws ExecutionException
{
48 if (param
instanceof DomainCommandParameter
) {
49 ((DomainCommandParameter
)param
).getDomain().enableEvents(eventNames
, monitor
);
54 public void enableSyscalls(CommandParameter param
, IProgressMonitor monitor
) throws ExecutionException
{
55 if (param
instanceof DomainCommandParameter
) {
56 ((DomainCommandParameter
)param
).getDomain().enableSyscalls(monitor
);
61 public void enableProbe(CommandParameter param
, String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
62 if (param
instanceof DomainCommandParameter
) {
63 ((DomainCommandParameter
)param
).getDomain().enableProbe(eventName
, isFunction
, probe
, monitor
);
68 public void enableLogLevel(CommandParameter param
, String eventName
, LogLevelType logLevelType
, TraceLogLevel level
, String filterExression
, IProgressMonitor monitor
) throws ExecutionException
{
69 if (param
instanceof DomainCommandParameter
) {
70 ((DomainCommandParameter
)param
).getDomain().enableLogLevel(eventName
, logLevelType
, level
, filterExression
, monitor
);
75 public TraceDomainComponent
getDomain(CommandParameter param
) {
76 if (param
instanceof DomainCommandParameter
) {
77 return ((DomainCommandParameter
)param
).getDomain();
83 public boolean isEnabled() {
84 // Get workbench page for the Control View
85 IWorkbenchPage page
= getWorkbenchPage();
90 TraceDomainComponent domain
= null;
91 TraceSessionComponent session
= null;
92 ISelection selection
= page
.getSelection(ControlView
.ID
);
93 if (selection
instanceof StructuredSelection
) {
94 StructuredSelection structered
= ((StructuredSelection
) selection
);
95 for (Iterator
<?
> iterator
= structered
.iterator(); iterator
.hasNext();) {
96 Object element
= iterator
.next();
97 if (element
instanceof TraceDomainComponent
) {
98 // Add only if corresponding TraceSessionComponents is inactive and not destroyed
99 TraceDomainComponent tmpDomain
= (TraceDomainComponent
) element
;
100 session
= tmpDomain
.getSession();
101 if(session
.getSessionState() == TraceSessionState
.INACTIVE
&& !session
.isDestroyed()) {
108 boolean isEnabled
= (domain
!= null);
113 fParam
= new DomainCommandParameter(checkNotNull(session
), checkNotNull(domain
));