29 import java.util.Hashtable; |
29 import java.util.Hashtable; |
30 import java.util.Iterator; |
30 import java.util.Iterator; |
31 import java.util.List; |
31 import java.util.List; |
32 |
32 |
33 import org.eclipse.core.resources.IFile; |
33 import org.eclipse.core.resources.IFile; |
34 import org.eclipse.core.resources.WorkspaceJob; |
|
35 import org.eclipse.core.runtime.CoreException; |
34 import org.eclipse.core.runtime.CoreException; |
36 import org.eclipse.core.runtime.IProgressMonitor; |
35 import org.eclipse.core.runtime.IProgressMonitor; |
37 import org.eclipse.core.runtime.IStatus; |
|
38 import org.eclipse.core.runtime.NullProgressMonitor; |
36 import org.eclipse.core.runtime.NullProgressMonitor; |
39 import org.eclipse.core.runtime.Status; |
|
40 import org.eclipse.core.runtime.jobs.IJobChangeEvent; |
|
41 import org.eclipse.core.runtime.jobs.IJobChangeListener; |
|
42 import org.eclipse.core.runtime.jobs.Job; |
|
43 import org.eclipse.jface.operation.IRunnableWithProgress; |
37 import org.eclipse.jface.operation.IRunnableWithProgress; |
44 import org.eclipse.swt.events.PaintEvent; |
38 import org.eclipse.swt.events.PaintEvent; |
45 import org.eclipse.swt.events.PaintListener; |
39 import org.eclipse.swt.events.PaintListener; |
46 import org.eclipse.swt.widgets.Composite; |
40 import org.eclipse.swt.widgets.Composite; |
47 import org.eclipse.swt.widgets.Display; |
41 import org.eclipse.swt.widgets.Display; |
61 import com.nokia.carbide.cpp.internal.pi.plugin.model.IVisualizable; |
55 import com.nokia.carbide.cpp.internal.pi.plugin.model.IVisualizable; |
62 import com.nokia.carbide.cpp.internal.pi.test.AnalysisInfoHandler; |
56 import com.nokia.carbide.cpp.internal.pi.test.AnalysisInfoHandler; |
63 import com.nokia.carbide.cpp.internal.pi.test.IProvideTraceAdditionalInfo; |
57 import com.nokia.carbide.cpp.internal.pi.test.IProvideTraceAdditionalInfo; |
64 import com.nokia.carbide.cpp.internal.pi.visual.GraphDrawRequest; |
58 import com.nokia.carbide.cpp.internal.pi.visual.GraphDrawRequest; |
65 import com.nokia.carbide.cpp.internal.pi.visual.PICompositePanel; |
59 import com.nokia.carbide.cpp.internal.pi.visual.PICompositePanel; |
66 import com.nokia.carbide.cpp.pi.PiPlugin; |
|
67 import com.nokia.carbide.cpp.pi.editors.PIPageEditor; |
60 import com.nokia.carbide.cpp.pi.editors.PIPageEditor; |
68 import com.nokia.carbide.cpp.pi.importer.SampleImporter; |
61 import com.nokia.carbide.cpp.pi.importer.SampleImporter; |
69 import com.nokia.carbide.cpp.pi.util.GeneralMessages; |
62 import com.nokia.carbide.cpp.pi.util.GeneralMessages; |
70 import com.nokia.carbide.cpp.pi.util.PIExceptionRuntime; |
63 import com.nokia.carbide.cpp.pi.util.PIExceptionRuntime; |
71 import com.nokia.carbide.cpp.pi.visual.IGenericTraceGraph; |
64 import com.nokia.carbide.cpp.pi.visual.IGenericTraceGraph; |
76 */ |
69 */ |
77 |
70 |
78 public class AnalyserDataProcessor { |
71 public class AnalyserDataProcessor { |
79 protected static final int MAX_CPU = 4; |
72 protected static final int MAX_CPU = 4; |
80 // whether the profile file was read correctly |
73 // whether the profile file was read correctly |
81 public static int STATE_OK = 0; |
74 public final static int STATE_OK = 0; |
82 public static int STATE_IMPORTING = 1; |
75 public final static int STATE_IMPORTING = 1; |
83 public static int STATE_OPENING = 2; |
76 public final static int STATE_OPENING = 2; |
84 public static int STATE_TIMESTAMP = 3; |
77 public final static int STATE_TIMESTAMP = 3; |
85 public static int STATE_CANCELED = 4; |
78 public final static int STATE_CANCELED = 4; |
86 public static int STATE_INVALID = 5; |
79 public final static int STATE_INVALID = 5; |
87 public static int TOTAL_PROGRESS_COUNT = 10000; |
80 public final static int TOTAL_PROGRESS_COUNT = 10000; |
88 |
81 |
89 static AnalyserDataProcessor instance = null; |
82 static AnalyserDataProcessor instance = null; |
90 |
83 |
91 // following states should be cleanup for every run |
84 // following states should be cleanup for every run |
92 |
85 |
383 openFile(analysisFile); |
376 openFile(analysisFile); |
384 } |
377 } |
385 |
378 |
386 }; |
379 }; |
387 |
380 |
388 |
|
389 |
|
390 try { |
381 try { |
391 progressService.busyCursorWhile(runnableImportAndSave); |
382 progressService.busyCursorWhile(runnableImportAndSave); |
392 |
383 final IRunnableWithProgress saveNpi = new IRunnableWithProgress() { |
393 final WorkspaceJob saveNpi = new WorkspaceJob (Messages.getString("AnalyserDataProcessor.savingImportedFile")) { //$NON-NLS-1$ |
384 public void run(IProgressMonitor monitor) |
394 |
385 throws InvocationTargetException, InterruptedException { |
395 public IStatus runInWorkspace(IProgressMonitor monitor) |
386 ProfileReader.getInstance().writeAnalysisFile( |
396 throws CoreException { |
387 analysisFile.getLocation().toString(), monitor, |
397 try { |
388 null, uid); |
398 ProfileReader.getInstance().writeAnalysisFile(analysisFile.getLocation().toString(), monitor, null, uid); |
389 |
399 } catch (InvocationTargetException e) { |
390 } |
400 return new Status(IStatus.ERROR, PiPlugin.PLUGIN_ID, Messages.getString("AnalyserDataProcessor.invocationTargetException"), e); //$NON-NLS-1$ //$NON-NLS-2$ |
391 |
401 } catch (InterruptedException e) { |
|
402 return new Status(IStatus.CANCEL, PiPlugin.PLUGIN_ID, Messages.getString("AnalyserDataProcessor.interruptedException"), e); //$NON-NLS-1$ //$NON-NLS-2$ |
|
403 } |
|
404 return new Status(IStatus.OK, PiPlugin.PLUGIN_ID, Messages.getString("AnalyserDataProcessor.ok"), null); //$NON-NLS-1$ //$NON-NLS-2$ |
|
405 } |
|
406 |
|
407 }; |
392 }; |
408 |
393 progressService.busyCursorWhile(saveNpi); |
409 progressService.busyCursorWhile(runnableOpen); |
394 progressService.busyCursorWhile(runnableOpen); |
410 |
|
411 saveNpi.setPriority(Job.DECORATE); |
|
412 saveNpi.addJobChangeListener(new IJobChangeListener () { |
|
413 |
|
414 public void aboutToRun(IJobChangeEvent event) { |
|
415 } |
|
416 |
|
417 public void awake(IJobChangeEvent event) { |
|
418 } |
|
419 |
|
420 public void done(IJobChangeEvent event) { |
|
421 if (saveNpi.getResult().getSeverity() != IStatus.OK) { |
|
422 handleRunnableException (saveNpi.getResult().getException(), uid, analysisFile); |
|
423 } |
|
424 } |
|
425 |
|
426 public void running(IJobChangeEvent event) { |
|
427 } |
|
428 |
|
429 public void scheduled(IJobChangeEvent event) { |
|
430 } |
|
431 |
|
432 public void sleeping(IJobChangeEvent event) { |
|
433 } |
|
434 |
|
435 }); |
|
436 |
|
437 saveNpi.schedule(); |
|
438 |
|
439 if (pollTillNpiSaved) { |
|
440 while (saveNpi.getState() != Job.NONE) { |
|
441 // until it's done |
|
442 } |
|
443 } |
|
444 |
|
445 } catch (InvocationTargetException e) { |
395 } catch (InvocationTargetException e) { |
446 handleRunnableException(e, uid, analysisFile); |
396 handleRunnableException(e, uid, analysisFile); |
447 } catch (InterruptedException e) { |
397 } catch (InterruptedException e) { |
448 handleRunnableException(e, uid, analysisFile); |
398 handleRunnableException(e, uid, analysisFile); |
449 } |
399 } |
450 } |
400 } |
451 |
401 |
452 public void importSave(final IFile analysisFile, final List<ITrace> pluginsToUse, String suffixTaskName, IProgressMonitor monitor) { |
402 public void importSave(final IFile analysisFile, final List<ITrace> pluginsToUse, String suffixTaskName, IProgressMonitor monitor) { |
453 analyserDataProcessorState = STATE_IMPORTING; |
403 analyserDataProcessorState = STATE_IMPORTING; |
454 setUp(); |
404 setUp(); |