Commit | Line | Data |
---|---|---|
eb1bab5b BH |
1 | /********************************************************************** |
2 | * Copyright (c) 2012 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.linuxtools.lttng.ui.views.control.model.impl; | |
14 | ||
15 | import org.eclipse.linuxtools.lttng.ui.views.control.model.IBaseEventInfo; | |
16 | import org.eclipse.linuxtools.lttng.ui.views.control.model.ITraceControlComponent; | |
17 | import org.eclipse.linuxtools.lttng.ui.views.control.model.IUstProviderInfo; | |
06b9339e BH |
18 | import org.eclipse.linuxtools.lttng.ui.views.control.property.UstProviderPropertySource; |
19 | import org.eclipse.ui.views.properties.IPropertySource; | |
eb1bab5b BH |
20 | |
21 | /** | |
22 | * <b><u>UstProviderComponent</u></b> | |
23 | * <p> | |
24 | * Implementation of the UST provider component. | |
25 | * </p> | |
26 | */ | |
27 | public class UstProviderComponent extends TraceControlComponent { | |
28 | ||
29 | // ------------------------------------------------------------------------ | |
30 | // Constants | |
31 | // ------------------------------------------------------------------------ | |
32 | /** | |
33 | * Path to icon file for this component. | |
34 | */ | |
35 | public static final String USTL_PROVIDER_ICON_FILE = "icons/obj16/targets.gif"; //$NON-NLS-1$ | |
36 | ||
37 | // ------------------------------------------------------------------------ | |
38 | // Attributes | |
39 | // ------------------------------------------------------------------------ | |
40 | /** | |
41 | * The UST provider information. | |
42 | */ | |
43 | private IUstProviderInfo fProviderInfo = null; | |
44 | ||
45 | // ------------------------------------------------------------------------ | |
46 | // Constructors | |
47 | // ------------------------------------------------------------------------ | |
48 | /** | |
49 | * Constructor | |
50 | * @param name - the name of the component. | |
51 | * @param parent - the parent of this component. | |
52 | */ | |
53 | public UstProviderComponent(String name, ITraceControlComponent parent) { | |
54 | super(name, parent); | |
55 | setImage(USTL_PROVIDER_ICON_FILE); | |
56 | fProviderInfo = new UstProviderInfo(name); | |
57 | } | |
58 | ||
59 | // ------------------------------------------------------------------------ | |
60 | // Accessors | |
61 | // ------------------------------------------------------------------------ | |
62 | /** | |
63 | * Sets the UST provider information to the given value. | |
64 | * @param providerInfo - the provider information to set | |
65 | */ | |
66 | public void setUstProvider(IUstProviderInfo providerInfo) { | |
67 | fProviderInfo = providerInfo; | |
68 | IBaseEventInfo[] events = providerInfo.getEvents(); | |
69 | for (int i = 0; i < events.length; i++) { | |
70 | BaseEventComponent component = new BaseEventComponent(events[i].getName(), this); | |
71 | component.setEventInfo(events[i]); | |
72 | addChild(component); | |
73 | } | |
74 | setToolTip("PID=" + fProviderInfo.getPid()); //$NON-NLS-1$ | |
75 | } | |
76 | ||
77 | /** | |
78 | * @return the process ID of the UST provider. | |
79 | */ | |
80 | public int getPid() { | |
81 | return fProviderInfo.getPid(); | |
82 | } | |
83 | ||
84 | /** | |
85 | * Sets the process ID of the UST provider to the given value. | |
86 | * @param pid - process ID to set | |
87 | */ | |
88 | public void setPid(int pid) { | |
89 | fProviderInfo.setPid(pid); | |
90 | } | |
91 | ||
06b9339e BH |
92 | /* |
93 | * (non-Javadoc) | |
94 | * @see org.eclipse.linuxtools.lttng.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class) | |
95 | */ | |
96 | @SuppressWarnings("rawtypes") | |
97 | @Override | |
98 | public Object getAdapter(Class adapter) { | |
99 | if (adapter == IPropertySource.class) { | |
100 | return new UstProviderPropertySource(this); | |
101 | } | |
102 | return null; | |
103 | } | |
104 | ||
eb1bab5b BH |
105 | // ------------------------------------------------------------------------ |
106 | // Operations | |
107 | // ------------------------------------------------------------------------ | |
108 | ||
109 | } | |
110 | ||
111 |