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
.TraceSessionState
;
23 import org
.eclipse
.linuxtools
.lttng
.ui
.views
.control
.model
.impl
.TraceSessionComponent
;
24 import org
.eclipse
.ui
.IWorkbenchPage
;
27 * <b><u>EnableEventOnSessionHandler</u></b>
29 * Command handler implementation to enable events for a known session and default channel 'channel0'
30 * (which will be created if doesn't exist).
33 public class EnableEventOnSessionHandler
extends BaseEnableEventHandler
{
35 // ------------------------------------------------------------------------
37 // ------------------------------------------------------------------------
39 //-------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
44 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(java.util.List, org.eclipse.core.runtime.IProgressMonitor)
47 void enableEvents(List
<String
> eventNames
, IProgressMonitor monitor
) throws ExecutionException
{
48 fSession
.enableEvents(eventNames
, true, monitor
);
53 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.core.runtime.IProgressMonitor)
56 void enableSyscalls(IProgressMonitor monitor
) throws ExecutionException
{
57 fSession
.enableSyscalls(monitor
);
62 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
65 void enableProbe(String eventName
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
66 fSession
.enableProbe(eventName
, probe
, monitor
);
71 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableFunctionProbe(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
74 void enableFunctionProbe(String eventName
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
75 fSession
.enableFunctionProbe(eventName
, probe
, monitor
);
80 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
83 public boolean isEnabled() {
84 // Get workbench page for the Control View
85 IWorkbenchPage page
= getWorkbenchPage();
92 // Check if one session is selected
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 TraceSessionComponent
) {
99 // Add only TraceSessionComponents is inactive and not destroyed
100 TraceSessionComponent session
= (TraceSessionComponent
) element
;
101 if(session
.getSessionState() == TraceSessionState
.INACTIVE
&& !session
.isDestroyed()) {
107 return fSession
!= null;