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
.ITmfTrace
;
53 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfExperiment
;
54 import org
.eclipse
.linuxtools
.tmf
.core
.trace
.TmfTrace
;
55 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.ITmfProjectModelElement
;
56 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfExperimentElement
;
57 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfNavigatorContentProvider
;
58 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfProjectElement
;
59 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfProjectRegistry
;
60 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceElement
;
61 import org
.eclipse
.linuxtools
.tmf
.ui
.project
.model
.TmfTraceType
;
62 import org
.eclipse
.linuxtools
.tmf
.ui
.viewers
.events
.TmfEventsTable
;
63 import org
.eclipse
.swt
.widgets
.Composite
;
64 import org
.eclipse
.swt
.widgets
.Display
;
65 import org
.eclipse
.ui
.IEditorInput
;
66 import org
.eclipse
.ui
.IEditorPart
;
67 import org
.eclipse
.ui
.IEditorSite
;
68 import org
.eclipse
.ui
.IFileEditorInput
;
69 import org
.eclipse
.ui
.IPartListener
;
70 import org
.eclipse
.ui
.IPropertyListener
;
71 import org
.eclipse
.ui
.IReusableEditor
;
72 import org
.eclipse
.ui
.IWorkbenchPart
;
73 import org
.eclipse
.ui
.PartInitException
;
74 import org
.eclipse
.ui
.ide
.IGotoMarker
;
75 import org
.eclipse
.ui
.part
.FileEditorInput
;
76 import org
.eclipse
.ui
.views
.properties
.IPropertySheetPage
;
77 import org
.osgi
.framework
.Bundle
;
80 * Editor for TMF events
83 * @author Patrick Tasse
86 public class TmfEventsEditor
extends TmfEditor
implements ITmfTraceEditor
, IReusableEditor
, IPropertyListener
, IResourceChangeListener
, ISelectionProvider
, ISelectionChangedListener
, IPartListener
{
88 /** ID for this class */
89 public static final String ID
= "org.eclipse.linuxtools.tmf.ui.editors.events"; //$NON-NLS-1$
91 private TmfEventsTable fEventsTable
;
93 private ITmfTrace fTrace
;
94 private Composite fParent
;
95 private ListenerList fSelectionChangedListeners
= new ListenerList();
98 public void doSave(final IProgressMonitor monitor
) {
102 public void doSaveAs() {
106 public void init(final IEditorSite site
, IEditorInput input
) throws PartInitException
{
107 IFileEditorInput fileEditorInput
;
108 if (input
instanceof TmfEditorInput
) {
109 fFile
= ((TmfEditorInput
) input
).getFile();
110 fTrace
= ((TmfEditorInput
) input
).getTrace();
111 /* change the input to a FileEditorInput to allow open handlers to find this editor */
112 fileEditorInput
= new FileEditorInput(fFile
);
113 } else if (input
instanceof IFileEditorInput
) {
114 fileEditorInput
= (IFileEditorInput
) input
;
115 fFile
= fileEditorInput
.getFile();
117 throw new PartInitException("Invalid IFileEditorInput: " + fileEditorInput
); //$NON-NLS-1$
120 final String traceTypeId
= fFile
.getPersistentProperty(TmfCommonConstants
.TRACETYPE
);
121 if (traceTypeId
== null) {
122 throw new PartInitException(Messages
.OpenTraceHandler_NoTraceType
);
124 if (traceTypeId
.equals(TmfExperiment
.class.getCanonicalName())) {
125 // Special case: experiment bookmark resource
126 final TmfNavigatorContentProvider ncp
= new TmfNavigatorContentProvider();
127 ncp
.getChildren(fFile
.getProject()); // force the model to be populated
128 final TmfProjectElement project
= TmfProjectRegistry
.getProject(fFile
.getProject());
129 if (project
== null) {
130 throw new PartInitException(Messages
.OpenExperimentHandler_NoTraceType
);
132 for (final ITmfProjectModelElement projectElement
: project
.getExperimentsFolder().getChildren()) {
133 final String traceName
= fFile
.getParent().getName();
134 if (projectElement
.getName().equals(traceName
)) {
135 final TmfExperimentElement experimentElement
= (TmfExperimentElement
) projectElement
;
136 // Instantiate the experiment's traces
137 final List
<TmfTraceElement
> traceEntries
= experimentElement
.getTraces();
138 final int nbTraces
= traceEntries
.size();
139 int cacheSize
= Integer
.MAX_VALUE
;
140 final ITmfTrace
[] traces
= new ITmfTrace
[nbTraces
];
141 for (int i
= 0; i
< nbTraces
; i
++) {
142 final TmfTraceElement traceElement
= traceEntries
.get(i
);
143 final ITmfTrace trace
= traceElement
.instantiateTrace();
144 final ITmfEvent traceEvent
= traceElement
.instantiateEvent();
145 if ((trace
== null) || (traceEvent
== null)) {
146 for (int j
= 0; j
< i
; j
++) {
149 throw new PartInitException(Messages
.OpenExperimentHandler_NoTraceType
);
152 trace
.initTrace(traceElement
.getResource(), traceElement
.getLocation().getPath(), traceEvent
.getClass());
153 } catch (final TmfTraceException e
) {
154 throw new PartInitException(Messages
.OpenTraceHandler_NoTrace
, e
);
156 cacheSize
= Math
.min(cacheSize
, trace
.getCacheSize());
159 final TmfExperiment experiment
= new TmfExperiment(ITmfEvent
.class, experimentElement
.getName(), traces
, cacheSize
);
160 experiment
.setBookmarksFile(fFile
);
165 } else if (traceTypeId
.equals(TmfTrace
.class.getCanonicalName())) {
166 // Special case: trace bookmark resource
167 final TmfNavigatorContentProvider ncp
= new TmfNavigatorContentProvider();
168 ncp
.getChildren(fFile
.getProject()); // force the model to be populated
169 final TmfProjectElement project
= TmfProjectRegistry
.getProject(fFile
.getProject());
170 for (final ITmfProjectModelElement projectElement
: project
.getTracesFolder().getChildren()) {
171 final String traceName
= fFile
.getParent().getName();
172 if (projectElement
.getName().equals(traceName
)) {
173 final TmfTraceElement traceElement
= (TmfTraceElement
) projectElement
;
174 // Instantiate the trace
175 final ITmfTrace trace
= traceElement
.instantiateTrace();
176 final ITmfEvent traceEvent
= traceElement
.instantiateEvent();
177 if ((trace
== null) || (traceEvent
== null)) {
178 throw new PartInitException(Messages
.OpenTraceHandler_NoTraceType
);
181 trace
.initTrace(traceElement
.getResource(), traceElement
.getLocation().getPath(), traceEvent
.getClass());
182 } catch (final TmfTraceException e
) {
183 throw new PartInitException(Messages
.OpenTraceHandler_NoTrace
, e
);
190 final TmfNavigatorContentProvider ncp
= new TmfNavigatorContentProvider();
191 ncp
.getChildren(fFile
.getProject()); // force the model to be populated
192 final TmfProjectElement project
= TmfProjectRegistry
.getProject(fFile
.getProject());
193 for (final ITmfProjectModelElement projectElement
: project
.getTracesFolder().getChildren()) {
194 if (projectElement
.getResource().equals(fFile
)) {
195 final TmfTraceElement traceElement
= (TmfTraceElement
) projectElement
;
196 // Instantiate the trace
197 final ITmfTrace trace
= traceElement
.instantiateTrace();
198 final ITmfEvent traceEvent
= traceElement
.instantiateEvent();
199 if ((trace
== null) || (traceEvent
== null)) {
200 throw new PartInitException(Messages
.OpenTraceHandler_NoTraceType
);
203 trace
.initTrace(traceElement
.getResource(), traceElement
.getLocation().getPath(), traceEvent
.getClass());
204 } catch (final TmfTraceException e
) {
205 throw new PartInitException(Messages
.OpenTraceHandler_NoTrace
, e
);
212 } catch (final PartInitException e
) {
214 } catch (final InvalidRegistryObjectException e
) {
215 Activator
.getDefault().logError("Error initializing TmfEventsEditor", e
); //$NON-NLS-1$
216 } catch (final CoreException e
) {
217 Activator
.getDefault().logError("Error initializing TmfEventsEditor", e
); //$NON-NLS-1$
220 throw new PartInitException("Invalid IEditorInput: " + input
.getClass()); //$NON-NLS-1$
222 if (fTrace
== null) {
223 throw new PartInitException("Invalid IEditorInput: " + fFile
.getName()); //$NON-NLS-1$
226 super.setInput(fileEditorInput
);
230 public boolean isDirty() {
235 public boolean isSaveAsAllowed() {
240 public void setInput(final IEditorInput input
) {
241 super.setInput(input
);
242 firePropertyChange(IEditorPart
.PROP_INPUT
);
246 public void propertyChanged(final Object source
, final int propId
) {
247 if (propId
== IEditorPart
.PROP_INPUT
&& getEditorInput() instanceof TmfEditorInput
) {
248 broadcast(new TmfTraceClosedSignal(this, fTrace
));
249 fFile
= ((TmfEditorInput
) getEditorInput()).getFile();
250 fTrace
= ((TmfEditorInput
) getEditorInput()).getTrace();
251 /* change the input to a FileEditorInput to allow open handlers to find this editor */
252 super.setInput(new FileEditorInput(fFile
));
253 fEventsTable
.dispose();
254 if (fTrace
!= null) {
255 fEventsTable
= createEventsTable(fParent
, fTrace
.getCacheSize());
256 fEventsTable
.addSelectionChangedListener(this);
257 fEventsTable
.setTrace(fTrace
, true);
258 fEventsTable
.refreshBookmarks(fFile
);
259 broadcast(new TmfTraceOpenedSignal(this, fTrace
, fFile
));
261 fEventsTable
= new TmfEventsTable(fParent
, 0);
262 fEventsTable
.addSelectionChangedListener(this);
269 public void createPartControl(final Composite parent
) {
271 if (fTrace
!= null) {
272 setPartName(fTrace
.getName());
273 fEventsTable
= createEventsTable(parent
, fTrace
.getCacheSize());
274 fEventsTable
.addSelectionChangedListener(this);
275 fEventsTable
.setTrace(fTrace
, true);
276 fEventsTable
.refreshBookmarks(fFile
);
277 broadcast(new TmfTraceOpenedSignal(this, fTrace
, fFile
));
279 setPartName(getEditorInput().getName());
280 fEventsTable
= new TmfEventsTable(parent
, 0);
281 fEventsTable
.addSelectionChangedListener(this);
283 addPropertyListener(this);
284 ResourcesPlugin
.getWorkspace().addResourceChangeListener(this, IResourceChangeEvent
.POST_CHANGE
);
285 // we need to wrap the ISelectionProvider interface in the editor because
286 // the events table can be replaced later while the selection changed listener
287 // is only added once by the platform to the selection provider set here
288 getSite().setSelectionProvider(this);
289 getSite().getPage().addPartListener(this);
293 public void dispose() {
294 if (getSite() != null) {
295 getSite().getPage().removePartListener(this);
297 ResourcesPlugin
.getWorkspace().removeResourceChangeListener(this);
298 removePropertyListener(this);
299 if (fTrace
!= null) {
300 broadcast(new TmfTraceClosedSignal(this, fTrace
));
302 if (fEventsTable
!= null) {
303 fEventsTable
.dispose();
309 * Create the events table
311 * @param parent the parent composite
312 * @param cacheSize the cache size
313 * @return an events table instance
315 protected TmfEventsTable
createEventsTable(final Composite parent
, final int cacheSize
) {
316 TmfEventsTable eventsTable
= getEventsTable(parent
, cacheSize
);
317 if (eventsTable
== null) {
318 eventsTable
= new TmfEventsTable(parent
, cacheSize
);
323 private TmfEventsTable
getEventsTable(final Composite parent
, final int cacheSize
) {
324 if (fTrace
instanceof TmfExperiment
) {
325 return getExperimentEventsTable((TmfExperiment
) fTrace
, parent
, cacheSize
);
327 TmfEventsTable eventsTable
= null;
329 if (fTrace
.getResource() == null) {
332 final String traceType
= fTrace
.getResource().getPersistentProperty(TmfCommonConstants
.TRACETYPE
);
333 if (traceType
== null) {
336 if (traceType
.startsWith(CustomTxtTrace
.class.getCanonicalName())) {
337 return new CustomEventsTable(((CustomTxtTrace
) fTrace
).getDefinition(), parent
, cacheSize
);
339 if (traceType
.startsWith(CustomXmlTrace
.class.getCanonicalName())) {
340 return new CustomEventsTable(((CustomXmlTrace
) fTrace
).getDefinition(), parent
, cacheSize
);
342 for (final IConfigurationElement ce
: TmfTraceType
.getTypeElements()) {
343 if (ce
.getAttribute(TmfTraceType
.ID_ATTR
).equals(traceType
)) {
344 final IConfigurationElement
[] eventsTableTypeCE
= ce
.getChildren(TmfTraceType
.EVENTS_TABLE_TYPE_ELEM
);
345 if (eventsTableTypeCE
.length
!= 1) {
348 final String eventsTableType
= eventsTableTypeCE
[0].getAttribute(TmfTraceType
.CLASS_ATTR
);
349 if ((eventsTableType
== null) || (eventsTableType
.length() == 0)) {
352 final Bundle bundle
= Platform
.getBundle(ce
.getContributor().getName());
353 final Class
<?
> c
= bundle
.loadClass(eventsTableType
);
354 final Class
<?
>[] constructorArgs
= new Class
[] { Composite
.class, int.class };
355 final Constructor
<?
> constructor
= c
.getConstructor(constructorArgs
);
356 final Object
[] args
= new Object
[] { parent
, cacheSize
};
357 eventsTable
= (TmfEventsTable
) constructor
.newInstance(args
);
361 } catch (final InvalidRegistryObjectException e
) {
362 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
363 } catch (final CoreException e
) {
364 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
365 } catch (final ClassNotFoundException e
) {
366 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
367 } catch (final SecurityException e
) {
368 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
369 } catch (final NoSuchMethodException e
) {
370 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
371 } catch (final IllegalArgumentException e
) {
372 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
373 } catch (final InstantiationException e
) {
374 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
375 } catch (final IllegalAccessException e
) {
376 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
377 } catch (final InvocationTargetException e
) {
378 Activator
.getDefault().logError("Error getting TmfEventsTable", e
); //$NON-NLS-1$
384 * Get the events table for an experiment. If all traces in the experiment
385 * are of the same type, use the extension point specified event table
390 * the parent Composite
392 * the event table cache size
393 * @return an events table of the appropriate type
395 private static TmfEventsTable
getExperimentEventsTable(
396 final TmfExperiment experiment
, final Composite parent
,
397 final int cacheSize
) {
398 TmfEventsTable eventsTable
= null;
399 String commonTraceType
= null;
401 for (final ITmfTrace trace
: experiment
.getTraces()) {
402 final IResource resource
= trace
.getResource();
403 if (resource
== null) {
406 final String traceType
= resource
.getPersistentProperty(TmfCommonConstants
.TRACETYPE
);
407 if ((commonTraceType
!= null) && !commonTraceType
.equals(traceType
)) {
410 commonTraceType
= traceType
;
412 if (commonTraceType
== null) {
415 if (commonTraceType
.startsWith(CustomTxtTrace
.class.getCanonicalName())) {
416 return new CustomEventsTable(((CustomTxtTrace
) experiment
.getTraces()[0]).getDefinition(), parent
, cacheSize
);
418 if (commonTraceType
.startsWith(CustomXmlTrace
.class.getCanonicalName())) {
419 return new CustomEventsTable(((CustomXmlTrace
) experiment
.getTraces()[0]).getDefinition(), parent
, cacheSize
);
421 for (final IConfigurationElement ce
: TmfTraceType
.getTypeElements()) {
422 if (ce
.getAttribute(TmfTraceType
.ID_ATTR
).equals(commonTraceType
)) {
423 final IConfigurationElement
[] eventsTableTypeCE
= ce
.getChildren(TmfTraceType
.EVENTS_TABLE_TYPE_ELEM
);
424 if (eventsTableTypeCE
.length
!= 1) {
427 final String eventsTableType
= eventsTableTypeCE
[0].getAttribute(TmfTraceType
.CLASS_ATTR
);
428 if ((eventsTableType
== null) || (eventsTableType
.length() == 0)) {
431 final Bundle bundle
= Platform
.getBundle(ce
.getContributor().getName());
432 final Class
<?
> c
= bundle
.loadClass(eventsTableType
);
433 final Class
<?
>[] constructorArgs
= new Class
[] { Composite
.class, int.class };
434 final Constructor
<?
> constructor
= c
.getConstructor(constructorArgs
);
435 final Object
[] args
= new Object
[] { parent
, cacheSize
};
436 eventsTable
= (TmfEventsTable
) constructor
.newInstance(args
);
440 } catch (final CoreException e
) {
441 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
442 } catch (final InvalidRegistryObjectException e
) {
443 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
444 } catch (final SecurityException e
) {
445 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
446 } catch (final IllegalArgumentException e
) {
447 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
448 } catch (final ClassNotFoundException e
) {
449 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
450 } catch (final NoSuchMethodException e
) {
451 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
452 } catch (final InstantiationException e
) {
453 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
454 } catch (final IllegalAccessException e
) {
455 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
456 } catch (final InvocationTargetException e
) {
457 Activator
.getDefault().logError("Error getting TmfEventsTable for experiment", e
); //$NON-NLS-1$
463 public ITmfTrace
getTrace() {
468 public IFile
getBookmarksFile() {
473 public void setFocus() {
474 fEventsTable
.setFocus();
478 public Object
getAdapter(final Class adapter
) {
479 if (IGotoMarker
.class.equals(adapter
)) {
481 } else if (IPropertySheetPage
.class.equals(adapter
)) {
482 return new UnsortedPropertySheetPage();
484 return super.getAdapter(adapter
);
488 public void resourceChanged(final IResourceChangeEvent event
) {
489 for (final IMarkerDelta delta
: event
.findMarkerDeltas(IMarker
.BOOKMARK
, false)) {
490 if (delta
.getResource().equals(fFile
)) {
491 if (delta
.getKind() == IResourceDelta
.REMOVED
) {
492 final IMarker bookmark
= delta
.getMarker();
493 Display
.getDefault().asyncExec(new Runnable() {
496 fEventsTable
.removeBookmark(bookmark
);
499 } else if (delta
.getKind() == IResourceDelta
.CHANGED
) {
500 Display
.getDefault().asyncExec(new Runnable() {
503 fEventsTable
.getTable().refresh();
511 // ------------------------------------------------------------------------
512 // ISelectionProvider
513 // ------------------------------------------------------------------------
516 * @see org.eclipse.jface.viewers.ISelectionProvider#addSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
522 public void addSelectionChangedListener(ISelectionChangedListener listener
) {
523 fSelectionChangedListeners
.add(listener
);
527 * @see org.eclipse.jface.viewers.ISelectionProvider#getSelection()
533 public ISelection
getSelection() {
534 if (fEventsTable
== null) {
535 return StructuredSelection
.EMPTY
;
537 return fEventsTable
.getSelection();
541 * @see org.eclipse.jface.viewers.ISelectionProvider#removeSelectionChangedListener(org.eclipse.jface.viewers.ISelectionChangedListener)
547 public void removeSelectionChangedListener(ISelectionChangedListener listener
) {
548 fSelectionChangedListeners
.remove(listener
);
552 * @see org.eclipse.jface.viewers.ISelectionProvider#setSelection(org.eclipse.jface.viewers.ISelection)
558 public void setSelection(ISelection selection
) {
563 * Notifies any selection changed listeners that the viewer's selection has changed.
564 * Only listeners registered at the time this method is called are notified.
566 * @param event a selection changed event
568 * @see ISelectionChangedListener#selectionChanged
571 protected void fireSelectionChanged(final SelectionChangedEvent event
) {
572 Object
[] listeners
= fSelectionChangedListeners
.getListeners();
573 for (int i
= 0; i
< listeners
.length
; ++i
) {
574 final ISelectionChangedListener l
= (ISelectionChangedListener
) listeners
[i
];
575 SafeRunnable
.run(new SafeRunnable() {
578 l
.selectionChanged(event
);
584 // ------------------------------------------------------------------------
585 // ISelectionChangedListener
586 // ------------------------------------------------------------------------
590 * @see org.eclipse.jface.viewers.ISelectionChangedListener#selectionChanged(org.eclipse.jface.viewers.SelectionChangedEvent)
596 public void selectionChanged(SelectionChangedEvent event
) {
597 fireSelectionChanged(event
);
600 // ------------------------------------------------------------------------
602 // ------------------------------------------------------------------------
606 * @see org.eclipse.ui.IPartListener#partActivated(org.eclipse.ui.IWorkbenchPart)
612 public void partActivated(IWorkbenchPart part
) {
613 if (part
== this && fTrace
!= null) {
614 broadcast(new TmfTraceSelectedSignal(this, fTrace
));
620 * @see org.eclipse.ui.IPartListener#partBroughtToTop(org.eclipse.ui.IWorkbenchPart)
626 public void partBroughtToTop(IWorkbenchPart part
) {
631 * @see org.eclipse.ui.IPartListener#partClosed(org.eclipse.ui.IWorkbenchPart)
637 public void partClosed(IWorkbenchPart part
) {
642 * @see org.eclipse.ui.IPartListener#partDeactivated(org.eclipse.ui.IWorkbenchPart)
648 public void partDeactivated(IWorkbenchPart part
) {
653 * @see org.eclipse.ui.IPartListener#partOpened(org.eclipse.ui.IWorkbenchPart)
659 public void partOpened(IWorkbenchPart part
) {
662 // ------------------------------------------------------------------------
664 // ------------------------------------------------------------------------
669 public void addBookmark() {
670 fEventsTable
.addBookmark(fFile
);
674 // ------------------------------------------------------------------------
676 // ------------------------------------------------------------------------
679 * Handler for the Trace Selected signal
681 * @param signal The incoming signal
684 public void traceSelected(final TmfTraceSelectedSignal signal
) {
685 if ((signal
.getSource() != this) && signal
.getTrace().equals(fTrace
)) {
686 getSite().getPage().bringToTop(this);
691 * Update the display to use the updated timestamp format
693 * @param signal the incoming signal
697 public void timestampFormatUpdated(TmfTimestampFormatUpdateSignal signal
) {
698 fEventsTable
.refresh();