ctf: Allow finalizing CTFTrace's if validation failed
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng2.ui / src / org / eclipse / linuxtools / internal / lttng2 / 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 **********************************************************************/
115b4a01 12package org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers;
498704b3
BH
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;
115b4a01
BH
21import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
22import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType;
23import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel;
24import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceSessionState;
25import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceDomainComponent;
26import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
498704b3
BH
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)
c56972bb 47 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
498704b3
BH
48 */
49 @Override
c56972bb
BH
50 public void enableEvents(CommandParameter param, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
51 param.getSession().enableEvents(eventNames, isKernel, monitor);
498704b3
BH
52 }
53
54 /*
55 * (non-Javadoc)
c56972bb 56 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, org.eclipse.core.runtime.IProgressMonitor)
498704b3
BH
57 */
58 @Override
c56972bb
BH
59 public void enableSyscalls(CommandParameter param, IProgressMonitor monitor) throws ExecutionException {
60 param.getSession().enableSyscalls(monitor);
498704b3
BH
61 }
62
63 /*
64 * (non-Javadoc)
c56972bb 65 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
498704b3
BH
66 */
67 @Override
c56972bb
BH
68 public void enableProbe(CommandParameter param, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
69 param.getSession().enableProbe(eventName, isFunction, probe, monitor);
498704b3
BH
70 }
71
72 /*
ccc66d01 73 * (non-Javadoc)
c56972bb 74 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
ccc66d01
BH
75 */
76 @Override
c56972bb
BH
77 public void enableLogLevel(CommandParameter param, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
78 param.getSession().enableLogLevel(eventName, logLevelType, level, monitor);
ccc66d01
BH
79 }
80
81
82 /*
83 * (non-Javadoc)
c56972bb 84 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#getDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter)
ccc66d01
BH
85 */
86 @Override
c56972bb 87 public TraceDomainComponent getDomain(CommandParameter param) {
ccc66d01
BH
88 return null;
89 }
498704b3
BH
90
91 /*
92 * (non-Javadoc)
93 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
94 */
95 @Override
96 public boolean isEnabled() {
97 // Get workbench page for the Control View
98 IWorkbenchPage page = getWorkbenchPage();
99 if (page == null) {
100 return false;
101 }
102
c56972bb 103 TraceSessionComponent session = null;
498704b3
BH
104 // Check if one session is selected
105 ISelection selection = page.getSelection(ControlView.ID);
106 if (selection instanceof StructuredSelection) {
107 StructuredSelection structered = ((StructuredSelection) selection);
108 for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
109 Object element = (Object) iterator.next();
110 if (element instanceof TraceSessionComponent) {
ccc66d01 111 // Add only if corresponding TraceSessionComponents is inactive and not destroyed
c56972bb
BH
112 TraceSessionComponent tmpSession = (TraceSessionComponent) element;
113 if(tmpSession.getSessionState() == TraceSessionState.INACTIVE && !tmpSession.isDestroyed()) {
114 session = tmpSession;
498704b3
BH
115 }
116 }
117 }
118 }
c56972bb
BH
119 boolean isEnabled = (session != null);
120 fLock.lock();
121 try {
122 fParam = null;
123 if(isEnabled) {
124 fParam = new CommandParameter(session);
125 }
126 } finally {
127 fLock.unlock();
128 }
129 return isEnabled;
498704b3
BH
130 }
131}
This page took 0.047489 seconds and 5 git commands to generate.