package eu.etaxonomy.taxeditor.preference;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Properties;
import java.util.Set;
import java.util.UUID;
return configurator;
}
+ /**
+ * This method will write language properties to the config.ini located in the configuration folder
+ * of the Taxonomic Ediitor. <b>This method is only used to set the default language for Taxonomic Editor.</b>
+ *
+ * @param setLanguage 0 is for german and 1 for english.
+ * @throws IOException
+ */
+ public void writePropertyToConfigFile(int setLanguage) throws IOException {
+ File file = org.eclipse.core.runtime.preferences.ConfigurationScope.INSTANCE.getLocation().toFile();
+ Properties properties = load(file.getAbsolutePath()+"/config.ini");
+ switch(setLanguage){
+ case 0:
+ properties.setProperty("osgi.nl", "de");
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "de");
+ break;
+ case 1:
+ properties.setProperty("osgi.nl", "en");
+ PreferencesUtil.getPreferenceStore().setValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, "en");
+ break;
+ default:
+ break;
+ }
+ save(file+"/config.ini", properties);
+ }
+
+ /**
+ * This method loads a property from a given file and returns it.
+ *
+ * @param filename
+ * @return
+ * @throws IOException
+ */
+ private Properties load(String filename) throws IOException {
+ FileInputStream in = new FileInputStream(filename);
+ Properties prop = new Properties();
+ prop.load(in);
+ in.close();
+ return prop;
+ }
+
+ /**
+ * This method saves a property to the specified file.
+ *
+ * @param filename
+ * @param properties
+ * @throws IOException
+ */
+ private void save(String filename, Properties properties) throws IOException{
+ FileOutputStream fos = new FileOutputStream(filename);
+ properties.store(fos, "");
+ fos.close();
+ }
+
}