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 | ||
115b4a01 | 13 | package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl; |
eb1bab5b | 14 | |
9315aeee BH |
15 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo; |
16 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo; | |
17 | import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.UstProviderInfo; | |
18 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages; | |
115b4a01 | 19 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.ITraceControlComponent; |
115b4a01 | 20 | import org.eclipse.linuxtools.internal.lttng2.ui.views.control.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> | |
dbd4432d BH |
27 | * |
28 | * @author Bernd Hufmann | |
eb1bab5b BH |
29 | */ |
30 | public class UstProviderComponent extends TraceControlComponent { | |
31 | ||
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$ | |
39 | ||
40 | // ------------------------------------------------------------------------ | |
41 | // Attributes | |
42 | // ------------------------------------------------------------------------ | |
43 | /** | |
44 | * The UST provider information. | |
45 | */ | |
46 | private IUstProviderInfo fProviderInfo = null; | |
47 | ||
48 | // ------------------------------------------------------------------------ | |
49 | // Constructors | |
50 | // ------------------------------------------------------------------------ | |
51 | /** | |
52 | * Constructor | |
53 | * @param name - the name of the component. | |
54 | * @param parent - the parent of this component. | |
55 | */ | |
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 | /** | |
67 | * Sets the UST provider information to the given value. | |
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 BH |
79 | } |
80 | ||
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 | /* |
97 | * (non-Javadoc) | |
115b4a01 | 98 | * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class) |
06b9339e BH |
99 | */ |
100 | @SuppressWarnings("rawtypes") | |
101 | @Override | |
102 | public Object getAdapter(Class adapter) { | |
103 | if (adapter == IPropertySource.class) { | |
104 | return new UstProviderPropertySource(this); | |
105 | } | |
106 | return null; | |
107 | } | |
108 | ||
eb1bab5b BH |
109 | // ------------------------------------------------------------------------ |
110 | // Operations | |
111 | // ------------------------------------------------------------------------ | |
112 | ||
113 | } | |
114 | ||
115 |