|
1 /* |
|
2 * Copyright (c) 2007 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.tracebuilder.eventhandler; |
|
20 |
|
21 import com.nokia.trace.eventrouter.TraceEvent; |
|
22 import com.nokia.trace.eventview.EventListEntry; |
|
23 import com.nokia.trace.eventview.TraceEventList; |
|
24 import com.nokia.tracebuilder.engine.TraceLocation; |
|
25 import com.nokia.tracebuilder.model.TraceObject; |
|
26 import com.nokia.tracebuilder.source.SourceLocation; |
|
27 |
|
28 /** |
|
29 * Asynchronously adds an event to the events list |
|
30 * |
|
31 */ |
|
32 final class EventAdder implements Runnable { |
|
33 |
|
34 /** |
|
35 * Event to be added |
|
36 */ |
|
37 private TraceEvent event; |
|
38 |
|
39 /** |
|
40 * The event list |
|
41 */ |
|
42 private TraceEventList eventList; |
|
43 |
|
44 /** |
|
45 * Constructor |
|
46 * |
|
47 * @param eventList |
|
48 * the event list |
|
49 * @param event |
|
50 * the event to be added |
|
51 */ |
|
52 EventAdder(TraceEventList eventList, TraceEvent event) { |
|
53 this.event = event; |
|
54 this.eventList = eventList; |
|
55 Object o = event.getSource(); |
|
56 // Adds a reference so the location does not get removed from the source |
|
57 if (o instanceof SourceLocation) { |
|
58 ((SourceLocation) o).reference(); |
|
59 } |
|
60 } |
|
61 |
|
62 /* |
|
63 * (non-Javadoc) |
|
64 * |
|
65 * @see java.lang.Runnable#run() |
|
66 */ |
|
67 public void run() { |
|
68 Object o = event.getSource(); |
|
69 EventListEntry entry = null; |
|
70 if (o instanceof TraceLocation) { |
|
71 // Location delete flag needs to be checked, since this is |
|
72 // called asynchronously. The location might have been deleted |
|
73 TraceLocation location = (TraceLocation) o; |
|
74 if (!location.isDeleted()) { |
|
75 entry = new EventListEntryTraceLocation(event.getType(), event |
|
76 .getDescription(), eventList, location); |
|
77 } |
|
78 } else if (o instanceof TraceObject) { |
|
79 TraceObject object = (TraceObject) o; |
|
80 entry = new EventListEntryTraceObject(event.getType(), event |
|
81 .getDescription(), object); |
|
82 } else if (o instanceof SourceLocation) { |
|
83 SourceLocation location = (SourceLocation) o; |
|
84 if (!location.isDeleted()) { |
|
85 entry = new EventListEntrySourceLocation(event.getType(), event |
|
86 .getDescription(), eventList, location); |
|
87 } |
|
88 } |
|
89 if (entry != null) { |
|
90 entry.setCategory(event.getCategory()); |
|
91 eventList.addEntry(entry); |
|
92 } |
|
93 } |
|
94 |
|
95 } |