1 /**********************************************************************
2 * Copyright (c) 2012 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 **********************************************************************/
12 package org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.handlers
;
14 import java
.util
.Iterator
;
15 import java
.util
.List
;
17 import org
.eclipse
.core
.commands
.ExecutionException
;
18 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
19 import org
.eclipse
.jface
.viewers
.ISelection
;
20 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
21 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.ControlView
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.LogLevelType
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceLogLevel
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.TraceSessionState
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceChannelComponent
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceDomainComponent
;
27 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceSessionComponent
;
28 import org
.eclipse
.ui
.IWorkbenchPage
;
31 * <b><u>EnableEventOnChannelHandler</u></b>
33 * Command handler implementation to enable events for a known channel.
36 public class EnableEventOnChannelHandler
extends BaseEnableEventHandler
{
38 // ------------------------------------------------------------------------
40 // ------------------------------------------------------------------------
42 * The channel component the command is to be executed on.
44 private TraceChannelComponent fChannel
= null;
46 // ------------------------------------------------------------------------
48 // ------------------------------------------------------------------------
51 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
54 public void enableEvents(List
<String
> eventNames
, boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
55 fChannel
.enableEvents(eventNames
, monitor
);
60 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.core.runtime.IProgressMonitor)
63 public void enableSyscalls(IProgressMonitor monitor
) throws ExecutionException
{
64 fChannel
.enableSyscalls(monitor
);
69 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
72 public void enableProbe(String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
73 fChannel
.enableProbe(eventName
, isFunction
, probe
, monitor
);
78 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(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)
81 public void enableLogLevel(String eventName
, LogLevelType logLevelType
, TraceLogLevel level
, IProgressMonitor monitor
) throws ExecutionException
{
82 fChannel
.enableLogLevel(eventName
, logLevelType
, level
, monitor
);
87 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#getDomain()
90 public TraceDomainComponent
getDomain() {
91 return (TraceDomainComponent
) fChannel
.getParent();
96 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
99 public boolean isEnabled() {
100 // Get workbench page for the Control View
101 IWorkbenchPage page
= getWorkbenchPage();
107 ISelection selection
= page
.getSelection(ControlView
.ID
);
108 if (selection
instanceof StructuredSelection
) {
109 StructuredSelection structered
= ((StructuredSelection
) selection
);
110 for (Iterator
<?
> iterator
= structered
.iterator(); iterator
.hasNext();) {
111 Object element
= (Object
) iterator
.next();
112 if (element
instanceof TraceChannelComponent
) {
113 // Add only if corresponding TraceSessionComponents is inactive and not destroyed
114 TraceChannelComponent channel
= (TraceChannelComponent
) element
;
115 TraceSessionComponent session
= channel
.getSession();
116 if(session
.getSessionState() == TraceSessionState
.INACTIVE
&& !session
.isDestroyed()) {
123 return fChannel
!= null;