-// $Id$
/**
* Copyright (C) 2014 EDIT
* European Distributed Institute of Taxonomy
*/
package eu.etaxonomy.taxeditor.ui.dialog;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
import java.io.IOException;
-import java.util.Properties;
import org.eclipse.jface.dialogs.IMessageProvider;
import org.eclipse.jface.dialogs.TitleAreaDialog;
import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Shell;
-import eu.etaxonomy.taxeditor.preference.IPreferenceKeys;
import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
private CCombo combo;
+ final PreferencesUtil preferencesUtil = new PreferencesUtil();
+
/**
* @param parentShell
*/
return composite;
}
-
/**
*
+ * @param parent
*/
private void createComboElement(Composite parent) {
Composite container1 = new Composite(parent, SWT.NONE);
@Override
public void widgetSelected(SelectionEvent e) {
try {
- writeConfigAndRestart(combo.getSelectionIndex());
+ preferencesUtil.writePropertyToConfigFile(combo.getSelectionIndex());
} catch (IOException e1) {
e1.printStackTrace();
}
@Override
public void widgetDefaultSelected(SelectionEvent e) {
- // TODO Auto-generated method stub
-
}
});
}
@Override
protected void okPressed() {
- try {
- writeConfigAndRestart(combo.getSelectionIndex());
- } catch (IOException e) {
- e.printStackTrace();
- }
- super.okPressed();
- }
-
-
- private void writeConfigAndRestart(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;
+ try {
+ preferencesUtil.writePropertyToConfigFile(combo.getSelectionIndex());
+ } catch (IOException e) {
+ e.printStackTrace();
}
- save(file+"/config.ini", properties);
- }
-
- private Properties load(String filename) throws IOException {
- FileInputStream in = new FileInputStream(filename);
- Properties prop = new Properties();
- prop.load(in);
- in.close();
- return prop;
- }
-
- private void save(String filename, Properties properties) throws IOException{
- FileOutputStream fos = new FileOutputStream(filename);
- properties.store(fos, "");
- fos.close();
+ super.okPressed();
}
private enum Language{
return label;
}
}
- private static final GridLayout GRID_LAYOUT (int columns, boolean equalwidth){
- GridLayout layout = new GridLayout();
- layout.marginTop = 0;
- layout.marginRight = 0;
- layout.marginBottom = 0;
- layout.marginLeft = 0;
- layout.numColumns = columns;
- layout.makeColumnsEqualWidth = equalwidth;
- return layout;
- }
}