lttng.control: Add support for enabling syscall by name
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / handlers / EnableEventOnSessionHandler.java
CommitLineData
498704b3 1/**********************************************************************
68d1057b 2 * Copyright (c) 2012, 2015 Ericsson
cfdb727a 3 *
498704b3
BH
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
cfdb727a
AM
8 *
9 * Contributors:
498704b3 10 * Bernd Hufmann - Initial API and implementation
ba3a9bd2 11 * Bernd Hufmann - Updated for support of LTTng Tools 2.1
498704b3 12 **********************************************************************/
9bc60be7 13package org.eclipse.tracecompass.internal.lttng2.control.ui.views.handlers;
498704b3
BH
14
15import java.util.Iterator;
16import java.util.List;
17
18import org.eclipse.core.commands.ExecutionException;
19import org.eclipse.core.runtime.IProgressMonitor;
20import org.eclipse.jface.viewers.ISelection;
21import org.eclipse.jface.viewers.StructuredSelection;
68d1057b 22import org.eclipse.tracecompass.common.core.NonNullUtils;
1bc37054 23import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceDomainType;
a20452b1 24import org.eclipse.tracecompass.internal.lttng2.control.core.model.ITraceLogLevel;
9bc60be7 25import org.eclipse.tracecompass.internal.lttng2.control.core.model.LogLevelType;
9bc60be7
AM
26import org.eclipse.tracecompass.internal.lttng2.control.core.model.TraceSessionState;
27import org.eclipse.tracecompass.internal.lttng2.control.ui.views.ControlView;
28import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceDomainComponent;
29import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl.TraceSessionComponent;
498704b3
BH
30import org.eclipse.ui.IWorkbenchPage;
31
32/**
498704b3
BH
33 * <p>
34 * Command handler implementation to enable events for a known session and default channel 'channel0'
35 * (which will be created if doesn't exist).
36 * </p>
cfdb727a 37 *
dbd4432d 38 * @author Bernd Hufmann
498704b3
BH
39 */
40public class EnableEventOnSessionHandler extends BaseEnableEventHandler {
41
42 // ------------------------------------------------------------------------
43 // Attributes
44 // ------------------------------------------------------------------------
cfdb727a 45
498704b3
BH
46 //-------------------------------------------------------------------------
47 // Operations
48 // ------------------------------------------------------------------------
11252342 49
498704b3 50 @Override
1bc37054
BR
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);
498704b3
BH
53 }
54
498704b3 55 @Override
207ff523
BR
56 public void enableSyscalls(CommandParameter param, List<String> syscallNames, IProgressMonitor monitor) throws ExecutionException {
57 param.getSession().enableSyscalls(syscallNames, monitor);
498704b3
BH
58 }
59
498704b3 60 @Override
c56972bb
BH
61 public void enableProbe(CommandParameter param, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
62 param.getSession().enableProbe(eventName, isFunction, probe, monitor);
498704b3
BH
63 }
64
ccc66d01 65 @Override
a20452b1
BR
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);
ccc66d01
BH
68 }
69
ccc66d01 70 @Override
c56972bb 71 public TraceDomainComponent getDomain(CommandParameter param) {
ccc66d01
BH
72 return null;
73 }
498704b3 74
498704b3
BH
75 @Override
76 public boolean isEnabled() {
77 // Get workbench page for the Control View
78 IWorkbenchPage page = getWorkbenchPage();
79 if (page == null) {
80 return false;
81 }
82
c56972bb 83 TraceSessionComponent session = null;
498704b3
BH
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();) {
cfdb727a 89 Object element = iterator.next();
498704b3 90 if (element instanceof TraceSessionComponent) {
ccc66d01 91 // Add only if corresponding TraceSessionComponents is inactive and not destroyed
cfdb727a 92 TraceSessionComponent tmpSession = (TraceSessionComponent) element;
c56972bb
BH
93 if(tmpSession.getSessionState() == TraceSessionState.INACTIVE && !tmpSession.isDestroyed()) {
94 session = tmpSession;
498704b3
BH
95 }
96 }
97 }
98 }
c56972bb
BH
99 boolean isEnabled = (session != null);
100 fLock.lock();
101 try {
102 fParam = null;
103 if(isEnabled) {
68d1057b 104 fParam = new CommandParameter(NonNullUtils.checkNotNull(session));
c56972bb
BH
105 }
106 } finally {
107 fLock.unlock();
108 }
109 return isEnabled;
498704b3
BH
110 }
111}
This page took 0.171952 seconds and 5 git commands to generate.