0d167ea56769e11ba4cbaba6a998df0a3451f8db
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / model / impl / UstProviderComponent.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 org.eclipse.tracecompass.internal.lttng2.control.core.model.IBaseEventInfo;
16 import org.eclipse.tracecompass.internal.lttng2.control.core.model.IUstProviderInfo;
17 import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.UstProviderInfo;
18 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
19 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
20 import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.UstProviderPropertySource;
21 import org.eclipse.ui.views.properties.IPropertySource;
22
23 /**
24 * <p>
25 * Implementation of the UST provider component.
26 * </p>
27 *
28 * @author Bernd Hufmann
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);
59 setToolTip(Messages.TraceControl_ProviderDisplayName);
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 }
78 setName(getName() + " [PID=" + fProviderInfo.getPid() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
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
96 @Override
97 public Object getAdapter(Class adapter) {
98 if (adapter == IPropertySource.class) {
99 return new UstProviderPropertySource(this);
100 }
101 return null;
102 }
103
104 }
This page took 0.032863 seconds and 4 git commands to generate.