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
.TraceDomainType
;
25 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.ITraceLogLevel
;
26 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.LogLevelType
;
27 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
28 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.ControlView
;
29 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceDomainComponent
;
30 import org
.eclipse
.tracecompass
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceSessionComponent
;
31 import org
.eclipse
.ui
.IWorkbenchPage
;
35 * Command handler implementation to enable events for a known domain and default channel 'channel0'
36 * (which will be created if doesn't exist).
39 * @author Bernd Hufmann
41 public class EnableEventOnDomainHandler
extends BaseEnableEventHandler
{
43 // ------------------------------------------------------------------------
45 // ------------------------------------------------------------------------
48 public void enableEvents(CommandParameter param
, List
<String
> eventNames
, TraceDomainType domain
, String filterExression
, List
<String
> excludedEvents
, IProgressMonitor monitor
) throws ExecutionException
{
49 if (param
instanceof DomainCommandParameter
) {
50 ((DomainCommandParameter
)param
).getDomain().enableEvents(eventNames
, filterExression
, excludedEvents
, monitor
);
55 public void enableSyscalls(CommandParameter param
, List
<String
> syscallNames
, IProgressMonitor monitor
) throws ExecutionException
{
56 if (param
instanceof DomainCommandParameter
) {
57 ((DomainCommandParameter
)param
).getDomain().enableSyscalls(syscallNames
, monitor
);
62 public void enableProbe(CommandParameter param
, String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
63 if (param
instanceof DomainCommandParameter
) {
64 ((DomainCommandParameter
)param
).getDomain().enableProbe(eventName
, isFunction
, probe
, monitor
);
69 public void enableLogLevel(CommandParameter param
, List
<String
> eventNames
, LogLevelType logLevelType
, ITraceLogLevel level
, String filterExression
, TraceDomainType domain
, IProgressMonitor monitor
) throws ExecutionException
{
70 if (param
instanceof DomainCommandParameter
) {
71 ((DomainCommandParameter
)param
).getDomain().enableLogLevel(eventNames
, logLevelType
, level
, filterExression
, domain
, monitor
);
76 public TraceDomainComponent
getDomain(CommandParameter param
) {
77 if (param
instanceof DomainCommandParameter
) {
78 return ((DomainCommandParameter
)param
).getDomain();
84 public boolean isEnabled() {
85 // Get workbench page for the Control View
86 IWorkbenchPage page
= getWorkbenchPage();
91 TraceDomainComponent domain
= 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 TraceDomainComponent
) {
99 // Add only if corresponding TraceSessionComponents is inactive and not destroyed
100 TraceDomainComponent tmpDomain
= (TraceDomainComponent
) element
;
101 session
= tmpDomain
.getSession();
102 if(session
.getSessionState() == TraceSessionState
.INACTIVE
&& !session
.isDestroyed()) {
109 boolean isEnabled
= (domain
!= null);
114 fParam
= new DomainCommandParameter(checkNotNull(session
), checkNotNull(domain
));