control: Bug 483560: Refresh UI once after adding all children events
[deliverable/tracecompass.git] / lttng / org.eclipse.tracecompass.lttng2.control.ui / src / org / eclipse / tracecompass / internal / lttng2 / control / ui / views / model / impl / UstProviderComponent.java
CommitLineData
eb1bab5b 1/**********************************************************************
ed902a2b 2 * Copyright (c) 2012, 2014 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
9bc60be7 13package org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.impl;
eb1bab5b 14
f0a2a4be
BH
15import java.util.ArrayList;
16import java.util.List;
17
9bc60be7
AM
18import org.eclipse.tracecompass.internal.lttng2.control.core.model.IBaseEventInfo;
19import org.eclipse.tracecompass.internal.lttng2.control.core.model.IUstProviderInfo;
20import org.eclipse.tracecompass.internal.lttng2.control.core.model.impl.UstProviderInfo;
21import org.eclipse.tracecompass.internal.lttng2.control.ui.views.messages.Messages;
22import org.eclipse.tracecompass.internal.lttng2.control.ui.views.model.ITraceControlComponent;
23import org.eclipse.tracecompass.internal.lttng2.control.ui.views.property.UstProviderPropertySource;
06b9339e 24import org.eclipse.ui.views.properties.IPropertySource;
eb1bab5b
BH
25
26/**
eb1bab5b
BH
27 * <p>
28 * Implementation of the UST provider component.
29 * </p>
ea21cd65 30 *
dbd4432d 31 * @author Bernd Hufmann
eb1bab5b
BH
32 */
33public class UstProviderComponent extends TraceControlComponent {
ea21cd65 34
eb1bab5b
BH
35 // ------------------------------------------------------------------------
36 // Constants
37 // ------------------------------------------------------------------------
38 /**
39 * Path to icon file for this component.
40 */
41 public static final String USTL_PROVIDER_ICON_FILE = "icons/obj16/targets.gif"; //$NON-NLS-1$
ea21cd65 42
eb1bab5b
BH
43 // ------------------------------------------------------------------------
44 // Attributes
45 // ------------------------------------------------------------------------
46 /**
47 * The UST provider information.
48 */
49 private IUstProviderInfo fProviderInfo = null;
ea21cd65 50
eb1bab5b
BH
51 // ------------------------------------------------------------------------
52 // Constructors
53 // ------------------------------------------------------------------------
54 /**
ea21cd65 55 * Constructor
eb1bab5b
BH
56 * @param name - the name of the component.
57 * @param parent - the parent of this component.
ea21cd65 58 */
eb1bab5b
BH
59 public UstProviderComponent(String name, ITraceControlComponent parent) {
60 super(name, parent);
61 setImage(USTL_PROVIDER_ICON_FILE);
7b48c899 62 setToolTip(Messages.TraceControl_ProviderDisplayName);
eb1bab5b
BH
63 fProviderInfo = new UstProviderInfo(name);
64 }
65
66 // ------------------------------------------------------------------------
67 // Accessors
68 // ------------------------------------------------------------------------
69 /**
ea21cd65 70 * Sets the UST provider information to the given value.
eb1bab5b
BH
71 * @param providerInfo - the provider information to set
72 */
73 public void setUstProvider(IUstProviderInfo providerInfo) {
74 fProviderInfo = providerInfo;
75 IBaseEventInfo[] events = providerInfo.getEvents();
f0a2a4be 76 List<ITraceControlComponent> eventComponents = new ArrayList<>();
eb1bab5b
BH
77 for (int i = 0; i < events.length; i++) {
78 BaseEventComponent component = new BaseEventComponent(events[i].getName(), this);
79 component.setEventInfo(events[i]);
f0a2a4be 80 eventComponents.add(component);
eb1bab5b 81 }
f0a2a4be 82 setChildren(eventComponents);
7b48c899 83 setName(getName() + " [PID=" + fProviderInfo.getPid() + "]"); //$NON-NLS-1$ //$NON-NLS-2$
eb1bab5b 84 }
ea21cd65 85
eb1bab5b
BH
86 /**
87 * @return the process ID of the UST provider.
88 */
89 public int getPid() {
90 return fProviderInfo.getPid();
91 }
92
93 /**
94 * Sets the process ID of the UST provider to the given value.
95 * @param pid - process ID to set
96 */
97 public void setPid(int pid) {
98 fProviderInfo.setPid(pid);
99 }
100
06b9339e 101 @Override
e58fe1d5 102 public <T> T getAdapter(Class<T> adapter) {
06b9339e 103 if (adapter == IPropertySource.class) {
e58fe1d5 104 return adapter.cast(new UstProviderPropertySource(this));
06b9339e
BH
105 }
106 return null;
ea21cd65
AM
107 }
108
eb1bab5b 109}
This page took 0.09093 seconds and 5 git commands to generate.