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
.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
.IChannelInfo
;
22 import org
.eclipse
.linuxtools
.internal
.lttng2
.core
.control
.model
.TraceSessionState
;
23 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.ControlView
;
24 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceDomainComponent
;
25 import org
.eclipse
.linuxtools
.internal
.lttng2
.ui
.views
.control
.model
.impl
.TraceSessionComponent
;
26 import org
.eclipse
.ui
.IWorkbenchPage
;
30 * Command handler implementation to enable a trace channel for known domain.
33 * @author Bernd Hufmann
35 public class EnableChannelOnDomainHandler
extends BaseEnableChannelHandler
{
37 // ------------------------------------------------------------------------
39 // ------------------------------------------------------------------------
41 // ------------------------------------------------------------------------
43 // ------------------------------------------------------------------------
46 public void enableChannel(CommandParameter param
, List
<String
> channelNames
, IChannelInfo info
, boolean isKernel
, IProgressMonitor monitor
) throws ExecutionException
{
47 if (param
instanceof DomainCommandParameter
) {
48 ((DomainCommandParameter
)param
).getDomain().enableChannels(channelNames
, info
, monitor
);
53 public TraceDomainComponent
getDomain(CommandParameter param
) {
54 if (param
instanceof DomainCommandParameter
) {
55 return ((DomainCommandParameter
)param
).getDomain();
61 public boolean isEnabled() {
63 // Get workbench page for the Control View
64 IWorkbenchPage page
= getWorkbenchPage();
69 TraceDomainComponent domain
= null;
70 TraceSessionComponent session
= null;
72 // Check if one domain is selected
73 ISelection selection
= page
.getSelection(ControlView
.ID
);
74 if (selection
instanceof StructuredSelection
) {
75 StructuredSelection structered
= ((StructuredSelection
) selection
);
76 for (Iterator
<?
> iterator
= structered
.iterator(); iterator
.hasNext();) {
77 Object element
= iterator
.next();
78 if (element
instanceof TraceDomainComponent
) {
79 TraceDomainComponent tmpDomain
= (TraceDomainComponent
) element
;
80 session
= (TraceSessionComponent
) tmpDomain
.getParent();
82 // Add only TraceDomainComponent whose TraceSessionComponent parent is inactive and not destroyed
83 if ((session
.getSessionState() == TraceSessionState
.INACTIVE
) && (!session
.isDestroyed())) {
90 boolean isEnabled
= domain
!= null;
96 fParam
= new DomainCommandParameter(session
, domain
);