Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
ed902a2b | 2 | * Copyright (c) 2012, 2014 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 | **********************************************************************/ | |
12 | ||
9bc60be7 | 13 | package org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl; |
eb1bab5b | 14 | |
f0a2a4be | 15 | import java.util.ArrayList; |
eb1bab5b BH |
16 | import java.util.Iterator; |
17 | import java.util.List; | |
18 | ||
9bc60be7 AM |
19 | import org.eclipse.tracecompass.internal.lttng2.control.core.model.IBaseEventInfo; |
20 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages; | |
21 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent; | |
22 | import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.KernelProviderPropertySource; | |
06b9339e | 23 | import org.eclipse.ui.views.properties.IPropertySource; |
eb1bab5b BH |
24 | |
25 | /** | |
eb1bab5b | 26 | * <p> |
dbd4432d | 27 | * Implementation of the Kernel provider component. |
eb1bab5b | 28 | * </p> |
cfdb727a | 29 | * |
dbd4432d | 30 | * @author Bernd Hufmann |
eb1bab5b BH |
31 | */ |
32 | public class KernelProviderComponent extends TraceControlComponent { | |
cfdb727a | 33 | |
eb1bab5b BH |
34 | // ------------------------------------------------------------------------ |
35 | // Constants | |
36 | // ------------------------------------------------------------------------ | |
11252342 | 37 | |
eb1bab5b BH |
38 | /** |
39 | * Path to icon file for this component. | |
40 | */ | |
41 | public static final String KERNEL_PROVIDER_ICON_FILE = "icons/obj16/targets.gif"; //$NON-NLS-1$ | |
42 | ||
eb1bab5b BH |
43 | // ------------------------------------------------------------------------ |
44 | // Constructors | |
45 | // ------------------------------------------------------------------------ | |
11252342 | 46 | |
eb1bab5b | 47 | /** |
cfdb727a | 48 | * Constructor |
eb1bab5b BH |
49 | * @param name - the name of the component. |
50 | * @param parent - the parent of this component. | |
51 | */ | |
52 | public KernelProviderComponent(String name, ITraceControlComponent parent) { | |
53 | super(name, parent); | |
7b48c899 | 54 | setToolTip(Messages.TraceControl_ProviderDisplayName); |
eb1bab5b BH |
55 | setImage(KERNEL_PROVIDER_ICON_FILE); |
56 | } | |
cfdb727a | 57 | |
eb1bab5b BH |
58 | // ------------------------------------------------------------------------ |
59 | // Accessors | |
60 | // ------------------------------------------------------------------------ | |
11252342 | 61 | |
eb1bab5b | 62 | /** |
cfdb727a AM |
63 | * Sets the events information for this component. |
64 | * @param eventInfos - events information to set. | |
eb1bab5b BH |
65 | */ |
66 | public void setEventInfo(List<IBaseEventInfo> eventInfos) { | |
f0a2a4be | 67 | List<ITraceControlComponent> eventComponents = new ArrayList<>(); |
eb1bab5b | 68 | for (Iterator<IBaseEventInfo> iterator = eventInfos.iterator(); iterator.hasNext();) { |
cfdb727a | 69 | IBaseEventInfo baseEventInfo = iterator.next(); |
eb1bab5b BH |
70 | BaseEventComponent component = new BaseEventComponent(baseEventInfo.getName(), this); |
71 | component.setEventInfo(baseEventInfo); | |
f0a2a4be | 72 | eventComponents.add(component); |
eb1bab5b | 73 | } |
f0a2a4be | 74 | setChildren(eventComponents); |
eb1bab5b BH |
75 | } |
76 | ||
06b9339e | 77 | @Override |
e58fe1d5 | 78 | public <T> T getAdapter(Class<T> adapter) { |
06b9339e | 79 | if (adapter == IPropertySource.class) { |
e58fe1d5 | 80 | return adapter.cast(new KernelProviderPropertySource(this)); |
06b9339e BH |
81 | } |
82 | return null; | |
cfdb727a | 83 | } |
06b9339e | 84 | |
eb1bab5b | 85 | } |