1 /**********************************************************************
2 * Copyright (c) 2012, 2013 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
.control
.ui
.views
.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
.control
.core
.model
.IChannelInfo
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.core
.model
.TraceSessionState
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.ControlView
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceDomainComponent
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.control
.ui
.views
.model
.impl
.TraceSessionComponent
;
26 import org
.eclipse
.ui
.IWorkbenchPage
;
30 * Command handler implementation to enable a trace channel for unknown domain
34 * @author Bernd Hufmann
36 public class EnableChannelOnSessionHandler
extends BaseEnableChannelHandler
{
38 // ------------------------------------------------------------------------
40 // ------------------------------------------------------------------------
43 public void enableChannel(CommandParameter param
, List
<String
> channelNames
, IChannelInfo info
, boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
44 param
.getSession().enableChannels(channelNames
, info
, isKernel
, monitor
);
48 public TraceDomainComponent
getDomain(CommandParameter param
) {
52 // ------------------------------------------------------------------------
54 // ------------------------------------------------------------------------
57 public boolean isEnabled() {
58 // Get workbench page for the Control View
59 IWorkbenchPage page
= getWorkbenchPage();
64 TraceSessionComponent session
= null;
65 // Check if one session is selected
66 ISelection selection
= page
.getSelection(ControlView
.ID
);
67 if (selection
instanceof StructuredSelection
) {
68 StructuredSelection structered
= ((StructuredSelection
) selection
);
69 for (Iterator
<?
> iterator
= structered
.iterator(); iterator
.hasNext();) {
70 Object element
= iterator
.next();
71 if (element
instanceof TraceSessionComponent
) {
72 // Add only TraceSessionComponents that are inactive and not destroyed
73 TraceSessionComponent tmpSession
= (TraceSessionComponent
) element
;
74 if ((tmpSession
.getSessionState() == TraceSessionState
.INACTIVE
) && (!tmpSession
.isDestroyed())) {
80 boolean isEnabled
= session
!= null;
86 fParam
= new CommandParameter(session
);