Commit | Line | Data |
---|---|---|
ce8319b6 BH |
1 | /******************************************************************************* |
2 | * Copyright (c) 2015 Ericsson | |
3 | * | |
4 | * All rights reserved. This program and the accompanying materials are made | |
5 | * 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.tracecompass.internal.analysis.os.linux.ui.views.latency.statistics; | |
14 | ||
15 | import org.eclipse.jdt.annotation.Nullable; | |
16 | import org.eclipse.swt.widgets.Composite; | |
17 | import org.eclipse.tracecompass.common.core.NonNullUtils; | |
18 | import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; | |
19 | import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager; | |
20 | import org.eclipse.tracecompass.tmf.ui.views.TmfView; | |
21 | ||
22 | /** | |
23 | * Abstract view to to be extended to display latency statistics. | |
24 | * | |
25 | * @author Bernd Hufmann | |
26 | * | |
27 | */ | |
28 | public abstract class AbstractLatencyStatisticsView extends TmfView { | |
29 | ||
30 | @Nullable private AbstractLatencyStatisticsViewer fStatsViewer = null; | |
31 | ||
32 | /** | |
33 | * Constructor | |
34 | */ | |
35 | public AbstractLatencyStatisticsView() { | |
36 | super("StatisticsView"); //$NON-NLS-1$ | |
37 | } | |
38 | ||
39 | @Override | |
40 | public void createPartControl(@Nullable Composite parent) { | |
41 | super.createPartControl(parent); | |
42 | AbstractLatencyStatisticsViewer statsViewer = createLatencyStatisticsViewer(NonNullUtils.checkNotNull(parent)); | |
43 | ITmfTrace trace = TmfTraceManager.getInstance().getActiveTrace(); | |
44 | if (trace != null) { | |
45 | statsViewer.loadTrace(trace); | |
46 | } | |
47 | fStatsViewer = statsViewer; | |
48 | } | |
49 | ||
50 | @Override | |
51 | public void setFocus() { | |
52 | AbstractLatencyStatisticsViewer statsViewer = fStatsViewer; | |
53 | if (statsViewer != null) { | |
54 | statsViewer.getControl().setFocus(); | |
55 | } | |
56 | } | |
57 | ||
58 | @Override | |
59 | public void dispose() { | |
60 | super.dispose(); | |
61 | AbstractLatencyStatisticsViewer statsViewer = fStatsViewer; | |
62 | if (statsViewer != null) { | |
63 | statsViewer.dispose(); | |
64 | } | |
65 | } | |
66 | ||
67 | /** | |
68 | * Creates a latency statistics viewer instance. | |
69 | * | |
70 | * @param parent | |
71 | * the parent composite to create the viewer in. | |
72 | * @return the latency statistics viewer implementation | |
73 | */ | |
74 | protected abstract AbstractLatencyStatisticsViewer createLatencyStatisticsViewer(Composite parent); | |
75 | ||
76 | } |