Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 82fea075ef94bbf421a11712bbab977bef70b94a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
/*******************************************************************************
 * Copyright (c) 2012 Ericsson
 *
 * All rights reserved. This program and the accompanying materials are
 * made available under the terms of the Eclipse Public License v1.0 which
 * accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *   Mathieu Denis <mathieu.denis@polymtl.ca> - Initial API and implementation
 *******************************************************************************/

package org.eclipse.linuxtools.tmf.ui.viewers;

import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
import org.eclipse.swt.widgets.Composite;

/**
 * Abstract class that extends {@link TmfComponent} to be specific to viewers.
 *
 * It allows the access to the control and the parent of a viewer.
 *
 * @author Mathieu Denis
 * @version 2.0
 * @since 2.0
 */
public abstract class TmfViewer extends TmfComponent implements ITmfViewer {

    /**
     * The parent composite that holds the viewer
     */
    protected Composite fParent;

    /**
     * Default constructor. The viewer have to be initialize through the
     * {@link TmfViewer#init(Composite, String)} function later on.
     */
    public TmfViewer() {
        super();
    }

    /**
     * Constructor that initializes the parent of the viewer
     *
     * @param parent
     *            The parent composite that holds this viewer
     *
     * @see TmfComponent#TmfComponent(String)
     */
    public TmfViewer(Composite parent) {
        this(parent, ""); //$NON-NLS-1$
    }

    /**
     * Constructor that initializes the parent of the viewer and that sets the
     * name of the viewer
     *
     * @param parent
     *            The parent composite that holds this viewer
     * @param name
     *            The name of the viewer
     */
    public TmfViewer(Composite parent, String name) {
        init(parent, name);
    }

    /**
     * Performs initialization of the viewer. It initializes the component. Need
     * to be called when the default constructor is used.
     *
     * @param parent
     *            The parent composite of the viewer
     * @param name
     *            The name to give to this viewer
     * @see TmfComponent#init(String)
     */
    public void init(Composite parent, String name) {
        super.init(name);
        fParent = parent;
    }

    /**
     * @return the parent of this viewer
     */
    public Composite getParent() {
        return fParent;
    }
}

Back to the top