Commit | Line | Data |
---|---|---|
eb1bab5b | 1 | /********************************************************************** |
11252342 | 2 | * Copyright (c) 2012, 2013 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 | ||
8e8c0226 | 13 | package org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.impl; |
eb1bab5b | 14 | |
8e8c0226 AM |
15 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.IBaseEventInfo; |
16 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.IUstProviderInfo; | |
17 | import org.eclipse.linuxtools.internal.lttng2.control.core.model.impl.UstProviderInfo; | |
18 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.messages.Messages; | |
19 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.model.ITraceControlComponent; | |
20 | import org.eclipse.linuxtools.internal.lttng2.control.ui.views.property.UstProviderPropertySource; | |
06b9339e | 21 | import 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 | */ |
30 | public 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 BH |
96 | @Override |
97 | public Object getAdapter(Class adapter) { | |
98 | if (adapter == IPropertySource.class) { | |
99 | return new UstProviderPropertySource(this); | |
100 | } | |
101 | return null; | |
ea21cd65 AM |
102 | } |
103 | ||
eb1bab5b | 104 | } |