sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi/src/com/nokia/carbide/cpp/internal/pi/analyser/ProfileReader.java
changeset 5 844b047e260d
parent 2 b9ab3b238396
child 12 ae255c9aa552
equal deleted inserted replaced
4:615035072f7e 5:844b047e260d
    98 	
    98 	
    99 	private ProfileReader()
    99 	private ProfileReader()
   100 	{
   100 	{
   101 		//singleton
   101 		//singleton
   102 	}
   102 	}
   103 
   103 	public boolean readTraceFile(ITrace plugin, File[] traceFiles, AnalyserDataProcessor dataInstance, int instanceUID){
   104 	// read a plugin's information from a profile data file
   104 
   105 	public boolean readTraceFile(ITrace plugin, File traceFile, AnalyserDataProcessor dataInstance, int instanceUID)
       
   106 	{
       
   107 		// prepare the trace repository
   105 		// prepare the trace repository
   108 		try 
   106 		try 
   109 		{
   107 		{
   110 			ParsedTraceData parsedTraceData = plugin.parseTraceFile(traceFile);
   108 			ParsedTraceData parsedTraceData = null;
       
   109 			if (traceFiles.length == 1){
       
   110 				parsedTraceData = plugin.parseTraceFile(traceFiles[0]);
       
   111 			} else {
       
   112 				parsedTraceData = plugin.parseTraceFiles(traceFiles);
       
   113 			}
   111 			
   114 			
   112 			if (parsedTraceData != null) 
   115 			if (parsedTraceData != null) 
   113 			{
   116 			{
   114 				// each resolvable trace is primarily resolved first 
   117 				// each resolvable trace is primarily resolved first 
   115 				// with its own functionresolver(s)
   118 				// with its own functionresolver(s)
   133 		{
   136 		{
   134 			e.printStackTrace();
   137 			e.printStackTrace();
   135 			return false;
   138 			return false;
   136 		}
   139 		}
   137 		return true;
   140 		return true;
       
   141 	
       
   142 	}
       
   143 
       
   144 	// read a plugin's information from a profile data file
       
   145 	public boolean readTraceFile(ITrace plugin, File traceFile, AnalyserDataProcessor dataInstance, int instanceUID){
       
   146 		return readTraceFile(plugin, new File[]{traceFile}, dataInstance, instanceUID);
   138 	}
   147 	}
   139 	
   148 	
   140 	public void loadAnalysisFile(String filePath, String displayName, IProgressMonitor progressMonitor, int instanceUID) throws IOException, InterruptedException
   149 	public void loadAnalysisFile(String filePath, String displayName, IProgressMonitor progressMonitor, int instanceUID) throws IOException, InterruptedException
   141 	{
   150 	{
   142 		final int workUnitsForLoad = AnalyserDataProcessor.TOTAL_PROGRESS_COUNT * 20 / 100;
   151 		final int workUnitsForLoad = AnalyserDataProcessor.TOTAL_PROGRESS_COUNT * 20 / 100;
   684 		} catch (IOException e) {
   693 		} catch (IOException e) {
   685 			GeneralMessages.showErrorMessage(e.getMessage());
   694 			GeneralMessages.showErrorMessage(e.getMessage());
   686 		}
   695 		}
   687 	}
   696 	}
   688 
   697 
   689 	void writeAnalysisFile(String fileName, IProgressMonitor monitor, int instanceUID) throws InvocationTargetException, InterruptedException {
   698 	void writeAnalysisFile(String fileName, IProgressMonitor monitor, String suffixTaskName, int instanceUID) throws InvocationTargetException, InterruptedException {
   690 		final int workUnitsForSave = AnalyserDataProcessor.TOTAL_PROGRESS_COUNT * 20 / 100;
   699 		final int workUnitsForSave = AnalyserDataProcessor.TOTAL_PROGRESS_COUNT * 20 / 100;
   691 		FileOutputStream fos = null;
   700 		FileOutputStream fos = null;
   692 		GZIPOutputStream gzo = null;
   701 		GZIPOutputStream gzo = null;
   693 		ObjectOutputStream oos = null;
   702 		ObjectOutputStream oos = null;
   694 
   703 
   700 		        f.delete();
   709 		        f.delete();
   701 		    }
   710 		    }
   702 		    fos = new FileOutputStream(f);
   711 		    fos = new FileOutputStream(f);
   703 		    gzo = new GZIPOutputStream(fos);
   712 		    gzo = new GZIPOutputStream(fos);
   704 		    oos = new ObjectOutputStream(gzo);
   713 		    oos = new ObjectOutputStream(gzo);
   705 
   714 		    
   706 		    monitor.setTaskName(Messages.getString("ProfileReader.15") + f.getName());  //$NON-NLS-1$
   715 			String taskName = Messages.getString("ProfileReader.15")+ f.getName(); //$NON-NLS-1$
       
   716 			if(suffixTaskName != null){
       
   717 				taskName += " "+suffixTaskName; //$NON-NLS-1$
       
   718 			}
       
   719 		    monitor.setTaskName(taskName );  //$NON-NLS-1$
   707 		    monitor.worked(workUnitsForSave * 1 / 100);
   720 		    monitor.worked(workUnitsForSave * 1 / 100);
   708 			int workUnitsLeft = workUnitsForSave;
   721 			int workUnitsLeft = workUnitsForSave;
   709 			monitor.worked(workUnitsForSave * 1 / 100); // kick it start to please user
   722 			monitor.worked(workUnitsForSave * 1 / 100); // kick it start to please user
   710 			if (monitor.isCanceled()) {
   723 			if (monitor.isCanceled()) {
   711 				throw new InterruptedException();
   724 				throw new InterruptedException();