sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi.wizards/src/com/nokia/carbide/cpp/internal/pi/wizards/ui/NewPIWizardSettings.java
changeset 12 ae255c9aa552
parent 5 844b047e260d
equal deleted inserted replaced
11:5b9d4d8641ce 12:ae255c9aa552
    39 
    39 
    40 /*
    40 /*
    41  *  Handles all import wizard's persist data
    41  *  Handles all import wizard's persist data
    42  */
    42  */
    43 
    43 
    44 public class NewPIWizardSettings {
    44 public final class NewPIWizardSettings {
    45 	static NewPIWizardSettings instance = null;
    45 	static NewPIWizardSettings instance = null;
    46 	
    46 	
    47 	static final int COMBO_MAX_ITEM_VALUES = 5;
    47 	static final int COMBO_MAX_ITEM_VALUES = 5;
    48 	
    48 	
    49 	//This means something on Windows and Unix, should be good enough for file path not having this
    49 	//This means something on Windows and Unix, should be good enough for file path not having this
    72 	static final String CUST_SEPARATOR_KEY = "separator";							//$NON-NLS-1$
    72 	static final String CUST_SEPARATOR_KEY = "separator";							//$NON-NLS-1$
    73 	static final String OUTPUT_PROJECT_KEY = "outputProject";						//$NON-NLS-1$
    73 	static final String OUTPUT_PROJECT_KEY = "outputProject";						//$NON-NLS-1$
    74 	static final String OUTPUT_NPI_KEY = "piFileName";								//$NON-NLS-1$
    74 	static final String OUTPUT_NPI_KEY = "piFileName";								//$NON-NLS-1$
    75 	static final String KEY_PROFILE_KEY = "keyProfile";								//$NON-NLS-1$
    75 	static final String KEY_PROFILE_KEY = "keyProfile";								//$NON-NLS-1$
    76 	static final String SAMPLEFILENAMES_KEY = "sampleFileName";						//$NON-NLS-1$
    76 	static final String SAMPLEFILENAMES_KEY = "sampleFileName";						//$NON-NLS-1$
    77 
    77 	private static final String DEFAULT_TRACE_PLUGINS = "defaultTracePlugins";      //$NON-NLS-1$
       
    78 	
    78 	boolean haveAppOnly = false;
    79 	boolean haveAppOnly = false;
    79 	boolean haveRomOnly = false;
    80 	boolean haveRomOnly = false;
    80 	boolean haveAppRom = false;
    81 	boolean haveAppRom = false;
    81 	boolean haveNothing = false;
    82 	boolean haveNothing = false;
    82 	boolean enableCust;
    83 	boolean enableCust;
    91 	String custSampleFile;
    92 	String custSampleFile;
    92 	boolean custValBased;
    93 	boolean custValBased;
    93 	boolean custNameBased;
    94 	boolean custNameBased;
    94 	String custSeparator;	
    95 	String custSeparator;	
    95 	IContainer outputContainer;
    96 	IContainer outputContainer;
       
    97 	boolean profilerActivator;
    96 //	end version 2
    98 //	end version 2
    97 //	start version 3
    99 //	start version 3
    98 	String piFileName;
   100 	String piFileName;
    99 //	end version 3
   101 //	end version 3
   100 //	start version 4
   102 //	start version 4
   102 //	end version 4
   104 //	end version 4
   103 //	start internal states not saved
   105 //	start internal states not saved
   104 	long sampleFileNameModifiedNanoTime;	// timestamp java.lang.System.nanoTime()
   106 	long sampleFileNameModifiedNanoTime;	// timestamp java.lang.System.nanoTime()
   105 	long piFileNameModifiedNanoTime;		// timestamp java.lang.System.nanoTime()
   107 	long piFileNameModifiedNanoTime;		// timestamp java.lang.System.nanoTime()
   106 //	end internal states not saved
   108 //	end internal states not saved
       
   109 	public int[] defaultPlugins;
   107 	
   110 	
   108 	public void clear() {
   111 	public void clear() {
   109 		haveAppOnly = false;
   112 		haveAppOnly = false;
   110 		haveRomOnly = false;
   113 		haveRomOnly = false;
   111 		haveAppRom = false;
   114 		haveAppRom = false;
   126 		outputContainer = null;
   129 		outputContainer = null;
   127 		piFileName= "";				//$NON-NLS-1$
   130 		piFileName= "";				//$NON-NLS-1$
   128 		keyMapProfile = null;
   131 		keyMapProfile = null;
   129 		sampleFileNameModifiedNanoTime = 0;
   132 		sampleFileNameModifiedNanoTime = 0;
   130 		piFileNameModifiedNanoTime = 0;
   133 		piFileNameModifiedNanoTime = 0;
       
   134 		profilerActivator = false;
       
   135 		defaultPlugins = null; 
   131 	}
   136 	}
   132 	
   137 	
   133 	private NewPIWizardSettings() {
   138 	private NewPIWizardSettings() {
   134 		clear();
   139 		clear();
   135 	}
   140 	}
   199 			dialogSettings.put(CUST_SEPARATOR_KEY, custSeparator);
   204 			dialogSettings.put(CUST_SEPARATOR_KEY, custSeparator);
   200 			String outProject = outputContainer.getFullPath().toString();
   205 			String outProject = outputContainer.getFullPath().toString();
   201 			dialogSettings.put(OUTPUT_PROJECT_KEY, outProject);
   206 			dialogSettings.put(OUTPUT_PROJECT_KEY, outProject);
   202 			dialogSettings.put(OUTPUT_NPI_KEY, piFileName);
   207 			dialogSettings.put(OUTPUT_NPI_KEY, piFileName);
   203 			dialogSettings.put(KEY_PROFILE_KEY, keyMapProfile != null ? keyMapProfile.toString() : "");	//$NON-NLS-1$
   208 			dialogSettings.put(KEY_PROFILE_KEY, keyMapProfile != null ? keyMapProfile.toString() : "");	//$NON-NLS-1$
       
   209 			
       
   210 			String[] plugins = convertIntegerArrayToStringArray(defaultPlugins);
       
   211 			if(plugins != null){
       
   212 				dialogSettings.put(DEFAULT_TRACE_PLUGINS, plugins);
       
   213 			}
       
   214 			
   204 //			 newer members go here
   215 //			 newer members go here
   205 		} catch (Exception e) {
   216 		} catch (Exception e) {
   206 			e.printStackTrace();
   217 			e.printStackTrace();
   207 		}
   218 		}
   208 	}
   219 	}
   325 				for (IBupEventMapProfile profile : profiles) {
   336 				for (IBupEventMapProfile profile : profiles) {
   326 					if(profile.toString().equals(keyProfileString)) {
   337 					if(profile.toString().equals(keyProfileString)) {
   327 						keyMapProfile = profile;
   338 						keyMapProfile = profile;
   328 					}
   339 					}
   329 				}
   340 				}
       
   341 				
       
   342 				String[] plugins = dialogSettings.getArray(DEFAULT_TRACE_PLUGINS);
       
   343 				if(plugins != null){
       
   344 					defaultPlugins = convertStringArrayToIntegerArray(plugins);
       
   345 					
       
   346 				}
       
   347 				
   330 			} // if (dialogSettings.getInt(IMPORTER_SETTING_VERSION) == CURRENT_VERSION)
   348 			} // if (dialogSettings.getInt(IMPORTER_SETTING_VERSION) == CURRENT_VERSION)
   331 		} catch (Exception e) {
   349 		} catch (Exception e) {
   332 			e.printStackTrace();
   350 			e.printStackTrace();
   333 		}
   351 		}
   334 	}	
   352 	}	
       
   353 	
       
   354 	private int[] convertStringArrayToIntegerArray(String[] strings){
       
   355 		if(strings == null){
       
   356 			return null;
       
   357 		}
       
   358 		int[] integers = new int[strings.length];
       
   359 		for(int i=0;i<strings.length;i++){
       
   360 			integers[i] = Integer.valueOf(strings[i]);
       
   361 		}
       
   362 		return integers;
       
   363 	}
       
   364 	
       
   365 	private String[] convertIntegerArrayToStringArray(int[] integers){
       
   366 		if(integers == null){
       
   367 			return null;
       
   368 		}
       
   369 		String[] strings = new String[integers.length];
       
   370 		for(int i=0;i<integers.length;i++){
       
   371 			strings[i] = String.valueOf(integers[i]);
       
   372 		}
       
   373 		return strings;
       
   374 	}
   335 }
   375 }