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
.lttng
.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
.lttng
.ui
.views
.control
.ControlView
;
22 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.impl
.TraceChannelComponent
;
23 import org
.eclipse
.ui
.IWorkbenchPage
;
26 * <b><u>EnableEventOnChannelHandler</u></b>
28 * Command handler implementation to enable events for a known channel.
31 public class EnableEventOnChannelHandler
extends BaseEnableEventHandler
{
33 // ------------------------------------------------------------------------
35 // ------------------------------------------------------------------------
37 * The channel component the command is to be executed on.
39 private TraceChannelComponent fChannel
= null;
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
46 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(java.util.List, org.eclipse.core.runtime.IProgressMonitor)
49 void enableEvents(List
<String
> eventNames
, IProgressMonitor monitor
) throws ExecutionException
{
50 fChannel
.enableEvents(eventNames
, monitor
);
55 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.core.runtime.IProgressMonitor)
58 void enableSyscalls(IProgressMonitor monitor
) throws ExecutionException
{
59 fChannel
.enableSyscalls(monitor
);
64 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
67 void enableProbe(String eventName
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
68 fChannel
.enableProbe(eventName
, probe
, monitor
);
73 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableFunctionProbe(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
76 void enableFunctionProbe(String eventName
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
77 fChannel
.enableFunctionProbe(eventName
, probe
, monitor
);
82 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
85 public boolean isEnabled() {
86 // Get workbench page for the Control View
87 IWorkbenchPage page
= getWorkbenchPage();
93 ISelection selection
= page
.getSelection(ControlView
.ID
);
94 if (selection
instanceof StructuredSelection
) {
95 StructuredSelection structered
= ((StructuredSelection
) selection
);
96 for (Iterator
<?
> iterator
= structered
.iterator(); iterator
.hasNext();) {
97 Object element
= (Object
) iterator
.next();
98 if (element
instanceof TraceChannelComponent
) {
99 fChannel
= (TraceChannelComponent
) element
;
100 fSession
= fChannel
.getSession();
104 return fChannel
!= null;