Commit 72a944ab authored by Romain Bioteau's avatar Romain Bioteau
Browse files

fix(importWorkspace) fix InvalidThreadAccess

parent 512f26f5
......@@ -98,7 +98,6 @@ public class DefinitionResourceProvider {
private final Map<String, ResourceBundle> resourceBundleCache = new WeakHashMap<>();
private final static Map<IRepositoryStore<? extends IRepositoryFileStore>, DefinitionResourceProvider> INSTANCES_MAP;
static {
INSTANCES_MAP = new WeakHashMap<>();
}
......@@ -136,10 +135,9 @@ public class DefinitionResourceProvider {
}
protected ImageRegistry createImageRegistry() {
// If we are in the UI Thread use that
if (Display.getCurrent() != null) {
return new ImageRegistry(Display.getCurrent());
if (Display.getDefault() != null) {
return new ImageRegistry(Display.getDefault());
}
if (PlatformUI.isWorkbenchRunning()) {
......@@ -204,7 +202,8 @@ public class DefinitionResourceProvider {
}
private String getCacheKey(final ConnectorDefinition definition, final Locale locale) {
return NamingUtils.toConnectorDefinitionFilename(definition.getId(), definition.getVersion(), false) + locale.toString();
return NamingUtils.toConnectorDefinitionFilename(definition.getId(), definition.getVersion(), false)
+ locale.toString();
}
private String getMessage(final ConnectorDefinition definition, final String key) {
......@@ -322,7 +321,8 @@ public class DefinitionResourceProvider {
.getAbsolutePath()
+ File.separatorChar
+ NamingUtils.toConnectorDefinitionFilename(definition.getId(),
definition.getVersion(), false) + ".properties";
definition.getVersion(), false)
+ ".properties";
final File defaultMessageFile = new File(fileName);
FileOutputStream fos = null;
try {
......@@ -799,5 +799,4 @@ public class DefinitionResourceProvider {
messages.remove(c.getId() + "." + category);
}
}
......@@ -19,6 +19,7 @@ import java.util.Optional;
import java.util.function.Predicate;
import java.util.stream.Stream;
import org.bonitasoft.studio.common.log.BonitaStudioLog;
import org.bonitasoft.studio.common.platform.tools.PlatformUtil;
import org.bonitasoft.studio.common.repository.BonitaProjectNature;
import org.bonitasoft.studio.common.repository.Repository;
......@@ -33,6 +34,7 @@ import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.IWorkspace;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
import org.eclipse.core.runtime.NullProgressMonitor;
import org.eclipse.equinox.app.IApplication;
import org.eclipse.equinox.app.IApplicationContext;
import org.eclipse.jface.preference.IPreferenceStore;
......@@ -148,6 +150,11 @@ public class ImportWorkspaceApplication implements IApplication {
*/
@Override
public void stop() {
try {
ResourcesPlugin.getWorkspace().save(true, new NullProgressMonitor());
} catch (CoreException e) {
BonitaStudioLog.error(e);
}
PlatformUI.getWorkbench().close();
}
......
Markdown is supported
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