lttng: Fix Javadoc and formatting in lttng2.ui
[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
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
BH
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;
9315aeee
BH
21import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType;
22import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
23import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceSessionState;
115b4a01 24import org.eclipse.linuxtools.internal.lttng2.ui.views.control.ControlView;
115b4a01
BH
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/**
498704b3
BH
30 * <p>
31 * Command handler implementation to enable events for a known session and default channel 'channel0'
32 * (which will be created if doesn't exist).
33 * </p>
cfdb727a 34 *
dbd4432d 35 * @author Bernd Hufmann
498704b3
BH
36 */
37public class EnableEventOnSessionHandler extends BaseEnableEventHandler {
38
39 // ------------------------------------------------------------------------
40 // Attributes
41 // ------------------------------------------------------------------------
cfdb727a 42
498704b3
BH
43 //-------------------------------------------------------------------------
44 // Operations
45 // ------------------------------------------------------------------------
46 /*
47 * (non-Javadoc)
c56972bb 48 * @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
49 */
50 @Override
c56972bb
BH
51 public void enableEvents(CommandParameter param, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
52 param.getSession().enableEvents(eventNames, isKernel, monitor);
498704b3
BH
53 }
54
55 /*
56 * (non-Javadoc)
c56972bb 57 * @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
58 */
59 @Override
c56972bb
BH
60 public void enableSyscalls(CommandParameter param, IProgressMonitor monitor) throws ExecutionException {
61 param.getSession().enableSyscalls(monitor);
498704b3
BH
62 }
63
64 /*
65 * (non-Javadoc)
c56972bb 66 * @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
67 */
68 @Override
c56972bb
BH
69 public void enableProbe(CommandParameter param, String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
70 param.getSession().enableProbe(eventName, isFunction, probe, monitor);
498704b3
BH
71 }
72
73 /*
ccc66d01 74 * (non-Javadoc)
c56972bb 75 * @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
76 */
77 @Override
c56972bb
BH
78 public void enableLogLevel(CommandParameter param, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
79 param.getSession().enableLogLevel(eventName, logLevelType, level, monitor);
ccc66d01
BH
80 }
81
cfdb727a 82
ccc66d01
BH
83 /*
84 * (non-Javadoc)
c56972bb 85 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#getDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter)
ccc66d01
BH
86 */
87 @Override
c56972bb 88 public TraceDomainComponent getDomain(CommandParameter param) {
ccc66d01
BH
89 return null;
90 }
498704b3
BH
91
92 /*
93 * (non-Javadoc)
94 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
95 */
96 @Override
97 public boolean isEnabled() {
98 // Get workbench page for the Control View
99 IWorkbenchPage page = getWorkbenchPage();
100 if (page == null) {
101 return false;
102 }
103
c56972bb 104 TraceSessionComponent session = null;
498704b3
BH
105 // Check if one session is selected
106 ISelection selection = page.getSelection(ControlView.ID);
107 if (selection instanceof StructuredSelection) {
108 StructuredSelection structered = ((StructuredSelection) selection);
109 for (Iterator<?> iterator = structered.iterator(); iterator.hasNext();) {
cfdb727a 110 Object element = iterator.next();
498704b3 111 if (element instanceof TraceSessionComponent) {
ccc66d01 112 // Add only if corresponding TraceSessionComponents is inactive and not destroyed
cfdb727a 113 TraceSessionComponent tmpSession = (TraceSessionComponent) element;
c56972bb
BH
114 if(tmpSession.getSessionState() == TraceSessionState.INACTIVE && !tmpSession.isDestroyed()) {
115 session = tmpSession;
498704b3
BH
116 }
117 }
118 }
119 }
c56972bb
BH
120 boolean isEnabled = (session != null);
121 fLock.lock();
122 try {
123 fParam = null;
124 if(isEnabled) {
125 fParam = new CommandParameter(session);
126 }
127 } finally {
128 fLock.unlock();
129 }
130 return isEnabled;
498704b3
BH
131 }
132}
This page took 0.049553 seconds and 5 git commands to generate.