1 /*******************************************************************************
2 * Copyright (c) 2009, 2010 Ericsson
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
10 * Francois Chouinard - Initial API and implementation
11 * Patrick Tasse - Factored out events table
12 *******************************************************************************/
14 package org
.eclipse
.linuxtools
.tmf
.ui
.views
.events
;
16 import org
.eclipse
.linuxtools
.tmf
.core
.event
.TmfEvent
;
17 import org
.eclipse
.linuxtools
.tmf
.core
.experiment
.TmfExperiment
;
18 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfExperimentDisposedSignal
;
19 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfExperimentSelectedSignal
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalHandler
;
21 import org
.eclipse
.linuxtools
.tmf
.ui
.TmfUiPlugin
;
22 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.events
.TmfEventsTable
;
23 import org
.eclipse
.linuxtools
.tmf
.ui
.views
.TmfView
;
24 import org
.eclipse
.swt
.widgets
.Composite
;
27 * <b><u>TmfEventsView</u></b>
30 * TODO: Implement me. Please.
31 * TODO: Handle column selection, sort, ... generically (nothing less...)
32 * TODO: Implement hide/display columns
34 public class TmfEventsView
extends TmfView
{
36 public static final String ID
= "org.eclipse.linuxtools.tmf.ui.views.events"; //$NON-NLS-1$
38 private TmfExperiment
<TmfEvent
> fExperiment
;
39 private TmfEventsTable fEventsTable
;
40 private static final int DEFAULT_CACHE_SIZE
= 100;
41 private final int fCacheSize
;
42 private String fTitlePrefix
;
44 // ------------------------------------------------------------------------
46 // ------------------------------------------------------------------------
48 public TmfEventsView(int cacheSize
) {
49 super("TmfEventsView"); //$NON-NLS-1$
50 fCacheSize
= cacheSize
;
53 public TmfEventsView() {
54 this(DEFAULT_CACHE_SIZE
);
57 // ------------------------------------------------------------------------
59 // ------------------------------------------------------------------------
62 @SuppressWarnings("unchecked")
63 public void createPartControl(Composite parent
) {
64 fEventsTable
= createEventsTable(parent
, fCacheSize
);
66 fTitlePrefix
= getTitle();
68 // If an experiment is already selected, update the table
69 fExperiment
= (TmfExperiment
<TmfEvent
>) TmfExperiment
.getCurrentExperiment();
70 if (fExperiment
!= null) {
71 experimentSelected(new TmfExperimentSelectedSignal
<TmfEvent
>(fEventsTable
, fExperiment
));
76 public void dispose() {
77 if (fEventsTable
!= null) {
78 fEventsTable
.dispose();
83 protected TmfEventsTable
createEventsTable(Composite parent
, int cacheSize
) {
84 return new TmfEventsTable(parent
, cacheSize
);
88 * @see org.eclipse.ui.part.WorkbenchPart#setFocus()
91 public void setFocus() {
92 fEventsTable
.setFocus();
96 * @see java.lang.Object#toString()
99 @SuppressWarnings("nls")
100 public String
toString() {
101 return "[TmfEventsView]";
104 // ------------------------------------------------------------------------
106 // ------------------------------------------------------------------------
108 @SuppressWarnings("unchecked")
110 public void experimentSelected(TmfExperimentSelectedSignal
<TmfEvent
> signal
) {
111 // Update the trace reference
112 TmfExperiment
<TmfEvent
> exp
= (TmfExperiment
<TmfEvent
>) signal
.getExperiment();
113 if (!exp
.equals(fExperiment
)) {
115 setPartName(fTitlePrefix
+ " - " + fExperiment
.getName()); //$NON-NLS-1$
116 if (fEventsTable
!= null) {
117 fEventsTable
.setTrace(fExperiment
, false);
122 @SuppressWarnings("unchecked")
124 public void experimentDisposed(TmfExperimentDisposedSignal
<TmfEvent
> signal
) {
125 // Clear the trace reference
126 TmfExperiment
<TmfEvent
> experiment
= (TmfExperiment
<TmfEvent
>) signal
.getExperiment();
127 if (experiment
.equals(fExperiment
)) {
128 fEventsTable
.setTrace(null, false);
131 TmfUiPlugin
.getDefault().getWorkbench().getWorkbenchWindows()[0].getShell().getDisplay().syncExec(new Runnable() {
134 setPartName(fTitlePrefix
);