sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi.button/src/com/nokia/carbide/cpp/pi/button/ButtonPlugin.java
changeset 2 b9ab3b238396
child 5 844b047e260d
equal deleted inserted replaced
1:1050670c6980 2:b9ab3b238396
       
     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.button;
       
    19 
       
    20 import java.io.File;
       
    21 import java.util.ArrayList;
       
    22 import java.util.Vector;
       
    23 
       
    24 import org.eclipse.jface.action.Action;
       
    25 import org.eclipse.jface.action.MenuManager;
       
    26 import org.eclipse.jface.preference.IPreferenceStore;
       
    27 import org.eclipse.jface.resource.ImageDescriptor;
       
    28 import org.eclipse.jface.window.Window;
       
    29 import org.eclipse.swt.widgets.Display;
       
    30 import org.eclipse.swt.widgets.Event;
       
    31 import org.osgi.framework.BundleContext;
       
    32 
       
    33 import com.nokia.carbide.cpp.internal.pi.analyser.NpiInstanceRepository;
       
    34 import com.nokia.carbide.cpp.internal.pi.analyser.ProfileVisualiser;
       
    35 import com.nokia.carbide.cpp.internal.pi.button.ui.SwitchBupMapDialog;
       
    36 import com.nokia.carbide.cpp.internal.pi.model.GenericTrace;
       
    37 import com.nokia.carbide.cpp.internal.pi.model.ParsedTraceData;
       
    38 import com.nokia.carbide.cpp.internal.pi.plugin.model.AbstractPiPlugin;
       
    39 import com.nokia.carbide.cpp.internal.pi.plugin.model.IClassReplacer;
       
    40 import com.nokia.carbide.cpp.internal.pi.plugin.model.IEventListener;
       
    41 import com.nokia.carbide.cpp.internal.pi.plugin.model.IFinalizeTrace;
       
    42 import com.nokia.carbide.cpp.internal.pi.plugin.model.ITrace;
       
    43 import com.nokia.carbide.cpp.internal.pi.plugin.model.IViewMenu;
       
    44 import com.nokia.carbide.cpp.internal.pi.plugin.model.IVisualizable;
       
    45 import com.nokia.carbide.cpp.internal.pi.test.AnalysisInfoHandler;
       
    46 import com.nokia.carbide.cpp.internal.pi.test.IProvideTraceAdditionalInfo;
       
    47 import com.nokia.carbide.cpp.internal.pi.test.TraceAdditionalInfo;
       
    48 import com.nokia.carbide.cpp.internal.pi.visual.GenericTraceGraph;
       
    49 import com.nokia.carbide.cpp.internal.pi.visual.GraphDrawRequest;
       
    50 import com.nokia.carbide.cpp.pi.editors.PIPageEditor;
       
    51 import com.nokia.carbide.cpp.pi.importer.SampleImporter;
       
    52 import com.nokia.carbide.cpp.pi.util.GeneralMessages;
       
    53 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK;
       
    54 import com.nokia.carbide.cpp.sdk.core.SDKCorePlugin;
       
    55 
       
    56 
       
    57 /**
       
    58  * The main plugin class to be used in the desktop.
       
    59  */
       
    60 public class ButtonPlugin extends AbstractPiPlugin
       
    61 			implements ITrace, IViewMenu, IEventListener, IClassReplacer, IVisualizable, IFinalizeTrace, IProvideTraceAdditionalInfo
       
    62 {
       
    63 	public static final String PLUGIN_ID = PIPageEditor.PI_ID + ".button";  //$NON-NLS-1$
       
    64 
       
    65 	// There will be three graphs - one each for editor pages 0, 1, 2
       
    66 	// This code may assume that page 0 has the threads graph, 1 the binaries, and 2 the functions
       
    67 	private final static int GRAPH_COUNT = 3;
       
    68 
       
    69 	//The shared instance.
       
    70 	private static ButtonPlugin plugin;
       
    71 	
       
    72 	private static IPreferenceStore prefsStore;
       
    73 	
       
    74 	private static void setPlugin(ButtonPlugin newPlugin)
       
    75 	{
       
    76 		plugin = newPlugin;
       
    77 	}
       
    78 
       
    79 	/**
       
    80 	 * The constructor.
       
    81 	 */
       
    82 	public ButtonPlugin() {
       
    83 		super();
       
    84 		setPlugin(this);
       
    85 	}
       
    86 
       
    87 	public Class getTraceClass() {
       
    88 		return BupTrace.class;
       
    89 	}
       
    90 
       
    91 	public Class getReplacedClass(String className)
       
    92 	{
       
    93 		if (   className.indexOf("com.nokia.carbide.cpp.pi.button.BupTrace") != -1 //$NON-NLS-1$
       
    94 			|| className.indexOf("com.nokia.carbide.pi.button.BupTrace") != -1 //$NON-NLS-1$
       
    95 			|| className.indexOf("fi.vtt.bappea.model.BupTrace") != -1 //$NON-NLS-1$
       
    96 			|| className.indexOf("fi.vtt.bappea.bupTracePlugin.BupTrace") != -1) //$NON-NLS-1$
       
    97 		{
       
    98 			return BupTrace.class;
       
    99 		}
       
   100 		else if (   className.indexOf("com.nokia.carbide.cpp.pi.button.BupSample") != -1 //$NON-NLS-1$
       
   101 				 || className.indexOf("com.nokia.carbide.pi.button.BupSample") != -1 )//$NON-NLS-1$
       
   102 		{
       
   103 			return BupSample.class;
       
   104 		}
       
   105 		else
       
   106 			return null;
       
   107 	}
       
   108 	
       
   109 	public void initialiseTrace(GenericTrace trace) 
       
   110 	{
       
   111 		if (!(trace instanceof BupTrace))
       
   112 			return;
       
   113 
       
   114 		BupTrace bupTrace = (BupTrace)trace;
       
   115 		
       
   116 		NpiInstanceRepository.getInstance().activeUidAddTrace("com.nokia.carbide.cpp.pi.button", trace); //$NON-NLS-1$
       
   117 	}
       
   118 
       
   119 	public String getTraceName() {
       
   120 		return "Button"; //$NON-NLS-1$
       
   121 	}
       
   122 
       
   123 	public int getTraceId() {
       
   124 		return 7;
       
   125 	}
       
   126 
       
   127 	public ParsedTraceData parseTraceFile(File file) throws Exception 
       
   128 	{
       
   129 		try
       
   130         {
       
   131             BupTraceParser parser;
       
   132             parser = new BupTraceParser();
       
   133             return parser.parse(file);
       
   134         } catch (Exception e)
       
   135         {
       
   136             e.printStackTrace();
       
   137             throw e;
       
   138         }
       
   139 	}
       
   140 
       
   141 	public MenuManager getViewOptionManager() {
       
   142 		// current tab
       
   143 		if (NpiInstanceRepository.getInstance().activeUidGetTrace("com.nokia.carbide.cpp.pi.button") == null) //$NON-NLS-1$
       
   144 			return null;	// no trace, so no MenuManager
       
   145 
       
   146 		Action action;
       
   147 
       
   148 		Boolean showEvents = Boolean.TRUE;		// by default, show button press events
       
   149 
       
   150 		// if there is a value associated with the current Analyser tab, then use it
       
   151 		Object obj = NpiInstanceRepository.getInstance().activeUidGetPersistState("com.nokia.carbide.cpp.pi.button.show"); //$NON-NLS-1$
       
   152 		if ((obj != null) && (obj instanceof Boolean))
       
   153 			// retrieve the current value
       
   154 			showEvents = (Boolean)obj;
       
   155 		else
       
   156 			// set the initial value
       
   157 			NpiInstanceRepository.getInstance().activeUidSetPersistState("com.nokia.carbide.cpp.pi.button.show", showEvents); //$NON-NLS-1$
       
   158 
       
   159 		action = new Action(Messages.getString("ButtonPlugin.showEventsAction"), Action.AS_CHECK_BOX) { //$NON-NLS-1$
       
   160 			public void run() {
       
   161 				if (this.isChecked())
       
   162 					receiveSelectionEvent("button_events_on"); //$NON-NLS-1$
       
   163 				else
       
   164 					receiveSelectionEvent("button_events_off"); //$NON-NLS-1$
       
   165 			}
       
   166 		};
       
   167 		action.setChecked(showEvents);
       
   168 		action.setToolTipText(Messages.getString("ButtonPlugin.showEventsTooltip")); //$NON-NLS-1$
       
   169 		PIPageEditor.currentMenuManager().add(action);
       
   170 
       
   171 		action = new Action("Apply New Key Press Profile", Action.AS_PUSH_BUTTON) {	//$NON-NLS-1$
       
   172 			public void run() {
       
   173 				switchMap();
       
   174 			}
       
   175 		};
       
   176 		action.setChecked(showEvents);
       
   177 		action.setToolTipText(Messages.getString("ButtonPlugin.applyProfile")); //$NON-NLS-1$
       
   178 		PIPageEditor.currentMenuManager().add(action);
       
   179 
       
   180 		return PIPageEditor.currentMenuManager();
       
   181 	}
       
   182 	
       
   183 	public void receiveEvent(String actionString, Event event) 
       
   184 	{
       
   185 		if (   actionString.equals("button_events_on")  //$NON-NLS-1$
       
   186 			|| actionString.equals("button_events_off")	//$NON-NLS-1$
       
   187 			|| actionString.equals("button_map_switch")) //$NON-NLS-1$
       
   188 	  	{
       
   189 			BupTrace bupTrace = (BupTrace)NpiInstanceRepository.getInstance().activeUidGetTrace("com.nokia.carbide.cpp.pi.button"); //$NON-NLS-1$
       
   190 			
       
   191 			if (bupTrace == null)
       
   192 				return;
       
   193 
       
   194 	  		((BupTraceGraph)bupTrace.getTraceGraph(PIPageEditor.THREADS_PAGE)).action(actionString);	
       
   195 	  		((BupTraceGraph)bupTrace.getTraceGraph(PIPageEditor.BINARIES_PAGE)).action(actionString);	
       
   196 	  		((BupTraceGraph)bupTrace.getTraceGraph(PIPageEditor.FUNCTIONS_PAGE)).action(actionString);	
       
   197 	  	}
       
   198 	}
       
   199 
       
   200 	public void receiveSelectionEvent(String actionString) 
       
   201 	{
       
   202 		if (actionString == null)
       
   203 			return;
       
   204 		
       
   205 		int currentPage = PIPageEditor.currentPageIndex();
       
   206 
       
   207 		if (   (currentPage != PIPageEditor.THREADS_PAGE)
       
   208 			&& (currentPage != PIPageEditor.BINARIES_PAGE)
       
   209 			&& (currentPage != PIPageEditor.FUNCTIONS_PAGE))
       
   210 			  return;
       
   211 
       
   212 		if (actionString.equals("button_events_on")) { //$NON-NLS-1$
       
   213 			NpiInstanceRepository.getInstance().activeUidSetPersistState("com.nokia.carbide.cpp.pi.button.show", true); //$NON-NLS-1$
       
   214 	  	} else if (actionString.equals("button_events_off")) { //$NON-NLS-1$
       
   215 	  		NpiInstanceRepository.getInstance().activeUidSetPersistState("com.nokia.carbide.cpp.pi.button.show", false); //$NON-NLS-1$
       
   216 	  	} else {
       
   217 	  		return;
       
   218 	  	}
       
   219 
       
   220 		BupTrace bupTrace = (BupTrace)NpiInstanceRepository.getInstance().activeUidGetTrace("com.nokia.carbide.cpp.pi.button"); //$NON-NLS-1$
       
   221 		
       
   222 		if (bupTrace == null)
       
   223 			return;
       
   224 
       
   225   		((BupTraceGraph)bupTrace.getTraceGraph(PIPageEditor.THREADS_PAGE)).action(actionString);	
       
   226   		((BupTraceGraph)bupTrace.getTraceGraph(PIPageEditor.BINARIES_PAGE)).action(actionString);	
       
   227   		((BupTraceGraph)bupTrace.getTraceGraph(PIPageEditor.FUNCTIONS_PAGE)).action(actionString);	
       
   228 	}
       
   229 
       
   230 	public Integer getLastSample(int graphIndex) {
       
   231 		return null;
       
   232 	}
       
   233 
       
   234 	public GraphDrawRequest getDrawRequest(int graphIndex) {
       
   235 		GraphDrawRequest request = new GraphDrawRequest();
       
   236 		request.addParentGraph(
       
   237 				graphIndex,
       
   238 				"com.nokia.carbide.cpp.pi.address.AddressPlugin", //$NON-NLS-1$
       
   239 				GraphDrawRequest.DRAW_TO_MOST_IMPORTANT_AVAILABLE,
       
   240 				1);
       
   241 		return request;
       
   242 	}
       
   243 
       
   244 //	public GenericTraceGraph getTraceGraph() 
       
   245 //	{
       
   246 //		return this.trace.getTraceGraph();
       
   247 //	}
       
   248 
       
   249 	public GenericTraceGraph getTraceGraph(int graphIndex) 
       
   250 	{
       
   251 		BupTrace bupTrace = (BupTrace)NpiInstanceRepository.getInstance().activeUidGetTrace("com.nokia.carbide.cpp.pi.button"); //$NON-NLS-1$
       
   252 		
       
   253 		if (bupTrace == null)
       
   254 			return null;
       
   255 
       
   256 		return bupTrace.getTraceGraph(graphIndex);
       
   257 	}
       
   258 
       
   259 	/**
       
   260 	 * This method is called upon plug-in activation
       
   261 	 */
       
   262 	public void start(BundleContext context) throws Exception {
       
   263 		super.start(context);
       
   264 	}
       
   265 
       
   266 	/**
       
   267 	 * This method is called when the plug-in is stopped
       
   268 	 */
       
   269 	public void stop(BundleContext context) throws Exception {
       
   270 		super.stop(context);
       
   271 		setPlugin(null);
       
   272 	}
       
   273 
       
   274 	/**
       
   275 	 * Returns the shared instance.
       
   276 	 */
       
   277 	public static ButtonPlugin getDefault() {
       
   278 		return plugin;
       
   279 	}
       
   280 
       
   281 	/**
       
   282 	 * Returns an image descriptor for the image file at the given
       
   283 	 * plug-in relative path.
       
   284 	 *
       
   285 	 * @param path the path
       
   286 	 * @return the image descriptor
       
   287 	 */
       
   288 	public static ImageDescriptor getImageDescriptor(String path) {
       
   289 		return AbstractPiPlugin.imageDescriptorFromPlugin("com.nokia.carbide.cpp.pi.button", path); //$NON-NLS-1$
       
   290 	}
       
   291 
       
   292 	public int getGraphCount() {
       
   293 		return GRAPH_COUNT;
       
   294 	}
       
   295 
       
   296 	public int getPageNumber(int graphIndex) {
       
   297 		// Assumes page 0 has the threads graph, 1 has the binaries, and 2 has the functions
       
   298 		return graphIndex;
       
   299 	}
       
   300 
       
   301 	// return whether this plugin's editor pages have been created
       
   302 	public boolean arePagesCreated() {
       
   303 		return false;
       
   304 	}
       
   305 	
       
   306 	public void setPagesCreated(boolean pagesCreated) {
       
   307 		return;
       
   308 	}
       
   309 
       
   310 	public int getCreatePageCount() {
       
   311 		return 0;
       
   312 	}
       
   313 
       
   314 	public int getCreatePageIndex(int index) {
       
   315 		return 0;
       
   316 	}
       
   317 
       
   318 	public ProfileVisualiser createPage(int index) {
       
   319 		return null;
       
   320 	}
       
   321 
       
   322 	public void setPageIndex(int index, int pageIndex) {
       
   323 		return;
       
   324 	}
       
   325 
       
   326 	/* (non-Javadoc)
       
   327 	 * @see com.nokia.carbide.cpp.internal.pi.plugin.model.IVisualizable#getGraphTitle(int)
       
   328 	 */
       
   329 	public String getGraphTitle(int graphIndex) {
       
   330 		return null;
       
   331 	}
       
   332 	
       
   333 	/**
       
   334 	 * Returns the shared preference store of this plugin
       
   335 	 */
       
   336 	public static IPreferenceStore getBupPrefsStore(){
       
   337 		if (prefsStore == null){
       
   338 			prefsStore = getDefault().getPreferenceStore();
       
   339 		}
       
   340 		
       
   341 		return prefsStore;
       
   342 	}
       
   343 
       
   344 	/* (non-Javadoc)
       
   345 	 * @see com.nokia.carbide.cpp.internal.pi.plugin.model.IPIPageEditorDispose#runOnDispose()
       
   346 	 */
       
   347 	public void runOnDispose() {
       
   348 		BupTrace bupTrace = (BupTrace)NpiInstanceRepository.getInstance().activeUidGetTrace("com.nokia.carbide.cpp.pi.button"); //$NON-NLS-1$
       
   349 		if (bupTrace != null) {
       
   350 			BupEventMapManager.getInstance().releaseMap(bupTrace.getCurrentBupMapInUse());
       
   351 		}
       
   352 	}
       
   353 	
       
   354 	public void switchMap() {
       
   355 		BupTrace bupTrace = (BupTrace)NpiInstanceRepository.getInstance().activeUidGetTrace("com.nokia.carbide.cpp.pi.button"); //$NON-NLS-1$
       
   356 		IBupEventMapProfile oldProfile = bupTrace.getCurrentBupMapInUse().getProfile();
       
   357 		SwitchBupMapDialog dialog = new SwitchBupMapDialog(Display.getCurrent().getActiveShell(), oldProfile);
       
   358 		if (dialog.open() == Window.OK) {
       
   359 			IBupEventMap oldMap = bupTrace.getCurrentBupMapInUse();
       
   360 			IBupEventMap newMap = BupEventMapManager.getInstance().captureMap(dialog.getNewProfile());
       
   361 			if (bupTrace != null) {
       
   362 				boolean resetAll = dialog.resetAll();
       
   363 				Vector<BupSample> samples = bupTrace.samples;
       
   364 				for (BupSample sample : samples) {
       
   365 					if (resetAll || !sample.isLabelModified()) {
       
   366 						sample.resetLabelToMapDefault(newMap);
       
   367 					}
       
   368 				}
       
   369 				bupTrace.setCurrentBupMapInUse(newMap);
       
   370 				AnalysisInfoHandler handler = NpiInstanceRepository.getInstance().activeUidGetAnalysisInfoHandler();
       
   371 				// apply profile change to AnalysisInfoHandler that handling additional info in NPI file lifetime
       
   372 				setBupMapProfileToInfoHandler(handler, dialog.getNewProfile());
       
   373 				PIPageEditor.currentPageEditor().setDirty();
       
   374 				// Use this for sending graph fresh
       
   375 				receiveEvent("button_map_switch", new Event());	//$NON-NLS-1$
       
   376 			}
       
   377 			BupEventMapManager.getInstance().releaseMap(oldMap);
       
   378 		}
       
   379 	}
       
   380 	
       
   381 	/*
       
   382 	 * (non-javadoc)
       
   383 	 * Only Bup Plugin should know about it's own additional info
       
   384 	 * This class keep around a profile, and handle transfer in and out fo additional info
       
   385 	 * in one place for consistence.
       
   386 	 */
       
   387 	private class BupInfoHandlerAdditionalInfo {
       
   388 		// index of additional info in NPI file
       
   389 		private static final transient int BUP_MAP_PROFILE_ID = 0;
       
   390 		private static final transient int BUP_MAP_SYMBIAN_SDK_ID = 1;
       
   391 		private static final transient int BUP_MAP_IS_BUILTIN = 2;
       
   392 		private static final transient int BUP_MAP_IS_WORSPACE = 3;
       
   393 		
       
   394 		IBupEventMapProfile profile;
       
   395 		
       
   396 		Vector<Object> toAdditionalInfo() {
       
   397 			
       
   398 			int maxSize = BUP_MAP_PROFILE_ID;
       
   399 			maxSize = Math.max(maxSize, BUP_MAP_SYMBIAN_SDK_ID);
       
   400 			maxSize = Math.max(maxSize, BUP_MAP_IS_WORSPACE);
       
   401 			maxSize = Math.max(maxSize, BUP_MAP_IS_BUILTIN);
       
   402 			Vector<Object> result = new Vector<Object>(maxSize + 1);
       
   403 			result.setSize(maxSize + 1);
       
   404 			result.setElementAt(profile.getProfileId(), BUP_MAP_PROFILE_ID);
       
   405 			result.setElementAt(profile.getSDK() != null ? profile.getSDK().getUniqueId() : "", BUP_MAP_SYMBIAN_SDK_ID); //$NON-NLS-1$
       
   406 			result.setElementAt(new Boolean(profile.getURI().equals(BupEventMapManager.WORKSPACE_PREF_KEY_MAP_URI)), BUP_MAP_IS_WORSPACE);
       
   407 			result.setElementAt(new Boolean(profile.getURI().equals(BupEventMapManager.DEFAULT_PROFILE_URI)), BUP_MAP_IS_BUILTIN);
       
   408 			
       
   409 			return result;
       
   410 		}
       
   411 		
       
   412 		void fromAddtionalInfo(Vector<Object> additional_info) {
       
   413 			if (!(additional_info.get(BUP_MAP_PROFILE_ID) instanceof String) ||
       
   414 					!(additional_info.get(BUP_MAP_SYMBIAN_SDK_ID) instanceof String) ||
       
   415 					!(additional_info.get(BUP_MAP_IS_BUILTIN) instanceof Boolean) ||
       
   416 					!(additional_info.get(BUP_MAP_IS_WORSPACE) instanceof Boolean))
       
   417 			{
       
   418 				// did you changed anything in analysisInfoHandlerToAdditonalInfo()?
       
   419 				// did you changed the data format of addition info?
       
   420 				GeneralMessages.showErrorMessage(Messages.getString("ButtonPlugin.InternalError")); //$NON-NLS-1$
       
   421 			}
       
   422 			ArrayList<IBupEventMapProfile> profiles = new ArrayList<IBupEventMapProfile>();
       
   423 			if (!additional_info.get(BUP_MAP_SYMBIAN_SDK_ID).equals("")) { //$NON-NLS-1$
       
   424 				String sdkId = (String) additional_info.get(BUP_MAP_SYMBIAN_SDK_ID);
       
   425 				ISymbianSDK sdk = SDKCorePlugin.getSDKManager().getSDK(sdkId, true);
       
   426 				profiles.addAll(BupEventMapManager.getInstance().getProfilesFromSDK(sdk));
       
   427 			} else if ((Boolean)additional_info.get(BUP_MAP_IS_WORSPACE)) {
       
   428 				profiles.addAll(BupEventMapManager.getInstance().getProfilesFromWorkspacePref());
       
   429 			} else if ((Boolean)additional_info.get(BUP_MAP_IS_BUILTIN)) {
       
   430 				profiles.addAll(BupEventMapManager.getInstance().getProfilesFromBuiltin());
       
   431 			}
       
   432 			
       
   433 			profile = null;
       
   434 			for (IBupEventMapProfile tempProfile : profiles) {
       
   435 				if (tempProfile.getProfileId().equals(additional_info.get(BUP_MAP_PROFILE_ID))) {
       
   436 					profile = tempProfile;
       
   437 					break;
       
   438 				}
       
   439 			}
       
   440 			if (profile == null) {
       
   441 				if (additional_info.get(BUP_MAP_PROFILE_ID).equals("")) {	//$NON-NLS-1$
       
   442 					profile = BupEventMapManager.getInstance().getLegacyProfile();
       
   443 				} else {
       
   444 					GeneralMessages.showWarningMessage(Messages.getString("ButtonPlugin.keyMapRemoved")); //$NON-NLS-1$
       
   445 					profile = BupEventMapManager.getInstance().getPrefSelectedProfile();					
       
   446 				}
       
   447 			}
       
   448 		}
       
   449 	}
       
   450 
       
   451 	public void setupInfoHandler(AnalysisInfoHandler handler) {
       
   452 		ArrayList<IBupEventMapProfile> profiles = new ArrayList<IBupEventMapProfile>();
       
   453 		if (SampleImporter.getInstance().getBupMapSymbianSDKId() != null &&
       
   454 			!SampleImporter.getInstance().getBupMapSymbianSDKId().equals("")) { //$NON-NLS-1$
       
   455 			ISymbianSDK sdk = SDKCorePlugin.getSDKManager().getSDK(SampleImporter.getInstance().getBupMapSymbianSDKId(), true);
       
   456 			profiles.addAll(BupEventMapManager.getInstance().getProfilesFromSDK(sdk));
       
   457 		} else if (SampleImporter.getInstance().isBupMapIsWorkspace()) {
       
   458 			profiles.addAll(BupEventMapManager.getInstance().getProfilesFromWorkspacePref());
       
   459 		} else if (SampleImporter.getInstance().isBupMapIsBuiltIn()) {
       
   460 			profiles.addAll(BupEventMapManager.getInstance().getProfilesFromBuiltin());
       
   461 		}
       
   462 
       
   463 		for (IBupEventMapProfile profile : profiles) {
       
   464 			if (profile.getProfileId().equals(SampleImporter.getInstance().getBupMapProfileId())) {
       
   465 				BupInfoHandlerAdditionalInfo info = (BupInfoHandlerAdditionalInfo) handler.getTraceDefinedInfo(getTraceId());
       
   466 				if (info == null) {
       
   467 					info = new BupInfoHandlerAdditionalInfo();
       
   468 				}
       
   469 				info.profile = profile;
       
   470 				handler.setTraceDefinedInfo(getTraceId(), info);
       
   471 				break;
       
   472 			}
       
   473 		}
       
   474 	}
       
   475 
       
   476 	public void additionalInfoToAnalysisInfoHandler(Vector<Object> additional_info, AnalysisInfoHandler handler) { 
       
   477 		BupInfoHandlerAdditionalInfo info = (BupInfoHandlerAdditionalInfo) handler.getTraceDefinedInfo(getTraceId());
       
   478 		if (info == null) {
       
   479 			info = new BupInfoHandlerAdditionalInfo();
       
   480 		}
       
   481 		info.fromAddtionalInfo(additional_info);
       
   482 		handler.setTraceDefinedInfo(getTraceId(), info);
       
   483 	}
       
   484 	
       
   485 	public void analysisInfoHandlerToAdditonalInfo(TraceAdditionalInfo info, AnalysisInfoHandler handler) {
       
   486 		Vector<Object> additional_info = new Vector<Object>();
       
   487 		Object handlerInfo = handler.getTraceDefinedInfo(getTraceId());
       
   488 		if (handlerInfo instanceof BupInfoHandlerAdditionalInfo) {
       
   489 			additional_info = ((BupInfoHandlerAdditionalInfo)handlerInfo).toAdditionalInfo();
       
   490 		}
       
   491 		info.addAdditionalInfo(getTraceId(), additional_info);
       
   492 	}
       
   493 
       
   494 	/* (non-Javadoc)
       
   495 	 * @see com.nokia.carbide.cpp.internal.pi.test.IProvideTraceAdditionalInfo#InfoHandlerToDisplayString(java.util.Vector)
       
   496 	 */
       
   497 	public String InfoHandlerToDisplayString(AnalysisInfoHandler handler) {
       
   498 		Object info = handler.getTraceDefinedInfo(getTraceId());
       
   499 		if (info instanceof BupInfoHandlerAdditionalInfo) {
       
   500 			return Messages.getString("ButtonPlugin.keyPressProfile") +((BupInfoHandlerAdditionalInfo)info).profile.toString(); //$NON-NLS-1$
       
   501 		}
       
   502 		return ""; //$NON-NLS-1$
       
   503 	}
       
   504 	
       
   505 	/*
       
   506 	 * (non-Javadoc)
       
   507 	 * Manipulate additional info among AnalysisInfoHandler during lifetime of loaded NPI file
       
   508 	 */
       
   509 	public void setBupMapProfileToInfoHandler(AnalysisInfoHandler handler, IBupEventMapProfile profile) {
       
   510 		BupInfoHandlerAdditionalInfo info = (BupInfoHandlerAdditionalInfo) handler.getTraceDefinedInfo(getTraceId());
       
   511 		if (info == null) {
       
   512 			info = new BupInfoHandlerAdditionalInfo();
       
   513 		}
       
   514 		info.profile = profile;
       
   515 		handler.setTraceDefinedInfo(getTraceId(), info);
       
   516 	}
       
   517 
       
   518 	/*
       
   519 	 * (non-Javadoc)
       
   520 	 * Read additional info among AnalysisInfoHandler during lifetime of loaded NPI file
       
   521 	 */
       
   522 	public IBupEventMapProfile getBupMapProfileFromInfoHandler(AnalysisInfoHandler handler) {
       
   523 		Object info = handler.getTraceDefinedInfo(getTraceId());
       
   524 		if (info != null && info instanceof BupInfoHandlerAdditionalInfo) {
       
   525 			return ((BupInfoHandlerAdditionalInfo)info).profile;
       
   526 		}
       
   527 		GeneralMessages.showWarningMessage(Messages.getString("ButtonPlugin.keyMapRemoved")); //$NON-NLS-1$
       
   528 		return BupEventMapManager.getInstance().getPrefSelectedProfile();
       
   529 	}
       
   530 }