Commit | Line | Data |
---|---|---|
05627bda MD |
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 | * Mathieu Denis <mathieu.denis@polymtl.ca> - Initial API and implementation | |
11 | *******************************************************************************/ | |
12 | ||
13 | package org.eclipse.linuxtools.tmf.ui.viewers; | |
14 | ||
15 | import org.eclipse.linuxtools.tmf.core.component.TmfComponent; | |
16 | import org.eclipse.swt.widgets.Composite; | |
17 | ||
18 | /** | |
19 | * Abstract class that extends {@link TmfComponent} to be specific to viewers. | |
20 | * | |
21 | * It allows the access to the control and the parent of a viewer. | |
22 | * | |
23 | * @author Mathieu Denis | |
24 | * @version 2.0 | |
25 | * @since 2.0 | |
26 | */ | |
27 | public abstract class TmfViewer extends TmfComponent implements ITmfViewer { | |
28 | ||
29 | /** | |
30 | * The parent composite that holds the viewer | |
31 | */ | |
32 | protected Composite fParent; | |
33 | ||
34 | /** | |
35 | * Default constructor. The viewer have to be initialize through the | |
36 | * {@link TmfViewer#init(Composite, String)} function later on. | |
37 | */ | |
38 | public TmfViewer() { | |
39 | super(); | |
40 | } | |
41 | ||
42 | /** | |
43 | * Constructor that initializes the parent of the viewer | |
44 | * | |
45 | * @param parent | |
46 | * The parent composite that holds this viewer | |
47 | * | |
48 | * @see TmfComponent#TmfComponent(String) | |
49 | */ | |
50 | public TmfViewer(Composite parent) { | |
51 | this(parent, ""); //$NON-NLS-1$ | |
52 | } | |
53 | ||
54 | /** | |
55 | * Constructor that initializes the parent of the viewer and that sets the | |
56 | * name of the viewer | |
57 | * | |
58 | * @param parent | |
59 | * The parent composite that holds this viewer | |
60 | * @param name | |
61 | * The name of the viewer | |
62 | */ | |
63 | public TmfViewer(Composite parent, String name) { | |
64 | init(parent, name); | |
65 | } | |
66 | ||
67 | /** | |
68 | * Performs initialization of the viewer. It initializes the component. Need | |
69 | * to be called when the default constructor is used. | |
70 | * | |
71 | * @param parent | |
72 | * The parent composite of the viewer | |
73 | * @param name | |
74 | * The name to give to this viewer | |
75 | * @see TmfComponent#init(String) | |
76 | */ | |
77 | public void init(Composite parent, String name) { | |
78 | super.init(name); | |
79 | fParent = parent; | |
80 | } | |
81 | ||
82 | /** | |
83 | * @return the parent of this viewer | |
84 | */ | |
85 | public Composite getParent() { | |
86 | return fParent; | |
87 | } | |
88 | } |