32 import org.eclipse.core.runtime.IPath; |
33 import org.eclipse.core.runtime.IPath; |
33 import org.eclipse.core.runtime.IProgressMonitor; |
34 import org.eclipse.core.runtime.IProgressMonitor; |
34 import org.eclipse.core.runtime.SubProgressMonitor; |
35 import org.eclipse.core.runtime.SubProgressMonitor; |
35 import org.eclipse.jface.dialogs.DialogSettings; |
36 import org.eclipse.jface.dialogs.DialogSettings; |
36 import org.eclipse.jface.dialogs.IDialogSettings; |
37 import org.eclipse.jface.dialogs.IDialogSettings; |
|
38 import org.eclipse.jface.dialogs.MessageDialog; |
37 import org.eclipse.jface.operation.IRunnableWithProgress; |
39 import org.eclipse.jface.operation.IRunnableWithProgress; |
38 import org.eclipse.jface.viewers.IStructuredSelection; |
40 import org.eclipse.jface.viewers.IStructuredSelection; |
39 import org.eclipse.jface.wizard.IWizardPage; |
41 import org.eclipse.jface.wizard.IWizardPage; |
40 import org.eclipse.jface.wizard.Wizard; |
42 import org.eclipse.jface.wizard.Wizard; |
41 import org.eclipse.swt.widgets.Composite; |
43 import org.eclipse.swt.widgets.Composite; |
42 import org.eclipse.swt.widgets.Display; |
44 import org.eclipse.swt.widgets.Display; |
43 import org.eclipse.ui.IImportWizard; |
45 import org.eclipse.ui.IImportWizard; |
44 import org.eclipse.ui.INewWizard; |
46 import org.eclipse.ui.INewWizard; |
|
47 import org.eclipse.ui.IViewPart; |
|
48 import org.eclipse.ui.IViewReference; |
45 import org.eclipse.ui.IWorkbench; |
49 import org.eclipse.ui.IWorkbench; |
|
50 import org.eclipse.ui.IWorkbenchPage; |
|
51 import org.eclipse.ui.IWorkbenchWindow; |
46 import org.eclipse.ui.PlatformUI; |
52 import org.eclipse.ui.PlatformUI; |
47 import org.eclipse.ui.progress.IProgressService; |
53 import org.eclipse.ui.progress.IProgressService; |
48 |
54 |
49 import com.nokia.carbide.cdt.builder.builder.CarbideCPPBuilder; |
55 import com.nokia.carbide.cdt.builder.builder.CarbideCPPBuilder; |
50 import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration; |
56 import com.nokia.carbide.cdt.builder.project.ICarbideBuildConfiguration; |
51 import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo; |
57 import com.nokia.carbide.cdt.builder.project.ISISBuilderInfo; |
52 import com.nokia.carbide.cpp.internal.api.sdk.SymbianBuildContext; |
58 import com.nokia.carbide.cpp.internal.api.sdk.SymbianBuildContext; |
53 import com.nokia.carbide.cpp.internal.pi.analyser.AnalyserDataProcessor; |
59 import com.nokia.carbide.cpp.internal.pi.analyser.AnalyserDataProcessor; |
|
60 import com.nokia.carbide.cpp.internal.pi.analyser.NpiInstanceRepository; |
|
61 import com.nokia.carbide.cpp.internal.pi.model.GenericSampledTrace; |
|
62 import com.nokia.carbide.cpp.internal.pi.model.GenericTrace; |
|
63 import com.nokia.carbide.cpp.internal.pi.model.ParsedTraceData; |
|
64 import com.nokia.carbide.cpp.internal.pi.model.TraceDataRepository; |
|
65 import com.nokia.carbide.cpp.internal.pi.plugin.model.ITrace; |
54 import com.nokia.carbide.cpp.internal.pi.utils.PIUtilities; |
66 import com.nokia.carbide.cpp.internal.pi.utils.PIUtilities; |
|
67 import com.nokia.carbide.cpp.internal.pi.wizards.model.SessionHandler; |
|
68 import com.nokia.carbide.cpp.internal.pi.wizards.model.TraceFile; |
55 import com.nokia.carbide.cpp.internal.pi.wizards.ui.util.IPkgEntry; |
69 import com.nokia.carbide.cpp.internal.pi.wizards.ui.util.IPkgEntry; |
56 import com.nokia.carbide.cpp.internal.pi.wizards.ui.util.RofsObySymbolPair; |
70 import com.nokia.carbide.cpp.internal.pi.wizards.ui.util.RofsObySymbolPair; |
|
71 import com.nokia.carbide.cpp.internal.pi.wizards.ui.views.PIView; |
|
72 import com.nokia.carbide.cpp.pi.PiPlugin; |
57 import com.nokia.carbide.cpp.pi.button.BupEventMapManager; |
73 import com.nokia.carbide.cpp.pi.button.BupEventMapManager; |
58 import com.nokia.carbide.cpp.pi.button.ButtonPlugin; |
74 import com.nokia.carbide.cpp.pi.button.ButtonPlugin; |
59 import com.nokia.carbide.cpp.pi.importer.SampleImporter; |
75 import com.nokia.carbide.cpp.pi.importer.SampleImporter; |
60 import com.nokia.carbide.cpp.pi.util.GeneralMessages; |
76 import com.nokia.carbide.cpp.pi.util.GeneralMessages; |
61 import com.nokia.carbide.cpp.pi.wizards.WizardsPlugin; |
77 import com.nokia.carbide.cpp.pi.wizards.WizardsPlugin; |
62 import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext; |
78 import com.nokia.carbide.cpp.sdk.core.ISymbianBuildContext; |
|
79 import com.nokia.carbide.cpp.sdk.core.ISymbianSDK; |
63 import com.nokia.carbide.cpp.ui.CarbideUIPlugin; |
80 import com.nokia.carbide.cpp.ui.CarbideUIPlugin; |
64 import com.nokia.carbide.cpp.ui.ICarbideSharedImages; |
81 import com.nokia.carbide.cpp.ui.ICarbideSharedImages; |
65 import com.nokia.cpp.internal.api.utils.core.Check; |
82 import com.nokia.cpp.internal.api.utils.core.Check; |
66 import com.nokia.cpp.internal.api.utils.core.FileUtils; |
83 import com.nokia.cpp.internal.api.utils.core.FileUtils; |
67 |
84 |
222 |
239 |
223 String container = wizardSettings.outputContainer.getFullPath().toString(); |
240 String container = wizardSettings.outputContainer.getFullPath().toString(); |
224 if (container.startsWith("/")) //$NON-NLS-1$ |
241 if (container.startsWith("/")) //$NON-NLS-1$ |
225 container = container.substring(1, container.length()); |
242 container = container.substring(1, container.length()); |
226 sampleImporter.setProjectName(container); |
243 sampleImporter.setProjectName(container); |
227 sampleImporter.setPiFileName(wizardSettings.piFileName); |
|
228 if (wizardSettings.haveRomOnly || wizardSettings.haveAppRom) { |
244 if (wizardSettings.haveRomOnly || wizardSettings.haveAppRom) { |
229 if (wizardSettings.romSdk != null && wizardSettings.romSdk.getEPOCROOT() != null) { |
245 if (wizardSettings.romSdk != null && wizardSettings.romSdk.getEPOCROOT() != null) { |
230 sampleImporter.setRomEpocroot(wizardSettings.romSdk.getEPOCROOT()); |
246 sampleImporter.setRomEpocroot(wizardSettings.romSdk.getEPOCROOT()); |
231 } |
247 } |
232 if (wizardSettings.romSymbolFile != null) { |
248 if (wizardSettings.romSymbolFile != null) { |
312 sampleImporter.setBupMapIsBuiltIn(false); |
328 sampleImporter.setBupMapIsBuiltIn(false); |
313 sampleImporter.setBupMapIsWorkspace(true); |
329 sampleImporter.setBupMapIsWorkspace(true); |
314 } |
330 } |
315 } |
331 } |
316 |
332 |
|
333 sampleImporter.setProfilerActivator(wizardSettings.profilerActivator); |
317 |
334 |
318 if(profilerDataPlugins.size() <= 1){ |
335 if(profilerDataPlugins.size() <= 1){ |
319 for(ProfilerDataPlugins pdp : profilerDataPlugins){ |
336 for(ProfilerDataPlugins pdp : profilerDataPlugins){ |
320 sampleImporter.setDatFileName(pdp.getProfilerDataPath().toString()); |
337 sampleImporter.setDatFileName(pdp.getProfilerDataPath().toString()); |
321 // due to PI shortcomings (i.e. plugins that create pages have to come first) |
338 // due to PI shortcomings (i.e. plugins that create pages have to come first) |
322 // the plugins have to be sorted by trace id |
339 // the plugins have to be sorted by trace id |
|
340 sampleImporter.setPiFileName(""); //$NON-NLS-1$ |
323 sampleImporter.importSamples(false, PIUtilities.sortPlugins(pdp.getSelectedPlugins()), true, null, null); |
341 sampleImporter.importSamples(false, PIUtilities.sortPlugins(pdp.getSelectedPlugins()), true, null, null); |
|
342 logImportedFile(pdp); |
324 break; |
343 break; |
325 } |
344 } |
326 } |
345 } |
327 else{ |
346 else{ |
328 final int[] i={1}; |
347 final int[] i={1}; |
337 if(progressMonitor.isCanceled()){ |
356 if(progressMonitor.isCanceled()){ |
338 break; |
357 break; |
339 } |
358 } |
340 suffixTaskName = MessageFormat.format(Messages.getString("NewPIWizard.suffixTaskName"), i[0]++, count); //$NON-NLS-1$ |
359 suffixTaskName = MessageFormat.format(Messages.getString("NewPIWizard.suffixTaskName"), i[0]++, count); //$NON-NLS-1$ |
341 sampleImporter.setDatFileName(pdp.getProfilerDataPath().toString()); |
360 sampleImporter.setDatFileName(pdp.getProfilerDataPath().toString()); |
|
361 sampleImporter.setPiFileName(""); //$NON-NLS-1$ |
342 sampleImporter.importSamples(false, PIUtilities |
362 sampleImporter.importSamples(false, PIUtilities |
343 .sortPlugins(pdp.getSelectedPlugins()), false, suffixTaskName, |
363 .sortPlugins(pdp.getSelectedPlugins()), false, suffixTaskName, |
344 new SubProgressMonitor(progressMonitor, AnalyserDataProcessor.TOTAL_PROGRESS_COUNT)); |
364 new SubProgressMonitor(progressMonitor, AnalyserDataProcessor.TOTAL_PROGRESS_COUNT)); |
|
365 logImportedFile(pdp); |
345 } |
366 } |
346 } |
367 } |
347 |
368 |
348 }; |
369 }; |
349 try { |
370 try { |
350 progressService.busyCursorWhile(runnable); |
371 progressService.busyCursorWhile(runnable); |
351 } catch (Exception e) { |
372 } catch (Exception e) { |
352 GeneralMessages.showErrorMessage(e.getMessage()); |
373 GeneralMessages.showErrorMessage(e.getMessage()); |
353 } |
374 } |
354 } |
375 } |
355 cleanTempPkgFile(); |
376 cleanTempPkgFile(); |
|
377 showPIViewer(); |
|
378 } |
|
379 |
|
380 /** |
|
381 * Log given imported file to show it on the PI view |
|
382 * |
|
383 * @param pdp instance of the ProfilerDataPlugins |
|
384 */ |
|
385 private void logImportedFile(ProfilerDataPlugins pdp){ |
|
386 SampleImporter sampleImporter = SampleImporter.getInstance(); |
|
387 ISymbianSDK sdk = NewPIWizardSettings.getInstance().romSdk; |
|
388 String sdkName = ""; |
|
389 if(sdk != null && (NewPIWizardSettings.getInstance().haveRomOnly || NewPIWizardSettings.getInstance().haveAppRom)){ |
|
390 sdkName = NewPIWizardSettings.getInstance().romSdk.getUniqueId(); |
|
391 } |
|
392 long sampleTime = -1; |
|
393 |
|
394 Iterator<ParsedTraceData> traces = TraceDataRepository.getInstance().getTraceCollectionIter(NpiInstanceRepository.getInstance().activeUid()); |
|
395 while(traces.hasNext()){ |
|
396 ParsedTraceData ptd = traces.next(); |
|
397 GenericTrace gt = ptd.traceData; |
|
398 if(gt instanceof GenericSampledTrace){ |
|
399 GenericSampledTrace gst = (GenericSampledTrace)gt; |
|
400 long lastSampleTime = gst.getLastSampleTime(); |
|
401 if(sampleTime < lastSampleTime){ |
|
402 sampleTime = lastSampleTime; |
|
403 } |
|
404 } |
|
405 } |
|
406 List<ITrace> plugins = pdp.getSelectedPlugins(); |
|
407 int[] pluginIds = new int[plugins.size()]; |
|
408 int i=0; |
|
409 for(ITrace plugin : plugins){ |
|
410 pluginIds[i++] = plugin.getTraceId(); |
|
411 } |
|
412 IPath filePath = sampleImporter.getPiFile().getFullPath(); |
|
413 SessionHandler.getInstance().addTraceFile(new TraceFile(filePath, sampleImporter.getProjectName(), sdkName, filePath.toFile().length(), sampleTime, pluginIds)); |
|
414 Display.getDefault().asyncExec(new Runnable() { |
|
415 |
|
416 public void run() { |
|
417 showPIViewer(); |
|
418 |
|
419 } |
|
420 }); |
356 } |
421 } |
357 |
422 |
358 public void init(IWorkbench workbench, IStructuredSelection selection) { |
423 public void init(IWorkbench workbench, IStructuredSelection selection) { |
359 this.workbench = workbench; |
424 this.workbench = workbench; |
360 setNeedsProgressMonitor(true); |
425 setNeedsProgressMonitor(true); |
425 } |
490 } |
426 } |
491 } |
427 return false; |
492 return false; |
428 } |
493 } |
429 |
494 |
|
495 /* (non-Javadoc) |
|
496 * @see org.eclipse.jface.wizard.Wizard#performCancel() |
|
497 */ |
|
498 @Override |
|
499 public boolean performCancel() { |
|
500 if(PiPlugin.isTraceProviderAvailable() && PiPlugin.getTraceProvider().isListening()){ |
|
501 showInformationDialog(); |
|
502 return false; |
|
503 } |
|
504 pageInput.handleTemporaryProfilerDataFiles(false); |
|
505 return super.performCancel(); |
|
506 } |
|
507 |
|
508 /** |
|
509 * Show information dialog about to stop tracing in order to go back or |
|
510 * close the wizard page |
|
511 */ |
|
512 public void showInformationDialog(){ |
|
513 MessageDialog.openInformation(getShell(), Messages.getString("NewPIWizard.informationDialogTitle"), Messages.getString("NewPIWizard.informationDialogMessage")); //$NON-NLS-1$ //$NON-NLS-2$ |
|
514 } |
|
515 |
|
516 /** |
|
517 * Show PI view |
|
518 */ |
|
519 private void showPIViewer(){ |
|
520 try { |
|
521 IWorkbenchWindow workbenchWindow = PiPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow(); |
|
522 if (workbenchWindow == null) |
|
523 return; |
|
524 IWorkbenchPage page = workbenchWindow.getActivePage(); |
|
525 // Checking if view is already open |
|
526 IViewReference[] viewRefs = page.getViewReferences(); |
|
527 for (int i = 0; i < viewRefs.length; i++) { |
|
528 IViewReference reference = viewRefs[i]; |
|
529 String id = reference.getId(); |
|
530 if(PIView.ID.equalsIgnoreCase(id)){ |
|
531 // Found, restoring the view |
|
532 IViewPart viewPart = reference.getView(true); |
|
533 page.activate(viewPart); |
|
534 ((PIView)viewPart).updateView(); |
|
535 return; |
|
536 } |
|
537 } |
|
538 |
|
539 // View was not found, opening it up as a new view. |
|
540 IViewPart viewPart = page.showView(PIView.ID); |
|
541 ((PIView)viewPart).updateView(); |
|
542 } catch (Exception e) { |
|
543 e.printStackTrace(); |
|
544 } |
|
545 } |
|
546 |
|
547 /* (non-Javadoc) |
|
548 * @see org.eclipse.jface.wizard.Wizard#dispose() |
|
549 */ |
|
550 @Override |
|
551 public void dispose() { |
|
552 showPIViewer(); |
|
553 super.dispose(); |
|
554 } |
|
555 |
430 } |
556 } |