Commit 5e2e49ae authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub
Browse files

fix(l10n) clear persistedSate when switching locale (#890)

Closes BS-17676
parent 6ccd99a9
......@@ -48,6 +48,10 @@
name="applicationXMI"
value="org.bonitasoft.studio.application/LegacyIDE.e4xmi">
</property>
<property
name="lifeCycleURI"
value="bundleclass://org.bonitasoft.studio.application/org.bonitasoft.studio.application.LifeCycleManager">
</property>
</product>
</extension>
......
/**
* Copyright (C) 2017 Bonitasoft S.A.
* Bonitasoft, 32 rue Gustave Eiffel - 38000 Grenoble
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2.0 of the License, or
* (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.bonitasoft.studio.application;
import java.io.File;
import org.eclipse.core.runtime.Platform;
import org.eclipse.e4.core.contexts.IEclipseContext;
import org.eclipse.e4.ui.workbench.IWorkbench;
import org.eclipse.e4.ui.workbench.lifecycle.PostContextCreate;
public class LifeCycleManager {
@PostContextCreate
public void disablePersistState(IEclipseContext context) {
System.setProperty(IWorkbench.CLEAR_PERSISTED_STATE, String.valueOf(shouldClearPersistedState()));
}
protected boolean shouldClearPersistedState() {
File installFolder = new File(Platform.getInstallLocation().getURL().getFile());
File clearStateFile = installFolder.toPath().resolve(".clearState").toFile();
if (clearStateFile.exists()) {
clearStateFile.delete();
return true;
}
return false;
}
}
......@@ -45,7 +45,6 @@ import org.eclipse.ui.preferences.ScopedPreferenceStore;
/**
* @author Romain Bioteau
*
*/
public class BonitaLanguagePreferencePage extends AbstractBonitaPreferencePage implements IWorkbenchPreferencePage {
......@@ -71,9 +70,12 @@ public class BonitaLanguagePreferencePage extends AbstractBonitaPreferencePage i
createTitleBar(Messages.BonitaPreferenceDialog_language, Pics.getImage(PicsConstants.preferenceLanguage), false);
studioLocale = new ComboFieldEditor(BonitaPreferenceConstants.CURRENT_STUDIO_LOCALE, Messages.bind(Messages.studioLocalLabel,
new Object[] { bonitaStudioModuleName }), toLocales(LocaleUtil.getStudioLocales()), getFieldEditorParent());
webLocale = new ComboFieldEditor(BonitaPreferenceConstants.CURRENT_UXP_LOCALE, Messages.consoleLocaleLabel, toLocales(LocaleUtil.getProtalLocales()),
studioLocale = new ComboFieldEditor(BonitaPreferenceConstants.CURRENT_STUDIO_LOCALE,
Messages.bind(Messages.studioLocalLabel,
new Object[] { bonitaStudioModuleName }),
toLocales(LocaleUtil.getStudioLocales()), getFieldEditorParent());
webLocale = new ComboFieldEditor(BonitaPreferenceConstants.CURRENT_UXP_LOCALE, Messages.consoleLocaleLabel,
toLocales(LocaleUtil.getProtalLocales()),
getFieldEditorParent());
addField(studioLocale);
......@@ -114,11 +116,11 @@ public class BonitaLanguagePreferencePage extends AbstractBonitaPreferencePage i
}
super.propertyChange(event);
}
@Override
protected void performDefaults() {
super.performDefaults();
newLocale = getPreferenceStore().getString(BonitaPreferenceConstants.CURRENT_STUDIO_LOCALE);
super.performDefaults();
newLocale = getPreferenceStore().getString(BonitaPreferenceConstants.CURRENT_STUDIO_LOCALE);
}
/*
......@@ -135,7 +137,8 @@ public class BonitaLanguagePreferencePage extends AbstractBonitaPreferencePage i
}
if (newLocale != null && !newLocale.isEmpty()) {
changeLocale(newLocale);
if (MessageDialog.openQuestion(getShell(), Messages.bind(Messages.restartQuestion_title, new Object[] { bonitaStudioModuleName }),
if (MessageDialog.openQuestion(getShell(),
Messages.bind(Messages.restartQuestion_title, new Object[] { bonitaStudioModuleName }),
Messages.bind(Messages.restartQuestion_msg, new Object[] { bonitaStudioModuleName }))) {
PlatformUI.getWorkbench().restart();
}
......@@ -157,8 +160,9 @@ public class BonitaLanguagePreferencePage extends AbstractBonitaPreferencePage i
return;
}
try {
File configIniFile = new File(new URL(configArea.getURL().toExternalForm() + File.separatorChar + "configuration" + File.separatorChar
+ "config.ini").getFile());
File configIniFile = new File(
new URL(configArea.getURL().toExternalForm() + File.separatorChar + "configuration" + File.separatorChar
+ "config.ini").getFile());
if (configIniFile.exists()) {
Properties configIniProperties = new Properties();
final FileInputStream inStream = new FileInputStream(configIniFile);
......@@ -176,6 +180,15 @@ public class BonitaLanguagePreferencePage extends AbstractBonitaPreferencePage i
} catch (IOException e) {
BonitaStudioLog.error(e);
}
File installFolder = new File(configArea.getURL().getFile());
File clearStateFile = installFolder.toPath().resolve(".clearState").toFile();
try {
clearStateFile.delete();
clearStateFile.createNewFile();
} catch (IOException e) {
BonitaStudioLog.error(e);
}
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment