Révision 3851

TXM/trunk/bundles/org.txm.core/src/java/org/txm/core/preferences/TXMPreferences.java (revision 3851)
1891 1891
	 */
1892 1892
	public static boolean flush(TXMResult result, File parametersFile) throws IOException {
1893 1893
		
1894
		// FIXME: less wtf version...
1895
		IPreferencesService service = org.eclipse.core.runtime.Platform.getPreferencesService();
1896
		FileOutputStream output = null;
1894
//		// FIXME: less wtf version... but does not work -> the properties name is absolute instead of local : "/project/VOEUX/txm_res_20230530_161548166_0000_Concordance/class=" instead of "class"
1895
//		IPreferencesService service = org.eclipse.core.runtime.Platform.getPreferencesService();
1896
//		FileOutputStream output = null;
1897
//		try {
1898
//			output = new FileOutputStream(parametersFile);
1899
//			service.exportPreferences((IEclipsePreferences) preferencesRootNode.node(result.getParametersNodePath()), output, null);
1900
//			output.close();
1901
//		}
1902
//		catch (Exception e1) {
1903
//			Log.severe(NLS.bind("Error: parameters NOT exported to the {0} file: {1}.", parametersFile, e1));
1904
//			e1.printStackTrace();
1905
//			if (output !=null) {
1906
//				output.close();
1907
//			}
1908
//			return false;
1909
//		}
1910
//		//return true;
1911
		
1912
		
1913
		// FIXME: wtf version...
1897 1914
		try {
1898
			output = new FileOutputStream(parametersFile);
1899
			service.exportPreferences((IEclipsePreferences) preferencesRootNode.node(result.getParametersNodePath()), output, null);
1900
			output.close();
1901
		}
1902
		catch (Exception e1) {
1903
			Log.severe(NLS.bind("Error: parameters NOT exported to the {0} file: {1}.", parametersFile, e1));
1904
			e1.printStackTrace();
1905
			if (output !=null) {
1906
				output.close();
1915
			preferencesRootNode.node(result.getParametersNodePath()).flush();
1916
			
1917
			Project p = result.getProject();
1918
			String store = p.getPreferencesScope().getLocation().toString();
1919
			String internalPath = result.getParametersNodePath();
1920
			String prefix = "/project/" + p.getRCPProject().getName();
1921
			if (internalPath.startsWith(prefix)) {
1922
				internalPath = internalPath.substring(prefix.length());
1907 1923
			}
1908
			return false;
1924
			File prefFile = new File(store, internalPath + ".prefs");
1925
			if (prefFile.exists()) {
1926
				parametersFile.delete();
1927
				FileCopy.copy(prefFile, parametersFile);
1928
				if (parametersFile.exists()) {
1929
					return true;
1930
				}
1931
				else {
1932
					System.out.println(NLS.bind("** Error: could not write parameters to {0} file.", parametersFile));
1933
				}
1934
			}
1935
			else {
1936
				System.out.println(NLS.bind("** Error: internal preference {0} file not found.", prefFile));
1937
			}
1909 1938
		}
1939
		catch (BackingStoreException e) {
1940
			System.out.println(NLS.bind("Parameters not exported to the {0} file: {1}.", parametersFile, e));
1941
			e.printStackTrace();
1942
			Log.severe(e.getMessage());
1943
		}
1910 1944
		return true;
1911
//		
1912
//		
1913
//		// FIXME: wtf version...
1914
//		try {
1915
//			preferencesRootNode.node(result.getParametersNodePath()).flush();
1916
//			
1917
//			Project p = result.getProject();
1918
//			String store = p.getPreferencesScope().getLocation().toString();
1919
//			String internalPath = result.getParametersNodePath();
1920
//			String prefix = "/project/" + p.getRCPProject().getName();
1921
//			if (internalPath.startsWith(prefix)) {
1922
//				internalPath = internalPath.substring(prefix.length());
1923
//			}
1924
//			File prefFile = new File(store, internalPath + ".prefs");
1925
//			if (prefFile.exists()) {
1926
//				parametersFile.delete();
1927
//				FileCopy.copy(prefFile, parametersFile);
1928
//				if (parametersFile.exists()) {
1929
//					return true;
1930
//				}
1931
//				else {
1932
//					System.out.println(NLS.bind("** Error: could not write parameters to {0} file.", parametersFile));
1933
//				}
1934
//			}
1935
//			else {
1936
//				System.out.println(NLS.bind("** Error: internal preference {0} file not found.", prefFile));
1937
//			}
1938
//		}
1939
//		catch (BackingStoreException e) {
1940
//			System.out.println(NLS.bind("Parameters not exported to the {0} file: {1}.", parametersFile, e));
1941
//			e.printStackTrace();
1942
//			Log.severe(e.getMessage());
1943
//		}
1944
//		return false;
1945 1945
	}
1946 1946
	
1947 1947
	

Formats disponibles : Unified diff