*/
package eu.etaxonomy.taxeditor.preference;
+import java.io.IOException;
+
import org.eclipse.jface.dialogs.MessageDialog;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.CCombo;
public class LanguageEditorPreferencePage extends CdmPreferencePage {
private CCombo combo;
- PreferencesUtil preferencesUtil = new PreferencesUtil();
+
private boolean isSelectionChanged = false;
private int initalSelectionIndex;
// preferencesUtil.writePropertyToConfigFile(combo.getSelectionIndex());
if(initalSelectionIndex != combo.getSelectionIndex()) {
isSelectionChanged = true;
+
}else{
isSelectionChanged = false;
}
@Override
public boolean performOk() {
-
- String item = combo.getItem(combo.getSelectionIndex());
- //preferencesUtil.writePropertyToConfigFile(combo.getSelectionIndex());
- if (item.equals(Language.ENGLISH.getLabel())) {
- PreferencesUtil.setStringValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, eu.etaxonomy.cdm.model.common.Language.ENGLISH().getUuid().toString());
- }else {
- PreferencesUtil.setStringValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, eu.etaxonomy.cdm.model.common.Language.GERMAN().getUuid().toString());
- }
-
- boolean result = MessageDialog.openConfirm(getShell(), Messages.LanguageEditorPreferencePage_PleaseRestart, Messages.LanguageEditorPreferencePage_EditorHasToRestart);
- if(result){
- //Press Ok
- PlatformUI.getWorkbench().restart();
+ if (isSelectionChanged) {
+ String item = combo.getItem(combo.getSelectionIndex());
+ try {
+ PreferencesUtil.writePropertyToConfigFile(combo.getSelectionIndex());
+ }catch(IOException e) {
+ e.printStackTrace();
+ }
+ if (item.equals(Language.ENGLISH.getLabel())) {
+ PreferencesUtil.setStringValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, eu.etaxonomy.cdm.model.common.Language.ENGLISH().getUuid().toString());
+ }else {
+ PreferencesUtil.setStringValue(IPreferenceKeys.DEFAULT_LANGUAGE_EDITOR, eu.etaxonomy.cdm.model.common.Language.GERMAN().getUuid().toString());
+ }
+
+ boolean result = MessageDialog.openConfirm(getShell(), Messages.LanguageEditorPreferencePage_PleaseRestart, Messages.LanguageEditorPreferencePage_EditorHasToRestart);
+ if(result){
+ //Press Ok
+ PlatformUI.getWorkbench().restart();
+ }
}