Merge branch 'master' into lttng_2_0_control_dev
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / internal / lttng / ui / views / control / handlers / EnableEventOnDomainHandler.java
CommitLineData
498704b3
BH
1/**********************************************************************
2 * Copyright (c) 2012 Ericsson
3 *
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
8 *
9 * Contributors:
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
31a6a4e4 12package org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers;
498704b3
BH
13
14import java.util.Iterator;
15import java.util.List;
16
17import org.eclipse.core.commands.ExecutionException;
18import org.eclipse.core.runtime.IProgressMonitor;
19import org.eclipse.jface.viewers.ISelection;
20import org.eclipse.jface.viewers.StructuredSelection;
31a6a4e4
BH
21import org.eclipse.linuxtools.internal.lttng.ui.views.control.ControlView;
22import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType;
23import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel;
24import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceSessionState;
25import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceDomainComponent;
26import org.eclipse.linuxtools.internal.lttng.ui.views.control.model.impl.TraceSessionComponent;
498704b3
BH
27import org.eclipse.ui.IWorkbenchPage;
28
29/**
30 * <b><u>EnableEventOnDomainHandler</u></b>
31 * <p>
32 * Command handler implementation to enable events for a known domain and default channel 'channel0'
33 * (which will be created if doesn't exist).
34 * </p>
35 */
36public class EnableEventOnDomainHandler extends BaseEnableEventHandler {
37
38 // ------------------------------------------------------------------------
39 // Attributes
40 // ------------------------------------------------------------------------
41 /**
42 * The domain component the command is to be executed on.
43 */
44 private TraceDomainComponent fDomain = null;
45
46 // ------------------------------------------------------------------------
47 // Operations
48 // ------------------------------------------------------------------------
49 /*
50 * (non-Javadoc)
31a6a4e4 51 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
498704b3
BH
52 */
53 @Override
ccc66d01 54 public void enableEvents(List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
498704b3
BH
55 fDomain.enableEvents(eventNames, monitor);
56 }
57
58 /*
59 * (non-Javadoc)
31a6a4e4 60 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.core.runtime.IProgressMonitor)
498704b3
BH
61 */
62 @Override
ccc66d01 63 public void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
498704b3
BH
64 fDomain.enableSyscalls(monitor);
65 }
66
67 /*
68 * (non-Javadoc)
31a6a4e4 69 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
498704b3
BH
70 */
71 @Override
d132bcc7
BH
72 public void enableProbe(String eventName, boolean isFunction, String probe, IProgressMonitor monitor) throws ExecutionException {
73 fDomain.enableProbe(eventName, isFunction, probe, monitor);
498704b3
BH
74 }
75
ccc66d01
BH
76 /*
77 * (non-Javadoc)
31a6a4e4 78 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(java.lang.String, org.eclipse.linuxtools.internal.lttng.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
ccc66d01
BH
79 */
80 @Override
81 public void enableLogLevel(String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
82 fDomain.enableLogLevel(eventName, logLevelType, level, monitor);
83 }
84
85 /*
86 * (non-Javadoc)
31a6a4e4 87 * @see org.eclipse.linuxtools.internal.lttng.ui.views.control.handlers.BaseEnableEventHandler#getDomain()
ccc66d01
BH
88 */
89 @Override
90 public TraceDomainComponent getDomain() {
91 return fDomain;
92 }
498704b3
BH
93 /*
94 * (non-Javadoc)
95 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
96 */
97 @Override
98 public boolean isEnabled() {
99 // Get workbench page for the Control View
100 IWorkbenchPage page = getWorkbenchPage();
101 if (page == null) {
102 return false;
103 }
104
105 fDomain = null;
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 TraceDomainComponent) {
ccc66d01 112 // Add only if corresponding TraceSessionComponents is inactive and not destroyed
498704b3
BH
113 TraceDomainComponent domain = (TraceDomainComponent) element;
114 TraceSessionComponent session = domain.getSession();
ccc66d01 115 if(session.getSessionState() == TraceSessionState.INACTIVE && !session.isDestroyed()) {
498704b3
BH
116 fDomain = domain;
117 fSession = session;
118 }
119 }
120 }
121 }
122 return fDomain != null;
123 }
124}
This page took 0.039861 seconds and 5 git commands to generate.