|
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 * SourceEditorUpdater instance to replace an existing trace location |
|
17 * |
|
18 */ |
|
19 package com.nokia.tracebuilder.engine.source; |
|
20 |
|
21 import com.nokia.tracebuilder.engine.TraceLocation; |
|
22 import com.nokia.tracebuilder.model.Trace; |
|
23 import com.nokia.tracebuilder.source.SourceLocationBase; |
|
24 import com.nokia.tracebuilder.source.SourceParserException; |
|
25 |
|
26 /** |
|
27 * SourceEditorUpdater instance to replace an existing trace location |
|
28 * |
|
29 */ |
|
30 class TraceLocationUpdateWriter extends SourceEditorUpdater { |
|
31 |
|
32 /** |
|
33 * The trace location to be updated |
|
34 */ |
|
35 private TraceLocation location; |
|
36 |
|
37 /** |
|
38 * Creates a new location writer for given location |
|
39 * |
|
40 * @param location |
|
41 * the location to be written to source |
|
42 */ |
|
43 TraceLocationUpdateWriter(TraceLocation location) { |
|
44 super(location.getSource()); |
|
45 this.location = location; |
|
46 } |
|
47 |
|
48 /* |
|
49 * (non-Javadoc) |
|
50 * |
|
51 * @see com.nokia.tracebuilder.engine.source.SourceEditorUpdater#runUpdate() |
|
52 */ |
|
53 @Override |
|
54 protected boolean runUpdate() throws SourceParserException { |
|
55 // If location has been deleted, it cannot be updated |
|
56 boolean updated; |
|
57 if (!location.isDeleted()) { |
|
58 Trace trace = location.getTrace(); |
|
59 int start = TraceLocationRemover.removeLocation(location); |
|
60 location.getSource().internalInsertTrace(trace, start, location, |
|
61 location.getProperties()); |
|
62 updated = true; |
|
63 } else { |
|
64 updated = false; |
|
65 } |
|
66 return updated; |
|
67 } |
|
68 |
|
69 /* |
|
70 * (non-Javadoc) |
|
71 * |
|
72 * @see com.nokia.tracebuilder.engine.source.SourceEditorUpdater#getPosition() |
|
73 */ |
|
74 @Override |
|
75 protected SourceLocationBase getPosition() { |
|
76 return location; |
|
77 } |
|
78 } |