|
1 /* |
|
2 * Copyright (c) 2009 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 the License "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 */ |
|
17 |
|
18 package com.nokia.carbide.cpp.pi; |
|
19 |
|
20 import org.eclipse.jface.resource.ImageDescriptor; |
|
21 import org.osgi.framework.BundleContext; |
|
22 |
|
23 import com.nokia.carbide.cpp.internal.pi.model.Binary; |
|
24 import com.nokia.carbide.cpp.internal.pi.model.CusSample; |
|
25 import com.nokia.carbide.cpp.internal.pi.model.Function; |
|
26 import com.nokia.carbide.cpp.internal.pi.model.GenericEvent; |
|
27 import com.nokia.carbide.cpp.internal.pi.model.GenericEventTrace; |
|
28 import com.nokia.carbide.cpp.internal.pi.model.GenericSample; |
|
29 import com.nokia.carbide.cpp.internal.pi.model.GenericSampleWithFunctions; |
|
30 import com.nokia.carbide.cpp.internal.pi.model.GenericSampledTrace; |
|
31 import com.nokia.carbide.cpp.internal.pi.model.GenericSampledTraceWithFunctions; |
|
32 import com.nokia.carbide.cpp.internal.pi.model.GenericThread; |
|
33 import com.nokia.carbide.cpp.internal.pi.model.GenericTrace; |
|
34 import com.nokia.carbide.cpp.internal.pi.plugin.model.AbstractPiPlugin; |
|
35 import com.nokia.carbide.cpp.internal.pi.plugin.model.IClassReplacer; |
|
36 import com.nokia.carbide.cpp.internal.pi.test.EnabledTrace; |
|
37 import com.nokia.carbide.cpp.internal.pi.test.PIAnalysisInfo; |
|
38 import com.nokia.carbide.cpp.internal.pi.test.BappeaAnalysisInfo; |
|
39 import com.nokia.carbide.cpp.internal.pi.test.TraceAdditionalInfo; |
|
40 import com.nokia.carbide.cpp.internal.pi.visual.AnalyserVisualState; |
|
41 |
|
42 |
|
43 /** |
|
44 * The main plugin class to be used in the desktop. |
|
45 */ |
|
46 public class PiPlugin extends AbstractPiPlugin { |
|
47 |
|
48 //The shared instance. |
|
49 private static PiPlugin plugin; |
|
50 |
|
51 private static void setPlugin(PiPlugin localPlugin) { |
|
52 plugin = localPlugin; |
|
53 } |
|
54 |
|
55 /** |
|
56 * The constructor. |
|
57 */ |
|
58 public PiPlugin() { |
|
59 setPlugin(this); |
|
60 } |
|
61 |
|
62 /** |
|
63 * This method is called upon plug-in activation |
|
64 */ |
|
65 public void start(BundleContext context) throws Exception { |
|
66 super.start(context); |
|
67 } |
|
68 |
|
69 /** |
|
70 * This method is called when the plug-in is stopped |
|
71 */ |
|
72 public void stop(BundleContext context) throws Exception { |
|
73 super.stop(context); |
|
74 setPlugin(null); |
|
75 } |
|
76 |
|
77 /** |
|
78 * Returns the shared instance. |
|
79 */ |
|
80 public static PiPlugin getDefault() { |
|
81 return plugin; |
|
82 } |
|
83 |
|
84 /** |
|
85 * Returns an image descriptor for the image file at the given |
|
86 * plug-in relative path. |
|
87 * |
|
88 * @param path the path |
|
89 * @return the image descriptor |
|
90 */ |
|
91 public static ImageDescriptor getImageDescriptor(String path) { |
|
92 return AbstractPiPlugin.imageDescriptorFromPlugin("com.nokia.carbide.cpp.pi", path); //$NON-NLS-1$ |
|
93 } |
|
94 |
|
95 public static Class getReplacedClass(String className) { |
|
96 // handle legacy PI analysis file class names |
|
97 if (!className.startsWith("fi.")) //$NON-NLS-1$ |
|
98 return null; |
|
99 |
|
100 if (className.equals("fi.vtt.bappea.model.GenericSample")) //$NON-NLS-1$ |
|
101 return GenericSample.class; |
|
102 |
|
103 if (className.equals("fi.vtt.bappea.model.GenericSampledTrace")) { //$NON-NLS-1$ |
|
104 return GenericSampledTrace.class; |
|
105 } |
|
106 |
|
107 if (className.equals("fi.vtt.bappea.model.GenericEventTrace")) { //$NON-NLS-1$ |
|
108 return GenericEventTrace.class; |
|
109 } |
|
110 |
|
111 if (className.equals("fi.vtt.bappea.model.GenericEvent")) { //$NON-NLS-1$ |
|
112 return GenericEvent.class; |
|
113 } |
|
114 |
|
115 if (className.equals("fi.vtt.bappea.model.GenericTrace")) { //$NON-NLS-1$ |
|
116 return GenericTrace.class; |
|
117 } |
|
118 |
|
119 if (className.equals("fi.vtt.bappea.model.GenericThread")) { //$NON-NLS-1$ |
|
120 return GenericThread.class; |
|
121 } |
|
122 |
|
123 if (className.equals("fi.vtt.bappea.model.GenericSampledTraceWithFunctions")) { //$NON-NLS-1$ |
|
124 return GenericSampledTraceWithFunctions.class; |
|
125 } |
|
126 |
|
127 if (className.equals("fi.vtt.bappea.model.GenericSampleWithFunctions")) { //$NON-NLS-1$ |
|
128 return GenericSampleWithFunctions.class; |
|
129 } |
|
130 |
|
131 if (className.equals("fi.vtt.bappea.model.Function")) { //$NON-NLS-1$ |
|
132 return Function.class; |
|
133 } |
|
134 |
|
135 if (className.equals("fi.vtt.bappea.model.Binary")) { //$NON-NLS-1$ |
|
136 return Binary.class; |
|
137 } |
|
138 |
|
139 if (className.equals("fi.vtt.bappea.model.CusSample")) { //$NON-NLS-1$ |
|
140 return CusSample.class; |
|
141 } |
|
142 |
|
143 if (className.equals("fi.vtt.bappea.test.PIAnalysisInfo")) { //$NON-NLS-1$ |
|
144 return PIAnalysisInfo.class; |
|
145 } |
|
146 |
|
147 if (className.equals("fi.vtt.bappea.test.EnabledTrace")) { //$NON-NLS-1$ |
|
148 return EnabledTrace.class; |
|
149 } |
|
150 |
|
151 if (className.equals("fi.vtt.bappea.test.TraceAdditionalInfo")) { //$NON-NLS-1$ |
|
152 return TraceAdditionalInfo.class; |
|
153 } |
|
154 |
|
155 if (className.equals("fi.vtt.bappea.test.BappeaAnalysisInfo")) { //$NON-NLS-1$ |
|
156 return BappeaAnalysisInfo.class; |
|
157 } |
|
158 |
|
159 if (className.equals("fi.vtt.bappea.visual.AnalyserVisualState")) { //$NON-NLS-1$ |
|
160 return AnalyserVisualState.class; |
|
161 } |
|
162 |
|
163 return null; |
|
164 } |
|
165 } |