Commit | Line | Data |
---|---|---|
eb1bab5b BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2012 Ericsson | |
cfdb727a | 3 | * |
eb1bab5b BH |
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 | |
cfdb727a AM |
8 | * |
9 | * Contributors: | |
eb1bab5b BH |
10 | * Bernd Hufmann - Initial API and implementation |
11 | **********************************************************************/ | |
115b4a01 | 12 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl; |
eb1bab5b BH |
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.core.runtime.NullProgressMonitor; | |
9315aeee BH |
20 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo; |
21 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo; | |
22 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; | |
115b4a01 | 23 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent; |
eb1bab5b BH |
24 | |
25 | /** | |
eb1bab5b BH |
26 | * <p> |
27 | * Implementation of the trace provider group. | |
28 | * </p> | |
cfdb727a | 29 | * |
dbd4432d | 30 | * @author Bernd Hufmann |
eb1bab5b BH |
31 | */ |
32 | public class TraceProviderGroup extends TraceControlComponent { | |
33 | // ------------------------------------------------------------------------ | |
34 | // Constants | |
35 | // ------------------------------------------------------------------------ | |
36 | /** | |
37 | * Path to icon file for this component. | |
38 | */ | |
39 | public static final String TRACE_PROVIDERS_ICON_FILE = "icons/obj16/providers.gif"; //$NON-NLS-1$ | |
cfdb727a | 40 | |
eb1bab5b BH |
41 | // ------------------------------------------------------------------------ |
42 | // Attributes | |
43 | // ------------------------------------------------------------------------ | |
cfdb727a | 44 | |
eb1bab5b BH |
45 | // ------------------------------------------------------------------------ |
46 | // Constructors | |
47 | // ------------------------------------------------------------------------ | |
48 | /** | |
cfdb727a | 49 | * Constructor |
eb1bab5b BH |
50 | * @param name - the name of the component. |
51 | * @param parent - the parent of this component. | |
cfdb727a | 52 | */ |
eb1bab5b BH |
53 | public TraceProviderGroup(String name, ITraceControlComponent parent) { |
54 | super(name, parent); | |
55 | setImage(TRACE_PROVIDERS_ICON_FILE); | |
56 | } | |
cfdb727a | 57 | |
eb1bab5b BH |
58 | // ------------------------------------------------------------------------ |
59 | // Accessors | |
60 | // ------------------------------------------------------------------------ | |
61 | ||
62 | // ------------------------------------------------------------------------ | |
63 | // Operations | |
64 | // ------------------------------------------------------------------------ | |
cfdb727a | 65 | |
eb1bab5b BH |
66 | /** |
67 | * Gets the provider information from the target node. | |
cfdb727a | 68 | * @throws ExecutionException If the command fails |
eb1bab5b BH |
69 | */ |
70 | public void getProviderFromNode() throws ExecutionException { | |
71 | getProviderFromNode(new NullProgressMonitor()); | |
72 | } | |
73 | ||
74 | /** | |
75 | * Gets the provider information from the target node. | |
76 | * @param monitor - a progress monitor | |
cfdb727a | 77 | * @throws ExecutionException If the command fails |
eb1bab5b BH |
78 | */ |
79 | public void getProviderFromNode(IProgressMonitor monitor) throws ExecutionException { | |
cfdb727a | 80 | |
eb1bab5b | 81 | List<IBaseEventInfo> eventInfos = getControlService().getKernelProvider(monitor); |
a07c7629 BH |
82 | |
83 | if (!eventInfos.isEmpty()) { | |
84 | KernelProviderComponent component = new KernelProviderComponent(Messages.TraceControl_KernelProviderDisplayName, this); | |
85 | addChild(component); | |
86 | component.setEventInfo(eventInfos); | |
87 | } | |
cfdb727a | 88 | |
eb1bab5b | 89 | List<IUstProviderInfo> allProviders = getControlService().getUstProvider(monitor); |
cfdb727a | 90 | |
eb1bab5b | 91 | for (Iterator<IUstProviderInfo> iterator = allProviders.iterator(); iterator.hasNext();) { |
cfdb727a | 92 | IUstProviderInfo ustProviderInfo = iterator.next(); |
eb1bab5b BH |
93 | UstProviderComponent ustComponent = new UstProviderComponent(ustProviderInfo.getName(), this); |
94 | addChild(ustComponent); | |
95 | ustComponent.setUstProvider(ustProviderInfo); | |
96 | } | |
97 | } | |
a07c7629 BH |
98 | |
99 | /** | |
100 | * Returns whether the kernel provider is available or not | |
101 | * @return <code>true</code> if kernel provide is available or <code>false</code> | |
102 | */ | |
103 | public boolean hasKernelProvider() { | |
104 | List<ITraceControlComponent> kernelList = getChildren(KernelProviderComponent.class); | |
105 | return !kernelList.isEmpty(); | |
106 | } | |
eb1bab5b BH |
107 | } |
108 |