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