2010-07-20 Francois Chouinard <fchouinard@gmail.com>
[deliverable/tracecompass.git] / org.eclipse.linuxtools.tmf.ui / src / org / eclipse / linuxtools / tmf / ui / views / TmfEventsView.java
1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 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 * Francois Chouinard - Initial API and implementation
11 * Patrick Tasse - Factored out events table
12 *******************************************************************************/
13
14 package org.eclipse.linuxtools.tmf.ui.views;
15
16 import org.eclipse.linuxtools.tmf.event.TmfEvent;
17 import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
18 import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal;
19 import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
20 import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;
21 import org.eclipse.swt.widgets.Composite;
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 */
31 public class TmfEventsView extends TmfView {
32
33 public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.events";
34
35 private TmfExperiment<TmfEvent> fExperiment;
36 private TmfEventsTable fEventsTable;
37 private static final int DEFAULT_CACHE_SIZE = 1000;
38 private final int fCacheSize;
39 private String fTitlePrefix;
40
41 // ------------------------------------------------------------------------
42 // Constructor
43 // ------------------------------------------------------------------------
44
45 public TmfEventsView(int cacheSize) {
46 super("TmfEventsView");
47 fCacheSize = cacheSize;
48 }
49
50 public TmfEventsView() {
51 this(DEFAULT_CACHE_SIZE);
52 }
53
54 // ------------------------------------------------------------------------
55 // ViewPart
56 // ------------------------------------------------------------------------
57
58 @SuppressWarnings("unchecked")
59 @Override
60 public void createPartControl(Composite parent) {
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 }
70 }
71
72 @Override
73 public void dispose() {
74 if (fEventsTable != null) {
75 fEventsTable.dispose();
76 }
77 super.dispose();
78 }
79
80 protected TmfEventsTable createEventsTable(Composite parent, int cacheSize) {
81 return new TmfEventsTable(parent, cacheSize);
82 }
83
84 /* (non-Javadoc)
85 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
86 */
87 @Override
88 public void setFocus() {
89 fEventsTable.setFocus();
90 }
91
92 /* (non-Javadoc)
93 * @see java.lang.Object#toString()
94 */
95 @Override
96 public String toString() {
97 return "[TmfEventsView]";
98 }
99
100 // ------------------------------------------------------------------------
101 // Signal handlers
102 // ------------------------------------------------------------------------
103
104 @SuppressWarnings("unchecked")
105 @TmfSignalHandler
106 public void experimentSelected(TmfExperimentSelectedSignal<TmfEvent> signal) {
107 // Update the trace reference
108 fExperiment = (TmfExperiment<TmfEvent>) signal.getExperiment();
109 setPartName(fTitlePrefix + " - " + fExperiment.getName());
110
111 if (fEventsTable != null) {
112 fEventsTable.setTrace(fExperiment);
113 }
114 }
115
116 }
This page took 0.035176 seconds and 5 git commands to generate.