Commit | Line | Data |
---|---|---|
b9fff7ad | 1 | /******************************************************************************* |
edded5c1 | 2 | * Copyright (c) 2015, 2016 Ericsson |
b9fff7ad BH |
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 | ||
edded5c1 | 14 | package org.eclipse.tracecompass.analysis.timing.ui.views.segmentstore.table; |
b9fff7ad BH |
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 | ||
6fe3b6eb | 35 | private @Nullable AbstractSegmentStoreTableViewer fSegmentStoreViewer; |
b9fff7ad BH |
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); | |
6fe3b6eb | 56 | fSegmentStoreViewer = createSegmentStoreViewer(tableViewer); |
b9fff7ad BH |
57 | setInitialData(); |
58 | } | |
59 | ||
60 | // ------------------------------------------------------------------------ | |
61 | // Operations | |
62 | // ------------------------------------------------------------------------ | |
63 | ||
64 | @Override | |
65 | public void setFocus() { | |
6fe3b6eb MK |
66 | if (fSegmentStoreViewer != null) { |
67 | fSegmentStoreViewer.getTableViewer().getControl().setFocus(); | |
b9fff7ad BH |
68 | } |
69 | } | |
70 | ||
71 | @Override | |
72 | public void dispose() { | |
73 | super.dispose(); | |
6fe3b6eb MK |
74 | if (fSegmentStoreViewer != null) { |
75 | fSegmentStoreViewer.dispose(); | |
b9fff7ad BH |
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 | */ | |
6fe3b6eb MK |
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 | } | |
b9fff7ad BH |
97 | |
98 | /** | |
99 | * Set initial data into the viewer | |
100 | */ | |
101 | private void setInitialData() { | |
6fe3b6eb MK |
102 | if (fSegmentStoreViewer != null) { |
103 | fSegmentStoreViewer.setData(fSegmentStoreViewer.getAnalysisModule()); | |
b9fff7ad BH |
104 | } |
105 | } | |
106 | } |