~ubuntu-branches/ubuntu/trusty/eclipse-linuxtools/trusty

« back to all changes in this revision

Viewing changes to lttng/org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/UstProviderComponent.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam
  • Date: 2012-06-29 12:07:30 UTC
  • Revision ID: package-import@ubuntu.com-20120629120730-bfri1xys1i71dpn6
Tags: upstream-1.0.0
ImportĀ upstreamĀ versionĀ 1.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 * <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
    /*
 
97
     * (non-Javadoc)
 
98
     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
 
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
 
 
109
    // ------------------------------------------------------------------------
 
110
    // Operations
 
111
    // ------------------------------------------------------------------------
 
112
    
 
113
}
 
114
 
 
115