Merge branch 'master' into lttng_2_0_control_dev
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.ui / src / org / eclipse / linuxtools / lttng / ui / views / control / handlers / EnableEventOnChannelHandler.java
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 **********************************************************************/
12 package org.eclipse.linuxtools.lttng.ui.views.control.handlers;
13
14 import java.util.Iterator;
15 import java.util.List;
16
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.impl.TraceChannelComponent;
23 import org.eclipse.ui.IWorkbenchPage;
24
25 /**
26 * <b><u>EnableEventOnChannelHandler</u></b>
27 * <p>
28 * Command handler implementation to enable events for a known channel.
29 * </p>
30 */
31 public class EnableEventOnChannelHandler extends BaseEnableEventHandler {
32
33 // ------------------------------------------------------------------------
34 // Attributes
35 // ------------------------------------------------------------------------
36 /**
37 * The channel component the command is to be executed on.
38 */
39 private TraceChannelComponent fChannel = null;
40
41 // ------------------------------------------------------------------------
42 // Operations
43 // ------------------------------------------------------------------------
44 /*
45 * (non-Javadoc)
46 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(java.util.List, org.eclipse.core.runtime.IProgressMonitor)
47 */
48 @Override
49 void enableEvents(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException {
50 fChannel.enableEvents(eventNames, monitor);
51 }
52
53 /*
54 * (non-Javadoc)
55 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableSyscalls(org.eclipse.core.runtime.IProgressMonitor)
56 */
57 @Override
58 void enableSyscalls(IProgressMonitor monitor) throws ExecutionException {
59 fChannel.enableSyscalls(monitor);
60 }
61
62 /*
63 * (non-Javadoc)
64 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableProbe(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
65 */
66 @Override
67 void enableProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
68 fChannel.enableProbe(eventName, probe, monitor);
69 }
70
71 /*
72 * (non-Javadoc)
73 * @see org.eclipse.linuxtools.lttng.ui.views.control.handlers.BaseEnableEventHandler#enableFunctionProbe(java.lang.String, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
74 */
75 @Override
76 void enableFunctionProbe(String eventName, String probe, IProgressMonitor monitor) throws ExecutionException {
77 fChannel.enableFunctionProbe(eventName, probe, monitor);
78 }
79
80 /*
81 * (non-Javadoc)
82 * @see org.eclipse.core.commands.AbstractHandler#isEnabled()
83 */
84 @Override
85 public boolean isEnabled() {
86 // Get workbench page for the Control View
87 IWorkbenchPage page = getWorkbenchPage();
88 if (page == null) {
89 return false;
90 }
91
92 fChannel = null;
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 TraceChannelComponent) {
99 fChannel = (TraceChannelComponent) element;
100 fSession = fChannel.getSession();
101 }
102 }
103 }
104 return fChannel != null;
105 }
106
107 }
This page took 0.03306 seconds and 6 git commands to generate.