| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2015 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; |
| 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 fTableViewer; |
| 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 | fTableViewer = getSegmentStoreViewer(tableViewer); |
| 57 | setInitialData(); |
| 58 | } |
| 59 | |
| 60 | // ------------------------------------------------------------------------ |
| 61 | // Operations |
| 62 | // ------------------------------------------------------------------------ |
| 63 | |
| 64 | @Override |
| 65 | public void setFocus() { |
| 66 | if (fTableViewer != null) { |
| 67 | fTableViewer.getTableViewer().getControl().setFocus(); |
| 68 | } |
| 69 | } |
| 70 | |
| 71 | @Override |
| 72 | public void dispose() { |
| 73 | super.dispose(); |
| 74 | if (fTableViewer != null) { |
| 75 | fTableViewer.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 getSegmentStoreViewer(TableViewer tableViewer); |
| 87 | |
| 88 | /** |
| 89 | * Set initial data into the viewer |
| 90 | */ |
| 91 | private void setInitialData() { |
| 92 | if (fTableViewer != null) { |
| 93 | fTableViewer.setData(fTableViewer.getAnalysisModule()); |
| 94 | } |
| 95 | } |
| 96 | } |