Added TMF statistics feature (Bug 360572)
[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.TmfExperimentDisposedSignal;
19 import org.eclipse.linuxtools.tmf.signal.TmfExperimentSelectedSignal;
20 import org.eclipse.linuxtools.tmf.signal.TmfSignalHandler;
21 import org.eclipse.linuxtools.tmf.ui.TmfUiPlugin;
22 import org.eclipse.linuxtools.tmf.ui.viewers.events.TmfEventsTable;
23 import org.eclipse.swt.widgets.Composite;
24
25 /**
26 * <b><u>TmfEventsView</u></b>
27 * <p>
28 *
29 * TODO: Implement me. Please.
30 * TODO: Handle column selection, sort, ... generically (nothing less...)
31 * TODO: Implement hide/display columns
32 */
33 public class TmfEventsView extends TmfView {
34
35 public static final String ID = "org.eclipse.linuxtools.tmf.ui.views.events"; //$NON-NLS-1$
36
37 private TmfExperiment<TmfEvent> fExperiment;
38 private TmfEventsTable fEventsTable;
39 private static final int DEFAULT_CACHE_SIZE = 100;
40 private final int fCacheSize;
41 private String fTitlePrefix;
42
43 // ------------------------------------------------------------------------
44 // Constructor
45 // ------------------------------------------------------------------------
46
47 public TmfEventsView(int cacheSize) {
48 super("TmfEventsView"); //$NON-NLS-1$
49 fCacheSize = cacheSize;
50 }
51
52 public TmfEventsView() {
53 this(DEFAULT_CACHE_SIZE);
54 }
55
56 // ------------------------------------------------------------------------
57 // ViewPart
58 // ------------------------------------------------------------------------
59
60 @Override
61 @SuppressWarnings("unchecked")
62 public void createPartControl(Composite parent) {
63 fEventsTable = createEventsTable(parent, fCacheSize);
64
65 fTitlePrefix = getTitle();
66
67 // If an experiment is already selected, update the table
68 fExperiment = (TmfExperiment<TmfEvent>) TmfExperiment.getCurrentExperiment();
69 if (fExperiment != null) {
70 experimentSelected(new TmfExperimentSelectedSignal<TmfEvent>(fEventsTable, fExperiment));
71 }
72 }
73
74 @Override
75 public void dispose() {
76 if (fEventsTable != null) {
77 fEventsTable.dispose();
78 }
79 super.dispose();
80 }
81
82 protected TmfEventsTable createEventsTable(Composite parent, int cacheSize) {
83 return new TmfEventsTable(parent, cacheSize);
84 }
85
86 /* (non-Javadoc)
87 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
88 */
89 @Override
90 public void setFocus() {
91 fEventsTable.setFocus();
92 }
93
94 /* (non-Javadoc)
95 * @see java.lang.Object#toString()
96 */
97 @Override
98 @SuppressWarnings("nls")
99 public String toString() {
100 return "[TmfEventsView]";
101 }
102
103 // ------------------------------------------------------------------------
104 // Signal handlers
105 // ------------------------------------------------------------------------
106
107 @SuppressWarnings("unchecked")
108 @TmfSignalHandler
109 public void experimentSelected(TmfExperimentSelectedSignal<TmfEvent> signal) {
110 // Update the trace reference
111 TmfExperiment<TmfEvent> exp = (TmfExperiment<TmfEvent>) signal.getExperiment();
112 if (!exp.equals(fExperiment)) {
113 fExperiment = exp;
114 setPartName(fTitlePrefix + " - " + fExperiment.getName()); //$NON-NLS-1$
115 if (fEventsTable != null) {
116 fEventsTable.setTrace(fExperiment, false);
117 }
118 }
119 }
120
121 @SuppressWarnings("unchecked")
122 @TmfSignalHandler
123 public void experimentDisposed(TmfExperimentDisposedSignal<TmfEvent> signal) {
124 // Clear the trace reference
125 TmfExperiment<TmfEvent> experiment = (TmfExperiment<TmfEvent>) signal.getExperiment();
126 if (experiment.equals(fExperiment)) {
127 fEventsTable.setTrace(null, false);
128 }
129
130 TmfUiPlugin.getDefault().getWorkbench().getWorkbenchWindows()[0].getShell().getDisplay().syncExec(new Runnable() {
131 @Override
132 public void run() {
133 setPartName(fTitlePrefix);
134 }
135 });
136 }
137
138 }
This page took 0.033247 seconds and 5 git commands to generate.