4a1460d198ab4d897208d5e2c61192f31a4d9163
[deliverable/tracecompass.git] / analysis / org.eclipse.tracecompass.analysis.timing.ui / src / org / eclipse / tracecompass / analysis / timing / ui / views / segmentstore / table / AbstractSegmentStoreTableView.java
1 /*******************************************************************************
2 * Copyright (c) 2015, 2016 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 * France Lapointe Nguyen - Initial API and implementation
11 * Bernd Hufmann - Move abstract class to TMF
12 *******************************************************************************/
13
14 package org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table;
15
16 import org.eclipse.jdt.annotation.Nullable;
17 import org.eclipse.jface.viewers.TableViewer;
18 import org.eclipse.swt.SWT;
19 import org.eclipse.swt.custom.SashForm;
20 import org.eclipse.swt.widgets.Composite;
21 import org.eclipse.tracecompass.tmf.ui.views.TmfView;
22
23 /**
24 * View for displaying a segment store analysis in a table.
25 *
26 * @author France Lapointe Nguyen
27 * @since 2.0
28 */
29 public abstract class AbstractSegmentStoreTableView extends TmfView {
30
31 // ------------------------------------------------------------------------
32 // Attributes
33 // ------------------------------------------------------------------------
34
35 private @Nullable AbstractSegmentStoreTableViewer fSegmentStoreViewer;
36
37 // ------------------------------------------------------------------------
38 // Constructor
39 // ------------------------------------------------------------------------
40
41 /**
42 * Constructor
43 */
44 public AbstractSegmentStoreTableView() {
45 super(""); //$NON-NLS-1$
46 }
47
48 // ------------------------------------------------------------------------
49 // ViewPart
50 // ------------------------------------------------------------------------
51
52 @Override
53 public void createPartControl(@Nullable Composite parent) {
54 SashForm sf = new SashForm(parent, SWT.NONE);
55 TableViewer tableViewer = new TableViewer(sf, SWT.FULL_SELECTION | SWT.VIRTUAL);
56 fSegmentStoreViewer = createSegmentStoreViewer(tableViewer);
57 setInitialData();
58 }
59
60 // ------------------------------------------------------------------------
61 // Operations
62 // ------------------------------------------------------------------------
63
64 @Override
65 public void setFocus() {
66 if (fSegmentStoreViewer != null) {
67 fSegmentStoreViewer.getTableViewer().getControl().setFocus();
68 }
69 }
70
71 @Override
72 public void dispose() {
73 super.dispose();
74 if (fSegmentStoreViewer != null) {
75 fSegmentStoreViewer.dispose();
76 }
77 }
78
79 /**
80 * Returns the latency analysis table viewer instance
81 *
82 * @param tableViewer
83 * the table viewer to use
84 * @return the latency analysis table viewer instance
85 */
86 protected abstract AbstractSegmentStoreTableViewer createSegmentStoreViewer(TableViewer tableViewer);
87
88 /**
89 * Get the table viewer
90 *
91 * @return the table viewer, useful for testing
92 */
93 @Nullable
94 public AbstractSegmentStoreTableViewer getSegmentStoreViewer() {
95 return fSegmentStoreViewer;
96 }
97
98 /**
99 * Set initial data into the viewer
100 */
101 private void setInitialData() {
102 if (fSegmentStoreViewer != null) {
103 fSegmentStoreViewer.setData(fSegmentStoreViewer.getSegmentProvider());
104 }
105 }
106 }
This page took 0.035173 seconds and 4 git commands to generate.