Commit | Line | Data |
---|---|---|
b0d3496e | 1 | /******************************************************************************* |
e31e01e8 | 2 | * Copyright (c) 2009, 2010 Ericsson |
b0d3496e ASL |
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 | * Francois Chouinard - Initial API and implementation | |
abfad0aa | 11 | * Patrick Tasse - Factored out events table |
b0d3496e ASL |
12 | *******************************************************************************/ |
13 | ||
14 | package org.eclipse.linuxtools.tmf.ui.views; | |
15 | ||
16 | import org.eclipse.linuxtools.tmf.event.TmfEvent; | |
e31e01e8 | 17 | import org.eclipse.linuxtools.tmf.experiment.TmfExperiment; |
ff4ed569 | 18 | import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal; |
b0d3496e | 19 | import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler; |
abfad0aa | 20 | import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable; |
b0d3496e | 21 | import org.eclipse.swt.widgets.Composite; |
b0d3496e ASL |
22 | |
23 | /** | |
24 | * <b><u>TmfEventsView</u></b> | |
25 | * <p> | |
26 | * | |
27 | * TODO: Implement me. Please. | |
28 | * TODO: Handle column selection, sort, ... generically (nothing less...) | |
29 | * TODO: Implement hide/display columns | |
30 | */ | |
79a3a76e | 31 | public class TmfEventsView extends TmfView { |
b0d3496e | 32 | |
3b38ea61 | 33 | public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.events"; //$NON-NLS-1$ |
b0d3496e | 34 | |
e31e01e8 | 35 | private TmfExperiment<TmfEvent> fExperiment; |
abfad0aa | 36 | private TmfEventsTable fEventsTable; |
529ee6a9 | 37 | private static final int DEFAULT_CACHE_SIZE = 100; |
e31e01e8 | 38 | private final int fCacheSize; |
abfad0aa | 39 | private String fTitlePrefix; |
e31e01e8 FC |
40 | |
41 | // ------------------------------------------------------------------------ | |
b0d3496e | 42 | // Constructor |
e31e01e8 | 43 | // ------------------------------------------------------------------------ |
b0d3496e | 44 | |
e31e01e8 | 45 | public TmfEventsView(int cacheSize) { |
3b38ea61 | 46 | super("TmfEventsView"); //$NON-NLS-1$ |
e31e01e8 | 47 | fCacheSize = cacheSize; |
b0d3496e ASL |
48 | } |
49 | ||
e31e01e8 FC |
50 | public TmfEventsView() { |
51 | this(DEFAULT_CACHE_SIZE); | |
52 | } | |
53 | ||
54 | // ------------------------------------------------------------------------ | |
55 | // ViewPart | |
56 | // ------------------------------------------------------------------------ | |
57 | ||
e31e01e8 | 58 | @Override |
3b38ea61 | 59 | @SuppressWarnings("unchecked") |
b0d3496e | 60 | public void createPartControl(Composite parent) { |
abfad0aa FC |
61 | fEventsTable = createEventsTable(parent, fCacheSize); |
62 | ||
63 | fTitlePrefix = getTitle(); | |
64 | ||
65 | // If an experiment is already selected, update the table | |
66 | fExperiment = (TmfExperiment<TmfEvent>) TmfExperiment.getCurrentExperiment(); | |
67 | if (fExperiment != null) { | |
68 | experimentSelected(new TmfExperimentSelectedSignal<TmfEvent>(fEventsTable, fExperiment)); | |
69 | } | |
8d2e2848 FC |
70 | } |
71 | ||
abfad0aa FC |
72 | @Override |
73 | public void dispose() { | |
74 | if (fEventsTable != null) { | |
75 | fEventsTable.dispose(); | |
b0d3496e | 76 | } |
abfad0aa FC |
77 | super.dispose(); |
78 | } | |
b0d3496e | 79 | |
abfad0aa FC |
80 | protected TmfEventsTable createEventsTable(Composite parent, int cacheSize) { |
81 | return new TmfEventsTable(parent, cacheSize); | |
82 | } | |
b0d3496e ASL |
83 | |
84 | /* (non-Javadoc) | |
85 | * @see org.eclipse.ui.part.WorkbenchPart#setFocus() | |
86 | */ | |
87 | @Override | |
88 | public void setFocus() { | |
abfad0aa | 89 | fEventsTable.setFocus(); |
b0d3496e ASL |
90 | } |
91 | ||
8d2e2848 FC |
92 | /* (non-Javadoc) |
93 | * @see java.lang.Object#toString() | |
94 | */ | |
95 | @Override | |
3b38ea61 | 96 | @SuppressWarnings("nls") |
8d2e2848 FC |
97 | public String toString() { |
98 | return "[TmfEventsView]"; | |
99 | } | |
100 | ||
abfad0aa | 101 | // ------------------------------------------------------------------------ |
b0d3496e | 102 | // Signal handlers |
e31e01e8 | 103 | // ------------------------------------------------------------------------ |
b0d3496e | 104 | |
e31e01e8 | 105 | @SuppressWarnings("unchecked") |
abfad0aa | 106 | @TmfSignalHandler |
951d134a | 107 | public void experimentSelected(TmfExperimentSelectedSignal<TmfEvent> signal) { |
abfad0aa FC |
108 | // Update the trace reference |
109 | fExperiment = (TmfExperiment<TmfEvent>) signal.getExperiment(); | |
3b38ea61 | 110 | setPartName(fTitlePrefix + " - " + fExperiment.getName()); //$NON-NLS-1$ |
b0d3496e | 111 | |
abfad0aa | 112 | if (fEventsTable != null) { |
529ee6a9 | 113 | fEventsTable.setTrace(fExperiment, false); |
abfad0aa | 114 | } |
cb866e08 | 115 | } |
9aae0442 | 116 | |
e31e01e8 | 117 | } |