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
.core
.control
.model
.LogLevelType
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceLogLevel
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceSessionState
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.ControlView
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceDomainComponent
;
26 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceSessionComponent
;
27 import org
.eclipse
.ui
.IWorkbenchPage
;
31 * Command handler implementation to enable events for a known session and default channel 'channel0'
32 * (which will be created if doesn't exist).
35 * @author Bernd Hufmann
37 public class EnableEventOnSessionHandler
extends BaseEnableEventHandler
{
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
43 //-------------------------------------------------------------------------
45 // ------------------------------------------------------------------------
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)
51 public void enableEvents(CommandParameter param
, List
<String
> eventNames
, boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
52 param
.getSession().enableEvents(eventNames
, isKernel
, monitor
);
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)
60 public void enableSyscalls(CommandParameter param
, IProgressMonitor monitor
) throws ExecutionException
{
61 param
.getSession().enableSyscalls(monitor
);
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)
69 public void enableProbe(CommandParameter param
, String eventName
, boolean isFunction
, String probe
, IProgressMonitor monitor
) throws ExecutionException
{
70 param
.getSession().enableProbe(eventName
, isFunction
, probe
, monitor
);
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)
78 public void enableLogLevel(CommandParameter param
, String eventName
, LogLevelType logLevelType
, TraceLogLevel level
, IProgressMonitor monitor
) throws ExecutionException
{
79 param
.getSession().enableLogLevel(eventName
, logLevelType
, level
, monitor
);
85 * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#getDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter)
88 public TraceDomainComponent
getDomain(CommandParameter param
) {
94 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
97 public boolean isEnabled() {
98 // Get workbench page for the Control View
99 IWorkbenchPage page
= getWorkbenchPage();
104 TraceSessionComponent session
= null;
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();) {
110 Object element
= (Object
) iterator
.next();
111 if (element
instanceof TraceSessionComponent
) {
112 // Add only if corresponding TraceSessionComponents is inactive and not destroyed
113 TraceSessionComponent tmpSession
= (TraceSessionComponent
) element
;
114 if(tmpSession
.getSessionState() == TraceSessionState
.INACTIVE
&& !tmpSession
.isDestroyed()) {
115 session
= tmpSession
;
120 boolean isEnabled
= (session
!= null);
125 fParam
= new CommandParameter(session
);