|
1 /* |
|
2 * Copyright (c) 2007-2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 * Asynchronously adds an event to the events list |
|
17 * |
|
18 */ |
|
19 package com.nokia.trace.eventview; |
|
20 |
|
21 import com.nokia.trace.eventrouter.TraceEvent; |
|
22 |
|
23 /** |
|
24 * Asynchronously adds an event to the events list |
|
25 * |
|
26 */ |
|
27 final class EventAdder implements Runnable { |
|
28 |
|
29 /** |
|
30 * Event to be added |
|
31 */ |
|
32 private TraceEvent event; |
|
33 |
|
34 /** |
|
35 * The content provider |
|
36 */ |
|
37 private EventListContentProvider contentProvider; |
|
38 |
|
39 /** |
|
40 * Constructor |
|
41 * |
|
42 * @param contentProvider |
|
43 * the content provider |
|
44 * @param event |
|
45 * the event to be added |
|
46 */ |
|
47 public EventAdder(EventListContentProvider contentProvider, TraceEvent event) { |
|
48 this.event = event; |
|
49 this.contentProvider = contentProvider; |
|
50 } |
|
51 |
|
52 /* |
|
53 * (non-Javadoc) |
|
54 * |
|
55 * @see java.lang.Runnable#run() |
|
56 */ |
|
57 public void run() { |
|
58 Object o = event.getSource(); |
|
59 EventListEntry entry = null; |
|
60 if (o instanceof Throwable) { |
|
61 entry = new EventListEntryThrowable(event.getType(), event |
|
62 .getDescription(), (Throwable) o); |
|
63 } else if (o instanceof String) { |
|
64 entry = new EventListEntryString(event.getType(), event |
|
65 .getDescription(), (String) o); |
|
66 } else { |
|
67 entry = new EventListEntryString(event.getType(), event |
|
68 .getDescription(), null); |
|
69 } |
|
70 entry.setCategory(event.getCategory()); |
|
71 contentProvider.addEntry(entry); |
|
72 if (TraceEventView.contentChangeListener != null) { |
|
73 TraceEventView.contentChangeListener.contentChanged(); |
|
74 } |
|
75 } |
|
76 |
|
77 } |