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 * Model listener for trace location mapper |
|
17 * |
|
18 */ |
|
19 package com.nokia.tracecompiler.engine; |
|
20 |
|
21 import com.nokia.tracecompiler.model.Trace; |
|
22 import com.nokia.tracecompiler.model.TraceCompilerException; |
|
23 import com.nokia.tracecompiler.model.TraceGroup; |
|
24 import com.nokia.tracecompiler.model.TraceModelListener; |
|
25 import com.nokia.tracecompiler.model.TraceObject; |
|
26 import com.nokia.tracecompiler.model.TraceParameter; |
|
27 |
|
28 /** |
|
29 * Model listener for trace location mapper |
|
30 * |
|
31 */ |
|
32 final class LocationMapModelListener implements TraceModelListener { |
|
33 |
|
34 /** |
|
35 * Trace location mapper |
|
36 */ |
|
37 private final TraceLocationMap locationMap; |
|
38 |
|
39 /** |
|
40 * Constructor |
|
41 * |
|
42 * @param map |
|
43 * the location mapper |
|
44 */ |
|
45 LocationMapModelListener(TraceLocationMap map) { |
|
46 locationMap = map; |
|
47 } |
|
48 |
|
49 /* |
|
50 * (non-Javadoc) |
|
51 * |
|
52 * @see com.nokia.tracecompiler.model.TraceModelListener# |
|
53 * objectAdded(com.nokia.tracecompiler.model.TraceObject, |
|
54 * com.nokia.tracecompiler.model.TraceObject) |
|
55 */ |
|
56 public void objectAdded(TraceObject owner, TraceObject object) { |
|
57 // A trace does not have a name yet, so this does nothing |
|
58 // The locations are assigned to the trace in propertyChanged |
|
59 } |
|
60 |
|
61 /* |
|
62 * (non-Javadoc) |
|
63 * |
|
64 * @see com.nokia.tracecompiler.model.TraceModelListener# |
|
65 * objectRemoved(com.nokia.tracecompiler.model.TraceObject, |
|
66 * com.nokia.tracecompiler.model.TraceObject) |
|
67 */ |
|
68 public void objectRemoved(TraceObject owner, TraceObject object) throws TraceCompilerException { |
|
69 if (object instanceof Trace) { |
|
70 locationMap.moveToUnrelated((Trace) object); |
|
71 } else if (object instanceof TraceGroup) { |
|
72 // Moves locations to unrelated list |
|
73 for (Trace trace : (TraceGroup) object) { |
|
74 locationMap.moveToUnrelated(trace); |
|
75 } |
|
76 } |
|
77 } |
|
78 |
|
79 /* |
|
80 * (non-Javadoc) |
|
81 * |
|
82 * @see com.nokia.tracecompiler.model.TraceModelListener# |
|
83 * propertiesUpdated(com.nokia.tracecompiler.model.TraceObject) |
|
84 */ |
|
85 public void propertyUpdated(TraceObject object, int property) throws TraceCompilerException { |
|
86 if (object instanceof Trace && property == NAME && object.isComplete()) { |
|
87 Trace trace = (Trace) object; |
|
88 locationMap.moveFromUnrelated(trace); |
|
89 } |
|
90 } |
|
91 |
|
92 /* |
|
93 * (non-Javadoc) |
|
94 * |
|
95 * @see com.nokia.tracecompiler.model.TraceModelListener# |
|
96 * objectCreationComplete(com.nokia.tracecompiler.model.TraceObject) |
|
97 */ |
|
98 public void objectCreationComplete(TraceObject object) throws TraceCompilerException { |
|
99 if (object instanceof Trace) { |
|
100 Trace trace = (Trace) object; |
|
101 locationMap.moveFromUnrelated(trace); |
|
102 } else if (object instanceof TraceParameter) { |
|
103 // If a parameter is added, the validity needs to be checked |
|
104 TraceLocationList list = ((TraceParameter) object).getTrace() |
|
105 .getExtension(TraceLocationList.class); |
|
106 if (list != null) { |
|
107 for (LocationProperties loc : list) { |
|
108 ((TraceLocation) loc).runValidityCheck(); |
|
109 } |
|
110 } |
|
111 } |
|
112 } |
|
113 } |
|