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