Commit b47c2f66 authored by Romain Bioteau's avatar Romain Bioteau Committed by GitHub

fix(perf) do not refresh in a worksapce runnable (#1588)

use a default m2 repo to avoid remote access
parent 48484a7f
......@@ -45,18 +45,12 @@ public abstract class AbstractFolderRepositoryStore<T extends IRepositoryFileSto
}
protected void refresh(final IFolder folder) {
try {
folder.getWorkspace().run(new IWorkspaceRunnable() {
@Override
public void run(IProgressMonitor monitor) throws CoreException {
if (!folder.isSynchronized(IResource.DEPTH_INFINITE)) {
folder.refreshLocal(IResource.DEPTH_INFINITE, monitor);
}
}
}, Repository.NULL_PROGRESS_MONITOR);
} catch (final CoreException e) {
BonitaStudioLog.error(e);
if (!folder.isSynchronized(IResource.DEPTH_INFINITE)) {
try {
folder.refreshLocal(IResource.DEPTH_INFINITE, Repository.NULL_PROGRESS_MONITOR);
} catch (CoreException e) {
BonitaStudioLog.error(e);
}
}
}
......
......@@ -26,6 +26,7 @@ import java.io.InputStream;
import java.util.Collections;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import org.bonitasoft.studio.common.extension.BonitaStudioExtensionRegistryManager;
import org.bonitasoft.studio.common.jface.BonitaErrorDialog;
......@@ -122,29 +123,21 @@ public abstract class AbstractRepositoryStore<T extends IRepositoryFileStore> im
} catch (final MigrationException e) {
BonitaStudioLog.error(e);
if (!FileActionDialog.getDisablePopup()) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
new BonitaErrorDialog(Display.getDefault().getActiveShell(), Messages.migrationFailedTitle,
Messages.migrationFailedMessage, e).open();
}
});
Display.getDefault()
.syncExec(() -> new BonitaErrorDialog(Display.getDefault().getActiveShell(),
Messages.migrationFailedTitle,
Messages.migrationFailedMessage, e).open());
}
return null;
} catch (final IOException e) {
BonitaStudioLog.error(e);
if (!FileActionDialog.getDisablePopup()) {
Display.getDefault().syncExec(new Runnable() {
@Override
public void run() {
new BonitaErrorDialog(Display.getDefault().getActiveShell(), Messages.importedFileIsInvalidTitle,
Display.getDefault()
.syncExec(() -> new BonitaErrorDialog(Display.getDefault().getActiveShell(),
Messages.importedFileIsInvalidTitle,
Messages.bind(
Messages.importedFileIsInvalid, fileName),
e).open();
}
});
e).open());
}
return null;
}
......@@ -320,13 +313,7 @@ public abstract class AbstractRepositoryStore<T extends IRepositoryFileStore> im
}
private Function<IResource, T> toFileStore() {
return new Function<IResource, T>() {
@Override
public T apply(final IResource resource) {
return createRepositoryFileStore(resource.getName());
}
};
return resource -> createRepositoryFileStore(resource.getName());
}
@Override
......@@ -353,7 +340,7 @@ public abstract class AbstractRepositoryStore<T extends IRepositoryFileStore> im
try {
folder.refreshLocal(IResource.DEPTH_INFINITE, Repository.NULL_PROGRESS_MONITOR);
} catch (final CoreException e1) {
BonitaStudioLog.error(e1);
BonitaStudioLog.warning(String.format("An error occured wihle refreshing folder %s: %s",folder.getName(),e1.getMessage()),CommonRepositoryPlugin.PLUGIN_ID);
}
}
}
......@@ -378,28 +365,26 @@ public abstract class AbstractRepositoryStore<T extends IRepositoryFileStore> im
@Override
public void migrate(final IProgressMonitor monitor) throws CoreException, MigrationException {
for (final IRepositoryFileStore fs : getChildren()) {
if (!fs.isReadOnly() && fs.canBeShared()) {
final IResource r = fs.getResource();
if (r instanceof IFile && r.exists()) {
monitor.subTask(r.getName());
final IFile iFile = (IFile) r;
InputStream newIs;
try (final InputStream is = iFile.getContents()) {
newIs = handlePreImport(r.getName(), is);
if (!is.equals(newIs)) {
iFile.setContents(newIs, IResource.FORCE, monitor);
iFile.refreshLocal(IResource.DEPTH_ONE, monitor);
}
} catch (final IOException e) {
throw new MigrationException("Cannot migrate resource " + r.getName() + " (not a valid file)", e);
}
} else {
throw new MigrationException("Cannot migrate resource " + r.getName() + " (not a file)",
new IOException("Not an existing file :"
+ r.getLocation()));
List<IFile> filesToMigrate = getChildren().stream()
.filter(fs -> !fs.isReadOnly())
.filter(IRepositoryFileStore::canBeShared)
.map(IRepositoryFileStore::getResource)
.filter(IFile.class::isInstance)
.map(IFile.class::cast)
.filter(IFile::exists)
.collect(Collectors.toList());
for (IFile file : filesToMigrate) {
monitor.subTask(file.getName());
InputStream newIs;
try (final InputStream is = file.getContents()) {
newIs = handlePreImport(file.getName(), is);
if (!is.equals(newIs)) {
file.setContents(newIs, IResource.FORCE, monitor);
file.refreshLocal(IResource.DEPTH_ONE, monitor);
}
} catch (final IOException e) {
throw new MigrationException("Cannot migrate resource " + file.getName() + " (not a valid file)", e);
}
}
}
......
......@@ -14,6 +14,10 @@
*/
package org.bonitasoft.studio.swtbot.framework.projectExplorer;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.allOf;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.widgetOfType;
import static org.eclipse.swtbot.swt.finder.matchers.WidgetMatcherFactory.withId;
import java.util.Objects;
import java.util.Optional;
......@@ -25,6 +29,9 @@ import org.bonitasoft.studio.swtbot.framework.connector.ConnectorDefinitionWizar
import org.bonitasoft.studio.swtbot.framework.connector.ConnectorImplementationWizardBot;
import org.bonitasoft.studio.swtbot.framework.diagram.BotProcessDiagramPerspective;
import org.bonitasoft.studio.swtbot.framework.organization.BotManageOrganizationWizard;
import org.eclipse.swt.widgets.Tree;
import org.eclipse.swtbot.eclipse.finder.matchers.WidgetMatcherFactory;
import org.eclipse.swtbot.eclipse.finder.waits.Conditions;
import org.eclipse.swtbot.eclipse.finder.widgets.SWTBotView;
import org.eclipse.swtbot.eclipse.gef.finder.SWTGefBot;
import org.eclipse.swtbot.swt.finder.exceptions.WidgetNotFoundException;
......@@ -157,6 +164,7 @@ public class ProjectExplorerBot extends BotBase {
}
protected SWTBotTree getProjectExplorerTree() {
bot.waitUntil(Conditions.waitForWidget(allOf(widgetOfType(Tree.class), withId("org.bonitasoft.studio.application.projectExplorerTree"))), 120000);
return bot.treeWithId("org.bonitasoft.studio.application.projectExplorerTree");
}
......
......@@ -97,7 +97,11 @@ public class SWTGefBotRule implements TestRule {
for (final SWTBotShell shell : shells) {
if (shell.isOpen() && !isEclipseShell(shell)) {
System.out.println(String.format("Trying to close shell '%s' after test failure %s",shell.getText(),e));
shell.close();
try {
shell.close();
}catch(TimeoutException e1) {
System.out.println(String.format("Failed to close shell %s: %s",shell.getText(),e1));
}
}
}
}
......
......@@ -25,7 +25,9 @@ Require-Bundle: org.junit,
org.eclipse.ui.workbench,
org.bonitasoft.studio.preferences;bundle-version="7.7.0",
org.eclipse.ui.browser;bundle-version="3.6.100",
org.bonitasoft.studio.connectors.model.edit
org.bonitasoft.studio.connectors.model.edit,
org.eclipse.m2e.core,
org.eclipse.equinox.preferences
Export-Package: org.bonitasoft.studio.console.test.util,
org.bonitasoft.studio.tests.utils.wizards,
org.bonitasoft.studio.util.test,
......
......@@ -14,6 +14,8 @@
*/
package org.bonitasoft.studio.util.test;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
......@@ -30,7 +32,12 @@ import org.bonitasoft.studio.preferences.BonitaCoolBarPreferenceConstant;
import org.bonitasoft.studio.preferences.BonitaPreferenceConstants;
import org.bonitasoft.studio.preferences.BonitaStudioPreferencesPlugin;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.FileLocator;
import org.eclipse.core.runtime.preferences.DefaultScope;
import org.eclipse.core.runtime.preferences.IEclipsePreferences;
import org.eclipse.jface.preference.IPreferenceStore;
import org.eclipse.m2e.core.internal.IMavenConstants;
import org.eclipse.m2e.core.internal.preferences.MavenPreferenceConstants;
import org.eclipse.swt.widgets.Display;
import org.eclipse.ui.internal.browser.WebBrowserUIPlugin;
import org.junit.runner.Description;
......@@ -202,6 +209,14 @@ public class BonitaSuite extends Suite {
WebBrowserUIPlugin.getInstance().getPreferenceStore()
.setValue(BonitaPreferenceConstants.CONSOLE_BROWSER_CHOICE, BonitaPreferenceConstants.INTERNAL_BROWSER);
EnginePlugin.getDefault().getPreferenceStore().setValue(EnginePreferenceConstants.LAZYLOAD_ENGINE, true);
IEclipsePreferences store = DefaultScope.INSTANCE.getNode(IMavenConstants.PLUGIN_ID);
try {
File defaultSettings = new File(
FileLocator.toFileURL(BonitaSuite.class.getResource("default_settings.xml")).getFile());
store.put(MavenPreferenceConstants.P_USER_SETTINGS_FILE, defaultSettings.getAbsolutePath()); //$NON-NLS-1$
} catch (IOException e) {
BonitaStudioLog.error(e);
}
FileActionDialog.setDisablePopup(true);
}
......
<?xml version="1.0" encoding="UTF-8"?>
<settings
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"
xmlns="http://maven.apache.org/SETTINGS/1.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<localRepository>${user.home}/.m2/studio-repository</localRepository>
</settings>
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