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