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 / UstProviderComponent.java
CommitLineData
eb1bab5b 1/**********************************************************************
ed902a2b 2 * Copyright (c) 2012, 2014 Ericsson
ea21cd65 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
ea21cd65
AM
8 *
9 * Contributors:
eb1bab5b
BH
10 * Bernd Hufmann - Initial API and implementation
11 **********************************************************************/
12
9bc60be7 13package org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl;
eb1bab5b 14
9bc60be7
AM
15import org.eclipse.tracecompass.internal.lttng2.control.core.model.IBaseEventInfo;
16import org.eclipse.tracecompass.internal.lttng2.control.core.model.IUstProviderInfo;
17import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.UstProviderInfo;
18import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
19import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
20import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.UstProviderPropertySource;
06b9339e 21import org.eclipse.ui.views.properties.IPropertySource;
eb1bab5b
BH
22
23/**
eb1bab5b
BH
24 * <p>
25 * Implementation of the UST provider component.
26 * </p>
ea21cd65 27 *
dbd4432d 28 * @author Bernd Hufmann
eb1bab5b
BH
29 */
30public class UstProviderComponent extends TraceControlComponent {
ea21cd65 31
eb1bab5b
BH
32 // ------------------------------------------------------------------------
33 // Constants
34 // ------------------------------------------------------------------------
35 /**
36 * Path to icon file for this component.
37 */
38 public static final String USTL_PROVIDER_ICON_FILE = "icons/obj16/targets.gif"; //$NON-NLS-1$
ea21cd65 39
eb1bab5b
BH
40 // ------------------------------------------------------------------------
41 // Attributes
42 // ------------------------------------------------------------------------
43 /**
44 * The UST provider information.
45 */
46 private IUstProviderInfo fProviderInfo = null;
ea21cd65 47
eb1bab5b
BH
48 // ------------------------------------------------------------------------
49 // Constructors
50 // ------------------------------------------------------------------------
51 /**
ea21cd65 52 * Constructor
eb1bab5b
BH
53 * @param name - the name of the component.
54 * @param parent - the parent of this component.
ea21cd65 55 */
eb1bab5b
BH
56 public UstProviderComponent(String name, ITraceControlComponent parent) {
57 super(name, parent);
58 setImage(USTL_PROVIDER_ICON_FILE);
7b48c899 59 setToolTip(Messages.TraceControl_ProviderDisplayName);
eb1bab5b
BH
60 fProviderInfo = new UstProviderInfo(name);
61 }
62
63 // ------------------------------------------------------------------------
64 // Accessors
65 // ------------------------------------------------------------------------
66 /**
ea21cd65 67 * Sets the UST provider information to the given value.
eb1bab5b
BH
68 * @param providerInfo - the provider information to set
69 */
70 public void setUstProvider(IUstProviderInfo providerInfo) {
71 fProviderInfo = providerInfo;
72 IBaseEventInfo[] events = providerInfo.getEvents();
73 for (int i = 0; i < events.length; i++) {
74 BaseEventComponent component = new BaseEventComponent(events[i].getName(), this);
75 component.setEventInfo(events[i]);
76 addChild(component);
77 }
7b48c899 78 setName(getName() + " [PID=" + fProviderInfo.getPid() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
eb1bab5b 79 }
ea21cd65 80
eb1bab5b
BH
81 /**
82 * @return the process ID of the UST provider.
83 */
84 public int getPid() {
85 return fProviderInfo.getPid();
86 }
87
88 /**
89 * Sets the process ID of the UST provider to the given value.
90 * @param pid - process ID to set
91 */
92 public void setPid(int pid) {
93 fProviderInfo.setPid(pid);
94 }
95
06b9339e 96 @Override
e58fe1d5 97 public <T> T getAdapter(Class<T> adapter) {
06b9339e 98 if (adapter == IPropertySource.class) {
e58fe1d5 99 return adapter.cast(new UstProviderPropertySource(this));
06b9339e
BH
100 }
101 return null;
ea21cd65
AM
102 }
103
eb1bab5b 104}
This page took 0.070506 seconds and 5 git commands to generate.