|
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.function; |
|
19 |
|
20 import org.eclipse.jface.action.Action; |
|
21 import org.eclipse.jface.resource.ImageDescriptor; |
|
22 import org.eclipse.swt.widgets.Event; |
|
23 import org.osgi.framework.BundleContext; |
|
24 |
|
25 import com.nokia.carbide.cpp.internal.pi.plugin.model.AbstractPiPlugin; |
|
26 import com.nokia.carbide.cpp.internal.pi.plugin.model.IAnalysisItem; |
|
27 import com.nokia.carbide.cpp.internal.pi.plugin.model.IEventListener; |
|
28 |
|
29 |
|
30 /** |
|
31 * The main plugin class to be used in the desktop. |
|
32 */ |
|
33 public class FunctionPlugin extends AbstractPiPlugin |
|
34 implements IAnalysisItem, IEventListener |
|
35 { |
|
36 //The shared instance. |
|
37 private static FunctionPlugin plugin; |
|
38 |
|
39 /** |
|
40 * The constructor. |
|
41 */ |
|
42 public FunctionPlugin() { |
|
43 plugin = this; |
|
44 } |
|
45 |
|
46 public Action getAnalysisAction() { |
|
47 return null; |
|
48 } |
|
49 |
|
50 public void action() |
|
51 { |
|
52 |
|
53 } |
|
54 |
|
55 // private boolean checkGfcRequirements(PICompositePanel compositePanel, GfcTrace gfcTrace) |
|
56 // { |
|
57 // boolean startOk = true; |
|
58 // boolean endOk = true; |
|
59 // |
|
60 // if ( compositePanel.getSelectionEnd() < gfcTrace.getFirstSampleNumber() || |
|
61 // compositePanel.getSelectionStart() > gfcTrace.getLastSampleNumber()) |
|
62 // { |
|
63 // GeneralMessages.showErrorMessage("There is no Gfc Trace Data for time "+ |
|
64 // (double)compositePanel.getSelectionStart()/1000+"s-"+ |
|
65 // ((double)compositePanel.getSelectionEnd())/1000+ |
|
66 // "s Current GFC trace is "+ |
|
67 // (double)gfcTrace.getFirstSampleNumber()/1000+"s-"+ |
|
68 // (double)gfcTrace.getLastSampleNumber()/1000+"s"); |
|
69 // return false; |
|
70 // } |
|
71 // |
|
72 // if (compositePanel.getSelectionStart() < gfcTrace.getFirstSampleNumber()) |
|
73 // { |
|
74 // boolean result = GeneralMessages.showProblemMessage("There is no Gfc Trace Data for time "+ |
|
75 // (double)compositePanel.getSelectionStart()/1000+"s-"+ |
|
76 // ((double)gfcTrace.getFirstSampleNumber()-1)/1000+ |
|
77 // "s Current GFC trace is "+ |
|
78 // (double)gfcTrace.getFirstSampleNumber()/1000+"s-"+ |
|
79 // (double)gfcTrace.getLastSampleNumber()/1000+"s"+ |
|
80 // " Do you want to move selection start to "+(double)gfcTrace.getFirstSampleNumber()/1000+"s ?"); |
|
81 // |
|
82 // if (result == true) |
|
83 // { |
|
84 // compositePanel.setSelectionFields( |
|
85 // gfcTrace.getFirstSampleNumber(),(int) compositePanel.getSelectionEnd()); |
|
86 // } |
|
87 // else startOk =false; |
|
88 // } |
|
89 // if (compositePanel.getSelectionEnd() > gfcTrace.getLastSampleNumber()) |
|
90 // { |
|
91 // boolean result = GeneralMessages.showProblemMessage("There is no Gfc Trace Data for time "+ |
|
92 // ((double)gfcTrace.getLastSampleNumber()+1)/1000+"s-"+ |
|
93 // (double)compositePanel.getSelectionEnd()/1000+ |
|
94 // "s Current GFC trace is "+ |
|
95 // (double)gfcTrace.getFirstSampleNumber()/1000+"s-"+ |
|
96 // (double)gfcTrace.getLastSampleNumber()/1000+"s"+ |
|
97 // " Do you want to move selection end to "+(double)gfcTrace.getLastSampleNumber()/1000+"s ?"); |
|
98 // |
|
99 // if (result == true) |
|
100 // { |
|
101 // compositePanel.setSelectionFields( |
|
102 // (int) compositePanel.getSelectionStart(),gfcTrace.getLastSampleNumber()); |
|
103 // } |
|
104 // else endOk =false; |
|
105 // } |
|
106 // if (startOk == false || endOk == false) return false; |
|
107 // else return true; |
|
108 // } |
|
109 |
|
110 public void receiveEvent(String action, Event event) |
|
111 { |
|
112 if (action.equals("functionAnalysis")) //$NON-NLS-1$ |
|
113 { |
|
114 try { |
|
115 /* |
|
116 AnalyseTab tab = PIPageEditor.currentTab(); |
|
117 PICompositePanel compositePanel = tab.getProfilePage(3).getTopSwingPanel(); |
|
118 |
|
119 if (compositePanel.getSelectionStart() == -1 || compositePanel.getSelectionEnd() == -1 || |
|
120 (compositePanel.getSelectionStart() == compositePanel.getSelectionEnd())) |
|
121 { |
|
122 GeneralMessages.showErrorMessage("Make a selection from the graph"); |
|
123 return; |
|
124 } |
|
125 else |
|
126 { |
|
127 ParsedTraceData ptd = TraceDataRepository.getTrace(tab.getTabId(), "com.nokia.carbide.cpp.pi.address.GppTrace"); |
|
128 |
|
129 int mode = ((GppTraceGraph)((GppTrace)ptd.traceData).getTraceGraph()).getDrawMode(); |
|
130 String[] selectedItems = null; |
|
131 if (mode == Defines.THREADS || mode == Defines.THREADS_FUNCTIONS) |
|
132 selectedItems = compositePanel.getSharedData().GPP_SelectedThreadNames; |
|
133 else |
|
134 selectedItems = compositePanel.getSharedData().GPP_SelectedBinaryNames; |
|
135 |
|
136 ptd = TraceDataRepository.getTrace(tab.getTabId(), "com.nokia.carbide.cpp.pi.call.GfcTrace"); |
|
137 //GfcTrace gfcTrace = (GfcTrace)ptd.traceData; |
|
138 if (ptd == null || |
|
139 this.checkGfcRequirements(compositePanel, (GfcTrace)ptd.traceData) == false) |
|
140 { |
|
141 GeneralMessages.showNotificationMessage("Linked function analysis is disabled"); |
|
142 new NewFunctionAnalyse(compositePanel, selectedItems, false, mode); |
|
143 } |
|
144 else |
|
145 { |
|
146 new NewFunctionAnalyse(compositePanel, selectedItems, true, mode); |
|
147 } |
|
148 } |
|
149 */ |
|
150 // this menu is not used in eclipse, replaced by function call |
|
151 throw new Exception (Messages.getString("FunctionPlugin.fixException")); //$NON-NLS-1$ |
|
152 } catch (Exception e) { |
|
153 e.printStackTrace(); |
|
154 } |
|
155 } |
|
156 } |
|
157 /** |
|
158 * This method is called upon plug-in activation |
|
159 */ |
|
160 public void start(BundleContext context) throws Exception { |
|
161 super.start(context); |
|
162 } |
|
163 |
|
164 /** |
|
165 * This method is called when the plug-in is stopped |
|
166 */ |
|
167 public void stop(BundleContext context) throws Exception { |
|
168 super.stop(context); |
|
169 plugin = null; |
|
170 } |
|
171 |
|
172 /** |
|
173 * Returns the shared instance. |
|
174 */ |
|
175 public static FunctionPlugin getDefault() { |
|
176 return plugin; |
|
177 } |
|
178 |
|
179 /** |
|
180 * Returns an image descriptor for the image file at the given |
|
181 * plug-in relative path. |
|
182 * |
|
183 * @param path the path |
|
184 * @return the image descriptor |
|
185 */ |
|
186 public static ImageDescriptor getImageDescriptor(String path) { |
|
187 return AbstractPiPlugin.imageDescriptorFromPlugin("com.nokia.carbide.cpp.pi.function", path); //$NON-NLS-1$ |
|
188 } |
|
189 } |