Add capability to enable events with different parameters on session,
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / control / handlers / EnableEventOnSessionHandler.java
CommitLineData
498704b3
BH
1/**********************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12package org.eclipse.linuxtools.lttng.ui.views.control.handlers;
13
14import java.util.Iterator;
15import java.util.List;
16
17import org.eclipse.core.commands.ExecutionException;
18import org.eclipse.core.runtime.IProgressMonitor;
19import org.eclipse.jface.viewers.ISelection;
20import org.eclipse.jface.viewers.StructuredSelection;
21import org.eclipse.linuxtools.lttng.ui.views.control.ControlView;
ccc66d01
BH
22import org.eclipse.linuxtools.lttng.ui.views.control.model.LogLevelType;
23import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceLogLevel;
498704b3 24import org.eclipse.linuxtools.lttng.ui.views.control.model.TraceSessionState;
ccc66d01 25import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceDomainComponent;
498704b3
BH
26import org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceSessionComponent;
27import org.eclipse.ui.IWorkbenchPage;
28
29/**
30 * <b><u>EnableEventOnSessionHandler</u></b>
31 * <p>
32 * Command handler implementation to enable events for a known session and default channel 'channel0'
33 * (which will be created if doesn't exist).
34 * </p>
35 */
36public class EnableEventOnSessionHandler extends BaseEnableEventHandler {
37
38 // ------------------------------------------------------------------------
39 // Attributes
40 // ------------------------------------------------------------------------
41
42 //-------------------------------------------------------------------------
43 // Operations
44 // ------------------------------------------------------------------------
45 /*
46 * (non-Javadoc)
ccc66d01 47 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
498704b3
BH
48 */
49 @Override
ccc66d01
BH
50 public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
51 fSession.enableEvents(eventNames, isKernel, monitor);
498704b3
BH
52 }
53
54 /*
55 * (non-Javadoc)
56 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.core.runtime.IProgressMonitor)
57 */
58 @Override
ccc66d01 59 public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
498704b3
BH
60 fSession.enableSyscalls(monitor);
61 }
62
63 /*
64 * (non-Javadoc)
65 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
66 */
67 @Override
ccc66d01 68 public void enableProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
498704b3
BH
69 fSession.enableProbe(eventName, probe, monitor);
70 }
71
72 /*
73 * (non-Javadoc)
74 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableFunctionProbe(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
75 */
76 @Override
ccc66d01 77 public void enableFunctionProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
498704b3
BH
78 fSession.enableFunctionProbe(eventName, probe, monitor);
79 }
ccc66d01
BH
80
81 /*
82 * (non-Javadoc)
83 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(java.lang.String, org.eclipse.linuxtools.lttng.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.lttng.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
84 */
85 @Override
86 public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
87 fSession.enableLogLevel(eventName, logLevelType, level, monitor);
88 }
89
90
91 /*
92 * (non-Javadoc)
93 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#getDomain()
94 */
95 @Override
96 public TraceDomainComponent getDomain() {
97 return null;
98 }
498704b3
BH
99
100 /*
101 * (non-Javadoc)
102 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
103 */
104 @Override
105 public boolean isEnabled() {
106 // Get workbench page for the Control View
107 IWorkbenchPage page = getWorkbenchPage();
108 if (page == null) {
109 return false;
110 }
111
112 fSession = null;
113
114 // Check if one session is selected
115 ISelection selection = page.getSelection(ControlView.ID);
116 if (selection instanceof StructuredSelection) {
117 StructuredSelection structered = ((StructuredSelection) selection);
118 for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
119 Object element = (Object) iterator.next();
120 if (element instanceof TraceSessionComponent) {
ccc66d01 121 // Add only if corresponding TraceSessionComponents is inactive and not destroyed
498704b3
BH
122 TraceSessionComponent session = (TraceSessionComponent) element;
123 if(session.getSessionState() == TraceSessionState.INACTIVE && !session.isDestroyed()) {
124 fSession = session;
125 }
126 }
127 }
128 }
129 return fSession != null;
130 }
131}
This page took 0.029083 seconds and 5 git commands to generate.