sysperfana/perfinvestigator/com.nokia.carbide.cpp.pi.wizards/src/com/nokia/carbide/cpp/internal/pi/wizards/ui/NewPIWizardSettings.java
changeset 5 844b047e260d
parent 2 b9ab3b238396
child 12 ae255c9aa552
equal deleted inserted replaced
4:615035072f7e 5:844b047e260d
    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 
    78 	
       
    79 //	start version 2
       
    80 	String sampleFileName;
       
    81 	String[] sampleFileNames;
       
    82 	boolean haveAppOnly = false;
    78 	boolean haveAppOnly = false;
    83 	boolean haveRomOnly = false;
    79 	boolean haveRomOnly = false;
    84 	boolean haveAppRom = false;
    80 	boolean haveAppRom = false;
    85 	boolean haveNothing = false;
    81 	boolean haveNothing = false;
    86 	boolean enableCust;
    82 	boolean enableCust;
   108 	long sampleFileNameModifiedNanoTime;	// timestamp java.lang.System.nanoTime()
   104 	long sampleFileNameModifiedNanoTime;	// timestamp java.lang.System.nanoTime()
   109 	long piFileNameModifiedNanoTime;		// timestamp java.lang.System.nanoTime()
   105 	long piFileNameModifiedNanoTime;		// timestamp java.lang.System.nanoTime()
   110 //	end internal states not saved
   106 //	end internal states not saved
   111 	
   107 	
   112 	public void clear() {
   108 	public void clear() {
   113 		sampleFileName = "";			//$NON-NLS-1$
       
   114 		haveAppOnly = false;
   109 		haveAppOnly = false;
   115 		haveRomOnly = false;
   110 		haveRomOnly = false;
   116 		haveAppRom = false;
   111 		haveAppRom = false;
   117 		haveNothing = false;
   112 		haveNothing = false;
   118 		enableCust = false;
   113 		enableCust = false;
   146 	}
   141 	}
   147 		
   142 		
   148 	public void saveState(IDialogSettings dialogSettings) {
   143 	public void saveState(IDialogSettings dialogSettings) {
   149 		try {
   144 		try {
   150 			dialogSettings.put(IMPORTER_SETTING_VERSION, CURRENT_VERSION);
   145 			dialogSettings.put(IMPORTER_SETTING_VERSION, CURRENT_VERSION);
   151 			dialogSettings.put(SAMPLEFILENAME_KEY, sampleFileName);
       
   152 			saveFileNameToArray();
       
   153 			dialogSettings.put(SAMPLEFILENAMES_KEY, sampleFileNames);
       
   154 			dialogSettings.put(ENABLE_CUST_KEY, enableCust);
   146 			dialogSettings.put(ENABLE_CUST_KEY, enableCust);
   155 			
   147 			
   156 			{	// traverse all entries of app config and pkg file
   148 			{	// traverse all entries of app config and pkg file
   157 				ArrayList<String> projectStringArrayList = new ArrayList<String>();
   149 				ArrayList<String> projectStringArrayList = new ArrayList<String>();
   158 				for (IProject selectedProject: selectedProjectList) {
   150 				for (IProject selectedProject: selectedProjectList) {
   219 		try {
   211 		try {
   220 			if (dialogSettings.get(IMPORTER_SETTING_VERSION) == null) {
   212 			if (dialogSettings.get(IMPORTER_SETTING_VERSION) == null) {
   221 				return;
   213 				return;
   222 			}
   214 			}
   223 			if (dialogSettings.getInt(IMPORTER_SETTING_VERSION) == CURRENT_VERSION) {
   215 			if (dialogSettings.getInt(IMPORTER_SETTING_VERSION) == CURRENT_VERSION) {
   224 				sampleFileName = dialogSettings.get(SAMPLEFILENAME_KEY);
       
   225 				sampleFileNames = dialogSettings.getArray(SAMPLEFILENAMES_KEY);
       
   226 //				if(!(new java.io.File(sampleFileName).exists()))
   216 //				if(!(new java.io.File(sampleFileName).exists()))
   227 //					sampleFileName = "";	//$NON-NLS-1$
   217 //					sampleFileName = "";	//$NON-NLS-1$
   228 				enableCust = dialogSettings.getBoolean(ENABLE_CUST_KEY);
   218 				enableCust = dialogSettings.getBoolean(ENABLE_CUST_KEY);
   229 				
   219 				
   230 				{	// traverse all entries of app config and pkg file
   220 				{	// traverse all entries of app config and pkg file
   339 				}
   329 				}
   340 			} // if (dialogSettings.getInt(IMPORTER_SETTING_VERSION) == CURRENT_VERSION)
   330 			} // if (dialogSettings.getInt(IMPORTER_SETTING_VERSION) == CURRENT_VERSION)
   341 		} catch (Exception e) {
   331 		} catch (Exception e) {
   342 			e.printStackTrace();
   332 			e.printStackTrace();
   343 		}
   333 		}
   344 	}
   334 	}	
   345 	
       
   346 	
       
   347 	
       
   348 	
       
   349 	/**
       
   350 	 * @param sampleFileName path to save
       
   351 	 * @param array name of the array which contains correct values
       
   352 	 * @param section section which has array 
       
   353 	 */
       
   354 	protected void saveFileNameToArray() {
       
   355 			
       
   356 		// No previous values exist
       
   357 		if (sampleFileNames == null) {
       
   358 			sampleFileNames = new String[1];
       
   359 			sampleFileNames[0] = sampleFileName;
       
   360 		// Previous values exists
       
   361 		} else {
       
   362 			int valuesCount = sampleFileNames.length;
       
   363 			
       
   364 			boolean valueExisted = false;
       
   365 			// see if passed value already exist.
       
   366 			for (int i = 0; i < valuesCount; i++) {
       
   367 				if (sampleFileNames[i].compareToIgnoreCase(sampleFileName) == 0) {
       
   368 					valueExisted = true;
       
   369 					
       
   370 					// passed value exists, move it to first position
       
   371 					for (int j = i; j > 0; j--) {
       
   372 						sampleFileNames[j] = sampleFileNames[j-1];
       
   373 					}
       
   374 					sampleFileNames[0] = sampleFileName;
       
   375 					
       
   376 					break;
       
   377 				}
       
   378 			}
       
   379 			
       
   380 			// passed value did not exist, add it to first position (and move older values "down")
       
   381 			if (!valueExisted) {
       
   382 				if (valuesCount >= COMBO_MAX_ITEM_VALUES) {
       
   383 					for (int i = valuesCount-1; i > 0; i--) {
       
   384 						sampleFileNames[i] = sampleFileNames[i-1];
       
   385 					}
       
   386 					sampleFileNames[0] = sampleFileName;
       
   387 				} else {
       
   388 					String[] values = new String[valuesCount + 1];
       
   389 					values[0] = sampleFileName;
       
   390 					for (int i = 0; i < valuesCount; i++) {
       
   391 						values[i+1] = sampleFileNames[i];
       
   392 					}
       
   393 					sampleFileNames = values;
       
   394 				}
       
   395 			}
       
   396 		}
       
   397 		
       
   398 	}
       
   399 	
       
   400 }
   335 }