29 import org.eclipse.core.resources.IResource; |
29 import org.eclipse.core.resources.IResource; |
30 import org.eclipse.core.resources.IWorkspace; |
30 import org.eclipse.core.resources.IWorkspace; |
31 import org.eclipse.core.resources.IWorkspaceRoot; |
31 import org.eclipse.core.resources.IWorkspaceRoot; |
32 import org.eclipse.core.resources.ResourcesPlugin; |
32 import org.eclipse.core.resources.ResourcesPlugin; |
33 import org.eclipse.core.runtime.CoreException; |
33 import org.eclipse.core.runtime.CoreException; |
|
34 import org.eclipse.core.runtime.IPath; |
34 import org.eclipse.core.runtime.IProgressMonitor; |
35 import org.eclipse.core.runtime.IProgressMonitor; |
35 import org.eclipse.core.runtime.Path; |
36 import org.eclipse.core.runtime.Path; |
36 import org.eclipse.ui.PlatformUI; |
37 import org.eclipse.ui.PlatformUI; |
37 import org.eclipse.ui.ide.IDE; |
38 import org.eclipse.ui.ide.IDE; |
38 |
39 |
81 // Bup sample |
82 // Bup sample |
82 private String bupMapProfileId; |
83 private String bupMapProfileId; |
83 private String bupMapSymbianSDKId; |
84 private String bupMapSymbianSDKId; |
84 private boolean bupMapIsBuiltIn; |
85 private boolean bupMapIsBuiltIn; |
85 private boolean bupMapIsWorkspace; |
86 private boolean bupMapIsWorkspace; |
|
87 |
|
88 private boolean profilerActivator; |
|
89 |
86 |
90 |
87 private SampleImporter() { |
91 private SampleImporter() { |
88 clear(); |
92 clear(); |
89 // singleton |
93 // singleton |
90 } |
94 } |
339 clearCustDelimitor (); |
343 clearCustDelimitor (); |
340 clearBupMapProfileId (); |
344 clearBupMapProfileId (); |
341 clearBupMapSymbianSDKId (); |
345 clearBupMapSymbianSDKId (); |
342 clearBupMapIsBuiltIn (); |
346 clearBupMapIsBuiltIn (); |
343 clearBupMapIsWorkspace (); |
347 clearBupMapIsWorkspace (); |
|
348 profilerActivator = false; |
344 } |
349 } |
345 |
350 |
346 public boolean validate () { |
351 public boolean validate () { |
347 if (getDatFileName().equals("")) { //$NON-NLS-1$ |
352 if (getDatFileName().equals("")) { //$NON-NLS-1$ |
348 return false; |
353 return false; |
434 } catch (Exception e) { |
439 } catch (Exception e) { |
435 e.printStackTrace(); |
440 e.printStackTrace(); |
436 return; |
441 return; |
437 } |
442 } |
438 } |
443 } |
439 |
444 // allow to set specific npi file name that is used from the JUnit test cases |
440 |
445 boolean piFileNameForced = false; |
441 // import the new project according to wizard |
446 if(piFileName.length() == 0){ |
442 piFileName = new Path(getDatFileName()).removeFileExtension().addFileExtension("npi").lastSegment(); //$NON-NLS-1$ |
447 // import the new project according to wizard |
|
448 piFileName = new Path(getDatFileName()).removeFileExtension().addFileExtension("npi").lastSegment(); //$NON-NLS-1$ |
|
449 }else{ |
|
450 piFileNameForced = true; |
|
451 } |
443 piFile = piContainer.getFile(new Path(piFileName)); |
452 piFile = piContainer.getFile(new Path(piFileName)); |
444 |
453 |
|
454 |
445 if (piFile.exists()) |
455 if (piFile.exists()) |
446 { |
456 { |
447 piFile = piContainer.getFile(new Path(generateNpiFileName(piContainer, piFileName))); |
457 if(piFileNameForced){ |
|
458 try { |
|
459 piFile.delete(true, null); |
|
460 } catch (CoreException e) { |
|
461 GeneralMessages.showErrorMessage(com.nokia.carbide.cpp.pi.importer.Messages.getString("SampleImporter.importerInternalError")); //$NON-NLS-1$ |
|
462 GeneralMessages.piLog(com.nokia.carbide.cpp.pi.importer.Messages.getString("SampleImporter.importerCoreException"), GeneralMessages.ERROR); //$NON-NLS-1$ |
|
463 return; |
|
464 } |
|
465 }else{ |
|
466 piFile = piContainer.getFile(new Path(generateNpiFileName(piContainer, piFileName))); |
|
467 } |
448 } |
468 } |
449 |
469 |
450 // import and save the file as npi |
470 // import and save the file as npi |
451 if(activate){ |
471 if(activate){ |
452 AnalyserDataProcessor.getInstance().importSaveAndOpen(piFile, pollTillNpiSaved, pluginsInTraceFile); |
472 AnalyserDataProcessor.getInstance().importSaveAndOpen(piFile, pollTillNpiSaved, pluginsInTraceFile); |
453 }else{ |
473 }else{ |
454 AnalyserDataProcessor.getInstance().importSave(piFile, pluginsInTraceFile, suffixTaskName, progressMonitor); |
474 AnalyserDataProcessor.getInstance().importSave(piFile, pluginsInTraceFile, suffixTaskName, progressMonitor); |
455 } |
475 } |
456 |
476 if(profilerActivator){ |
|
477 IPath datPath = new Path(getDatFileName()); |
|
478 IPath piPath = piFile.getLocation(); |
|
479 piPath = piPath.removeFileExtension().addFileExtension(datPath.getFileExtension()); |
|
480 if(!datPath.toFile().renameTo(piPath.toFile())){ |
|
481 GeneralMessages.piLog(Messages.getString("SampleImporter.failedToMoveProfilerDataFile"), GeneralMessages.INFO); //$NON-NLS-1$ |
|
482 } |
|
483 |
|
484 } |
457 if (dummySymbol != null) { |
485 if (dummySymbol != null) { |
458 if(getRomSymbolFile().equals(dummySymbol.toString())){ |
486 if(getRomSymbolFile().equals(dummySymbol.toString())){ |
459 dummySymbol.delete(); |
487 dummySymbol.delete(); |
460 dummySymbol = null; |
488 dummySymbol = null; |
461 setRomSymbolFile(null); |
489 setRomSymbolFile(null); |
466 private String generateNpiFileName(IContainer container, String initialFilename) { |
494 private String generateNpiFileName(IContainer container, String initialFilename) { |
467 // get just the file name(last part) |
495 // get just the file name(last part) |
468 initialFilename = new java.io.File(initialFilename).getName(); |
496 initialFilename = new java.io.File(initialFilename).getName(); |
469 |
497 |
470 String baseName; |
498 String baseName; |
471 Long suffixNumber = new Long(0); |
499 Long suffixNumber = Long.valueOf(0); |
472 |
500 |
473 int dot = initialFilename.lastIndexOf("."); //$NON-NLS-1$ |
501 int dot = initialFilename.lastIndexOf("."); //$NON-NLS-1$ |
474 if (dot > 1) { |
502 if (dot > 1) { |
475 baseName = initialFilename.substring(0, dot); //$NON-NLS-1$ |
503 baseName = initialFilename.substring(0, dot); //$NON-NLS-1$ |
476 } else { |
504 } else { |