1 /*******************************************************************************
2 * Copyright (c) 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 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.tmf
.ui
.editors
;
15 import java
.lang
.reflect
.Constructor
;
16 import java
.lang
.reflect
.InvocationTargetException
;
17 import java
.util
.List
;
19 import org
.eclipse
.core
.resources
.IFile
;
20 import org
.eclipse
.core
.resources
.IMarker
;
21 import org
.eclipse
.core
.resources
.IMarkerDelta
;
22 import org
.eclipse
.core
.resources
.IResource
;
23 import org
.eclipse
.core
.resources
.IResourceChangeEvent
;
24 import org
.eclipse
.core
.resources
.IResourceChangeListener
;
25 import org
.eclipse
.core
.resources
.IResourceDelta
;
26 import org
.eclipse
.core
.resources
.ResourcesPlugin
;
27 import org
.eclipse
.core
.runtime
.CoreException
;
28 import org
.eclipse
.core
.runtime
.IConfigurationElement
;
29 import org
.eclipse
.core
.runtime
.IProgressMonitor
;
30 import org
.eclipse
.core
.runtime
.InvalidRegistryObjectException
;
31 import org
.eclipse
.core
.runtime
.ListenerList
;
32 import org
.eclipse
.core
.runtime
.Platform
;
33 import org
.eclipse
.jface
.util
.SafeRunnable
;
34 import org
.eclipse
.jface
.viewers
.ISelection
;
35 import org
.eclipse
.jface
.viewers
.ISelectionChangedListener
;
36 import org
.eclipse
.jface
.viewers
.ISelectionProvider
;
37 import org
.eclipse
.jface
.viewers
.SelectionChangedEvent
;
38 import org
.eclipse
.jface
.viewers
.StructuredSelection
;
39 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.Activator
;
40 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomEventsTable
;
41 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomTxtTrace
;
42 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.parsers
.custom
.CustomXmlTrace
;
43 import org
.eclipse
.linuxtools
.internal
.tmf
.ui
.project
.handlers
.Messages
;
44 import org
.eclipse
.linuxtools
.tmf
.core
.TmfCommonConstants
;
45 import org
.eclipse
.linuxtools
.tmf
.core
.event
.ITmfEvent
;
46 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TmfTraceException
;
47 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfSignalHandler
;
48 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTimestampFormatUpdateSignal
;
49 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceClosedSignal
;
50 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceOpenedSignal
;
51 import org
.eclipse
.linuxtools
.tmf
.core
.signal
.TmfTraceSelectedSignal
;
52 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfContext
;
53 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.ITmfTrace
;
54 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfExperiment
;
55 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTrace
;
56 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.ITmfProjectModelElement
;
57 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfExperimentElement
;
58 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfNavigatorContentProvider
;
59 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfProjectElement
;
60 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfProjectRegistry
;
61 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceElement
;
62 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceType
;
63 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.events
.TmfEventsTable
;
64 import org
.eclipse
.swt
.widgets
.Composite
;
65 import org
.eclipse
.swt
.widgets
.Display
;
66 import org
.eclipse
.ui
.IEditorInput
;
67 import org
.eclipse
.ui
.IEditorPart
;
68 import org
.eclipse
.ui
.IEditorSite
;
69 import org
.eclipse
.ui
.IFileEditorInput
;
70 import org
.eclipse
.ui
.IPartListener
;
71 import org
.eclipse
.ui
.IPropertyListener
;
72 import org
.eclipse
.ui
.IReusableEditor
;
73 import org
.eclipse
.ui
.IWorkbenchPart
;
74 import org
.eclipse
.ui
.PartInitException
;
75 import org
.eclipse
.ui
.ide
.IGotoMarker
;
76 import org
.eclipse
.ui
.part
.FileEditorInput
;
77 import org
.eclipse
.ui
.views
.properties
.IPropertySheetPage
;
78 import org
.osgi
.framework
.Bundle
;
81 * Editor for TMF events
84 * @author Patrick Tasse
87 public class TmfEventsEditor
extends TmfEditor
implements ITmfTraceEditor
, IReusableEditor
, IPropertyListener
, IResourceChangeListener
, ISelectionProvider
, ISelectionChangedListener
, IPartListener
{
89 /** ID for this class */
90 public static final String ID
= "org.eclipse.linuxtools.tmf.ui.editors.events"; //$NON-NLS-1$
92 private TmfEventsTable fEventsTable
;
94 private ITmfTrace fTrace
;
95 private Composite fParent
;
96 private ListenerList fSelectionChangedListeners
= new ListenerList();
99 public void doSave(final IProgressMonitor monitor
) {
103 public void doSaveAs() {
107 public void init(final IEditorSite site
, IEditorInput input
) throws PartInitException
{
108 IFileEditorInput fileEditorInput
;
109 if (input
instanceof TmfEditorInput
) {
110 fFile
= ((TmfEditorInput
) input
).getFile();
111 fTrace
= ((TmfEditorInput
) input
).getTrace();
112 /* change the input to a FileEditorInput to allow open handlers to find this editor */
113 fileEditorInput
= new FileEditorInput(fFile
);
114 } else if (input
instanceof IFileEditorInput
) {
115 fileEditorInput
= (IFileEditorInput
) input
;
116 fFile
= fileEditorInput
.getFile();
118 throw new PartInitException("Invalid IFileEditorInput: " + fileEditorInput
); //$NON-NLS-1$
121 final String traceTypeId
= fFile
.getPersistentProperty(TmfCommonConstants
.TRACETYPE
);
122 if (traceTypeId
== null) {
123 throw new PartInitException(Messages
.OpenTraceHandler_NoTraceType
);
125 if (traceTypeId
.equals(TmfExperiment
.class.getCanonicalName())) {
126 // Special case: experiment bookmark resource
127 final TmfNavigatorContentProvider ncp
= new TmfNavigatorContentProvider();
128 ncp
.getChildren(fFile
.getProject()); // force the model to be populated
129 final TmfProjectElement project
= TmfProjectRegistry
.getProject(fFile
.getProject());
130 if (project
== null) {
131 throw new PartInitException(Messages
.OpenExperimentHandler_NoTraceType
);
133 for (final ITmfProjectModelElement projectElement
: project
.getExperimentsFolder().getChildren()) {
134 final String traceName
= fFile
.getParent().getName();
135 if (projectElement
.getName().equals(traceName
)) {
136 final TmfExperimentElement experimentElement
= (TmfExperimentElement
) projectElement
;
137 // Instantiate the experiment's traces
138 final List
<TmfTraceElement
> traceEntries
= experimentElement
.getTraces();
139 final int nbTraces
= traceEntries
.size();
140 int cacheSize
= Integer
.MAX_VALUE
;
141 final ITmfTrace
[] traces
= new ITmfTrace
[nbTraces
];
142 for (int i
= 0; i
< nbTraces
; i
++) {
143 final TmfTraceElement traceElement
= traceEntries
.get(i
);
144 final ITmfTrace trace
= traceElement
.instantiateTrace();
145 final ITmfEvent traceEvent
= traceElement
.instantiateEvent();
146 if ((trace
== null) || (traceEvent
== null)) {
147 for (int j
= 0; j
< i
; j
++) {
150 throw new PartInitException(Messages
.OpenExperimentHandler_NoTraceType
);
153 trace
.initTrace(traceElement
.getResource(), traceElement
.getLocation().getPath(), traceEvent
.getClass());
154 } catch (final TmfTraceException e
) {
155 throw new PartInitException(Messages
.OpenTraceHandler_InitError
, e
);
157 cacheSize
= Math
.min(cacheSize
, trace
.getCacheSize());
160 final TmfExperiment experiment
= new TmfExperiment(ITmfEvent
.class, experimentElement
.getName(), traces
, cacheSize
);
161 experiment
.setBookmarksFile(fFile
);
166 } else if (traceTypeId
.equals(TmfTrace
.class.getCanonicalName())) {
167 // Special case: trace bookmark resource
168 final TmfNavigatorContentProvider ncp
= new TmfNavigatorContentProvider();
169 ncp
.getChildren(fFile
.getProject()); // force the model to be populated
170 final TmfProjectElement project
= TmfProjectRegistry
.getProject(fFile
.getProject());
171 for (final ITmfProjectModelElement projectElement
: project
.getTracesFolder().getChildren()) {
172 final String traceName
= fFile
.getParent().getName();
173 if (projectElement
.getName().equals(traceName
)) {
174 final TmfTraceElement traceElement
= (TmfTraceElement
) projectElement
;
175 // Instantiate the trace
176 final ITmfTrace trace
= traceElement
.instantiateTrace();
177 final ITmfEvent traceEvent
= traceElement
.instantiateEvent();
178 if ((trace
== null) || (traceEvent
== null)) {
179 throw new PartInitException(Messages
.OpenTraceHandler_NoTraceType
);
182 trace
.initTrace(traceElement
.getResource(), traceElement
.getLocation().getPath(), traceEvent
.getClass());
183 } catch (final TmfTraceException e
) {
184 throw new PartInitException(Messages
.OpenTraceHandler_InitError
, e
);
191 final TmfNavigatorContentProvider ncp
= new TmfNavigatorContentProvider();
192 ncp
.getChildren(fFile
.getProject()); // force the model to be populated
193 final TmfProjectElement project
= TmfProjectRegistry
.getProject(fFile
.getProject());
194 for (final ITmfProjectModelElement projectElement
: project
.getTracesFolder().getChildren()) {
195 if (projectElement
.getResource().equals(fFile
)) {
196 final TmfTraceElement traceElement
= (TmfTraceElement
) projectElement
;
197 // Instantiate the trace
198 final ITmfTrace trace
= traceElement
.instantiateTrace();
199 final ITmfEvent traceEvent
= traceElement
.instantiateEvent();
200 if ((trace
== null) || (traceEvent
== null)) {
201 throw new PartInitException(Messages
.OpenTraceHandler_NoTraceType
);
204 trace
.initTrace(traceElement
.getResource(), traceElement
.getLocation().getPath(), traceEvent
.getClass());
205 } catch (final TmfTraceException e
) {
206 throw new PartInitException(Messages
.OpenTraceHandler_InitError
, e
);
213 } catch (final PartInitException e
) {
215 } catch (final InvalidRegistryObjectException e
) {
216 Activator
.getDefault().logError("Error initializing TmfEventsEditor", e
); //$NON-NLS-1$
217 } catch (final CoreException e
) {
218 Activator
.getDefault().logError("Error initializing TmfEventsEditor", e
); //$NON-NLS-1$
221 throw new PartInitException("Invalid IEditorInput: " + input
.getClass()); //$NON-NLS-1$
223 if (fTrace
== null) {
224 throw new PartInitException("Invalid IEditorInput: " + fFile
.getName()); //$NON-NLS-1$
227 super.setInput(fileEditorInput
);
231 public boolean isDirty() {
236 public boolean isSaveAsAllowed() {
241 public void setInput(final IEditorInput input
) {
242 super.setInput(input
);
243 firePropertyChange(IEditorPart
.PROP_INPUT
);
247 public void propertyChanged(final Object source
, final int propId
) {
248 if (propId
== IEditorPart
.PROP_INPUT
&& getEditorInput() instanceof TmfEditorInput
) {
249 broadcast(new TmfTraceClosedSignal(this, fTrace
));
250 fFile
= ((TmfEditorInput
) getEditorInput()).getFile();
251 fTrace
= ((TmfEditorInput
) getEditorInput()).getTrace();
252 /* change the input to a FileEditorInput to allow open handlers to find this editor */
253 super.setInput(new FileEditorInput(fFile
));
254 fEventsTable
.dispose();
255 if (fTrace
!= null) {
256 fEventsTable
= createEventsTable(fParent
, fTrace
.getCacheSize());
257 fEventsTable
.addSelectionChangedListener(this);
258 fEventsTable
.setTrace(fTrace
, true);
259 fEventsTable
.refreshBookmarks(fFile
);
260 broadcast(new TmfTraceOpenedSignal(this, fTrace
, fFile
));
262 fEventsTable
= new TmfEventsTable(fParent
, 0);
263 fEventsTable
.addSelectionChangedListener(this);
270 public void createPartControl(final Composite parent
) {
272 if (fTrace
!= null) {
273 setPartName(fTrace
.getName());
274 fEventsTable
= createEventsTable(parent
, fTrace
.getCacheSize());
275 fEventsTable
.addSelectionChangedListener(this);
276 fEventsTable
.setTrace(fTrace
, true);
277 fEventsTable
.refreshBookmarks(fFile
);
279 /* ensure start time is set */
280 final ITmfContext context
= fTrace
.seekEvent(0);
281 fTrace
.getNext(context
);
284 broadcast(new TmfTraceOpenedSignal(this, fTrace
, fFile
));
286 setPartName(getEditorInput().getName());
287 fEventsTable
= new TmfEventsTable(parent
, 0);
288 fEventsTable
.addSelectionChangedListener(this);
290 addPropertyListener(this);
291 ResourcesPlugin
.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent
.POST_CHANGE
);
292 // we need to wrap the ISelectionProvider interface in the editor because
293 // the events table can be replaced later while the selection changed listener
294 // is only added once by the platform to the selection provider set here
295 getSite().setSelectionProvider(this);
296 getSite().getPage().addPartListener(this);
300 public void dispose() {
301 if (getSite() != null) {
302 getSite().getPage().removePartListener(this);
304 ResourcesPlugin
.getWorkspace().removeResourceChangeListener(this);
305 removePropertyListener(this);
306 if (fTrace
!= null) {
307 broadcast(new TmfTraceClosedSignal(this, fTrace
));
309 if (fEventsTable
!= null) {
310 fEventsTable
.dispose();
316 * Create the events table
318 * @param parent the parent composite
319 * @param cacheSize the cache size
320 * @return an events table instance
322 protected TmfEventsTable
createEventsTable(final Composite parent
, final int cacheSize
) {
323 TmfEventsTable eventsTable
= getEventsTable(parent
, cacheSize
);
324 if (eventsTable
== null) {
325 eventsTable
= new TmfEventsTable(parent
, cacheSize
);
330 private TmfEventsTable
getEventsTable(final Composite parent
, final int cacheSize
) {
331 if (fTrace
instanceof TmfExperiment
) {
332 return getExperimentEventsTable((TmfExperiment
) fTrace
, parent
, cacheSize
);
334 TmfEventsTable eventsTable
= null;
336 if (fTrace
.getResource() == null) {
339 final String traceType
= fTrace
.getResource().getPersistentProperty(TmfCommonConstants
.TRACETYPE
);
340 if (traceType
== null) {
343 if (traceType
.startsWith(CustomTxtTrace
.class.getCanonicalName())) {
344 return new CustomEventsTable(((CustomTxtTrace
) fTrace
).getDefinition(), parent
, cacheSize
);
346 if (traceType
.startsWith(CustomXmlTrace
.class.getCanonicalName())) {
347 return new CustomEventsTable(((CustomXmlTrace
) fTrace
).getDefinition(), parent
, cacheSize
);
349 for (final IConfigurationElement ce
: TmfTraceType
.getTypeElements()) {
350 if (ce
.getAttribute(TmfTraceType
.ID_ATTR
).equals(traceType
)) {
351 final IConfigurationElement
[] eventsTableTypeCE
= ce
.getChildren(TmfTraceType
.EVENTS_TABLE_TYPE_ELEM
);
352 if (eventsTableTypeCE
.length
!= 1) {
355 final String eventsTableType
= eventsTableTypeCE
[0].getAttribute(TmfTraceType
.CLASS_ATTR
);
356 if ((eventsTableType
== null) || (eventsTableType
.length() == 0)) {
359 final Bundle bundle
= Platform
.getBundle(ce
.getContributor().getName());
360 final Class
<?
> c
= bundle
.loadClass(eventsTableType
);
361 final Class
<?
>[] constructorArgs
= new Class
[] { Composite
.class, int.class };
362 final Constructor
<?
> constructor
= c
.getConstructor(constructorArgs
);
363 final Object
[] args
= new Object
[] { parent
, cacheSize
};
364 eventsTable
= (TmfEventsTable
) constructor
.newInstance(args
);
368 } catch (final InvalidRegistryObjectException e
) {
369 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
370 } catch (final CoreException e
) {
371 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
372 } catch (final ClassNotFoundException e
) {
373 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
374 } catch (final SecurityException e
) {
375 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
376 } catch (final NoSuchMethodException e
) {
377 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
378 } catch (final IllegalArgumentException e
) {
379 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
380 } catch (final InstantiationException e
) {
381 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
382 } catch (final IllegalAccessException e
) {
383 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
384 } catch (final InvocationTargetException e
) {
385 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
391 * Get the events table for an experiment. If all traces in the experiment
392 * are of the same type, use the extension point specified event table
397 * the parent Composite
399 * the event table cache size
400 * @return an events table of the appropriate type
402 private static TmfEventsTable
getExperimentEventsTable(
403 final TmfExperiment experiment
, final Composite parent
,
404 final int cacheSize
) {
405 TmfEventsTable eventsTable
= null;
406 String commonTraceType
= null;
408 for (final ITmfTrace trace
: experiment
.getTraces()) {
409 final IResource resource
= trace
.getResource();
410 if (resource
== null) {
413 final String traceType
= resource
.getPersistentProperty(TmfCommonConstants
.TRACETYPE
);
414 if ((commonTraceType
!= null) && !commonTraceType
.equals(traceType
)) {
417 commonTraceType
= traceType
;
419 if (commonTraceType
== null) {
422 if (commonTraceType
.startsWith(CustomTxtTrace
.class.getCanonicalName())) {
423 return new CustomEventsTable(((CustomTxtTrace
) experiment
.getTraces()[0]).getDefinition(), parent
, cacheSize
);
425 if (commonTraceType
.startsWith(CustomXmlTrace
.class.getCanonicalName())) {
426 return new CustomEventsTable(((CustomXmlTrace
) experiment
.getTraces()[0]).getDefinition(), parent
, cacheSize
);
428 for (final IConfigurationElement ce
: TmfTraceType
.getTypeElements()) {
429 if (ce
.getAttribute(TmfTraceType
.ID_ATTR
).equals(commonTraceType
)) {
430 final IConfigurationElement
[] eventsTableTypeCE
= ce
.getChildren(TmfTraceType
.EVENTS_TABLE_TYPE_ELEM
);
431 if (eventsTableTypeCE
.length
!= 1) {
434 final String eventsTableType
= eventsTableTypeCE
[0].getAttribute(TmfTraceType
.CLASS_ATTR
);
435 if ((eventsTableType
== null) || (eventsTableType
.length() == 0)) {
438 final Bundle bundle
= Platform
.getBundle(ce
.getContributor().getName());
439 final Class
<?
> c
= bundle
.loadClass(eventsTableType
);
440 final Class
<?
>[] constructorArgs
= new Class
[] { Composite
.class, int.class };
441 final Constructor
<?
> constructor
= c
.getConstructor(constructorArgs
);
442 final Object
[] args
= new Object
[] { parent
, cacheSize
};
443 eventsTable
= (TmfEventsTable
) constructor
.newInstance(args
);
447 } catch (final CoreException e
) {
448 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
449 } catch (final InvalidRegistryObjectException e
) {
450 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
451 } catch (final SecurityException e
) {
452 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
453 } catch (final IllegalArgumentException e
) {
454 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
455 } catch (final ClassNotFoundException e
) {
456 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
457 } catch (final NoSuchMethodException e
) {
458 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
459 } catch (final InstantiationException e
) {
460 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
461 } catch (final IllegalAccessException e
) {
462 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
463 } catch (final InvocationTargetException e
) {
464 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
470 public ITmfTrace
getTrace() {
475 public IFile
getBookmarksFile() {
480 public void setFocus() {
481 fEventsTable
.setFocus();
485 public Object
getAdapter(final Class adapter
) {
486 if (IGotoMarker
.class.equals(adapter
)) {
488 } else if (IPropertySheetPage
.class.equals(adapter
)) {
489 return new UnsortedPropertySheetPage();
491 return super.getAdapter(adapter
);
495 public void resourceChanged(final IResourceChangeEvent event
) {
496 for (final IMarkerDelta delta
: event
.findMarkerDeltas(IMarker
.BOOKMARK
, false)) {
497 if (delta
.getResource().equals(fFile
)) {
498 if (delta
.getKind() == IResourceDelta
.REMOVED
) {
499 final IMarker bookmark
= delta
.getMarker();
500 Display
.getDefault().asyncExec(new Runnable() {
503 fEventsTable
.removeBookmark(bookmark
);
506 } else if (delta
.getKind() == IResourceDelta
.CHANGED
) {
507 Display
.getDefault().asyncExec(new Runnable() {
510 fEventsTable
.getTable().refresh();
518 // ------------------------------------------------------------------------
519 // ISelectionProvider
520 // ------------------------------------------------------------------------
523 * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
529 public void addSelectionChangedListener(ISelectionChangedListener listener
) {
530 fSelectionChangedListeners
.add(listener
);
534 * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
540 public ISelection
getSelection() {
541 if (fEventsTable
== null) {
542 return StructuredSelection
.EMPTY
;
544 return fEventsTable
.getSelection();
548 * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
554 public void removeSelectionChangedListener(ISelectionChangedListener listener
) {
555 fSelectionChangedListeners
.remove(listener
);
559 * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)
565 public void setSelection(ISelection selection
) {
570 * Notifies any selection changed listeners that the viewer's selection has changed.
571 * Only listeners registered at the time this method is called are notified.
573 * @param event a selection changed event
575 * @see ISelectionChangedListener#selectionChanged
578 protected void fireSelectionChanged(final SelectionChangedEvent event
) {
579 Object
[] listeners
= fSelectionChangedListeners
.getListeners();
580 for (int i
= 0; i
< listeners
.length
; ++i
) {
581 final ISelectionChangedListener l
= (ISelectionChangedListener
) listeners
[i
];
582 SafeRunnable
.run(new SafeRunnable() {
585 l
.selectionChanged(event
);
591 // ------------------------------------------------------------------------
592 // ISelectionChangedListener
593 // ------------------------------------------------------------------------
597 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
603 public void selectionChanged(SelectionChangedEvent event
) {
604 fireSelectionChanged(event
);
607 // ------------------------------------------------------------------------
609 // ------------------------------------------------------------------------
613 * @see org.eclipse.ui.IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart)
619 public void partActivated(IWorkbenchPart part
) {
620 if (part
== this && fTrace
!= null) {
621 broadcast(new TmfTraceSelectedSignal(this, fTrace
));
627 * @see org.eclipse.ui.IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart)
633 public void partBroughtToTop(IWorkbenchPart part
) {
638 * @see org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart)
644 public void partClosed(IWorkbenchPart part
) {
649 * @see org.eclipse.ui.IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart)
655 public void partDeactivated(IWorkbenchPart part
) {
660 * @see org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
666 public void partOpened(IWorkbenchPart part
) {
669 // ------------------------------------------------------------------------
671 // ------------------------------------------------------------------------
676 public void addBookmark() {
677 fEventsTable
.addBookmark(fFile
);
681 // ------------------------------------------------------------------------
683 // ------------------------------------------------------------------------
686 * Handler for the Trace Selected signal
688 * @param signal The incoming signal
691 public void traceSelected(final TmfTraceSelectedSignal signal
) {
692 if ((signal
.getSource() != this) && signal
.getTrace().equals(fTrace
)) {
693 getSite().getPage().bringToTop(this);
698 * Update the display to use the updated timestamp format
700 * @param signal the incoming signal
704 public void timestampFormatUpdated(TmfTimestampFormatUpdateSignal signal
) {
705 fEventsTable
.refresh();