tmf: Rename packages to org.eclipse.tracecompass.*
[deliverable/tracecompass.git] / org.eclipse.tracecompass.tmf.ui / src / org / eclipse / tracecompass / tmf / ui / views / TmfChartView.java
1 /**********************************************************************
2 * Copyright (c) 2013, 2014 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 package org.eclipse.tracecompass.tmf.ui.views;
13
14 import org.eclipse.swt.widgets.Composite;
15 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
16 import org.eclipse.tracecompass.tmf.ui.viewers.xycharts.TmfXYChartViewer;
17
18 /**
19 * Base class to be used with a chart viewer {@link TmfXYChartViewer}.
20 * It is responsible to instantiate the viewer class and load the trace
21 * into the viewer when the view is created.
22 *
23 * @author Bernd Hufmann
24 * @since 3.0
25 */
26 abstract public class TmfChartView extends TmfView {
27
28 // ------------------------------------------------------------------------
29 // Attributes
30 // ------------------------------------------------------------------------
31 /** The TMF XY Chart reference */
32 private TmfXYChartViewer fChartViewer;
33 /** The Trace reference */
34 private ITmfTrace fTrace;
35
36 // ------------------------------------------------------------------------
37 // Constructors
38 // ------------------------------------------------------------------------
39 /**
40 * Standard Constructor
41 *
42 * @param viewName
43 * The view name
44 */
45 public TmfChartView(String viewName) {
46 super(viewName);
47 }
48
49 // ------------------------------------------------------------------------
50 // Accessors
51 // ------------------------------------------------------------------------
52 /**
53 * Returns the TMF XY chart viewer implementation.
54 *
55 * @return the TMF XY chart viewer {@link TmfXYChartViewer}
56 */
57 protected TmfXYChartViewer getChartViewer() {
58 return fChartViewer;
59 }
60
61 /**
62 * Sets the TMF XY chart viewer implementation.
63 *
64 * @param chartViewer
65 * The TMF XY chart viewer {@link TmfXYChartViewer}
66 */
67 protected void setChartViewer(TmfXYChartViewer chartViewer) {
68 fChartViewer = chartViewer;
69 }
70
71 /**
72 * Returns the ITmfTrace implementation
73 *
74 * @return the ITmfTrace implementation {@link ITmfTrace}
75 */
76 protected ITmfTrace getTrace() {
77 return fTrace;
78 }
79
80 /**
81 * Sets the ITmfTrace implementation
82 *
83 * @param trace
84 * The ITmfTrace implementation {@link ITmfTrace}
85 */
86 protected void setTrace(ITmfTrace trace) {
87 fTrace = trace;
88 }
89
90 // ------------------------------------------------------------------------
91 // Operations
92 // ------------------------------------------------------------------------
93 @Override
94 public void createPartControl(Composite parent) {
95 ITmfTrace trace = getActiveTrace();
96 if (trace != null) {
97 setTrace(trace);
98 loadTrace();
99 }
100 }
101
102 @Override
103 public void dispose() {
104 if (fChartViewer != null) {
105 fChartViewer.dispose();
106 }
107 }
108
109 /**
110 * Load the trace into view.
111 */
112 protected void loadTrace() {
113 if (fChartViewer != null) {
114 fChartViewer.loadTrace(fTrace);
115 }
116 }
117
118 }
This page took 0.040551 seconds and 5 git commands to generate.