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 | |
e31e01e8 | 33 | public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.events"; |
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) { |
fc6ccf6f | 46 | super("TmfEventsView"); |
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 | ||
58 | @SuppressWarnings("unchecked") | |
59 | @Override | |
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 | |
96 | public String toString() { | |
97 | return "[TmfEventsView]"; | |
98 | } | |
99 | ||
abfad0aa | 100 | // ------------------------------------------------------------------------ |
b0d3496e | 101 | // Signal handlers |
e31e01e8 | 102 | // ------------------------------------------------------------------------ |
b0d3496e | 103 | |
e31e01e8 | 104 | @SuppressWarnings("unchecked") |
abfad0aa | 105 | @TmfSignalHandler |
951d134a | 106 | public void experimentSelected(TmfExperimentSelectedSignal<TmfEvent> signal) { |
abfad0aa FC |
107 | // Update the trace reference |
108 | fExperiment = (TmfExperiment<TmfEvent>) signal.getExperiment(); | |
109 | setPartName(fTitlePrefix + " - " + fExperiment.getName()); | |
b0d3496e | 110 | |
abfad0aa | 111 | if (fEventsTable != null) { |
529ee6a9 | 112 | fEventsTable.setTrace(fExperiment, false); |
abfad0aa | 113 | } |
cb866e08 | 114 | } |
9aae0442 | 115 | |
e31e01e8 | 116 | } |