sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi.power/src/com/nokia/carbide/cpp/pi/power/PowerPlugin.java
changeset 5 844b047e260d
parent 2 b9ab3b238396
child 12 ae255c9aa552
equal deleted inserted replaced
4:615035072f7e 5:844b047e260d
    46 
    46 
    47 
    47 
    48 public class PowerPlugin extends AbstractPiPlugin
    48 public class PowerPlugin extends AbstractPiPlugin
    49 		implements IViewMenu, ITrace, IClassReplacer, IVisualizable, IEventListener
    49 		implements IViewMenu, ITrace, IClassReplacer, IVisualizable, IEventListener
    50 {
    50 {
       
    51 
       
    52 	/** The plug-in ID */
       
    53 	public static final String PLUGIN_ID = "com.nokia.carbide.cpp.pi.power"; //$NON-NLS-1$
       
    54 
    51 	private static final String HELP_CONTEXT_ID = PIPageEditor.PI_ID + ".power";  //$NON-NLS-1$
    55 	private static final String HELP_CONTEXT_ID = PIPageEditor.PI_ID + ".power";  //$NON-NLS-1$
       
    56 	/** context help id of the main page */
       
    57 	public static final String HELP_CONTEXT_ID_MAIN_PAGE = HELP_CONTEXT_ID + ".powerPageContext";  //$NON-NLS-1$
    52 
    58 
    53 	// There will be three graphs - one each for editor pages 0, 1, 2
    59 	// There will be three graphs - one each for editor pages 0, 1, 2
    54 	// This code may assume that page 0 has the threads graph, 1 the binaries, and 2 the functions
    60 	// This code may assume that page 0 has the threads graph, 1 the binaries, and 2 the functions
    55 	private final static int GRAPH_COUNT = 3;
    61 	private final static int GRAPH_COUNT = 3;
    56 
    62 
   143 
   149 
   144 	public String getTraceName() {
   150 	public String getTraceName() {
   145 		return "Power"; //$NON-NLS-1$
   151 		return "Power"; //$NON-NLS-1$
   146 	}
   152 	}
   147 
   153 
       
   154 	/* (non-Javadoc)
       
   155 	 * @see com.nokia.carbide.cpp.internal.pi.plugin.model.ITrace#getTraceTitle()
       
   156 	 */
       
   157 	public String getTraceTitle() {
       
   158 		return Messages.getString("PowerPlugin.0"); //$NON-NLS-1$
       
   159 	}
       
   160 
   148 	public int getTraceId() {
   161 	public int getTraceId() {
   149 		return 11;
   162 		return 11;
       
   163 	}
       
   164 
       
   165 	/* (non-Javadoc)
       
   166 	 * @see com.nokia.carbide.cpp.internal.pi.plugin.model.ITrace#parseTraceFiles(java.io.File[])
       
   167 	 */
       
   168 	public ParsedTraceData parseTraceFiles(File[] files) throws Exception {
       
   169 		throw new UnsupportedOperationException();
   150 	}
   170 	}
   151 
   171 
   152 	public ParsedTraceData parseTraceFile(File file) throws Exception 
   172 	public ParsedTraceData parseTraceFile(File file) throws Exception 
   153 	{
   173 	{
   154 		try
   174 		try
   232 		{
   252 		{
   233 			((PowerTraceGraph)trace.getTraceGraph(PIPageEditor.THREADS_PAGE,   uid)).action(actionString);	
   253 			((PowerTraceGraph)trace.getTraceGraph(PIPageEditor.THREADS_PAGE,   uid)).action(actionString);	
   234 			((PowerTraceGraph)trace.getTraceGraph(PIPageEditor.BINARIES_PAGE,  uid)).action(actionString);	
   254 			((PowerTraceGraph)trace.getTraceGraph(PIPageEditor.BINARIES_PAGE,  uid)).action(actionString);	
   235 			((PowerTraceGraph)trace.getTraceGraph(PIPageEditor.FUNCTIONS_PAGE, uid)).action(actionString);	
   255 			((PowerTraceGraph)trace.getTraceGraph(PIPageEditor.FUNCTIONS_PAGE, uid)).action(actionString);	
   236 		} else if (actionString.equals("scroll")) //$NON-NLS-1$
   256 		} else if (actionString.equals("scroll")) //$NON-NLS-1$
   237 		{
   257 		{			
   238 			if (   !(event.data instanceof String)
       
   239 				|| !((String)event.data).equals("FigureCanvas")) //$NON-NLS-1$
       
   240 				return;
       
   241 			
       
   242 			PIEvent be = new PIEvent(event, PIEvent.SCROLLED);
   258 			PIEvent be = new PIEvent(event, PIEvent.SCROLLED);
   243 			
   259 			
   244 			((PowerTraceGraph)trace.getTraceGraph(PIPageEditor.THREADS_PAGE,   uid)).piEventReceived(be);
   260 			((PowerTraceGraph)trace.getTraceGraph(PIPageEditor.THREADS_PAGE,   uid)).piEventReceived(be);
   245 			((PowerTraceGraph)trace.getTraceGraph(PIPageEditor.BINARIES_PAGE,  uid)).piEventReceived(be);
   261 			((PowerTraceGraph)trace.getTraceGraph(PIPageEditor.BINARIES_PAGE,  uid)).piEventReceived(be);
   246 			((PowerTraceGraph)trace.getTraceGraph(PIPageEditor.FUNCTIONS_PAGE, uid)).piEventReceived(be);
   262 			((PowerTraceGraph)trace.getTraceGraph(PIPageEditor.FUNCTIONS_PAGE, uid)).piEventReceived(be);
   293 
   309 
   294 	public Integer getLastSample(int graphIndex) {
   310 	public Integer getLastSample(int graphIndex) {
   295 		PwrTrace trace = (PwrTrace) NpiInstanceRepository.getInstance().activeUidGetTrace("com.nokia.carbide.cpp.pi.power"); //$NON-NLS-1$
   311 		PwrTrace trace = (PwrTrace) NpiInstanceRepository.getInstance().activeUidGetTrace("com.nokia.carbide.cpp.pi.power"); //$NON-NLS-1$
   296 
   312 
   297 		if (trace != null)
   313 		if (trace != null)
   298 			return new Integer(trace.getLastSampleNumber());
   314 			return Integer.valueOf(trace.getLastSampleNumber());
   299 		else
   315 		else
   300 			return null;
   316 			return null;
   301 	}
   317 	}
   302 
   318 
   303 	public GraphDrawRequest getDrawRequest(int graphIndex) {
   319 	public GraphDrawRequest getDrawRequest(int graphIndex) {
   344 	}
   360 	}
   345 
   361 
   346 	public void setPageIndex(int index, int pageIndex) {
   362 	public void setPageIndex(int index, int pageIndex) {
   347 		return;
   363 		return;
   348 	}
   364 	}
   349 
       
   350 	/* (non-Javadoc)
       
   351 	 * @see com.nokia.carbide.cpp.internal.pi.plugin.model.IVisualizable#getGraphTitle(int)
       
   352 	 */
       
   353 	public String getGraphTitle(int graphIndex) {
       
   354 		return Messages.getString("PowerPlugin.pluginTitle"); //$NON-NLS-1$
       
   355 	}
       
   356 }
   365 }